Merging 2024Q2_RC into main, creating 2024Q2 Release

Merging 2024Q2_RC into main, creating 2024Q2 Release #7 (closed)

Merge request reports

Loading
+41 −0
Changes for src/main/java/org/etsi/osl/mano/ActiveMQComponentConfig.java: 41 added lines, 0 removed lines.
Original line number Diff line number Diff line
/*-
 * ========================LICENSE_START=================================
 * org.etsi.osl.bugzilla
 * %%
 * Copyright (C) 2019 openslice.io
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =========================LICENSE_END==================================
 */
package org.etsi.osl.mano;

import jakarta.jms.ConnectionFactory;

import org.apache.camel.component.activemq.ActiveMQComponent;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author ctranoris
 *
 */
@Configuration
public class ActiveMQComponentConfig {

    @Bean(name = "activemq")
    public ActiveMQComponent createComponent(ConnectionFactory factory) {
        ActiveMQComponent activeMQComponent = new ActiveMQComponent();
        activeMQComponent.setConnectionFactory(factory);
        return activeMQComponent;
    }
}
+54 −0
Changes for src/main/java/org/etsi/osl/mano/AlarmsService.java: 54 added lines, 0 removed lines.
Original line number Diff line number Diff line
package org.etsi.osl.mano;

import java.io.IOException;

import org.apache.camel.CamelContext;
import org.apache.camel.ProducerTemplate;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;

import org.etsi.osl.tmf.am642.model.AlarmCreate;

@Service
public class AlarmsService {

	private static final transient Log logger = LogFactory.getLog(AlarmsService.class.getName());

	@Autowired
	CamelContext contxt;

	@Autowired
	ProducerTemplate template;
	
	@Value("${ALARMS_ADD_ALARM}")
	private String ALARMS_ADD_ALARM ="";

	/**
	 * @param al
	 * @return a response in string
	 * @throws IOException
	 */
	public String createAlarm(AlarmCreate al) throws IOException {
			
		String body;
		body = toJsonString(al);
		logger.info("createAlarm body = " + body);
		Object response = template.requestBody( ALARMS_ADD_ALARM, body);
		return response.toString();
	}
	
	

	static String toJsonString(Object object) throws IOException {
		ObjectMapper mapper = new ObjectMapper();
		mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
		return mapper.writeValueAsString(object);
	}

}
+1316 −0

File added.

Preview size limit exceeded, changes collapsed.

+2885 −0

File added.

Preview size limit exceeded, changes collapsed.

+283 −0
Changes for src/main/java/org/etsi/osl/mano/MANORouteBuilder.java: 283 added lines, 0 removed lines.
Original line number Diff line number Diff line
/*-
 * ========================LICENSE_START=================================
 * org.etsi.osl.portal.api
 * %%
 * Copyright (C) 2019 openslice.io
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =========================LICENSE_END==================================
 */


package org.etsi.osl.mano;

import org.apache.camel.CamelContext;
import org.apache.camel.LoggingLevel;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.model.dataformat.JsonLibrary;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import org.etsi.osl.model.nfv.ScaleDescriptor;
import org.etsi.osl.model.nfv.VxFOnBoardedDescriptor;

/**
 * @author ctranoris
 *
 */
@Component
@Configuration
public class MANORouteBuilder  extends RouteBuilder{
	

	@Autowired
	MANOController aMANOController;


	@Value("${NFV_CATALOG_NSACTIONS_SCALE}")
	private String NFV_CATALOG_NSACTIONS_SCALE ="";
	
	
	public static void main(String[] args) throws Exception {
		//new Main().run(args);				
		CamelContext tempcontext = new DefaultCamelContext();
		try {
		RouteBuilder rb = new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                from( "timer://getVNFRepoTimer?period=2000&repeatCount=3&daemon=true"  )
        		.log( "Will check VNF repo");
                
                from( "timer://getNSDRepoTimer?period=2000&repeatCount=3&daemon=true"  )
        		.log( "Will check NSD repo");
            }
        };
        tempcontext.addRoutes( rb);
        tempcontext.start();
        Thread.sleep(30000);
		} finally {			
			tempcontext.stop();
        }							
	}
	

	public void configure() {
		
//		/**
//		 * OnBoard New Added VxF
//		 */		
//		//We get the message here and we need to route it to the proper point.
//		//If onboarding is successfull we need to send a Bugzilla message
//		//If it is unsuccessful we need to send another Bugzilla message
//		from("seda:vxf.onboard?multipleConsumers=true")
//		.doTry()
//		.bean( aMANOController,"onBoardVxFToMANOProvider") //returns exception or nothing
//		.log("VNFD Onboarded handled")
//		.doCatch(Exception.class)
//		.log("VNFD Onboarding failed!");
//
//		from("seda:nsd.onboard?multipleConsumers=true")
//		.doTry()
//		.bean( aMANOController,"onBoardNSDToMANOProvider") //returns exception or nothing
//		.log("NSD Onboarded handled")
//		.doCatch(Exception.class)
//		.log("NSD Onboarding failed!");		

//**********************************************************************************************
// 		THESE NOW ARE CALLED DIRECTLY AND ARE NOT REQUIRED ANY MORE 26122019
//		from("seda:nsd.deploy?multipleConsumers=true")
//		.doTry()
//		.bean( aMANOController,"deployNSDToMANOProvider") //returns exception or nothing
//		.log("NS deployed handled").stop()
//		.doCatch(Exception.class)
//		.log("NS deployment failed!"+"${exception.message}").stop();		
//
//		from("seda:nsd.deployment.complete?multipleConsumers=true")
//		.doTry()
//		.bean( aMANOController,"terminateNSFromMANOProvider") //returns exception or nothing
//		.log("NS completed handled")
//		.doCatch(Exception.class)
//		.log("NS completion failed!").stop();
//
//		from("seda:nsd.deployment.delete?multipleConsumers=true")
//		.doTry()
//		.bean( aMANOController,"deleteNSFromMANOProvider") //returns exception or nothing
//		.log("NS deleted handled")
//		.doCatch(Exception.class)
//		.log("NS deletion failed!").stop();
//		**********************************************************************************************
		
		from("timer://checkAndUpdateRunningDeploymentDescriptors?delay=1s&period=60000").bean(  aMANOController,"checkAndUpdateRunningDeploymentDescriptors").stop();
//		from("timer://checkAndUpdateMANOProvidersResources?delay=1s&period=60000").bean(  aMANOController,"checkAndUpdateMANOProvidersResources").stop();
		
		// THESE SEND THE DeploymentDescriptor Object to Bugzilla for status updates		
		// Here we needed to add getDeploymentEagerDataJson from portal.api.service.DeploymentDescriptorService 
		// in order to create the marshalling
		from("seda:nsd.deployment.instantiation.success?multipleConsumers=true")
		.marshal().json( JsonLibrary.Jackson, true)
		.convertBodyTo( String.class )
		.to( "activemq:topic:nsd.deployment.instantiation.success" );

		from("seda:nsd.deployment.instantiation.fail?multipleConsumers=true")
		.marshal().json( JsonLibrary.Jackson, true)
		.convertBodyTo( String.class )
		.to( "activemq:topic:nsd.deployment.instantiation.fail" );		

		from("seda:nsd.deployment.termination.success?multipleConsumers=true")
		.marshal().json( JsonLibrary.Jackson, true)
		.convertBodyTo( String.class )
		.to( "activemq:topic:nsd.deployment.termination.success" );				

		from("seda:nsd.deployment.termination.fail?multipleConsumers=true")
		.marshal().json( JsonLibrary.Jackson, true)
		.convertBodyTo( String.class )
		.to( "activemq:topic:nsd.deployment.termination.fail" );		
		
		from("seda:vxf.onboard.success?multipleConsumers=true")
		.marshal().json( JsonLibrary.Jackson, VxFOnBoardedDescriptor.class, true)
		.convertBodyTo( String.class )
		.to( "activemq:topic:vxf.onboard.success" );
										
		from("activemq:topic:vxf.onboard")
		.log( "activemq:topic:vxf.onboard for ${body} !" )
		.unmarshal().json( JsonLibrary.Jackson, org.etsi.osl.model.nfv.VxFOnBoardedDescriptor.class, true)
		.bean( aMANOController, "onBoardVxFToMANOProviderByOBD" )
		.to("log:DEBUG?showBody=true&showHeaders=true");
		
		from("activemq:topic:vxf.onboardbyfile")
		.log( "activemq:topic:vxf.onboardbyfile for ${body} !" )
		.unmarshal().json( JsonLibrary.Jackson, org.etsi.osl.model.nfv.VxFOnBoardedDescriptor.class, true)
		.bean( aMANOController, "onBoardVxFToMANOProviderByFile" )
		.to("log:DEBUG?showBody=true&showHeaders=true");

		from("activemq:topic:vxf.onBoardByCompositeObj")
		.log( "activemq:topic:vxf.onBoardByCompositeObj for ${body} !" )
		.unmarshal().json( JsonLibrary.Jackson, org.etsi.osl.model.nfv.CompositeVxFOnBoardDescriptor.class, true)
		.bean( aMANOController, "onBoardVxFToMANOProviderByCompositeObj" )
		.to("log:DEBUG?showBody=true&showHeaders=true");
		
		from("activemq:topic:vxf.offboard")
		.log( "activemq:topic:vxf.offboard for ${body} !" )
		.unmarshal().json( JsonLibrary.Jackson, org.etsi.osl.model.nfv.VxFOnBoardedDescriptor.class, true)
		.doTry()
			.bean( aMANOController, "offBoardVxFFromMANOProvider" ) //Replies with a ResponseInstance 
			.marshal().json( JsonLibrary.Jackson, true)
			.convertBodyTo(String.class)
        	.log("offboarding ok with ${body}")
        .doCatch(Exception.class)
        	.setBody(exceptionMessage())
        	.log("offboard failed with exception ${body}")
        .end();

		from("activemq:topic:nsd.onboardbyfile")
		.log( "activemq:topic:nsd.onboardbyfile for ${body} !" )
		.unmarshal().json( JsonLibrary.Jackson, org.etsi.osl.model.nfv.ExperimentOnBoardDescriptor.class, true)
		.bean( aMANOController, "onBoardNSDToMANOProviderByFile" )
		.to("log:DEBUG?showBody=true&showHeaders=true");		

		from("activemq:topic:nsd.onBoardByCompositeObj")
		.log( "activemq:topic:nsd.onBoardByCompositeObj for ${body} !" )
		.unmarshal().json( JsonLibrary.Jackson, org.etsi.osl.model.nfv.CompositeExperimentOnBoardDescriptor.class, true)
		.bean( aMANOController, "onBoardNSDToMANOProviderByCompositeObj" )
		.to("log:DEBUG?showBody=true&showHeaders=true");
		
		from("activemq:topic:nsd.onboard")
		.log( "activemq:topic:nsd.onboard for ${body} !" )
		.unmarshal().json( JsonLibrary.Jackson, org.etsi.osl.model.nfv.ExperimentOnBoardDescriptor.class, true)
		.bean( aMANOController, "onBoardNSDToMANOProvider" )
		.to("log:DEBUG?showBody=true&showHeaders=true");
		
		from("activemq:topic:nsd.offboard")
		.log( "activemq:topic:nsd.offboard for ${body} !" )
		.unmarshal().json( JsonLibrary.Jackson, org.etsi.osl.model.nfv.ExperimentOnBoardDescriptor.class, true)
		.doTry()
			.bean( aMANOController, "offBoardNSDFromMANOProvider" ) //Replies with a ResponseInstance 
			.marshal().json( JsonLibrary.Jackson, true)
			.convertBodyTo(String.class)
        	.log("offboarding ok with ${body}")
        .doCatch(Exception.class)
        	.setBody(exceptionMessage())
        	.log("offboard failed with exception ${body}")
        .end();
		
		
		from("activemq:topic:vxf.metadata.retrieve")
		.log("activemq:topic:vxf.metadata.retrieve")
		.choice()
        .when(header("OSMType").isEqualTo("OSMvTEN"))
    		.bean(aMANOController, "mapOSM10VNFD2ProductEagerDataJson")
        .when(header("OSMType").isEqualTo("OSMvELEVEN"))
    		.bean(aMANOController, "mapOSM10VNFD2ProductEagerDataJson")
        .when(header("OSMType").isEqualTo("OSMvTHIRTEEN"))
    		.bean(aMANOController, "mapOSM10VNFD2ProductEagerDataJson");
        //.when(header("OSMType").isEqualTo("GenericSOL005"))
        //	.bean(aMANOController, "mapOSM7VNFD2ProductEagerDataJson");

		from("activemq:topic:ns.metadata.retrieve")
		.log("activemq:topic:ns.metadata.retrieve")
		.choice()
        .when(header("OSMType").isEqualTo("OSMvTEN"))
    		.bean(aMANOController, "mapOSM10NSD2ProductEagerDataJson")
        .when(header("OSMType").isEqualTo("OSMvELEVEN"))
    		.bean(aMANOController, "mapOSM10NSD2ProductEagerDataJson")
        .when(header("OSMType").isEqualTo("OSMvTHIRTEEN"))
    		.bean(aMANOController, "mapOSM10NSD2ProductEagerDataJson");
        //.when(header("OSMType").isEqualTo("GenericSOL005"))
        //	.bean(aMANOController, "mapOSM7NSD2ProductEagerDataJson");

		from("jms:queue:ns.action.run")
		.log("jms:queue:ns.action.run")
		.convertBodyTo( String.class )
		.bean(aMANOController, "performNSInstanceAction")
		.marshal().json( JsonLibrary.Jackson, true)
		.convertBodyTo(String.class)
		.log("action run ok with ${body}");

		from("jms:queue:ns.scale.run")
		.log("jms:queue:ns.scale.run")
		.convertBodyTo( String.class )
		.bean(aMANOController, "performNSInstanceScale")
		.marshal().json( JsonLibrary.Jackson, true)
		.convertBodyTo(String.class)
		.log("scale operation run ok with ${body}");
				

		from( NFV_CATALOG_NSACTIONS_SCALE )
		.log(LoggingLevel.INFO, log, NFV_CATALOG_NSACTIONS_SCALE + " message received!")
		.to("log:DEBUG?showBody=true&showHeaders=true")
		.unmarshal()
		.json( JsonLibrary.Jackson, ScaleDescriptor.class, true) 
		.bean(aMANOController, "performNSScale")
		.convertBodyTo(String.class);
		
		
		
		
		
		from("activemq:topic:ns.action.getnslcmdetails")
		.log("activemq:topic:ns.action.getnslcmdetails")
		.convertBodyTo( String.class )
		.bean(aMANOController, "getNSLCMDetails")
		.convertBodyTo(JSONObject.class)
    	.log("action run ok with ${body}");
		
		from("activemq:queue:ns.scalealert")
		.convertBodyTo( String.class )
		.bean(aMANOController, "getScaleAlertMessageBody");
				
	}	
}
Loading
Loading