# moco properties
cli.sample.gen.enable=true
+cli.sample.gen.name=$s{env:OPEN_CLI_USECASE}
cli.sample.gen.target=$s{env:OPEN_CLI_HOME}/open-cli-sample
# mrkanag Move this to db, once exteranl command registration is supported in place of discovery
public static final String SAMPLE_GEN_ENABLED = "cli.sample.gen.enable";
public static final String SAMPLE_GEN_TARGET_FOLDER = "cli.sample.gen.target";
+ public static final String SAMPLE_GEN_NAME = "cli.sample.gen.name";
public static final String OPEN_CLI_SAMPLE_VERSION = "open_cli_sample_version";
public static final String OPEN_CLI_SAMPLE_VERSION_VALUE_1_0 = "1.0";
# moco properties
cli.sample.gen.enable=false
+cli.sample.gen.name=sample1
cli.sample.gen.target=./open-cli-sample
# mrkanag Move this to db, once exteranl command registration is supported in place of discovery
SampleYamlGenerator.generateSampleYaml(cmd.getName(), args, cmd.getResult().print(),
cmd.getInfo().getProduct(),
OnapCommandConfig.getPropertyValue(OnapCommandConstants.SAMPLE_GEN_TARGET_FOLDER) + "/" + cmd.getSchemaName().replaceAll(".yaml", "") + "-sample.yaml",
- cmd.getResult().isDebug());
+ cmd.getResult().isDebug(),
+ OnapCommandConfig.getPropertyValue(OnapCommandConstants.SAMPLE_GEN_NAME));
} catch (IOException error) {
throw new OnapCommandInvalidSample(this.cmdName, error);
}
open_cli_sample_version: 1.0
-name: vnf-tosca-provision
+name: vnf-tosca-lcm
version: onap-dublin
samples:
sample1:
- name: vnf-tosca-provision
+ name: vnf-tosca-lcm
input: --mode checkup --vsp c:\Users\k00365106\Desktop\vtp\tosca-lcm\vgw.csar --vnf-csar c:\Users\k00365106\Desktop\vtp\tosca-lcm\vgw.csar --ns-csar c:\Users\k00365106\Desktop\vtp\tosca-lcm\vgw.csar --vnfm-driver hwvnfmdriver --timeout 800000 --vnf-name vgw12345678901 --vnf-vendor-name vnfvendor12345678901 --onap-objects D:\workspace\cli\deployment\zip\target\deployunzip\data\tmp\1234567890-1567065851687_result.json
moco: vnf-tosca-provision-dublin-schema-moco.json
output: |
# limitations under the License.
open_cli_schema_version: 1.0
-name: vnf-tosca-provision
+name: vnf-tosca-lcm
description: |
ONAP TOSCA VNF validation using ONAP CLI and Open Command Platform (OCOMP)
Similarly, other service IP and Port could be discovered like above, in case not know earlier :)
This profile would be used while running the command with ONAP setup configured in it, as below
- oclip --profile onap-dublin vnf-tosca-provision .....
+ oclip --profile onap-dublin vnf-tosca-lcm .....
e. Verify these details once by typing 'set'
type: string
short_option: x
long_option: config-json
- default_value: $s{env:OPEN_CLI_HOME}/conf/vnf-tosca-provision.json
+ default_value: $s{env:OPEN_CLI_HOME}/conf/vnf-tosca-lcm.json
is_optional: false
- name: vsp
description: Path to the ONAP vendor service product (VSP) for the VNF to provision
scope: short
cmd:
command:
- - python $s{env:OPEN_CLI_HOME}/script/vnf-tosca-provision.py --vendor-name ${vnf-vendor-name} --vnf-name ${vnf-name} --mode ${mode} --result-json $s{tmp:result.json:onap-objects} --conf ${config-json} --vsp ${vsp} --vnf-csar ${vnf-csar} --ns-csar ${ns-csar} --vnfm-driver ${vnfm-driver}
+ - python $s{env:OPEN_CLI_HOME}/script/vnf-tosca-lcm.py --vendor-name ${vnf-vendor-name} --vnf-name ${vnf-name} --mode ${mode} --result-json $s{tmp:result.json:onap-objects} --conf ${config-json} --vsp ${vsp} --vnf-csar ${vnf-csar} --ns-csar ${ns-csar} --vnfm-driver ${vnfm-driver}
success_codes:
- 0
working_directory: .
# See the License for the specific language governing permissions and
# limitations under the License.
+# This script uses the ONAP CLI for providing the end-end service creation and termination.
+# Used in devops, testing, certification and production
+# NOTE: This feature is avaialble as ONAP CLI vnf-tosca-lcm
+#
+# Author: kanagaraj.manickam@huawei.com
+#
+
import json
import os
import argparse
import subprocess
import platform
import datetime
+import string
+import random
+
from argparse import RawTextHelpFormatter
if platform.system() == 'Windows':
conf,
request_id,
debug = False):
- self.conf = conf
+ self.conf = conf or {}
self.ocomp = OCOMP(request_id, debug, product=product, profile=profile)
self.preload()
self.tag = 'Powered by Open Command Platform - OCOMP'
if self.conf['ONAP']:
for attr in self.conf['ONAP']:
setattr(self, attr, self.conf['ONAP'][attr])
+ else:
+ self.conf['ONAP'] = {}
def create_vlm(self):
submit = False
def setup_cloud_and_subscription(self):
associate = False
if not self.location_id and not self.location_version:
- location_id = 'ocomp-region-{}'.format(self.ocomp.request_id)
+ location_id = 'ocomp-region-{}'.format(self.conf['ONAP']['uid'])
self.ocomp.run(command='complex-create',
params={'physical-location-id': location_id,
'data-center-code': 'ocomp',
break
if not self.cloud_id and not self.cloud_version:
- cloud_id = 'OCOMP-{}'.format(self.ocomp.request_id)
+ cloud_id = 'OCOMP-{}'.format(self.conf['ONAP']['uid'])
self.ocomp.run(command='cloud-create',
params={'region-name': self.conf['cloud']['region'],
'complex-name': self.location_id,
subscribe = False
if not self.service_type_id and not self.service_type_version:
- service_type_id = '{}-{}'.format(self.conf['subscription']['service-type'], self.ocomp.request_id)
+ service_type_id = '{}-{}'.format(self.conf['subscription']['service-type'], self.conf['ONAP']['uid'])
self.ocomp.run(command='service-type-create',
params={'service-type': service_type_id,
'service-type-id': service_type_id})
break
if not self.customer_id and not self.customer_version:
- customer_id = '{}-{}'.format(self.conf['subscription']['customer-name'], self.ocomp.request_id)
+ customer_id = '{}-{}'.format(self.conf['subscription']['customer-name'], self.ocomp.conf['ONAP']['random'])
self.ocomp.run(command='customer-create',
params={'customer-name': customer_id,
'subscriber-name': customer_id})
def cleanup(self):
if self.ns_instance_id:
+ self.ocomp.run(command='vfc-nslcm-terminate',
+ params={'ns-instance-id': self.ns_instance_id})
self.ocomp.run(command='vfc-nslcm-delete',
params={'ns-instance-id': self.ns_instance_id})
self.ns_instance_id = None
config_file = args.config_file_path
with open(config_file) as json_file:
conf = json.load(json_file)
+ if not conf['ONAP']['uid']:
+ conf['ONAP']['uid'] = ''.join(random.sample(string.ascii_lowercase,5))
if vsp_csar:
conf['vnf']['vsp-csar'] = vsp_csar
if vnf_csar:
conf['vnf']['ns-csar'] = vnf_csar
if vnf_name:
conf['vnf']['name'] = vnf_name
- conf['vnf']['name'] = '{}{}'.format(conf['vnf']['name'], request_id).replace("-", "").replace("_", "")
- if vnf_name:
+ conf['vnf']['name'] = '{}{}'.format(conf['vnf']['name'], conf['ONAP']['uid'])
+ if vendor_name:
conf['vnf']['vendor-name'] = vendor_name
- conf['vnf']['vendor-name'] = '{}-{}'.format(conf['vnf']['vendor-name'], request_id)
-
+ conf['vnf']['vendor-name'] = '{}-{}'.format(conf['vnf']['vendor-name'], conf['ONAP']['uid'])
if args.result:
result_file = args.result
[ {
"request" : {
"method" : "post",
- "uri" : "/api/catalog/v1/nspackages",
- "headers" : {
- "Accept" : "application/json",
- "Content-Type" : "application/json"
- },
- "json" : {
- "csarId" : "a3394090-c5b4-49b4-974c-00a6eac755ab"
- }
+ "uri" : "/api/catalog/v1/nspackages"
},
"response" : {
"status" : 202,
[ {
"request" : {
"method" : "post",
- "uri" : "/api/catalog/v1/vnfpackages",
- "headers" : {
- "Accept" : "application/json",
- "Content-Type" : "application/json"
- },
- "json" : {
- "csarId" : "c1cec675-1069-487d-b1a9-c256b17c3291"
- }
+ "uri" : "/api/catalog/v1/vnfpackages"
},
"response" : {
"status" : 202,
"jobId" : "1d871fc4-380c-4699-8f7f-77e508f9734d"
}
}
-} ]
\ No newline at end of file
+} ]
--- /dev/null
+[
+ {
+ "include" : "catalog/vfc-catalog-onboard-vnf-schema-moco.json"
+ },
+ {
+ "include" : "catalog/vfc-catalog-onboard-ns-schema-moco.json"
+ },
+ {
+ "include" : "nslcm/vfc-nslcm-create-schema-moco.json"
+ },
+ {
+ "include" : "nslcm/vfc-nslcm-instantiate-schema-moco.json"
+ },
+ {
+ "include" : "nslcm/vfc-nslcm-delete-schema-moco.json"
+ },
+ {
+ "include" : "nslcm/vfc-nslcm-terminate-schema-moco.json"
+ }
+]
\ No newline at end of file
[ {
"request" : {
"method" : "post",
- "uri" : "/api/nslcm/v1/ns",
- "headers" : {
- "Accept" : "application/json",
- "Content-Type" : "application/json"
- },
- "json" : {
- "csarId" : "a3394090-c5b4-49b4-974c-00a6eac755ab",
- "nsName" : "vcpe1"
- }
+ "uri" : "/api/nslcm/v1/ns"
},
"response" : {
"status" : 201,
--- /dev/null
+[ {
+ "request" : {
+ "method" : "delete",
+ "uri" : "/api/nslcm/v1/ns/25f3159c-ff2d-4ad0-ac66-3270941bfa52"
+ },
+ "response" : {
+ "status" : 204,
+ "json" : null
+ }
+} ]
--- /dev/null
+open_cli_sample_version: 1.0
+name: vfc-nslcm-delete
+version: onap-dublin
+samples:
+ sample1:
+ name: vfc-nslcm-delete
+ input: --host-url http://localhost:12306 --ns-instance-id 25f3159c-ff2d-4ad0-ac66-3270941bfa52
+ moco: vfc-nslcm-delete-schema-moco.json
+ output:
\ No newline at end of file
--- /dev/null
+[ {
+ "request" : {
+ "method" : "post",
+ "uri" : "/api/nslcm/v1/ns/25f3159c-ff2d-4ad0-ac66-3270941bfa52/instantiate"
+ },
+ "response" : {
+ "status" : 200,
+ "json" : {
+ "jobId" : "7b06898d-e67a-4c9f-b1ce-90346ed6e520"
+ }
+ }
+} ]
--- /dev/null
+open_cli_sample_version: 1.0
+name: vfc-nslcm-instantiate
+version: onap-dublin
+samples:
+ sample1:
+ name: vfc-nslcm-instantiate
+ input: --host-url http://localhost:12306 --ns-instance-id 25f3159c-ff2d-4ad0-ac66-3270941bfa52 --location OCOMP-lcm3_RegionOVP --sdn-controller-id 1
+ moco: vfc-nslcm-instantiate-schema-moco.json
+ output: |
+ +--------------------------------------+
+ |job-id |
+ +--------------------------------------+
+ |7b06898d-e67a-4c9f-b1ce-90346ed6e520 |
+ +--------------------------------------+
--- /dev/null
+[ {
+ "request" : {
+ "method" : "post",
+ "uri" : "/api/nslcm/v1/ns/25f3159c-ff2d-4ad0-ac66-3270941bfa52/terminate"
+ },
+ "response" : {
+ "status" : 202,
+ "json" : {
+ "jobId" : "f479d5eb-82a1-4a1f-9174-e071ee46c841"
+ }
+ }
+} ]
--- /dev/null
+open_cli_sample_version: 1.0
+name: vfc-nslcm-terminate
+version: onap-dublin
+samples:
+ sample1:
+ name: vfc-nslcm-terminate
+ input: --host-url http://localhost:12306 --ns-instance-id 25f3159c-ff2d-4ad0-ac66-3270941bfa52
+ moco: vfc-nslcm-terminate-schema-moco.json
+ output: |
+ +--------------------------------------+
+ |job-id |
+ +--------------------------------------+
+ |f479d5eb-82a1-4a1f-9174-e071ee46c841 |
+ +--------------------------------------+
is_optional: false
results:
- direction: landscape
+ direction: portrait
attributes:
- name: ns-instance-id
description: ns-instance-id
long_option: ns-instance-id
is_optional: false
-results:
- direction: landscape
- attributes:
- - name: status
- description: status
- scope: short
- type: string
-
http:
service:
auth: none
Accept: application/json
success_codes:
- 204
- result_map:
- status: ${success_codes}
+
author: ONAP HPA Integration Team (haibin.huang@intel.com)
results:
- direction: landscape
+ direction: portrait
attributes:
- name: ns-instance-id
description: ns-instance-id
is_optional: false
results:
- direction: landscape
+ direction: portrait
attributes:
- name: job-id
description: job id
is_optional: false
results:
- direction: landscape
+ direction: portrait
attributes:
- name: job-id
description: job id
static int nTab;
public static void generateSampleYaml(String cmdName, List<String> input, String output, String version,
- String targetPath, boolean debug) throws IOException {
+ String targetPath, boolean debug, String name) throws IOException {
PrintWriter writer = new PrintWriter(targetPath, "UTF-8");
writeKeyValuePair(writer, "open_cli_sample_version", "1.0");
writeKeyValuePair(writer, "name", cmdName);
writeKeyValuePair(writer, "version", version);
+ if (name == null) {
+ name = "sample1";
+ }
writeKey(writer, "samples");
- writeKey(writer, "sample1");
+ writeKey(writer, name);
writeKeyValuePair(writer, "name", cmdName);
writeKeyValuePair(writer, "input", input.stream().collect(Collectors.joining(" ")).trim());
@Test
public void testGenerateSampleYaml() throws IOException {
SampleYamlGenerator.generateSampleYaml("testcmd", Arrays.asList("-a", "argument"),
- "+--------+\n+val +\n+argument+", "test-version-1.0", "target/test.yaml", false);
+ "+--------+\n+val +\n+argument+", "test-version-1.0", "target/test.yaml", false, "sample1");
}
}