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(
31 INSTANTIATE="INSTANTIATE",
32 TERMINATE="TERMINATE",
33 HEAL_CREATE="Heal Create",
34 HEAL_RESTART="Heal Restart",
36 SCALE_OUT="SCALE_OUT",
37 CHANGE_FLAVOUR="CHANGE_FLAVOUR",
39 CHANGE_CONNECTIVITY="CHANGE_CONNECTIVITY",
44 INSTANTIATING="instantiating",
48 TERMINATING="terminating",
50 OPERATING="operating",
55 OPERATION_TYPE = enum(
56 INSTANTIATE="INSTANTIATE",
58 SCALE_TO_LEVEL="SCALE_TO_LEVEL",
59 CHANGE_FLAVOUR="CHANGE_FLAVOUR",
60 TERMINATE="TERMINATE",
63 CHANGE_EXT_CONN="CHANGE_EXT_CONN",
64 MODIFY_INFO="MODIFY_INFO"
67 INSTANTIATION_STATE = enum(
68 NOT_INSTANTIATED="NOT_INSTANTIATED",
69 INSTANTIATED="INSTANTIATED"
72 LCM_NOTIFICATION_STATUS = enum(START="START", RESULT="RESULT")
74 OPERATION_STATE_TYPE = enum(
76 PROCESSING="PROCESSING",
77 COMPLETED="COMPLETED",
78 FAILED_TEMP="FAILED_TEMP",
80 ROLLING_BACK="ROLLING_BACK",
81 ROLLED_BACK="ROLLED_BACK"
85 OPERATION_STATE_TYPE.COMPLETED,
86 OPERATION_STATE_TYPE.FAILED_TEMP,
87 OPERATION_STATE_TYPE.FAILED,
88 OPERATION_STATE_TYPE.ROLLED_BACK
92 OPERATION_STATE_TYPE.STARTING,
93 OPERATION_STATE_TYPE.PROCESSING,
94 OPERATION_STATE_TYPE.ROLLING_BACK
98 OPERATION_STATE_TYPE.COMPLETED,
99 OPERATION_STATE_TYPE.FAILED,
100 OPERATION_STATE_TYPE.ROLLED_BACK
107 TEMPORARY='TEMPORARY',
108 LINK_PORT_ADDED='LINK_PORT_ADDED',
109 LINK_PORT_REMOVED='LINK_PORT_REMOVED'
112 RESOURCE_MAP = {'Storage': 'volumn', 'Network': 'network', 'SubNetwork': 'subnet', 'Port': 'port',
113 'Flavour': 'flavor', 'Vm': 'vm'}
115 URL_PREFIX = "http://%s:%s/api/vnflcm/v1" % (config.MSB_SERVICE_IP, config.MSB_SERVICE_PORT)
117 ROOT_URI = "api/vnflcm/v1/subscriptions/"
119 AUTH_TYPES = ["BASIC", "OAUTH2_CLIENT_CREDENTIALS", "TLS_CERT"]
123 OAUTH2_CLIENT_CREDENTIALS = "OAUTH2_CLIENT_CREDENTIALS"
125 LCCNNOTIFICATION = "VnfLcmOperationOccurrenceNotification"
127 NOTIFICATION_TYPES = [
128 "VnfLcmOperationOccurrenceNotification",
129 "VnfIdentifierCreationNotification",
130 "VnfIdentifierDeletionNotification"
133 LCM_OPERATION_TYPES = [
134 OPERATION_TYPE.INSTANTIATE,
135 OPERATION_TYPE.SCALE,
136 OPERATION_TYPE.SCALE_TO_LEVEL,
137 OPERATION_TYPE.CHANGE_FLAVOUR,
138 OPERATION_TYPE.TERMINATE,
140 OPERATION_TYPE.OPERATE,
141 OPERATION_TYPE.CHANGE_EXT_CONN,
142 OPERATION_TYPE.MODIFY_INFO
145 LCM_OPERATION_STATE_TYPES = [
146 OPERATION_STATE_TYPE.STARTING,
147 OPERATION_STATE_TYPE.PROCESSING,
148 OPERATION_STATE_TYPE.COMPLETED,
149 OPERATION_STATE_TYPE.FAILED_TEMP,
150 OPERATION_STATE_TYPE.FAILED,
151 OPERATION_STATE_TYPE.ROLLING_BACK,
152 OPERATION_STATE_TYPE.ROLLED_BACK
157 "flavourId": "flavour_1",
158 "instantiationLevelId": "instantiationLevel_1",
161 "id": "extVirtualLink_1",
162 "vimConnectionId": "vimConnection_1",
163 "resourceProviderId": "resourceProvider_1",
164 "resourceId": "resource_1",
165 "resourceSubnetId": "resourceSubnet_1",
171 "cpInstanceId": "cpInstance_1",
172 "linkPortId": "linkPort_1",
175 "layerProtocol": "IP_OVER_ETHERNET",
177 "macAddress": "00:f3:43:20:a2:a3",
181 "fixedAddresses": ["192.168.104.2", ],
182 "numDynamicAddresses": 0,
183 "addressRange": None,
184 "subnetId": "subnet_1",
196 "id": "extLinkPort_1",
198 "vimConnectionId": "vimConnection_1",
199 "resourceProviderId": "resourceProvider_1",
200 "resourceId": "resource_1",
201 "vimLevelResourceType": "vimLevelResourceType_1",
207 "extManagedVirtualLinks": [
209 "id": 'extManagedVirtualLink_1',
210 "virtualLinkDescId": 'virtualLinkDesc_1',
211 "vimConnectionId": 'vimConnection_1',
212 "resourceProviderId": 'resourceProvider_1',
213 "resourceId": 'resource_1',
216 "vimConnectionInfo": [
218 "id": 'vimConnection_1',
222 "apiVersion": "apiVersion_1",
223 "protocolType": "http"
226 "tenant": "tenant_vCPE",
228 "password": "vCPE_321",
233 "localizationLanguage": "en_US",
234 "additionalParams": {
247 'domain_type': u'CN',
248 'version': u'v4.14.10',
249 'vmnumber_overquota_alarm': False,
252 'vnfd_version': u'V00000001',
253 'id': u'sss-vnf-template',
254 'name': u'sss-vnf-template'
259 "description": "vdu description",
261 "name": "vduinstname",
264 "support_scaling": True,
267 "tenant": "tenantname",
268 "availability_zone": "zone1",
271 "local_affinity_antiaffinity_rule": [
273 "affinity_antiaffinity": "anti-affinity",
277 "affinity_antiaffinity": "affinity",
281 "inject_data_list": [
283 "file_name": "abc.xml",
284 "file_data": "<a>xxx</a><b>ssss</b>"
287 "storage_policy": "HIGH",
289 "manual_scale_select_vim": False,
291 "enabledelay": 600000,
294 "is_predefined": False,
295 "allow_scale_updown": False,
296 "inject_network_address": True,
297 "inner_hugepage_num": 100,
298 "inner_hugepage_size": "2048",
301 "image_file": u'sss',
306 "virtual_storages": [
308 "virtual_storage_id": "volume_storage1",
309 "location": "/usr/data",
310 "device": "/dev/hda1"
320 "cpu_frequency": "1GHz",
321 "flavor_extra_specs": {
322 "hw: cpu_policy": "shared",
323 "hw: cpu_max_threads": 50,
324 "hw: cpu_sockets": 10,
325 "hw: cpu_max_sockets": 20,
326 "hw: cpu_max_cores": 8,
327 "hw: cpu_threads": 30,
328 "hw: numa_mem.0": 12288,
329 "hw: hugepage_num": 100,
330 "hw: high_performance": "dvs_high",
332 "hw: numa_cpus.0": "2,4,8",
333 "hw: numa_pci": True,
335 "pci_passthrough: alias": "ColetoCreek: 1",
336 "hw: mem_page_size": "large",
337 "hw: mem_paging_mechanism": "EPT"
349 "default_instances": 1
354 "implementation": "<implementationScript>",
356 "param1Name": "value1",
357 "paramNName": "valueN"
361 "implementation": "<implementationScript>",
363 "param1Name": "value1",
364 "paramNName": "valueN"
368 "implementation": "<implementationScript>",
370 "param1Name": "value1",
371 "paramNName": "valueN"
375 "implementation": "<implementationScript>",
377 "param1Name": "value1",
378 "paramNName": "valueN"
382 "implementation": "<implementationScript>",
384 "param1Name": "value1",
385 "paramNName": "valueN"
396 "volume_storage_id": "volume_storage1",
399 "size": "\"100 GB\"",
401 "volume_name": "volumeStorage1",
402 "custom_volume_type": "type1",
404 "delete_on_termination_vm": True,
407 "tenant": "tenantname_1",
408 "availability_zone": "zone1"
410 "is_predefined": False,
423 'policy_id': u'policy_scale_sss-vnf-template',
425 'policy_file': '*-vnfd.zip/*-vnf-policy.xml'
434 'name': u'opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
436 'disk_format': u'VMDK',
437 'file_url': u'./zte-cn-sss-main-image/OMM/opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
438 'container_type': 'vm',
440 'hypervisor_type': 'kvm'
442 'image_file_id': u'opencos_sss_omm_img_release_20150723-1-disk1'
449 'disk_format': u'VMDK',
450 'file_url': u'./zte-cn-sss-main-image/NE/sss.vmdk',
451 'container_type': 'vm',
453 'hypervisor_type': 'kvm'
455 'image_file_id': u'sss'
463 "name": "umac_241_control",
464 "network_name": "umac_control",
465 "is_predefined": False,
467 "netmask": "255.255.255.0",
469 "network_type": "vlan",
470 "physical_network": "phynet01",
471 "segmentation_id": "30",
472 "vlan_transparent": False,
474 "cidr": "192.168.199.0/24",
476 "gateway_ip": "192.168.199.1",
477 "dhcp_enabled": False,
482 "start_ip": "192.168.199.2",
483 "end_ip": "192.168.199.254",
486 "destination": "10.43.26.0/24",
487 "nexthop": "10.41.23.1"
492 "tenant": "tenantname_1"
496 "route_id": "router01",
497 "route_external": False
506 "mac_address": "00:d9:00:82:11:e1",
507 "ip_address:": "192.168.1.21",
508 "ip_range_start": "192.168.1.20",
509 "ip_range_end": "192.168.1.29",
510 "floating_ip_address": {
511 "external_network": "extnet01",
512 "ip_address": "10.43.53.23"
514 "service_ip_address": "192.168.1.23",
517 "vnic_type": "normal",
518 "allowed_address_pairs": [
520 "ip": "192.168.1.13",
521 "mac": "00:f3:43:20:a2:a3"
526 "macbond": "00:d9:00:82:11:d1",
527 "sfc_encapsulation": "",
529 "gateway_ip": "192.168.199.1",
530 "netmask": "255.255.255.0",
531 "interface_name": "fe-01-02",
533 "function": "control"
545 c1_data_get_tenant_id = {
549 "name": "chinamobile"
553 c1_data_get_tenant_id_1 = {
564 c2_data_create_volume = {
565 "id": "4bd3e9eb-cd8b-456a-8589-910836a0ab31",
568 "vimId": "vim_volume_1",
569 "vimName": "vim_volume_1",
570 "tenantId": "vim_volume_1",
572 "availabilityZone": "availabilityZone",
573 "status": "availuable",
574 "createTime": "2015-12-02T06:39:40.000000",
580 c3_data_get_volume = {
581 "status": "available",
585 "device": "/dev/vdc",
586 "serverId": "3030e666-528e-4954-88f5-cc21dab1262b",
587 "volumeId": "4bd3e9eb-cd8b-456a-8589-910836a0ab31",
589 "id": "4bd3e9eb-cd8b-456a-8589-910836a0ab31"
592 "createTime": "2015-12-02T06:39:40.000000",
594 "id": "4bd3e9eb-cd8b-456a-8589-910836a0ab31",
599 c4_data_create_network = {
604 "id": "3c9eebdbbfd345658269340b9ea6fb73",
606 "tenantId": "tenant1",
607 "networkName": "ommnet",
609 "vlanTransparent": True,
610 "networkType": "vlan",
611 "segmentationId": 202,
612 "physicalNetwork": "physnet1",
613 "routerExternal": False
617 c5_data_create_subnet = {
622 "id": "d62019d3-bc6e-4319-9c1d-6722fc136a23",
623 "tenantId": "tenant1",
624 "networkId": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
625 "networkName": "networkName",
627 "cidr": "10.43.35.0/24",
630 "gatewayIp": "10.43.35.1",
631 "dnsNameservers": [],
634 "start": "192.168.199.2",
635 "end": "192.168.199.254"
642 c6_data_create_port = {
647 "id": " 872019d3-bc6e-4319-9c1d-6722fc136afg",
648 "tenantId": "tenant1",
650 "networkId": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
651 "networkName": "networkName",
652 "subnetId": "d62019d3-bc6e-4319-9c1d-6722fc136a23",
653 "subnetName": "subnet1",
654 "macAddress": "212.12.61.23",
656 "vnicType": "direct",
661 c7_data_create_flavor = {
665 "id": "142019d3-bc6e-4319-9c1d-6722fc136afg",
666 "tenantId": "tenant1",
674 "extraSpecs": "testtt"
678 c8_data_list_image = {
684 "id": "5e2757c1-f846-4727-915c-9a872553ed75",
692 c9_data_create_vm = {
694 "id": "3c9eebdbbfd345658269340b9ea6fb73",
698 "tenantId": "tenant1",
701 "volumeArray": "dfdf",
702 "availabilityZone": "fdvfdv",
703 "flavorId": "fdvfdv",
704 "metadata": "fdvfdv",
705 "securityGroups": "fdvfdv",
706 "serverGroup": "fdvfdv",
713 "id": "3c9eebdbbfd345658269340b9ea6fb73",
717 "tenantId": "tenant1",
724 "volume_storage_id": "test",
728 "tenant": "chinamobile",
729 "availability_zone": "test",
731 "volume_name": "test",
732 "custom_volume_type": "test",
733 "size_of_storage": "\"10 GB\"",
735 "image_file": "test",
744 "tenant": "chinamobile",
747 "networkName": "test",
748 "networkType": "test",
749 "physicalNetwork": "test",
750 "vlanTransparent": "test",
751 "segmentationId": "1",
753 "dhcpEnabled": "test",
758 "connectivity_type": {
759 "layer_protocol": "ipv4",
761 "dns_nameservers": "test",
762 "host_routes": "test",
764 "route_external": "test",
771 "networkId": "", # TODO
772 "subnetId": "", # TODO
776 "mac_address": "test",
781 "fixed_ip_address": "test"
786 "vnic_type": "direct",
788 "virtual_network_interface_requirements": [
790 "network_interface_requirements": {
791 "interfaceType": '{"schemaVersion": "0", "schemaLocation":"", "platformId": "generic", "mandatory": false, "configurationValue": "SR-IOV"}'
793 "support_mandatory": False,
794 "name": "SRIOV_Port",
795 "description": "sriov"
807 "tenant": "chinamobile",
808 "availability_zone": "test",
815 "vduName": "VDU_vbng_0",
827 "type": "tosca.nodes.nfv.Vdu.Compute",
830 "num_virtual_cpu": "16",
833 "virtual_mem_size": "8000 MB",
834 "vdu_memory_requirements": {
835 "memoryPageSize": "8 MB",
839 "virtual_storages": [{
840 "virtual_storage_id": "test",
841 "type_of_storage": "ephemeral",
842 "size_of_storage": "10 GB",
844 "type": "tosca.nodes.nfv.Vdu.Compute",
847 "artifact_name": "sw_image",
853 "volume_storage_id": "test",
860 "local_storages": [],
868 "description": "pe1_idofunderlayvpn"
872 "description": "pe2_idofunderlayvpn"
876 "description": "serviceTypeofunderlayvpn"
880 "description": "descriptionofunderlayvpn"
884 "description": "ac2_routeofunderlayvpn"
888 "description": "ac1_routeofunderlayvpn"
892 "description": "ac1_svlanofunderlayvpn"
896 "description": "ac2_ipofunderlayvpn"
900 "description": "ac1_ipofunderlayvpn"
904 "description": "ac2_portofunderlayvpn"
908 "description": "topologyofunderlayvpn"
912 "description": "technologyofunderlayvpn"
916 "description": "ac1_portofunderlayvpn"
920 "description": "ac2_svlanofunderlayvpn"
924 "description": "Nameofunderlayervpn"
929 "name": "underlayervpn",
930 "csarVersion": "1.0",
932 "csarProvider": "huawei",
935 "id": "ns_underlayervpn_1_0"
941 "csarId": "vOpenNAT",
943 "csarName": "vOpenNAT.csar",
944 "vnfdModel": json.dumps(vnfdModel),
945 "vnfdProvider": "Intel",
946 "vnfdId": "openNAT_1.0",
947 "downloadUrl": "http://10.96.33.39:8806/static/catalog/vOpenNAT/vOpenNAT.csar",
948 "vnfVersion": "v1.0",
949 "vnfdVersion": "v1.0",
950 "vnfPackageId": "vOpenNAT"
959 # "designer": "sdno",
960 # "name": "underlayervpn",
961 # "csarVersion": "1.0",
962 # "csarType": "SSAR",
963 # "csarProvider": "huawei",
966 # "id": "ns_underlayervpn_1_0"
970 # "id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
971 # "type_name": "tosca.nodes.sdn.l3ac",
972 # "template_name": "ac2",
975 # "type_name": "string"
978 # "type_name": "string"
981 # "type_name": "string"
984 # "type_name": "string"
989 # "name": "Standard",
990 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
996 # "type_name": "tosca.capabilities.Node"
1000 # "type_name": "tosca.capabilities.sdn.ac"
1003 # "relationships": [
1005 # "target_node_id": "pe2_go3vo1ctxr1vlbl0ij8stbtj6",
1006 # "target_capability_name": "feature"
1009 # "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
1010 # "target_capability_name": "feature"
1015 # "id": "ac1_jqows1ai0j0cmwk9jdvuknt97",
1016 # "type_name": "tosca.nodes.sdn.l3ac",
1017 # "template_name": "ac1",
1020 # "type_name": "string"
1023 # "type_name": "string"
1026 # "type_name": "string"
1029 # "type_name": "string"
1034 # "name": "Standard",
1035 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
1040 # "name": "feature",
1041 # "type_name": "tosca.capabilities.Node"
1045 # "type_name": "tosca.capabilities.sdn.ac"
1048 # "relationships": [
1050 # "target_node_id": "pe1_e58ekps6m45g6w9egs9lue2j7",
1051 # "target_capability_name": "feature"
1054 # "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
1055 # "target_capability_name": "feature"
1060 # "id": "vpn_ie0xim076f7cje67fvrrq9tg1",
1061 # "type_name": "tosca.nodes.sdn.underlayVPN",
1062 # "template_name": "vpn",
1065 # "type_name": "string"
1068 # "type_name": "string"
1071 # "type_name": "string"
1074 # "type_name": "string"
1079 # "name": "Standard",
1080 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
1085 # "name": "feature",
1086 # "type_name": "tosca.capabilities.Node"
1089 # "relationships": [
1091 # "target_node_id": "ac1_jqows1ai0j0cmwk9jdvuknt97",
1092 # "target_capability_name": "feature"
1095 # "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
1096 # "target_capability_name": "feature"
1101 # "id": "pe1_e58ekps6m45g6w9egs9lue2j7",
1102 # "type_name": "tosca.nodes.sdn.l3pe",
1103 # "template_name": "pe1",
1106 # "type_name": "string"
1111 # "name": "Standard",
1112 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
1117 # "name": "feature",
1118 # "type_name": "tosca.capabilities.Node"
1122 # "type_name": "tosca.capabilities.sdn.pe"
1127 # "id": "pe2_go3vo1ctxr1vlbl0ij8stbtj6",
1128 # "type_name": "tosca.nodes.sdn.l3pe",
1129 # "template_name": "pe2",
1132 # "type_name": "string"
1137 # "name": "Standard",
1138 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
1143 # "name": "feature",
1144 # "type_name": "tosca.capabilities.Node"
1148 # "type_name": "tosca.capabilities.sdn.pe"
1154 # "node_type_name": "tosca.nodes.sdn.ext.NS.ns_underlayervpn"
1158 # "type_name": "string",
1159 # "description": "ac2_ipofunderlayvpn"
1162 # "type_name": "string",
1163 # "description": "ac2_routeofunderlayvpn"
1166 # "type_name": "string",
1167 # "description": "serviceTypeofunderlayvpn"
1170 # "type_name": "string",
1171 # "description": "descriptionofunderlayvpn"
1174 # "type_name": "string",
1175 # "description": "pe2_idofunderlayvpn"
1178 # "type_name": "string",
1179 # "description": "ac1_routeofunderlayvpn"
1182 # "type_name": "integer",
1183 # "description": "ac1_svlanofunderlayvpn"
1186 # "type_name": "string",
1187 # "description": "Nameofunderlayervpn"
1190 # "type_name": "string",
1191 # "description": "ac1_ipofunderlayvpn"
1194 # "type_name": "string",
1195 # "description": "ac2_portofunderlayvpn"
1198 # "type_name": "string",
1199 # "description": "pe1_idofunderlayvpn"
1202 # "type_name": "string",
1203 # "description": "technologyofunderlayvpn"
1206 # "type_name": "string",
1207 # "description": "ac1_portofunderlayvpn"
1210 # "type_name": "integer",
1211 # "description": "ac2_svlanofunderlayvpn"
1214 # "type_name": "string",
1215 # "description": "topologyofunderlayvpn"