2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.mso.adapters.vnf.test;
24 import java.util.HashMap;
27 import javax.xml.ws.Holder;
29 import org.openecomp.mso.adapters.vnf.MsoVnfAdapter;
30 import org.openecomp.mso.adapters.vnf.MsoVnfAdapterImpl;
31 import org.openecomp.mso.openstack.beans.VnfRollback;
32 import org.openecomp.mso.adapters.vnf.exceptions.VnfException;
34 public class VnfCreateTest {
35 public final static void main (String args[])
37 MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl();
38 log ("Got a VnfAdapter");
41 String cloudId = "MT";
42 String tenantName = "John_Test";
43 String vnfType = "ApacheDemo";
44 String vnfName = "AdapterTest";
45 Map<String,String> inputs = new HashMap<>();
46 inputs.put("vnf_id", "abc");
47 inputs.put("extra", "whocares");
48 inputs.put("private_subnet_gateway", "10.4.1.1");
49 inputs.put("private_subnet_cidr", "10.4.1.0/29");
51 // Web Service Outputs
52 Holder<String> vnfId = new Holder<>();
53 Holder<Map<String,String>> outputs = new Holder<>();
54 Holder<VnfRollback> vnfRollback = new Holder<>();
57 vnfAdapter.createVnf(cloudId, tenantName, vnfType,null, vnfName, null, null, inputs, false, true, null,
58 vnfId, outputs, vnfRollback);
59 } catch (VnfException e) {
60 log ("Got a Create Exception: " + e);
64 log ("Created VNF, ID = " + vnfId.value);
65 for (String key : outputs.value.keySet()) {
66 log (" " + key + " = " + outputs.value.get(key));
68 if (vnfRollback.value != null)
69 log (vnfRollback.value.toString());
73 } catch (InterruptedException e) {}
75 log ("Rolling Back VNF");
77 vnfAdapter.rollbackVnf(vnfRollback.value);
78 } catch (VnfException e) {
79 log ("Got a Rollback Exception: " + e);
81 log ("VNF Rolled Back");
84 private static void log (String msg) {
85 System.out.println (msg);