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.utils.jobutil import enum
18 HEAL_ACTION_TYPE = enum(START="vmCreate", RESTART="vmReset")
19 ACTION_TYPE = enum(START=1, STOP=2, REBOOT=3)
20 GRANT_TYPE = enum(INSTANTIATE="INSTANTIATE", TERMINATE="TERMINATE", HEAL_CREATE="Heal Create", HEAL_RESTART="Heal Restart", OPERATE="OPERATE")
21 VNF_STATUS = enum(NULL='null', INSTANTIATING="instantiating", INACTIVE='inactive', ACTIVE="active",
22 FAILED="failed", TERMINATING="terminating", SCALING="scaling", OPERATING="operating",
23 UPDATING="updating", HEALING="healing")
25 OPERATION_TYPE = enum(
26 INSTANTIATE="INSTANTIATE",
28 SCALE_TO_LEVEL="SCALE_TO_LEVEL",
29 CHANGE_FLAVOUR="CHANGE_FLAVOUR",
30 TERMINATE="TERMINATE",
33 CHANGE_EXT_CONN="CHANGE_EXT_CONN",
34 MODIFY_INFO="MODIFY_INFO"
37 LCM_NOTIFICATION_STATUS = enum(START="START", RESULT="RESULT")
39 OPERATION_STATE_TYPE = enum(
41 PROCESSING="PROCESSING",
42 COMPLETED="COMPLETED",
43 FAILED_TEMP="FAILED_TEMP",
45 ROLLING_BACK="ROLLING_BACK",
46 ROLLED_BACK="ROLLED_BACK"
53 TEMPORARY='TEMPORARY',
54 LINK_PORT_ADDED='LINK_PORT_ADDED',
55 LINK_PORT_REMOVED='LINK_PORT_REMOVED'
58 RESOURCE_MAP = {'Storage': 'volumn', 'Network': 'network', 'SubNetwork': 'subnet', 'Port': 'port',
59 'Flavour': 'flavor', 'Vm': 'vm'}
61 ROOT_URI = "api/vnflcm/v1/subscriptions/"
63 AUTH_TYPES = ["BASIC", "OAUTH2_CLIENT_CREDENTIALS", "TLS_CERT"]
67 OAUTH2_CLIENT_CREDENTIALS = "OAUTH2_CLIENT_CREDENTIALS"
69 LCCNNOTIFICATION = "VnfLcmOperationOccurrenceNotification"
71 NOTIFICATION_TYPES = [
72 "VnfLcmOperationOccurrenceNotification",
73 "VnfIdentifierCreationNotification",
74 "VnfIdentifierDeletionNotification"
77 LCM_OPERATION_TYPES = [
78 OPERATION_TYPE.INSTANTIATE,
80 OPERATION_TYPE.SCALE_TO_LEVEL,
81 OPERATION_TYPE.CHANGE_FLAVOUR,
82 OPERATION_TYPE.TERMINATE,
84 OPERATION_TYPE.OPERATE,
85 OPERATION_TYPE.CHANGE_EXT_CONN,
86 OPERATION_TYPE.MODIFY_INFO
89 LCM_OPERATION_STATE_TYPES = [
90 OPERATION_STATE_TYPE.STARTING,
91 OPERATION_STATE_TYPE.PROCESSING,
92 OPERATION_STATE_TYPE.COMPLETED,
93 OPERATION_STATE_TYPE.FAILED_TEMP,
94 OPERATION_STATE_TYPE.FAILED,
95 OPERATION_STATE_TYPE.ROLLING_BACK,
96 OPERATION_STATE_TYPE.ROLLED_BACK
101 "flavourId": "flavour_1",
102 "instantiationLevelId": "instantiationLevel_1",
105 "id": "extVirtualLink_1",
106 "vimConnectionId": "vimConnection_1",
107 "resourceProviderId": "resourceProvider_1",
108 "resourceId": "resource_1",
109 "resourceSubnetId": "resourceSubnet_1",
115 "cpInstanceId": "cpInstance_1",
116 "linkPortId": "linkPort_1",
119 "layerProtocol": "IP_OVER_ETHERNET",
121 "macAddress": "00:f3:43:20:a2:a3",
125 "fixedAddresses": ["192.168.104.2", ],
126 "numDynamicAddresses": 0,
127 "addressRange": None,
128 "subnetId": "subnet_1",
140 "id": "extLinkPort_1",
142 "vimConnectionId": "vimConnection_1",
143 "resourceProviderId": "resourceProvider_1",
144 "resourceId": "resource_1",
145 "vimLevelResourceType": "vimLevelResourceType_1",
151 "extManagedVirtualLinks": [
153 "id": 'extManagedVirtualLink_1',
154 "virtualLinkDescId": 'virtualLinkDesc_1',
155 "vimConnectionId": 'vimConnection_1',
156 "resourceProviderId": 'resourceProvider_1',
157 "resourceId": 'resource_1',
160 "vimConnectionInfo": [
162 "id": 'vimConnection_1',
166 "apiVersion": "apiVersion_1",
167 "protocolType": "http"
170 "tenant": "tenant_vCPE",
172 "password": "vCPE_321",
177 "localizationLanguage": "en_US",
178 "additionalParams": {
191 'domain_type': u'CN',
192 'version': u'v4.14.10',
193 'vmnumber_overquota_alarm': False,
196 'vnfd_version': u'V00000001',
197 'id': u'sss-vnf-template',
198 'name': u'sss-vnf-template'
203 "description": "vdu description",
205 "name": "vduinstname",
208 "support_scaling": True,
211 "tenant": "tenantname",
212 "availability_zone": "zone1",
215 "local_affinity_antiaffinity_rule": [
217 "affinity_antiaffinity": "anti-affinity",
221 "affinity_antiaffinity": "affinity",
225 "inject_data_list": [
227 "file_name": "abc.xml",
228 "file_data": "<a>xxx</a><b>ssss</b>"
231 "storage_policy": "HIGH",
233 "manual_scale_select_vim": False,
235 "enabledelay": 600000,
238 "is_predefined": False,
239 "allow_scale_updown": False,
240 "inject_network_address": True,
241 "inner_hugepage_num": 100,
242 "inner_hugepage_size": "2048",
245 "image_file": u'sss',
252 "volume_storage_id": "volume_storage1",
253 "location": "/usr/data",
254 "device": "/dev/hda1"
264 "cpu_frequency": "1GHz",
265 "flavor_extra_specs": {
266 "hw: cpu_policy": "shared",
267 "hw: cpu_max_threads": 50,
268 "hw: cpu_sockets": 10,
269 "hw: cpu_max_sockets": 20,
270 "hw: cpu_max_cores": 8,
271 "hw: cpu_threads": 30,
272 "hw: numa_mem.0": 12288,
273 "hw: hugepage_num": 100,
274 "hw: high_performance": "dvs_high",
276 "hw: numa_cpus.0": "2,4,8",
277 "hw: numa_pci": True,
279 "pci_passthrough: alias": "ColetoCreek: 1",
280 "hw: mem_page_size": "large",
281 "hw: mem_paging_mechanism": "EPT"
293 "default_instances": 1
298 "implementation": "<implementationScript>",
300 "param1Name": "value1",
301 "paramNName": "valueN"
305 "implementation": "<implementationScript>",
307 "param1Name": "value1",
308 "paramNName": "valueN"
312 "implementation": "<implementationScript>",
314 "param1Name": "value1",
315 "paramNName": "valueN"
319 "implementation": "<implementationScript>",
321 "param1Name": "value1",
322 "paramNName": "valueN"
326 "implementation": "<implementationScript>",
328 "param1Name": "value1",
329 "paramNName": "valueN"
340 "volume_storage_id": "volume_storage1",
345 "volume_name": "volumeStorage1",
346 "custom_volume_type": "type1",
348 "delete_on_termination_vm": True,
351 "tenant": "tenantname_1",
352 "availability_zone": "zone1"
354 "is_predefined": False,
367 'policy_id': u'policy_scale_sss-vnf-template',
369 'policy_file': '*-vnfd.zip/*-vnf-policy.xml'
378 'name': u'opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
380 'disk_format': u'VMDK',
381 'file_url': u'./zte-cn-sss-main-image/OMM/opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
382 'container_type': 'vm',
384 'hypervisor_type': 'kvm'
386 'image_file_id': u'opencos_sss_omm_img_release_20150723-1-disk1'
393 'disk_format': u'VMDK',
394 'file_url': u'./zte-cn-sss-main-image/NE/sss.vmdk',
395 'container_type': 'vm',
397 'hypervisor_type': 'kvm'
399 'image_file_id': u'sss'
407 "name": "umac_241_control",
408 "network_name": "umac_control",
409 "is_predefined": False,
411 "netmask": "255.255.255.0",
413 "network_type": "vlan",
414 "physical_network": "phynet01",
415 "segmentation_id": "30",
416 "vlan_transparent": False,
418 "cidr": "192.168.199.0/24",
420 "gateway_ip": "192.168.199.1",
421 "dhcp_enabled": False,
426 "start_ip": "192.168.199.2",
427 "end_ip": "192.168.199.254",
430 "destination": "10.43.26.0/24",
431 "nexthop": "10.41.23.1"
436 "tenant": "tenantname_1"
440 "route_id": "router01",
441 "route_external": False
450 "mac_address": "00:d9:00:82:11:e1",
451 "ip_address:": "192.168.1.21",
452 "ip_range_start": "192.168.1.20",
453 "ip_range_end": "192.168.1.29",
454 "floating_ip_address": {
455 "external_network": "extnet01",
456 "ip_address": "10.43.53.23"
458 "service_ip_address": "192.168.1.23",
461 "vnic_type": "normal",
462 "allowed_address_pairs": [
464 "ip": "192.168.1.13",
465 "mac": "00:f3:43:20:a2:a3"
470 "macbond": "00:d9:00:82:11:d1",
471 "sfc_encapsulation": "",
473 "gateway_ip": "192.168.199.1",
474 "netmask": "255.255.255.0",
475 "interface_name": "fe-01-02",
477 "function": "control"
489 c1_data_get_tenant_id = {
493 "name": "chinamobile"
497 c1_data_get_tenant_id_1 = {
508 c2_data_create_volume = {
509 "id": "4bd3e9eb-cd8b-456a-8589-910836a0ab31",
512 "vimId": "vim_volume_1",
513 "vimName": "vim_volume_1",
514 "tenantId": "vim_volume_1",
516 "availabilityZone": "availabilityZone",
517 "status": "availuable",
518 "createTime": "2015-12-02T06:39:40.000000",
524 c3_data_get_volume = {
525 "status": "available",
529 "device": "/dev/vdc",
530 "serverId": "3030e666-528e-4954-88f5-cc21dab1262b",
531 "volumeId": "4bd3e9eb-cd8b-456a-8589-910836a0ab31",
533 "id": "4bd3e9eb-cd8b-456a-8589-910836a0ab31"
536 "createTime": "2015-12-02T06:39:40.000000",
538 "id": "4bd3e9eb-cd8b-456a-8589-910836a0ab31",
543 c4_data_create_network = {
548 "id": "3c9eebdbbfd345658269340b9ea6fb73",
550 "tenantId": "tenant1",
551 "networkName": "ommnet",
553 "vlanTransparent": True,
554 "networkType": "vlan",
555 "segmentationId": 202,
556 "physicalNetwork": "physnet1",
557 "routerExternal": False
561 c5_data_create_subnet = {
566 "id": "d62019d3-bc6e-4319-9c1d-6722fc136a23",
567 "tenantId": "tenant1",
568 "networkId": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
569 "networkName": "networkName",
571 "cidr": "10.43.35.0/24",
574 "gatewayIp": "10.43.35.1",
575 "dnsNameservers": [],
578 "start": "192.168.199.2",
579 "end": "192.168.199.254"
586 c6_data_create_port = {
591 "id": " 872019d3-bc6e-4319-9c1d-6722fc136afg",
592 "tenantId": "tenant1",
594 "networkId": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
595 "networkName": "networkName",
596 "subnetId": "d62019d3-bc6e-4319-9c1d-6722fc136a23",
597 "subnetName": "subnet1",
598 "macAddress": "212.12.61.23",
600 "vnicType": "direct",
605 c7_data_create_flavor = {
609 "id": "142019d3-bc6e-4319-9c1d-6722fc136afg",
610 "tenantId": "tenant1",
618 "extraSpecs": "testtt"
622 c8_data_list_image = {
628 "id": "5e2757c1-f846-4727-915c-9a872553ed75",
636 c9_data_create_vm = {
638 "id": "3c9eebdbbfd345658269340b9ea6fb73",
642 "tenantId": "tenant1",
645 "volumeArray": "dfdf",
646 "availabilityZone": "fdvfdv",
647 "flavorId": "fdvfdv",
648 "metadata": "fdvfdv",
649 "securityGroups": "fdvfdv",
650 "serverGroup": "fdvfdv",
657 "id": "3c9eebdbbfd345658269340b9ea6fb73",
661 "tenantId": "tenant1",
668 "volume_storage_id": "test",
672 "tenant": "chinamobile",
673 "availability_zone": "test",
675 "volume_name": "test",
676 "custom_volume_type": "test",
679 "image_file": "test",
688 "tenant": "chinamobile",
691 "networkName": "test",
692 "networkType": "test",
693 "physicalNetwork": "test",
694 "vlanTransparent": "test",
695 "segmentationId": "1",
697 "dhcpEnabled": "test",
702 "connectivity_type": {
703 "layer_protocol": "ipv4",
705 "dns_nameservers": "test",
706 "host_routes": "test",
708 "route_external": "test",
715 "networkId": "", # TODO
716 "subnetId": "", # TODO
720 "mac_address": "test",
725 "fixed_ip_address": "test"
730 "vnic_type": "direct",
732 "virtual_network_interface_requirements": [
734 "network_interface_requirements": {
735 "interfaceType": '{"schema-version": "0", "schema-location":"", "platform-id": "generic", "mandatory": false, "configuration-value": "SR-IOV"}'
737 "support_mandatory": False,
738 "name": "SRIOV_Port",
739 "description": "sriov"
751 "tenant": "chinamobile",
752 "availability_zone": "test",
759 "vduName": "VDU_vbng_0",
760 "flavorName": "flavor_1",
771 "type": "tosca.nodes.nfv.Vdu.Compute",
774 "num_virtual_cpu": "16",
777 "virtual_mem_size": "8000 MB",
778 "vdu_memory_requirements": {
779 "memoryPageSize": "8 MB",
784 "type_of_storage": "ephemeral",
785 "size_of_storage": "10 GB",
787 "type": "tosca.nodes.nfv.Vdu.Compute",
790 "artifact_name": "sw_image",
796 "volume_storage_id": "test",
803 "local_storages": [],
811 "description": "pe1_idofunderlayvpn"
815 "description": "pe2_idofunderlayvpn"
819 "description": "serviceTypeofunderlayvpn"
823 "description": "descriptionofunderlayvpn"
827 "description": "ac2_routeofunderlayvpn"
831 "description": "ac1_routeofunderlayvpn"
835 "description": "ac1_svlanofunderlayvpn"
839 "description": "ac2_ipofunderlayvpn"
843 "description": "ac1_ipofunderlayvpn"
847 "description": "ac2_portofunderlayvpn"
851 "description": "topologyofunderlayvpn"
855 "description": "technologyofunderlayvpn"
859 "description": "ac1_portofunderlayvpn"
863 "description": "ac2_svlanofunderlayvpn"
867 "description": "Nameofunderlayervpn"
872 "name": "underlayervpn",
873 "csarVersion": "1.0",
875 "csarProvider": "huawei",
878 "id": "ns_underlayervpn_1_0"
884 "csarId": "vOpenNAT",
886 "csarName": "vOpenNAT.csar",
887 "vnfdModel": json.dumps(vnfdModel),
888 "vnfdProvider": "Intel",
889 "vnfdId": "openNAT_1.0",
890 "downloadUrl": "http://10.96.33.39:8806/static/catalog/vOpenNAT/vOpenNAT.csar",
891 "vnfVersion": "v1.0",
892 "vnfdVersion": "v1.0",
893 "vnfPackageId": "vOpenNAT"
902 # "designer": "sdno",
903 # "name": "underlayervpn",
904 # "csarVersion": "1.0",
905 # "csarType": "SSAR",
906 # "csarProvider": "huawei",
909 # "id": "ns_underlayervpn_1_0"
913 # "id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
914 # "type_name": "tosca.nodes.sdn.l3ac",
915 # "template_name": "ac2",
918 # "type_name": "string"
921 # "type_name": "string"
924 # "type_name": "string"
927 # "type_name": "string"
932 # "name": "Standard",
933 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
939 # "type_name": "tosca.capabilities.Node"
943 # "type_name": "tosca.capabilities.sdn.ac"
948 # "target_node_id": "pe2_go3vo1ctxr1vlbl0ij8stbtj6",
949 # "target_capability_name": "feature"
952 # "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
953 # "target_capability_name": "feature"
958 # "id": "ac1_jqows1ai0j0cmwk9jdvuknt97",
959 # "type_name": "tosca.nodes.sdn.l3ac",
960 # "template_name": "ac1",
963 # "type_name": "string"
966 # "type_name": "string"
969 # "type_name": "string"
972 # "type_name": "string"
977 # "name": "Standard",
978 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
984 # "type_name": "tosca.capabilities.Node"
988 # "type_name": "tosca.capabilities.sdn.ac"
993 # "target_node_id": "pe1_e58ekps6m45g6w9egs9lue2j7",
994 # "target_capability_name": "feature"
997 # "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
998 # "target_capability_name": "feature"
1003 # "id": "vpn_ie0xim076f7cje67fvrrq9tg1",
1004 # "type_name": "tosca.nodes.sdn.underlayVPN",
1005 # "template_name": "vpn",
1008 # "type_name": "string"
1011 # "type_name": "string"
1014 # "type_name": "string"
1017 # "type_name": "string"
1022 # "name": "Standard",
1023 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
1028 # "name": "feature",
1029 # "type_name": "tosca.capabilities.Node"
1032 # "relationships": [
1034 # "target_node_id": "ac1_jqows1ai0j0cmwk9jdvuknt97",
1035 # "target_capability_name": "feature"
1038 # "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
1039 # "target_capability_name": "feature"
1044 # "id": "pe1_e58ekps6m45g6w9egs9lue2j7",
1045 # "type_name": "tosca.nodes.sdn.l3pe",
1046 # "template_name": "pe1",
1049 # "type_name": "string"
1054 # "name": "Standard",
1055 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
1060 # "name": "feature",
1061 # "type_name": "tosca.capabilities.Node"
1065 # "type_name": "tosca.capabilities.sdn.pe"
1070 # "id": "pe2_go3vo1ctxr1vlbl0ij8stbtj6",
1071 # "type_name": "tosca.nodes.sdn.l3pe",
1072 # "template_name": "pe2",
1075 # "type_name": "string"
1080 # "name": "Standard",
1081 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
1086 # "name": "feature",
1087 # "type_name": "tosca.capabilities.Node"
1091 # "type_name": "tosca.capabilities.sdn.pe"
1097 # "node_type_name": "tosca.nodes.sdn.ext.NS.ns_underlayervpn"
1101 # "type_name": "string",
1102 # "description": "ac2_ipofunderlayvpn"
1105 # "type_name": "string",
1106 # "description": "ac2_routeofunderlayvpn"
1109 # "type_name": "string",
1110 # "description": "serviceTypeofunderlayvpn"
1113 # "type_name": "string",
1114 # "description": "descriptionofunderlayvpn"
1117 # "type_name": "string",
1118 # "description": "pe2_idofunderlayvpn"
1121 # "type_name": "string",
1122 # "description": "ac1_routeofunderlayvpn"
1125 # "type_name": "integer",
1126 # "description": "ac1_svlanofunderlayvpn"
1129 # "type_name": "string",
1130 # "description": "Nameofunderlayervpn"
1133 # "type_name": "string",
1134 # "description": "ac1_ipofunderlayvpn"
1137 # "type_name": "string",
1138 # "description": "ac2_portofunderlayvpn"
1141 # "type_name": "string",
1142 # "description": "pe1_idofunderlayvpn"
1145 # "type_name": "string",
1146 # "description": "technologyofunderlayvpn"
1149 # "type_name": "string",
1150 # "description": "ac1_portofunderlayvpn"
1153 # "type_name": "integer",
1154 # "description": "ac2_svlanofunderlayvpn"
1157 # "type_name": "string",
1158 # "description": "topologyofunderlayvpn"