1 # Copyright 2017 ZTE Corporation.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
16 from lcm.pub.config import config
17 from lcm.pub.utils.jobutil import enum
19 HEAL_ACTION_TYPE = enum(START="vmCreate", RESTART="vmReset")
20 ACTION_TYPE = enum(START=1, STOP=2, REBOOT=3)
21 GRANT_TYPE = enum(INSTANTIATE="INSTANTIATE", TERMINATE="TERMINATE", HEAL_CREATE="Heal Create", HEAL_RESTART="Heal Restart", OPERATE="OPERATE")
22 VNF_STATUS = enum(NULL='null', INSTANTIATING="instantiating", INACTIVE='inactive', ACTIVE="active",
23 FAILED="failed", TERMINATING="terminating", SCALING="scaling", OPERATING="operating",
24 UPDATING="updating", HEALING="healing")
26 OPERATION_TYPE = enum(
27 INSTANTIATE="INSTANTIATE",
29 SCALE_TO_LEVEL="SCALE_TO_LEVEL",
30 CHANGE_FLAVOUR="CHANGE_FLAVOUR",
31 TERMINATE="TERMINATE",
34 CHANGE_EXT_CONN="CHANGE_EXT_CONN",
35 MODIFY_INFO="MODIFY_INFO"
38 INSTANTIATION_STATE = enum(
39 NOT_INSTANTIATED="NOT_INSTANTIATED",
40 INSTANTIATED="INSTANTIATED"
43 LCM_NOTIFICATION_STATUS = enum(START="START", RESULT="RESULT")
45 OPERATION_STATE_TYPE = enum(
47 PROCESSING="PROCESSING",
48 COMPLETED="COMPLETED",
49 FAILED_TEMP="FAILED_TEMP",
51 ROLLING_BACK="ROLLING_BACK",
52 ROLLED_BACK="ROLLED_BACK"
56 OPERATION_STATE_TYPE.COMPLETED,
57 OPERATION_STATE_TYPE.FAILED_TEMP,
58 OPERATION_STATE_TYPE.FAILED,
59 OPERATION_STATE_TYPE.ROLLED_BACK
63 OPERATION_STATE_TYPE.STARTING,
64 OPERATION_STATE_TYPE.PROCESSING,
65 OPERATION_STATE_TYPE.ROLLING_BACK
69 OPERATION_STATE_TYPE.COMPLETED,
70 OPERATION_STATE_TYPE.FAILED,
71 OPERATION_STATE_TYPE.ROLLED_BACK
78 TEMPORARY='TEMPORARY',
79 LINK_PORT_ADDED='LINK_PORT_ADDED',
80 LINK_PORT_REMOVED='LINK_PORT_REMOVED'
83 RESOURCE_MAP = {'Storage': 'volumn', 'Network': 'network', 'SubNetwork': 'subnet', 'Port': 'port',
84 'Flavour': 'flavor', 'Vm': 'vm'}
86 URL_PREFIX = "http://%s:%s/api/vnflcm/v1" % (config.MSB_SERVICE_IP, config.MSB_SERVICE_PORT)
88 ROOT_URI = "api/vnflcm/v1/subscriptions/"
90 AUTH_TYPES = ["BASIC", "OAUTH2_CLIENT_CREDENTIALS", "TLS_CERT"]
94 OAUTH2_CLIENT_CREDENTIALS = "OAUTH2_CLIENT_CREDENTIALS"
96 LCCNNOTIFICATION = "VnfLcmOperationOccurrenceNotification"
98 NOTIFICATION_TYPES = [
99 "VnfLcmOperationOccurrenceNotification",
100 "VnfIdentifierCreationNotification",
101 "VnfIdentifierDeletionNotification"
104 LCM_OPERATION_TYPES = [
105 OPERATION_TYPE.INSTANTIATE,
106 OPERATION_TYPE.SCALE,
107 OPERATION_TYPE.SCALE_TO_LEVEL,
108 OPERATION_TYPE.CHANGE_FLAVOUR,
109 OPERATION_TYPE.TERMINATE,
111 OPERATION_TYPE.OPERATE,
112 OPERATION_TYPE.CHANGE_EXT_CONN,
113 OPERATION_TYPE.MODIFY_INFO
116 LCM_OPERATION_STATE_TYPES = [
117 OPERATION_STATE_TYPE.STARTING,
118 OPERATION_STATE_TYPE.PROCESSING,
119 OPERATION_STATE_TYPE.COMPLETED,
120 OPERATION_STATE_TYPE.FAILED_TEMP,
121 OPERATION_STATE_TYPE.FAILED,
122 OPERATION_STATE_TYPE.ROLLING_BACK,
123 OPERATION_STATE_TYPE.ROLLED_BACK
128 "flavourId": "flavour_1",
129 "instantiationLevelId": "instantiationLevel_1",
132 "id": "extVirtualLink_1",
133 "vimConnectionId": "vimConnection_1",
134 "resourceProviderId": "resourceProvider_1",
135 "resourceId": "resource_1",
136 "resourceSubnetId": "resourceSubnet_1",
142 "cpInstanceId": "cpInstance_1",
143 "linkPortId": "linkPort_1",
146 "layerProtocol": "IP_OVER_ETHERNET",
148 "macAddress": "00:f3:43:20:a2:a3",
152 "fixedAddresses": ["192.168.104.2", ],
153 "numDynamicAddresses": 0,
154 "addressRange": None,
155 "subnetId": "subnet_1",
167 "id": "extLinkPort_1",
169 "vimConnectionId": "vimConnection_1",
170 "resourceProviderId": "resourceProvider_1",
171 "resourceId": "resource_1",
172 "vimLevelResourceType": "vimLevelResourceType_1",
178 "extManagedVirtualLinks": [
180 "id": 'extManagedVirtualLink_1',
181 "virtualLinkDescId": 'virtualLinkDesc_1',
182 "vimConnectionId": 'vimConnection_1',
183 "resourceProviderId": 'resourceProvider_1',
184 "resourceId": 'resource_1',
187 "vimConnectionInfo": [
189 "id": 'vimConnection_1',
193 "apiVersion": "apiVersion_1",
194 "protocolType": "http"
197 "tenant": "tenant_vCPE",
199 "password": "vCPE_321",
204 "localizationLanguage": "en_US",
205 "additionalParams": {
218 'domain_type': u'CN',
219 'version': u'v4.14.10',
220 'vmnumber_overquota_alarm': False,
223 'vnfd_version': u'V00000001',
224 'id': u'sss-vnf-template',
225 'name': u'sss-vnf-template'
230 "description": "vdu description",
232 "name": "vduinstname",
235 "support_scaling": True,
238 "tenant": "tenantname",
239 "availability_zone": "zone1",
242 "local_affinity_antiaffinity_rule": [
244 "affinity_antiaffinity": "anti-affinity",
248 "affinity_antiaffinity": "affinity",
252 "inject_data_list": [
254 "file_name": "abc.xml",
255 "file_data": "<a>xxx</a><b>ssss</b>"
258 "storage_policy": "HIGH",
260 "manual_scale_select_vim": False,
262 "enabledelay": 600000,
265 "is_predefined": False,
266 "allow_scale_updown": False,
267 "inject_network_address": True,
268 "inner_hugepage_num": 100,
269 "inner_hugepage_size": "2048",
272 "image_file": u'sss',
277 "virtual_storages": [
279 "virtual_storage_id": "volume_storage1",
280 "location": "/usr/data",
281 "device": "/dev/hda1"
291 "cpu_frequency": "1GHz",
292 "flavor_extra_specs": {
293 "hw: cpu_policy": "shared",
294 "hw: cpu_max_threads": 50,
295 "hw: cpu_sockets": 10,
296 "hw: cpu_max_sockets": 20,
297 "hw: cpu_max_cores": 8,
298 "hw: cpu_threads": 30,
299 "hw: numa_mem.0": 12288,
300 "hw: hugepage_num": 100,
301 "hw: high_performance": "dvs_high",
303 "hw: numa_cpus.0": "2,4,8",
304 "hw: numa_pci": True,
306 "pci_passthrough: alias": "ColetoCreek: 1",
307 "hw: mem_page_size": "large",
308 "hw: mem_paging_mechanism": "EPT"
320 "default_instances": 1
325 "implementation": "<implementationScript>",
327 "param1Name": "value1",
328 "paramNName": "valueN"
332 "implementation": "<implementationScript>",
334 "param1Name": "value1",
335 "paramNName": "valueN"
339 "implementation": "<implementationScript>",
341 "param1Name": "value1",
342 "paramNName": "valueN"
346 "implementation": "<implementationScript>",
348 "param1Name": "value1",
349 "paramNName": "valueN"
353 "implementation": "<implementationScript>",
355 "param1Name": "value1",
356 "paramNName": "valueN"
367 "volume_storage_id": "volume_storage1",
370 "size": "\"100 GB\"",
372 "volume_name": "volumeStorage1",
373 "custom_volume_type": "type1",
375 "delete_on_termination_vm": True,
378 "tenant": "tenantname_1",
379 "availability_zone": "zone1"
381 "is_predefined": False,
394 'policy_id': u'policy_scale_sss-vnf-template',
396 'policy_file': '*-vnfd.zip/*-vnf-policy.xml'
405 'name': u'opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
407 'disk_format': u'VMDK',
408 'file_url': u'./zte-cn-sss-main-image/OMM/opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
409 'container_type': 'vm',
411 'hypervisor_type': 'kvm'
413 'image_file_id': u'opencos_sss_omm_img_release_20150723-1-disk1'
420 'disk_format': u'VMDK',
421 'file_url': u'./zte-cn-sss-main-image/NE/sss.vmdk',
422 'container_type': 'vm',
424 'hypervisor_type': 'kvm'
426 'image_file_id': u'sss'
434 "name": "umac_241_control",
435 "network_name": "umac_control",
436 "is_predefined": False,
438 "netmask": "255.255.255.0",
440 "network_type": "vlan",
441 "physical_network": "phynet01",
442 "segmentation_id": "30",
443 "vlan_transparent": False,
445 "cidr": "192.168.199.0/24",
447 "gateway_ip": "192.168.199.1",
448 "dhcp_enabled": False,
453 "start_ip": "192.168.199.2",
454 "end_ip": "192.168.199.254",
457 "destination": "10.43.26.0/24",
458 "nexthop": "10.41.23.1"
463 "tenant": "tenantname_1"
467 "route_id": "router01",
468 "route_external": False
477 "mac_address": "00:d9:00:82:11:e1",
478 "ip_address:": "192.168.1.21",
479 "ip_range_start": "192.168.1.20",
480 "ip_range_end": "192.168.1.29",
481 "floating_ip_address": {
482 "external_network": "extnet01",
483 "ip_address": "10.43.53.23"
485 "service_ip_address": "192.168.1.23",
488 "vnic_type": "normal",
489 "allowed_address_pairs": [
491 "ip": "192.168.1.13",
492 "mac": "00:f3:43:20:a2:a3"
497 "macbond": "00:d9:00:82:11:d1",
498 "sfc_encapsulation": "",
500 "gateway_ip": "192.168.199.1",
501 "netmask": "255.255.255.0",
502 "interface_name": "fe-01-02",
504 "function": "control"
516 c1_data_get_tenant_id = {
520 "name": "chinamobile"
524 c1_data_get_tenant_id_1 = {
535 c2_data_create_volume = {
536 "id": "4bd3e9eb-cd8b-456a-8589-910836a0ab31",
539 "vimId": "vim_volume_1",
540 "vimName": "vim_volume_1",
541 "tenantId": "vim_volume_1",
543 "availabilityZone": "availabilityZone",
544 "status": "availuable",
545 "createTime": "2015-12-02T06:39:40.000000",
551 c3_data_get_volume = {
552 "status": "available",
556 "device": "/dev/vdc",
557 "serverId": "3030e666-528e-4954-88f5-cc21dab1262b",
558 "volumeId": "4bd3e9eb-cd8b-456a-8589-910836a0ab31",
560 "id": "4bd3e9eb-cd8b-456a-8589-910836a0ab31"
563 "createTime": "2015-12-02T06:39:40.000000",
565 "id": "4bd3e9eb-cd8b-456a-8589-910836a0ab31",
570 c4_data_create_network = {
575 "id": "3c9eebdbbfd345658269340b9ea6fb73",
577 "tenantId": "tenant1",
578 "networkName": "ommnet",
580 "vlanTransparent": True,
581 "networkType": "vlan",
582 "segmentationId": 202,
583 "physicalNetwork": "physnet1",
584 "routerExternal": False
588 c5_data_create_subnet = {
593 "id": "d62019d3-bc6e-4319-9c1d-6722fc136a23",
594 "tenantId": "tenant1",
595 "networkId": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
596 "networkName": "networkName",
598 "cidr": "10.43.35.0/24",
601 "gatewayIp": "10.43.35.1",
602 "dnsNameservers": [],
605 "start": "192.168.199.2",
606 "end": "192.168.199.254"
613 c6_data_create_port = {
618 "id": " 872019d3-bc6e-4319-9c1d-6722fc136afg",
619 "tenantId": "tenant1",
621 "networkId": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
622 "networkName": "networkName",
623 "subnetId": "d62019d3-bc6e-4319-9c1d-6722fc136a23",
624 "subnetName": "subnet1",
625 "macAddress": "212.12.61.23",
627 "vnicType": "direct",
632 c7_data_create_flavor = {
636 "id": "142019d3-bc6e-4319-9c1d-6722fc136afg",
637 "tenantId": "tenant1",
645 "extraSpecs": "testtt"
649 c8_data_list_image = {
655 "id": "5e2757c1-f846-4727-915c-9a872553ed75",
663 c9_data_create_vm = {
665 "id": "3c9eebdbbfd345658269340b9ea6fb73",
669 "tenantId": "tenant1",
672 "volumeArray": "dfdf",
673 "availabilityZone": "fdvfdv",
674 "flavorId": "fdvfdv",
675 "metadata": "fdvfdv",
676 "securityGroups": "fdvfdv",
677 "serverGroup": "fdvfdv",
684 "id": "3c9eebdbbfd345658269340b9ea6fb73",
688 "tenantId": "tenant1",
695 "volume_storage_id": "test",
699 "tenant": "chinamobile",
700 "availability_zone": "test",
702 "volume_name": "test",
703 "custom_volume_type": "test",
704 "size_of_storage": "\"10 GB\"",
706 "image_file": "test",
715 "tenant": "chinamobile",
718 "networkName": "test",
719 "networkType": "test",
720 "physicalNetwork": "test",
721 "vlanTransparent": "test",
722 "segmentationId": "1",
724 "dhcpEnabled": "test",
729 "connectivity_type": {
730 "layer_protocol": "ipv4",
732 "dns_nameservers": "test",
733 "host_routes": "test",
735 "route_external": "test",
742 "networkId": "", # TODO
743 "subnetId": "", # TODO
747 "mac_address": "test",
752 "fixed_ip_address": "test"
757 "vnic_type": "direct",
759 "virtual_network_interface_requirements": [
761 "network_interface_requirements": {
762 "interfaceType": '{"schemaVersion": "0", "schemaLocation":"", "platformId": "generic", "mandatory": false, "configurationValue": "SR-IOV"}'
764 "support_mandatory": False,
765 "name": "SRIOV_Port",
766 "description": "sriov"
778 "tenant": "chinamobile",
779 "availability_zone": "test",
786 "vduName": "VDU_vbng_0",
798 "type": "tosca.nodes.nfv.Vdu.Compute",
801 "num_virtual_cpu": "16",
804 "virtual_mem_size": "8000 MB",
805 "vdu_memory_requirements": {
806 "memoryPageSize": "8 MB",
810 "virtual_storages": [{
811 "virtual_storage_id": "test",
812 "type_of_storage": "ephemeral",
813 "size_of_storage": "10 GB",
815 "type": "tosca.nodes.nfv.Vdu.Compute",
818 "artifact_name": "sw_image",
824 "volume_storage_id": "test",
831 "local_storages": [],
839 "description": "pe1_idofunderlayvpn"
843 "description": "pe2_idofunderlayvpn"
847 "description": "serviceTypeofunderlayvpn"
851 "description": "descriptionofunderlayvpn"
855 "description": "ac2_routeofunderlayvpn"
859 "description": "ac1_routeofunderlayvpn"
863 "description": "ac1_svlanofunderlayvpn"
867 "description": "ac2_ipofunderlayvpn"
871 "description": "ac1_ipofunderlayvpn"
875 "description": "ac2_portofunderlayvpn"
879 "description": "topologyofunderlayvpn"
883 "description": "technologyofunderlayvpn"
887 "description": "ac1_portofunderlayvpn"
891 "description": "ac2_svlanofunderlayvpn"
895 "description": "Nameofunderlayervpn"
900 "name": "underlayervpn",
901 "csarVersion": "1.0",
903 "csarProvider": "huawei",
906 "id": "ns_underlayervpn_1_0"
912 "csarId": "vOpenNAT",
914 "csarName": "vOpenNAT.csar",
915 "vnfdModel": json.dumps(vnfdModel),
916 "vnfdProvider": "Intel",
917 "vnfdId": "openNAT_1.0",
918 "downloadUrl": "http://10.96.33.39:8806/static/catalog/vOpenNAT/vOpenNAT.csar",
919 "vnfVersion": "v1.0",
920 "vnfdVersion": "v1.0",
921 "vnfPackageId": "vOpenNAT"
930 # "designer": "sdno",
931 # "name": "underlayervpn",
932 # "csarVersion": "1.0",
933 # "csarType": "SSAR",
934 # "csarProvider": "huawei",
937 # "id": "ns_underlayervpn_1_0"
941 # "id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
942 # "type_name": "tosca.nodes.sdn.l3ac",
943 # "template_name": "ac2",
946 # "type_name": "string"
949 # "type_name": "string"
952 # "type_name": "string"
955 # "type_name": "string"
960 # "name": "Standard",
961 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
967 # "type_name": "tosca.capabilities.Node"
971 # "type_name": "tosca.capabilities.sdn.ac"
976 # "target_node_id": "pe2_go3vo1ctxr1vlbl0ij8stbtj6",
977 # "target_capability_name": "feature"
980 # "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
981 # "target_capability_name": "feature"
986 # "id": "ac1_jqows1ai0j0cmwk9jdvuknt97",
987 # "type_name": "tosca.nodes.sdn.l3ac",
988 # "template_name": "ac1",
991 # "type_name": "string"
994 # "type_name": "string"
997 # "type_name": "string"
1000 # "type_name": "string"
1005 # "name": "Standard",
1006 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
1011 # "name": "feature",
1012 # "type_name": "tosca.capabilities.Node"
1016 # "type_name": "tosca.capabilities.sdn.ac"
1019 # "relationships": [
1021 # "target_node_id": "pe1_e58ekps6m45g6w9egs9lue2j7",
1022 # "target_capability_name": "feature"
1025 # "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
1026 # "target_capability_name": "feature"
1031 # "id": "vpn_ie0xim076f7cje67fvrrq9tg1",
1032 # "type_name": "tosca.nodes.sdn.underlayVPN",
1033 # "template_name": "vpn",
1036 # "type_name": "string"
1039 # "type_name": "string"
1042 # "type_name": "string"
1045 # "type_name": "string"
1050 # "name": "Standard",
1051 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
1056 # "name": "feature",
1057 # "type_name": "tosca.capabilities.Node"
1060 # "relationships": [
1062 # "target_node_id": "ac1_jqows1ai0j0cmwk9jdvuknt97",
1063 # "target_capability_name": "feature"
1066 # "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
1067 # "target_capability_name": "feature"
1072 # "id": "pe1_e58ekps6m45g6w9egs9lue2j7",
1073 # "type_name": "tosca.nodes.sdn.l3pe",
1074 # "template_name": "pe1",
1077 # "type_name": "string"
1082 # "name": "Standard",
1083 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
1088 # "name": "feature",
1089 # "type_name": "tosca.capabilities.Node"
1093 # "type_name": "tosca.capabilities.sdn.pe"
1098 # "id": "pe2_go3vo1ctxr1vlbl0ij8stbtj6",
1099 # "type_name": "tosca.nodes.sdn.l3pe",
1100 # "template_name": "pe2",
1103 # "type_name": "string"
1108 # "name": "Standard",
1109 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
1114 # "name": "feature",
1115 # "type_name": "tosca.capabilities.Node"
1119 # "type_name": "tosca.capabilities.sdn.pe"
1125 # "node_type_name": "tosca.nodes.sdn.ext.NS.ns_underlayervpn"
1129 # "type_name": "string",
1130 # "description": "ac2_ipofunderlayvpn"
1133 # "type_name": "string",
1134 # "description": "ac2_routeofunderlayvpn"
1137 # "type_name": "string",
1138 # "description": "serviceTypeofunderlayvpn"
1141 # "type_name": "string",
1142 # "description": "descriptionofunderlayvpn"
1145 # "type_name": "string",
1146 # "description": "pe2_idofunderlayvpn"
1149 # "type_name": "string",
1150 # "description": "ac1_routeofunderlayvpn"
1153 # "type_name": "integer",
1154 # "description": "ac1_svlanofunderlayvpn"
1157 # "type_name": "string",
1158 # "description": "Nameofunderlayervpn"
1161 # "type_name": "string",
1162 # "description": "ac1_ipofunderlayvpn"
1165 # "type_name": "string",
1166 # "description": "ac2_portofunderlayvpn"
1169 # "type_name": "string",
1170 # "description": "pe1_idofunderlayvpn"
1173 # "type_name": "string",
1174 # "description": "technologyofunderlayvpn"
1177 # "type_name": "string",
1178 # "description": "ac1_portofunderlayvpn"
1181 # "type_name": "integer",
1182 # "description": "ac2_svlanofunderlayvpn"
1185 # "type_name": "string",
1186 # "description": "topologyofunderlayvpn"