2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * ================================================================================
9 * Modifications Copyright (C) 2019 Ericsson
10 * =============================================================================
11 * Licensed under the Apache License, Version 2.0 (the "License");
12 * you may not use this file except in compliance with the License.
13 * You may obtain a copy of the License at
15 * http://www.apache.org/licenses/LICENSE-2.0
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
23 * ============LICENSE_END=========================================================
26 package org.onap.appc.seqgen.provider;
28 import java.util.HashMap;
29 import java.util.HashSet;
30 import java.util.LinkedList;
31 import java.util.List;
34 import java.util.concurrent.ExecutorService;
35 import java.util.concurrent.Executors;
36 import java.util.concurrent.Future;
37 import org.apache.commons.lang.StringUtils;
38 import org.onap.appc.dg.objects.InventoryModel;
39 import org.onap.appc.dg.objects.Node;
40 import org.onap.appc.dg.objects.VnfcDependencyModel;
41 import org.onap.appc.domainmodel.Vnf;
42 import org.onap.appc.domainmodel.Vnfc;
43 import org.onap.appc.domainmodel.Vserver;
44 import org.onap.appc.domainmodel.lcm.VNFOperation;
45 import org.onap.appc.exceptions.APPCException;
46 import org.onap.appc.seqgen.SequenceGenerator;
47 import org.onap.appc.seqgen.impl.SequenceGeneratorFactory;
48 import org.onap.appc.seqgen.objects.CapabilityModel;
49 import org.onap.appc.seqgen.objects.Constants;
50 import org.onap.appc.seqgen.objects.Constants.Action;
51 import org.onap.appc.seqgen.objects.PreCheckOption;
52 import org.onap.appc.seqgen.objects.RequestInfo;
53 import org.onap.appc.seqgen.objects.RequestInfoBuilder;
54 import org.onap.appc.seqgen.objects.Response;
55 import org.onap.appc.seqgen.objects.SequenceGeneratorInput;
56 import org.onap.appc.seqgen.objects.SequenceGeneratorInputBuilder;
57 import org.onap.appc.seqgen.objects.Transaction;
58 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
59 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
60 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
61 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
62 import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.GenerateSequenceInput;
63 import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.GenerateSequenceOutput;
64 import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.GenerateSequenceOutputBuilder;
65 import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.SequenceGeneratorService;
66 import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.dependency.info.dependency.info.Vnfcs;
67 import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.inventory.info.inventory.info.vnf.info.Vm;
68 import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.response.StatusBuilder;
69 import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.response.Transactions;
70 import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.response.TransactionsBuilder;
71 import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.response.transactions.ActionIdentifier;
72 import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.response.transactions.ActionIdentifierBuilder;
73 import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.response.transactions.PrecheckOptions;
74 import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.response.transactions.PrecheckOptionsBuilder;
75 import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.response.transactions.Responses;
76 import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.response.transactions.ResponsesBuilder;
77 import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.response.transactions.responses.ResponseActionBuilder;
78 import org.opendaylight.yangtools.yang.common.RpcResult;
79 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
80 import com.att.eelf.configuration.EELFLogger;
81 import com.att.eelf.configuration.EELFManager;
82 import com.google.common.util.concurrent.Futures;
83 import com.google.common.util.concurrent.ListenableFuture;
86 public class SequenceGeneratorProvider implements AutoCloseable,SequenceGeneratorService {
87 protected DataBroker dataBroker;
88 protected RpcProviderRegistry rpcRegistry;
89 protected NotificationPublishService notificationService;
90 protected BindingAwareBroker.RpcRegistration<SequenceGeneratorService> rpcRegistration;
91 private final EELFLogger log = EELFManager.getInstance().getLogger(SequenceGeneratorProvider.class);
92 private final ExecutorService executor;
93 private final static String APP_NAME = "SequenceGeneratorProvider";
95 public SequenceGeneratorProvider(DataBroker dataBroker2, NotificationPublishService notificationProviderService,
96 RpcProviderRegistry rpcRegistry2) {
97 log.info("Creating provider for " + APP_NAME);
98 executor = Executors.newFixedThreadPool(1);
99 this.dataBroker = dataBroker2;
100 this.notificationService = notificationProviderService;
102 this.rpcRegistry = rpcRegistry2;
104 if (this.rpcRegistry != null) {
105 rpcRegistration = rpcRegistry.addRpcImplementation(SequenceGeneratorService.class, this);
107 log.info("Initialization complete for " + APP_NAME);
111 public void close() throws Exception {
112 log.info("Closing provider for " + APP_NAME);
113 if(this.executor != null){
116 if(this.rpcRegistration != null) {
117 rpcRegistration.close();
119 log.info("Successfully closed provider for " + APP_NAME);
123 public ListenableFuture<RpcResult<GenerateSequenceOutput>> generateSequence(GenerateSequenceInput input) {
124 RpcResult<GenerateSequenceOutput> rpcResult=null;
125 log.debug("Received input = " + input );
127 if(input.getRequestInfo()==null){
128 throw new APPCException("Request info is missing in the input");
130 SequenceGenerator seqGenerator = SequenceGeneratorFactory.getInstance()
131 .createSequenceGenerator(VNFOperation.findByString(input.getRequestInfo().getAction().name()));
132 SequenceGeneratorInput seqGenInput = buildSeqGenInput(input);
133 List<Transaction> transactions = seqGenerator.generateSequence(seqGenInput);
134 if (transactions.isEmpty()) {
135 rpcResult = buildFailureResponse("Request is not supported", 450);
137 rpcResult = buildSuccessResponse(transactions);
139 } catch (Exception e) {
140 log.error("Error Generating Sequence",e);
141 rpcResult = buildFailureResponse(e.getMessage(), 0);
143 return Futures.immediateFuture(rpcResult);
146 private RpcResult<GenerateSequenceOutput> buildSuccessResponse(List<Transaction> transactions) {
147 log.info("Building response from the list of transactions");
148 List<Transactions> transactionList = new LinkedList<>();
149 for(Transaction transaction: transactions) {
150 ActionIdentifier actionIdentifier = buildActionIdentifierForResponse(transaction);
151 List<PrecheckOptions> precheckOptions = buildPrecheckOptionsForResponse(transaction);
152 List<Responses> responseList = getResponses(transaction);
153 Transactions transactionObj
154 = new TransactionsBuilder()
155 .setActionIdentifier(actionIdentifier)
156 .setAction(transaction.getAction())
157 .setActionLevel(transaction.getActionLevel())
158 .setPrecheckOperator(transaction.getPreCheckOperator())
159 .setPayload(transaction.getPayload())
160 .setTransactionId(transaction.getTransactionId())
161 .setPrecheckOptions(precheckOptions)
162 .setResponses(responseList)
164 transactionList.add(transactionObj);
167 GenerateSequenceOutputBuilder builder = new GenerateSequenceOutputBuilder()
168 .setTransactions(transactionList);
170 return RpcResultBuilder
171 .<GenerateSequenceOutput> status(true)
172 .withResult(builder.build()).build();
175 private ActionIdentifier buildActionIdentifierForResponse(Transaction transaction) {
176 log.info("Adding action identifiers to response.");
177 ActionIdentifier actionIdentifier = null;
178 if(transaction.getActionIdentifier() != null){
179 actionIdentifier = new ActionIdentifierBuilder()
180 .setVnfId(transaction.getActionIdentifier().getVnfId())
181 .setVnfcName(transaction.getActionIdentifier().getVnfcName())
182 .setVserverId(transaction.getActionIdentifier().getvServerId())
185 return actionIdentifier;
188 private List<PrecheckOptions> buildPrecheckOptionsForResponse(Transaction transaction) {
189 log.info("Adding Precheck options to response");
190 List<PrecheckOptions> precheckOptions = new LinkedList<>();
191 if(transaction.getPrecheckOptions() != null){
192 for(PreCheckOption option:transaction.getPrecheckOptions()){
193 PrecheckOptions precheckOption = new PrecheckOptionsBuilder()
194 .setParamName(option.getParamName())
195 .setParamValue(option.getParamValue())
196 .setPreTransactionId(option.getPreTransactionId())
197 .setRule(option.getRule())
199 precheckOptions.add(precheckOption);
202 return precheckOptions;
204 private List<Responses> getResponses(Transaction transaction) {
205 log.info("Building response from the Transaction");
206 List<Responses> responseList = new LinkedList<>();
207 for(Response resp : transaction.getResponses()){
208 Map<String,String> responseActions = resp.getResponseAction();
209 ResponseActionBuilder responseActionBuilder = new ResponseActionBuilder();
210 if(responseActions.get(Constants.ResponseAction.WAIT.getAction()) != null){
211 responseActionBuilder = responseActionBuilder.setWait(Integer.parseInt(responseActions.get(Constants.ResponseAction.WAIT.getAction())));
213 if(responseActions.get(Constants.ResponseAction.RETRY.getAction()) != null){
214 responseActionBuilder = responseActionBuilder.setRetry(Integer.parseInt(responseActions.get(Constants.ResponseAction.RETRY.getAction())));
216 if(responseActions.get(Constants.ResponseAction.CONTINUE.getAction().toLowerCase())!=null){
217 responseActionBuilder = responseActionBuilder
218 .setContinue(Boolean.parseBoolean(responseActions.get(Constants.ResponseAction.CONTINUE.getAction().toLowerCase())));
220 if(responseActions.get(Constants.ResponseAction.IGNORE.getAction()) != null){
221 responseActionBuilder = responseActionBuilder.setIgnore(Boolean.parseBoolean(responseActions.get(Constants.ResponseAction.IGNORE.getAction())));
223 if(responseActions.get(Constants.ResponseAction.STOP.getAction()) != null){
224 responseActionBuilder = responseActionBuilder.setStop(Boolean.parseBoolean(responseActions.get(Constants.ResponseAction.STOP.getAction())));
226 if(responseActions.get(Constants.ResponseAction.JUMP.getAction()) != null){
227 responseActionBuilder = responseActionBuilder.setJump(Integer.parseInt(responseActions.get(Constants.ResponseAction.JUMP.getAction())));
229 Responses response = new ResponsesBuilder()
230 .setResponseMessage(resp.getResponseMessage())
231 .setResponseAction(responseActionBuilder.build())
233 responseList.add(response);
238 private SequenceGeneratorInput buildSeqGenInput(GenerateSequenceInput input) throws APPCException {
240 log.info("Building SequenceGeneratorInput from Yang object GenerateSequenceInput.");
241 validateMandatory(input);
243 RequestInfo requestInfo = buildRequestInfoForSeqGenInput(input);
244 InventoryModel inventoryModel = readInventoryModel(input);
246 VnfcDependencyModel dependencyModel = readDependencyModel(input);
247 if(dependencyModel != null){
248 validateInventoryModelWithDependencyModel(dependencyModel, inventoryModel);
251 CapabilityModel capModel = buildCapabilitiesForSeqGenInput(input);
253 SequenceGeneratorInputBuilder builder = new SequenceGeneratorInputBuilder()
254 .requestInfo(requestInfo)
255 .inventoryModel(inventoryModel)
256 .dependendcyModel(dependencyModel)
257 .capabilityModel(capModel);
259 builder = buildTunableParamsForSeqGenInput(input, builder);
261 return builder.build();
264 private SequenceGeneratorInputBuilder buildTunableParamsForSeqGenInput(GenerateSequenceInput input, SequenceGeneratorInputBuilder builder) {
265 log.info("Initializing Tunable Parameters based on YANG object.");
266 if(input.getTunableParameters() != null){
267 builder = builder.tunableParameter(Constants.RETRY_COUNT,String.valueOf(input.getTunableParameters().getRetryCount()))
268 .tunableParameter(Constants.WAIT_TIME,String.valueOf(input.getTunableParameters().getWaitTime()));
269 if(input.getTunableParameters().getStrategy() != null){
270 builder = builder.tunableParameter(Constants.STRATEGY,input.getTunableParameters().getStrategy().name());
276 public CapabilityModel buildCapabilitiesForSeqGenInput(GenerateSequenceInput input) {
277 log.info("Initializing capabilities based on YANG object.");
279 List<String> vnfCapabilities = null;
280 List<String> vfModuleCapabilities = null;
281 Map<String, List<String>> vmCapabilities = null;
282 List<String> vnfcCapabilities = null;
284 if(input.getCapabilities()!=null){
285 if(input.getCapabilities().getVnf()!=null){
286 vnfCapabilities = input.getCapabilities().getVnf();
288 if(input.getCapabilities().getVnfc()!=null){
289 vfModuleCapabilities = input.getCapabilities().getVnfc();
291 if(input.getCapabilities().getVm()!=null){
292 vmCapabilities = new HashMap<String, List<String>>();
293 vmCapabilities.put(Action.ATTACH_VOLUME.getActionType(), input.getCapabilities().getVm().getAttachVolume());
294 vmCapabilities.put(Action.DETACH_VOLUME.getActionType(), input.getCapabilities().getVm().getDetachVolume());
295 vmCapabilities.put(Action.EVACUATE.getActionType(), input.getCapabilities().getVm().getEvacuate());
296 vmCapabilities.put(Action.MIGRATE.getActionType(), input.getCapabilities().getVm().getMigrate());
297 vmCapabilities.put(Action.REBOOT.getActionType(), input.getCapabilities().getVm().getReboot());
298 vmCapabilities.put(Action.REBUILD.getActionType(), input.getCapabilities().getVm().getRebuild());
299 vmCapabilities.put(Action.RESTART.getActionType(), input.getCapabilities().getVm().getRestart());
300 vmCapabilities.put(Action.SNAPSHOT.getActionType(), input.getCapabilities().getVm().getSnapshot());
301 vmCapabilities.put(Action.START.getActionType(), input.getCapabilities().getVm().getStart());
302 vmCapabilities.put(Action.STOP.getActionType(), input.getCapabilities().getVm().getStop());
304 if(input.getCapabilities().getVfModule()!=null){
305 vnfcCapabilities = input.getCapabilities().getVfModule();
308 return new CapabilityModel(vnfCapabilities, vfModuleCapabilities, vmCapabilities, vnfcCapabilities);
311 private void validateInventoryModelWithDependencyModel(VnfcDependencyModel dependencyModel, InventoryModel inventoryModel) throws APPCException {
312 Set<String> dependencyModelVnfcSet = new HashSet<>();
313 Set<String> dependencyModelMandatoryVnfcSet = new HashSet<>();
314 Set<String> inventoryModelVnfcsSet = new HashSet<>();
316 for (Node<Vnfc> node : dependencyModel.getDependencies()) {
317 dependencyModelVnfcSet.add(node.getChild().getVnfcType().toLowerCase());
318 if (node.getChild().isMandatory()) {
319 dependencyModelMandatoryVnfcSet.add(node.getChild().getVnfcType().toLowerCase());
323 for (Vnfc vnfc : inventoryModel.getVnf().getVnfcs()) {
324 inventoryModelVnfcsSet.add(vnfc.getVnfcType().toLowerCase());
327 // if dependency model and inventory model contains same set of VNFCs, validation succeed and hence return
328 if (dependencyModelVnfcSet.equals(inventoryModelVnfcsSet)) {
332 if (inventoryModelVnfcsSet.size() >= dependencyModelVnfcSet.size()) {
333 Set<String> difference = new HashSet<>(inventoryModelVnfcsSet);
334 difference.removeAll(dependencyModelVnfcSet);
335 log.error("Dependency model is missing following vnfc type(s): " + difference);
336 throw new APPCException("Dependency model is missing following vnfc type(s): " + difference);
338 Set<String> difference = new HashSet<>(dependencyModelMandatoryVnfcSet);
339 difference.removeAll(inventoryModelVnfcsSet);
340 if (difference.size() > 0) {
341 log.error("Inventory model is missing following mandatory vnfc type(s): " + difference);
342 throw new APPCException("VMs missing for the mandatory VNFC : " + difference);
347 private RequestInfo buildRequestInfoForSeqGenInput(GenerateSequenceInput input) {
348 log.info("Building RequestInfo from Yang object");
349 RequestInfoBuilder requestInfobuilder = buildRequestInformation(input);
351 if(input.getRequestInfo().getActionIdentifier() != null){
352 requestInfobuilder = buildActionIdentifiers(input, requestInfobuilder);
355 return requestInfobuilder.build();
358 private RequestInfoBuilder buildActionIdentifiers(GenerateSequenceInput input, RequestInfoBuilder requestInfobuilder) {
359 log.info("Initializing actionIdentifier for RequestInfo");
360 requestInfobuilder = requestInfobuilder
362 .vnfId(input.getRequestInfo().getActionIdentifier().getVnfId())
363 .vnfcName(input.getRequestInfo().getActionIdentifier().getVnfcName())
364 .vServerId(input.getRequestInfo().getActionIdentifier().getVserverId());
365 return requestInfobuilder;
368 private RequestInfoBuilder buildRequestInformation(GenerateSequenceInput input) {
369 log.info("Initializing action, actionLevel and payload for RequestInfo");
370 return new RequestInfoBuilder()
371 .action(input.getRequestInfo().getAction().name())
372 .actionLevel(input.getRequestInfo().getActionLevel().getName().toLowerCase())
373 .payload(input.getRequestInfo().getPayload());
376 private void validateMandatory(GenerateSequenceInput input) throws APPCException {
377 if(input.getRequestInfo() == null){
378 throw new APPCException("Request Info is not present in the request");
380 if(input.getRequestInfo().getAction() == null){
381 throw new APPCException("Action is not present in the request");
383 if(input.getInventoryInfo() == null){
384 throw new APPCException("inventoryInfo is not provided in the input");
386 if (input.getInventoryInfo().getVnfInfo() == null) {
387 log.error("vnfInfo is null in the input");
388 throw new APPCException("vnfInfo is missing in the input");
390 if(input.getInventoryInfo().getVnfInfo().getVm().isEmpty()){
391 log.error("Null vm information in input.");
392 throw new APPCException("VnfInfo is missing in the input");
394 log.info("Mandatory information present in the request.");
397 private VnfcDependencyModel readDependencyModel(GenerateSequenceInput input) throws APPCException{
398 log.info("Initializing DependencyModel from YANG model.");
399 if(input.getDependencyInfo() == null || input.getDependencyInfo().getVnfcs() == null || input.getDependencyInfo().getVnfcs().isEmpty()){
400 log.info("No dependency model information is present for the request.");
403 List<Vnfcs> vnfcs = input.getDependencyInfo().getVnfcs();
404 Set<Node<org.onap.appc.domainmodel.Vnfc>> dependencies = new HashSet<>();
405 Set<String> parentVnfcs = new HashSet<>();
406 Set<String> allVnfcTypes = new HashSet<>();
407 for(Vnfcs vnfcObj:vnfcs) {
408 org.onap.appc.domainmodel.Vnfc vnfc = new org.onap.appc.domainmodel.Vnfc();
409 vnfc.setVnfcType(vnfcObj.getVnfcType());
410 allVnfcTypes.add(vnfcObj.getVnfcType());
411 vnfc.setResilienceType(vnfcObj.getResilience());
412 Node<Vnfc> currentNode = buildVnfcNodeForDependenyInfo(dependencies, vnfcObj, vnfc);
413 for(String parentVnfcType:vnfcObj.getParents()) {
414 parentVnfcs.add(parentVnfcType);
415 Node<Vnfc> parentNode = readNode(parentVnfcType, dependencies);
416 if(parentNode == null){
417 Vnfc parentVnfc = new Vnfc();
418 parentVnfc.setVnfcType(parentVnfcType);
419 parentNode = new Node<>(parentVnfc);
420 currentNode.addParent(parentVnfc);
421 dependencies.add(parentNode);
424 currentNode.addParent(parentNode.getChild());
428 for(String parent:parentVnfcs){
429 if(!allVnfcTypes.contains(parent)){
430 throw new APPCException("Dependency model missing vnfc type " + parent);
433 return new VnfcDependencyModel(dependencies);
436 private Node<Vnfc> buildVnfcNodeForDependenyInfo(Set<Node<Vnfc>> dependencies, Vnfcs vnfcObj, Vnfc vnfc) {
437 Node<Vnfc> currentNode = readNode(vnfcObj.getVnfcType(), dependencies);
438 if(currentNode == null){
439 currentNode = new Node<>(vnfc);
440 dependencies.add(currentNode);
443 currentNode.getChild().setResilienceType(vnfcObj.getResilience());
444 currentNode.getChild().setMandatory(vnfcObj.isMandatory());
449 private Node<org.onap.appc.domainmodel.Vnfc> readNode(String vnfcType, Set<Node<org.onap.appc.domainmodel.Vnfc>> dependencies) {
450 for(Node<org.onap.appc.domainmodel.Vnfc> node : dependencies){
451 if(node.getChild().getVnfcType().equalsIgnoreCase(vnfcType)){
458 private InventoryModel readInventoryModel(GenerateSequenceInput input) throws APPCException {
460 log.info("Initializing InventoryModel from Yang input model");
461 Vnf vnf = createVnfForInventoryModel(input);
462 Map<org.onap.appc.domainmodel.Vnfc, List<Vserver>> map = new HashMap<>();
463 buildVserverDetailsForInventoryModel(input, vnf, map);
464 for(Map.Entry<org.onap.appc.domainmodel.Vnfc, List<Vserver>> entry:map.entrySet()){
465 org.onap.appc.domainmodel.Vnfc vnfc = entry.getKey();
466 List<Vserver> vmList = entry.getValue();
467 vnfc.addVservers(vmList);
469 return new InventoryModel(vnf);
472 private void buildVserverDetailsForInventoryModel(GenerateSequenceInput input, Vnf vnf, Map<Vnfc, List<Vserver>> map) throws APPCException {
473 if(input.getInventoryInfo().getVnfInfo().getVm().size() < 1) {
474 throw new APPCException("vnfInfo is missing in the input");
476 for(Vm vm:input.getInventoryInfo().getVnfInfo().getVm()) {
477 if(StringUtils.isBlank(vm.getVserverId())){
478 throw new APPCException("vserver-id not found ");
480 Vserver vserver=new Vserver();
481 vserver.setId(vm.getVserverId());
482 if(!StringUtils.isBlank(vm.getVnfc().getVnfcName()) &&
483 !StringUtils.isBlank(vm.getVnfc().getVnfcType())) {
484 Vnfc vfc = new Vnfc();
485 vfc.setVnfcName(vm.getVnfc().getVnfcName());
486 vfc.setVnfcType(vm.getVnfc().getVnfcType());
487 vfc.setVnfcFunctionCode(vm.getVnfc().getVnfcFunctionCode());
488 vserver.setVnfc(vfc);
489 List<Vserver> vms = map.get(vfc);
491 vms = new LinkedList<>();
496 vnf.addVserver(vserver);
500 private Vnf createVnfForInventoryModel(GenerateSequenceInput input) {
501 log.info("Setting VnfId and VnfType values for Vnf Inventory Model ");
503 vnf.setVnfId(input.getInventoryInfo().getVnfInfo().getVnfId());
504 vnf.setVnfType(input.getInventoryInfo().getVnfInfo().getVnfType());
505 vnf.setIdentityUrl(input.getInventoryInfo().getVnfInfo().getIdentityUrl());
509 private RpcResult<GenerateSequenceOutput> buildFailureResponse(String errorMessage, int errorCode){
510 GenerateSequenceOutputBuilder sequenceGeneratorOutputBuilder=new GenerateSequenceOutputBuilder();
511 StatusBuilder statusBuilder = new StatusBuilder();
512 statusBuilder.setCode((errorCode != 0)? errorCode : 401);
513 statusBuilder.setMessage(errorMessage);
514 sequenceGeneratorOutputBuilder.setStatus(statusBuilder.build());
515 return RpcResultBuilder
516 .<GenerateSequenceOutput> status(true)
517 .withResult(sequenceGeneratorOutputBuilder.build())