aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzhaoliping123 <zhaoliping@chinamobile.com>2020-04-20 19:58:57 +0800
committerLiping Zhao <zhaoliping@chinamobile.com>2020-04-21 03:19:44 +0000
commit5b181bb499d9dbfccd1e81f643b48d9cb7218d2c (patch)
treef72cb359699ec0aeba314e772bfe6efa4ddf30b9
parent252b3e313b435e5333b1001f2a4decf904d2c892 (diff)
update vnf-tosca-lcm.py
Issue-ID: CLI-263 Change-Id: I16533c3da0ea12c7a594174393d56a516f94f9cc Signed-off-by: zhaoliping123 <zhaoliping@chinamobile.com>
-rw-r--r--products/onap-dublin/features/integration/src/main/resources/script/vnf-tosca-lcm.py105
-rw-r--r--products/onap-dublin/features/vfc/src/main/resources/open-cli-sample/nslcm/vfc-nslcm-get-jobid-schema-moco.json75
-rw-r--r--products/onap-dublin/features/vfc/src/main/resources/open-cli-sample/nslcm/vfc-nslcm-get-jobid-schema-sample.yaml19
-rw-r--r--products/onap-dublin/features/vfc/src/main/resources/open-cli-schema/nslcm/vfc-nslcm-get-jobid.yaml29
-rw-r--r--products/onap-elalto/features/vfc/src/main/resources/open-cli-schema/nslcm/vfc-nslcm-get-jobid.yaml66
5 files changed, 246 insertions, 48 deletions
diff --git a/products/onap-dublin/features/integration/src/main/resources/script/vnf-tosca-lcm.py b/products/onap-dublin/features/integration/src/main/resources/script/vnf-tosca-lcm.py
index d04d54a0..af9cb9b2 100644
--- a/products/onap-dublin/features/integration/src/main/resources/script/vnf-tosca-lcm.py
+++ b/products/onap-dublin/features/integration/src/main/resources/script/vnf-tosca-lcm.py
@@ -30,6 +30,7 @@ import platform
import datetime
import string
import random
+import time
from argparse import RawTextHelpFormatter
@@ -248,8 +249,8 @@ class ONAP:
output = self.ocomp.run(command='vf-model-create',
params={'name': '{} Vnf'.format(self.conf['vnf']['name']),
'vendor-name': self.conf['vnf']['vendor-name'],
-# 'vsp-id': self.vsp_id,
-# 'vsp-version': self.vsp_version, # TODO: SDC fails to add VSP, check it
+ 'vsp-id': self.vsp_id,
+ 'vsp-version': self.vsp_version, # TODO: SDC fails to add VSP, check it
'description': self.tag})
vf_id = output['id']
@@ -259,7 +260,7 @@ class ONAP:
params={'vf-id': vf_id,
'remarks': self.tag,
'artifact': self.conf['vnf']['vnf-csar'],
- 'artifact-name': 'tosca csar'})
+ 'artifact-name': 'vnf.csar'})
output = self.ocomp.run(command='vf-model-certify',
params={'vf-id': vf_id,
@@ -293,7 +294,8 @@ class ONAP:
params={'service-id': ns_id,
'remarks': self.tag,
'artifact': self.conf['vnf']['ns-csar'],
- 'artifact-name': 'tosca csar'})
+ 'artifact-group-type': 'DEPLOYMENT',
+ 'artifact-name': 'ns.csar'})
#set property vnfmdriver
for input in self.vf_inputs:
if input.endswith('.nf_type'):
@@ -367,7 +369,7 @@ class ONAP:
'complex-name': self.location_id,
'identity-url': self.conf['cloud']['identity-url'],
'cloud-owner': cloud_id,
- 'cloud-type': 'OpenStack',
+ 'cloud-type': 'openstack',
'owner-type': 'ocomp',
'cloud-region-version': self.conf['cloud']['version'],
'cloud-zone': 'az1',
@@ -396,6 +398,9 @@ class ONAP:
'cloud-region': self.conf['cloud']['region'],
'cloud-owner': self.cloud_id})
+ self.ocomp.run(command='multicloud-register-cloud',
+ params={'cloud-region': self.conf['cloud']['region'], 'cloud-owner': self.cloud_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.conf['ONAP']['uid'])
@@ -413,7 +418,7 @@ class ONAP:
break
if not self.customer_id and not self.customer_version:
- customer_id = '{}-{}'.format(self.conf['subscription']['customer-name'], self.ocomp.conf['ONAP']['random'])
+ customer_id = '{}-{}'.format(self.conf['subscription']['customer-name'], self.conf['ONAP']['uid'])
self.ocomp.run(command='customer-create',
params={'customer-name': customer_id,
'subscriber-name': customer_id})
@@ -428,23 +433,16 @@ class ONAP:
break
if not self.tenant_id and not self.tenant_version:
- tenant_id = str(uuid.uuid4())
- self.ocomp.run(command='tenant-create',
- params={'tenant-name': self.conf['cloud']['tenant'],
- 'tenant-id': tenant_id,
- 'cloud':self.cloud_id,
- 'region': self.conf['cloud']['region']})
- self.tenant_id = tenant_id
- subscribe = True
-
output = self.ocomp.run(command='tenant-list', params={
'cloud': self.cloud_id,
'region': self.conf['cloud']['region']
})
for tenant in output:
- if tenant['tenant-id'] == self.tenant_id:
+ if tenant['tenant-name'] == self.conf['cloud']['tenant']:
+ self.tenant_id = tenant['tenant-id']
self.tenant_version = tenant['resource-version']
+ subscribe = True
break
if subscribe:
@@ -471,7 +469,7 @@ class ONAP:
esr_vnfm_id = str(uuid.uuid4())
self.ocomp.run(command='vnfm-create',
- params={'vim-id': self.cloud_id,
+ params={'vim-id': self.cloud_id + "_" + self.conf['cloud']['region'],
'vnfm-id': esr_vnfm_id,
'name': 'OCOMP {}'.format(vnfmdriver),
'type': vnfmdriver,
@@ -495,7 +493,19 @@ class ONAP:
def create_vnf(self):
self.ocomp.run(command='vfc-catalog-onboard-vnf',
- params={'vnf-csar-uuid': self.vf_uuid})
+ params={'vnf-csar-uuid': self.vf_uuid})
+
+ vnf_flag = False
+ for i in range(60):
+ output = self.ocomp.run(command='vfc-catalog-get-vnf')
+ for csar in output:
+ if csar.get("csar-id") == self.vf_uuid:
+ vnf_flag = True
+ break
+ if vnf_flag:
+ break
+ else:
+ time.sleep(1)
self.ocomp.run(command='vfc-catalog-onboard-ns',
params={'ns-csar-uuid': self.ns_uuid})
@@ -508,20 +518,36 @@ class ONAP:
self.ns_instance_id = output['ns-instance-id']
- vnfmdriver = self.conf['vnf']['vnfm-driver']
- self.ocomp.run(command='vfc-nslcm-instantiate',
+ output = self.ocomp.run(command='vfc-nslcm-instantiate',
params={'ns-instance-id': self.ns_instance_id,
- 'location': self.cloud_id,
+ 'location': self.cloud_id + "_" + self.conf['cloud']['region'],
'sdn-controller-id': self.esr_vnfm_id})
+ jobid = output['job-id']
+ self.waitProcessFinished(jobid)
+
def vnf_status_check(self):
self.vnf_status = 'active'
self.ns_instance_status = 'active'
+ def waitProcessFinished(self, job_id):
+ for i in range(150):
+ output = self.ocomp.run(command='vfc-nslcm-get-jobid',
+ params={'ns-job-id': job_id})
+ progress_rep = int(output["job-progress"])
+ if 100 != progress_rep:
+ if 255 == progress_rep:
+ break
+ time.sleep(1)
+ else:
+ break
+
def cleanup(self):
if self.ns_instance_id:
- self.ocomp.run(command='vfc-nslcm-terminate',
+ output = self.ocomp.run(command='vfc-nslcm-terminate',
params={'ns-instance-id': self.ns_instance_id})
+ jobid = output['job-id']
+ self.waitProcessFinished(jobid)
self.ocomp.run(command='vfc-nslcm-delete',
params={'ns-instance-id': self.ns_instance_id})
self.ns_instance_id = None
@@ -580,24 +606,23 @@ class ONAP:
'resource-version': self.tenant_version})
self.tenant_id = self.tenant_version = None
- if self.cloud_id and self.location_id:
- self.ocomp.run(command='complex-disassociate',
- params={'cloud-owner': self.cloud_id,
- 'cloud-region': self.conf['cloud']['region'],
- 'complex-name': self.location_id})
-
- if self.cloud_id and self.cloud_version:
- output = self.ocomp.run(command='cloud-list')
-
- for c in output:
- if c['cloud'] == self.cloud_id and c['region'] == self.conf['cloud']['region']:
- self.cloud_version = c['resource-version']
+ if self.cloud_id:
+ self.ocomp.run(command='multicloud-cloud-delete',
+ params={'cloud-owner': self.cloud_id,
+ 'cloud-region': self.conf['cloud']['region']})
+
+ for i in range(30):
+ cloud_flag = False
+ output = self.ocomp.run(command='cloud-list')
+ for cloud in output:
+ if cloud.get('cloud') == self.cloud_id:
+ cloud_flag = True
+ break
+ if not cloud_flag:
break
+ else:
+ time.sleep(1)
- self.ocomp.run(command='cloud-delete',
- params={'cloud-name': self.cloud_id,
- 'region-name': self.conf['cloud']['region'],
- 'resource-version': self.cloud_version})
self.cloud_id = self.cloud_version = None
if self.location_id and self.location_version:
@@ -696,13 +721,15 @@ if __name__ == '__main__':
if vnf_csar:
conf['vnf']['vnf-csar'] = vnf_csar
if ns_csar:
- conf['vnf']['ns-csar'] = vnf_csar
+ conf['vnf']['ns-csar'] = ns_csar
if vnf_name:
conf['vnf']['name'] = 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'], conf['ONAP']['uid'])
+ if vnfm_driver:
+ conf['vnf']['vnfm-driver'] = vnfm_driver
if args.result:
result_file = args.result
diff --git a/products/onap-dublin/features/vfc/src/main/resources/open-cli-sample/nslcm/vfc-nslcm-get-jobid-schema-moco.json b/products/onap-dublin/features/vfc/src/main/resources/open-cli-sample/nslcm/vfc-nslcm-get-jobid-schema-moco.json
new file mode 100644
index 00000000..772367a6
--- /dev/null
+++ b/products/onap-dublin/features/vfc/src/main/resources/open-cli-sample/nslcm/vfc-nslcm-get-jobid-schema-moco.json
@@ -0,0 +1,75 @@
+
+[ {
+ "request" : {
+ "method" : "get",
+ "uri" : "/api/nslcm/v1/jobs/NS-NS_INST-330366c3-3a42-4739-9d46-6f468cf7e6ec-a85c262c-8099-11ea-80f5-0227d810af52",
+ "headers" : {
+ "Accept" : "application/json",
+ "Content-Type" : "application/json"
+ }
+ },
+ "response" : {
+ "status" : 200,
+ "json" : {
+ "jobId": "NS-NS_INST-330366c3-3a42-4739-9d46-6f468cf7e6ec-a85c262c-8099-11ea-80f5-0227d810af52",
+ "responseDescriptor": {
+ "status": "finished",
+ "progress": 100,
+ "statusDescription": "Create NS successfully.",
+ "errorCode": "0",
+ "responseId": 8,
+ "responseHistoryList": [
+ {
+ "status": "processing",
+ "progress": 90,
+ "statusDescription": "Start to post deal",
+ "errorCode": "0",
+ "responseId": 7
+ },
+ {
+ "status": "processing",
+ "progress": 70,
+ "statusDescription": "Start to create SFC",
+ "errorCode": "0",
+ "responseId": 6
+ },
+ {
+ "status": "processing",
+ "progress": 50,
+ "statusDescription": "Start to create PNF",
+ "errorCode": "0",
+ "responseId": 5
+ },
+ {
+ "status": "processing",
+ "progress": 30,
+ "statusDescription": "Start to create VNF",
+ "errorCode": "0",
+ "responseId": 4
+ },
+ {
+ "status": "processing",
+ "progress": 10,
+ "statusDescription": "Start to create VL",
+ "errorCode": "0",
+ "responseId": 3
+ },
+ {
+ "status": "processing",
+ "progress": 10,
+ "statusDescription": "NS inst(330366c3-3a42-4739-9d46-6f468cf7e6ec) buildin workflow started.",
+ "errorCode": "0",
+ "responseId": 2
+ },
+ {
+ "status": "processing",
+ "progress": 5,
+ "statusDescription": "Start query nsd(be194bc4-eb04-467c-a4ee-67e43ecbb7ad)",
+ "errorCode": "0",
+ "responseId": 1
+ }
+ ]
+ }
+ }
+ }
+} ]
diff --git a/products/onap-dublin/features/vfc/src/main/resources/open-cli-sample/nslcm/vfc-nslcm-get-jobid-schema-sample.yaml b/products/onap-dublin/features/vfc/src/main/resources/open-cli-sample/nslcm/vfc-nslcm-get-jobid-schema-sample.yaml
new file mode 100644
index 00000000..895ca2d6
--- /dev/null
+++ b/products/onap-dublin/features/vfc/src/main/resources/open-cli-sample/nslcm/vfc-nslcm-get-jobid-schema-sample.yaml
@@ -0,0 +1,19 @@
+open_cli_sample_version: 1.0
+name: vfc-nslcm-get-jobid
+version: onap-dublin
+samples:
+ sample1:
+ name: vfc-nslcm-get-jobid
+ input: -m http://10.12.5.155:30280 -i NS-NS_INST-330366c3-3a42-4739-9d46-6f468cf7e6ec-a85c262c-8099-11ea-80f5-0227d810af52
+ moco: vfc-nslcm-get-jobid-schema-moco.json
+ output: |
+ +--------------+----------------------------------------------------+
+ |property |value |
+ +--------------+----------------------------------------------------+
+ |ns-job-id |NS-NS_INST-330366c3-3a42-4739-9d46-6f468cf7e6ec-a8 |
+ | |5c262c-8099-11ea-80f5-0227d810af52 |
+ +--------------+----------------------------------------------------+
+ |job-status |finished |
+ +--------------+----------------------------------------------------+
+ |job-progress |100 |
+ +--------------+----------------------------------------------------+
diff --git a/products/onap-dublin/features/vfc/src/main/resources/open-cli-schema/nslcm/vfc-nslcm-get-jobid.yaml b/products/onap-dublin/features/vfc/src/main/resources/open-cli-schema/nslcm/vfc-nslcm-get-jobid.yaml
index a35c508d..d15cd5cb 100644
--- a/products/onap-dublin/features/vfc/src/main/resources/open-cli-schema/nslcm/vfc-nslcm-get-jobid.yaml
+++ b/products/onap-dublin/features/vfc/src/main/resources/open-cli-schema/nslcm/vfc-nslcm-get-jobid.yaml
@@ -18,19 +18,29 @@ info:
service: vfc
author: ONAP VFC Team (yangyanyj@chinamobile.com)
+parameters:
+ - name: ns-job-id
+ description: ns job id
+ type: string
+ short_option: i
+ long_option: ns-job-id
+ is_optional: false
+
results:
direction: portrait
attributes:
- name: ns-job-id
- description: ns-job-id
+ description: ns job id
scope: short
type: string
- - name: ns-name
- description: ns-name
+
+ - name: job-status
+ description: job status
scope: short
type: string
- - name: description
- description: description
+
+ - name: job-progress
+ description: job progress
scope: short
type: string
@@ -39,7 +49,7 @@ http:
auth: none
mode: direct
request:
- uri: /api/nsd/v1/ns_descriptors
+ uri: /api/nslcm/v1/jobs/${ns-job-id}
method: GET
context:
remove_empty_node: true
@@ -49,7 +59,8 @@ http:
Accept: application/json
success_codes:
- 200
+
result_map:
- ns-job-id: $b{$.ns-job-id}
- ns-name: $b{$.nsName}
- description: $b{$.description}
+ ns-job-id: $b{$.jobId}
+ job-status: $b{$.responseDescriptor.status}
+ job-progress: $b{$.responseDescriptor.progress} \ No newline at end of file
diff --git a/products/onap-elalto/features/vfc/src/main/resources/open-cli-schema/nslcm/vfc-nslcm-get-jobid.yaml b/products/onap-elalto/features/vfc/src/main/resources/open-cli-schema/nslcm/vfc-nslcm-get-jobid.yaml
new file mode 100644
index 00000000..bfb8fee5
--- /dev/null
+++ b/products/onap-elalto/features/vfc/src/main/resources/open-cli-schema/nslcm/vfc-nslcm-get-jobid.yaml
@@ -0,0 +1,66 @@
+# Copyright (c) 2019, CMCC Technologies Co., Ltd.
+# 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.
+
+open_cli_schema_version: 1.0
+name: vfc-nslcm-get-jobid
+description: vfc nsclm get the jobid of ns created job
+
+info:
+ product: onap-elalto
+ service: vfc
+ author: ONAP VFC Team (yangyanyj@chinamobile.com)
+
+parameters:
+ - name: ns-job-id
+ description: ns job id
+ type: string
+ short_option: i
+ long_option: ns-job-id
+ is_optional: false
+
+results:
+ direction: portrait
+ attributes:
+ - name: ns-job-id
+ description: ns job id
+ scope: short
+ type: string
+
+ - name: job-status
+ description: job status
+ scope: short
+ type: string
+
+ - name: job-progress
+ description: job progress
+ scope: short
+ type: string
+
+http:
+ service:
+ auth: none
+ mode: direct
+ request:
+ uri: /api/nslcm/v1/jobs/${ns-job-id}
+ method: GET
+ context:
+ remove_empty_node: true
+ body: '{}'
+ headers:
+ Content-Type: application/json
+ Accept: application/json
+ success_codes:
+ - 200
+
+ result_map:
+ ns-job-id: $b{$.jobId}
+ job-status: $b{$.responseDescriptor.status}
+ job-progress: $b{$.responseDescriptor.progress} \ No newline at end of file