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 OPERATION_STATE_TYPE = enum(
39 PROCESSING="PROCESSING",
40 COMPLETED="COMPLETED",
41 FAILED_TEMP="FAILED_TEMP",
43 ROLLING_BACK="ROLLING_BACK",
44 ROLLED_BACK="ROLLED_BACK"
51 TEMPORARY='TEMPORARY',
52 LINK_PORT_ADDED='LINK_PORT_ADDED',
53 LINK_PORT_REMOVED='LINK_PORT_REMOVED'
56 RESOURCE_MAP = {'Storage': 'volumn', 'Network': 'network', 'SubNetwork': 'subnet', 'Port': 'port',
57 'Flavour': 'flavor', 'Vm': 'vm'}
59 ROOT_URI = "api/vnflcm/v1/subscriptions/"
61 AUTH_TYPES = ["BASIC", "OAUTH2_CLIENT_CREDENTIALS", "TLS_CERT"]
65 OAUTH2_CLIENT_CREDENTIALS = "OAUTH2_CLIENT_CREDENTIALS"
67 LCCNNOTIFICATION = "VnfLcmOperationOccurrenceNotification"
69 NOTIFICATION_TYPES = [
70 "VnfLcmOperationOccurrenceNotification",
71 "VnfIdentifierCreationNotification",
72 "VnfIdentifierDeletionNotification"
75 LCM_OPERATION_TYPES = [
76 OPERATION_TYPE.INSTANTIATE,
78 OPERATION_TYPE.SCALE_TO_LEVEL,
79 OPERATION_TYPE.CHANGE_FLAVOUR,
80 OPERATION_TYPE.TERMINATE,
82 OPERATION_TYPE.OPERATE,
83 OPERATION_TYPE.CHANGE_EXT_CONN,
84 OPERATION_TYPE.MODIFY_INFO
87 LCM_OPERATION_STATE_TYPES = [
88 OPERATION_STATE_TYPE.STARTING,
89 OPERATION_STATE_TYPE.PROCESSING,
90 OPERATION_STATE_TYPE.COMPLETED,
91 OPERATION_STATE_TYPE.FAILED_TEMP,
92 OPERATION_STATE_TYPE.FAILED,
93 OPERATION_STATE_TYPE.ROLLING_BACK,
94 OPERATION_STATE_TYPE.ROLLED_BACK
99 "flavourId": "flavour_1",
100 "instantiationLevelId": "instantiationLevel_1",
103 "id": "extVirtualLink_1",
104 "vimConnectionId": "vimConnection_1",
105 "resourceProviderId": "resourceProvider_1",
106 "resourceId": "resource_1",
107 "resourceSubnetId": "resourceSubnet_1",
113 "cpInstanceId": "cpInstance_1",
114 "linkPortId": "linkPort_1",
117 "layerProtocol": "IP_OVER_ETHERNET",
119 "macAddress": "00:f3:43:20:a2:a3",
123 "fixedAddresses": ["192.168.104.2", ],
124 "numDynamicAddresses": 0,
125 "addressRange": None,
126 "subnetId": "subnet_1",
138 "id": "extLinkPort_1",
140 "vimConnectionId": "vimConnection_1",
141 "resourceProviderId": "resourceProvider_1",
142 "resourceId": "resource_1",
143 "vimLevelResourceType": "vimLevelResourceType_1",
149 "extManagedVirtualLinks": [
151 "id": 'extManagedVirtualLink_1',
152 "virtualLinkDescId": 'virtualLinkDesc_1',
153 "vimConnectionId": 'vimConnection_1',
154 "resourceProviderId": 'resourceProvider_1',
155 "resourceId": 'resource_1',
158 "vimConnectionInfo": [
160 "id": 'vimConnection_1',
164 "apiVersion": "apiVersion_1",
165 "protocolType": "http"
168 "tenant": "tenant_vCPE",
170 "password": "vCPE_321",
175 "localizationLanguage": "en_US",
176 "additionalParams": {
189 'domain_type': u'CN',
190 'version': u'v4.14.10',
191 'vmnumber_overquota_alarm': False,
194 'vnfd_version': u'V00000001',
195 'id': u'sss-vnf-template',
196 'name': u'sss-vnf-template'
201 "description": "vdu description",
203 "name": "vduinstname",
206 "support_scaling": True,
209 "tenant": "tenantname",
210 "availability_zone": "zone1",
213 "local_affinity_antiaffinity_rule": [
215 "affinity_antiaffinity": "anti-affinity",
219 "affinity_antiaffinity": "affinity",
223 "inject_data_list": [
225 "file_name": "abc.xml",
226 "file_data": "<a>xxx</a><b>ssss</b>"
229 "storage_policy": "HIGH",
231 "manual_scale_select_vim": False,
233 "enabledelay": 600000,
236 "is_predefined": False,
237 "allow_scale_updown": False,
238 "inject_network_address": True,
239 "inner_hugepage_num": 100,
240 "inner_hugepage_size": "2048",
243 "image_file": u'sss',
250 "volume_storage_id": "volume_storage1",
251 "location": "/usr/data",
252 "device": "/dev/hda1"
262 "cpu_frequency": "1GHz",
263 "flavor_extra_specs": {
264 "hw: cpu_policy": "shared",
265 "hw: cpu_max_threads": 50,
266 "hw: cpu_sockets": 10,
267 "hw: cpu_max_sockets": 20,
268 "hw: cpu_max_cores": 8,
269 "hw: cpu_threads": 30,
270 "hw: numa_mem.0": 12288,
271 "hw: hugepage_num": 100,
272 "hw: high_performance": "dvs_high",
274 "hw: numa_cpus.0": "2,4,8",
275 "hw: numa_pci": True,
277 "pci_passthrough: alias": "ColetoCreek: 1",
278 "hw: mem_page_size": "large",
279 "hw: mem_paging_mechanism": "EPT"
291 "default_instances": 1
296 "implementation": "<implementationScript>",
298 "param1Name": "value1",
299 "paramNName": "valueN"
303 "implementation": "<implementationScript>",
305 "param1Name": "value1",
306 "paramNName": "valueN"
310 "implementation": "<implementationScript>",
312 "param1Name": "value1",
313 "paramNName": "valueN"
317 "implementation": "<implementationScript>",
319 "param1Name": "value1",
320 "paramNName": "valueN"
324 "implementation": "<implementationScript>",
326 "param1Name": "value1",
327 "paramNName": "valueN"
334 "artifact_name": "software_version_file",
335 "type": "tosca.artifacts.Deployment",
336 "file": "AppSoftwares/zte-cn-xgw-V5.16.11_NFV-version.zip",
345 "volume_storage_id": "volume_storage1",
350 "volume_name": "volumeStorage1",
351 "custom_volume_type": "type1",
353 "delete_on_termination_vm": True,
356 "tenant": "tenantname_1",
357 "availability_zone": "zone1"
359 "is_predefined": False,
372 'policy_id': u'policy_scale_sss-vnf-template',
374 'policy_file': '*-vnfd.zip/*-vnf-policy.xml'
383 'name': u'opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
385 'disk_format': u'VMDK',
386 'file_url': u'./zte-cn-sss-main-image/OMM/opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
387 'container_type': 'vm',
389 'hypervisor_type': 'kvm'
391 'image_file_id': u'opencos_sss_omm_img_release_20150723-1-disk1'
398 'disk_format': u'VMDK',
399 'file_url': u'./zte-cn-sss-main-image/NE/sss.vmdk',
400 'container_type': 'vm',
402 'hypervisor_type': 'kvm'
404 'image_file_id': u'sss'
412 "name": "umac_241_control",
413 "network_name": "umac_control",
414 "is_predefined": False,
416 "netmask": "255.255.255.0",
418 "network_type": "vlan",
419 "physical_network": "phynet01",
420 "segmentation_id": "30",
421 "vlan_transparent": False,
423 "cidr": "192.168.199.0/24",
425 "gateway_ip": "192.168.199.1",
426 "dhcp_enabled": False,
431 "start_ip": "192.168.199.2",
432 "end_ip": "192.168.199.254",
435 "destination": "10.43.26.0/24",
436 "nexthop": "10.41.23.1"
441 "tenant": "tenantname_1"
445 "route_id": "router01",
446 "route_external": False
455 "mac_address": "00:d9:00:82:11:e1",
456 "ip_address:": "192.168.1.21",
457 "ip_range_start": "192.168.1.20",
458 "ip_range_end": "192.168.1.29",
459 "floating_ip_address": {
460 "external_network": "extnet01",
461 "ip_address": "10.43.53.23"
463 "service_ip_address": "192.168.1.23",
466 "vnic_type": "normal",
467 "allowed_address_pairs": [
469 "ip": "192.168.1.13",
470 "mac": "00:f3:43:20:a2:a3"
475 "macbond": "00:d9:00:82:11:d1",
476 "sfc_encapsulation": "",
478 "gateway_ip": "192.168.199.1",
479 "netmask": "255.255.255.0",
480 "interface_name": "fe-01-02",
482 "function": "control"
494 c1_data_get_tenant_id = {
498 "name": "chinamobile"
504 c2_data_create_volume = {
505 "id": "4bd3e9eb-cd8b-456a-8589-910836a0ab31",
508 "vimId": "vim_volume_1",
509 "vimName": "vim_volume_1",
510 "tenantId": "vim_volume_1",
512 "availabilityZone": "availabilityZone",
513 "status": "availuable",
514 "createTime": "2015-12-02T06:39:40.000000",
520 c3_data_get_volume = {
521 "status": "available",
525 "device": "/dev/vdc",
526 "serverId": "3030e666-528e-4954-88f5-cc21dab1262b",
527 "volumeId": "4bd3e9eb-cd8b-456a-8589-910836a0ab31",
529 "id": "4bd3e9eb-cd8b-456a-8589-910836a0ab31"
532 "createTime": "2015-12-02T06:39:40.000000",
534 "id": "4bd3e9eb-cd8b-456a-8589-910836a0ab31",
539 c4_data_create_network = {
544 "id": "3c9eebdbbfd345658269340b9ea6fb73",
546 "tenantId": "tenant1",
547 "networkName": "ommnet",
549 "vlanTransparent": True,
550 "networkType": "vlan",
551 "segmentationId": 202,
552 "physicalNetwork": "physnet1",
553 "routerExternal": False
557 c5_data_create_subnet = {
562 "id": "d62019d3-bc6e-4319-9c1d-6722fc136a23",
563 "tenantId": "tenant1",
564 "networkId": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
565 "networkName": "networkName",
567 "cidr": "10.43.35.0/24",
570 "gatewayIp": "10.43.35.1",
571 "dnsNameservers": [],
574 "start": "192.168.199.2",
575 "end": "192.168.199.254"
582 c6_data_create_port = {
587 "id": " 872019d3-bc6e-4319-9c1d-6722fc136afg",
588 "tenantId": "tenant1",
590 "networkId": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
591 "networkName": "networkName",
592 "subnetId": "d62019d3-bc6e-4319-9c1d-6722fc136a23",
593 "subnetName": "subnet1",
594 "macAddress": "212.12.61.23",
596 "vnicType": "direct",
601 c7_data_create_flavor = {
605 "id": "142019d3-bc6e-4319-9c1d-6722fc136afg",
606 "tenantId": "tenant1",
614 "extraSpecs": "testtt"
618 c8_data_list_image = {
624 "id": "5e2757c1-f846-4727-915c-9a872553ed75",
632 c9_data_create_vm = {
634 "id": "3c9eebdbbfd345658269340b9ea6fb73",
638 "tenantId": "tenant1",
641 "volumeArray": "dfdf",
642 "availabilityZone": "fdvfdv",
643 "flavorId": "fdvfdv",
644 "metadata": "fdvfdv",
645 "securityGroups": "fdvfdv",
646 "serverGroup": "fdvfdv",
653 "id": "3c9eebdbbfd345658269340b9ea6fb73",
657 "tenantId": "tenant1",
664 "volume_storage_id": "test",
668 "tenant": "chinamobile",
669 "availability_zone": "test",
671 "volume_name": "test",
672 "custom_volume_type": "test",
675 "image_file": "test",
684 "tenant": "chinamobile",
687 "networkName": "test",
688 "networkType": "test",
689 "physicalNetwork": "test",
690 "vlanTransparent": "test",
691 "segmentationId": "1",
693 "dhcpEnabled": "test",
698 "connectivity_type": {
699 "layer_protocol": "ipv4",
701 "dns_nameservers": "test",
702 "host_routes": "test",
704 "route_external": "test",
711 "networkId": "", # TODO
712 "subnetId": "", # TODO
716 "mac_address": "test",
721 "fixed_ip_address": "test"
726 "vnic_type": "direct",
728 "virtual_network_interface_requirements": [
730 "network_interface_requirements": {
731 "interfaceType": '{"schema-version": "0", "schema-location":"", "platform-id": "generic", "mandatory": false, "configuration-value": "SR-IOV"}'
733 "support_mandatory": False,
734 "name": "SRIOV_Port",
735 "description": "sriov"
747 "tenant": "chinamobile",
748 "availability_zone": "test",
755 "vduName": "VDU_vbng_0",
756 "flavorName": "flavor_1",
767 "type": "tosca.nodes.nfv.Vdu.Compute",
770 "num_virtual_cpu": "16",
773 "virtual_mem_size": "8000 MB",
774 "vdu_memory_requirements": {
775 "memoryPageSize": "8 MB",
780 "type_of_storage": "ephemeral",
781 "size_of_storage": "10 GB",
783 "type": "tosca.nodes.nfv.Vdu.Compute",
786 "artifact_name": "sw_image",
792 "volume_storage_id": "test",
799 "local_storages": [],
807 "description": "pe1_idofunderlayvpn"
811 "description": "pe2_idofunderlayvpn"
815 "description": "serviceTypeofunderlayvpn"
819 "description": "descriptionofunderlayvpn"
823 "description": "ac2_routeofunderlayvpn"
827 "description": "ac1_routeofunderlayvpn"
831 "description": "ac1_svlanofunderlayvpn"
835 "description": "ac2_ipofunderlayvpn"
839 "description": "ac1_ipofunderlayvpn"
843 "description": "ac2_portofunderlayvpn"
847 "description": "topologyofunderlayvpn"
851 "description": "technologyofunderlayvpn"
855 "description": "ac1_portofunderlayvpn"
859 "description": "ac2_svlanofunderlayvpn"
863 "description": "Nameofunderlayervpn"
868 "name": "underlayervpn",
869 "csarVersion": "1.0",
871 "csarProvider": "huawei",
874 "id": "ns_underlayervpn_1_0"
880 "csarId": "vOpenNAT",
882 "csarName": "vOpenNAT.csar",
883 "vnfdModel": json.dumps(vnfdModel),
884 "vnfdProvider": "Intel",
885 "vnfdId": "openNAT_1.0",
886 "downloadUrl": "http://10.96.33.39:8806/static/catalog/vOpenNAT/vOpenNAT.csar",
887 "vnfVersion": "v1.0",
888 "vnfdVersion": "v1.0",
889 "vnfPackageId": "vOpenNAT"
898 # "designer": "sdno",
899 # "name": "underlayervpn",
900 # "csarVersion": "1.0",
901 # "csarType": "SSAR",
902 # "csarProvider": "huawei",
905 # "id": "ns_underlayervpn_1_0"
909 # "id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
910 # "type_name": "tosca.nodes.sdn.l3ac",
911 # "template_name": "ac2",
914 # "type_name": "string"
917 # "type_name": "string"
920 # "type_name": "string"
923 # "type_name": "string"
928 # "name": "Standard",
929 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
935 # "type_name": "tosca.capabilities.Node"
939 # "type_name": "tosca.capabilities.sdn.ac"
944 # "target_node_id": "pe2_go3vo1ctxr1vlbl0ij8stbtj6",
945 # "target_capability_name": "feature"
948 # "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
949 # "target_capability_name": "feature"
954 # "id": "ac1_jqows1ai0j0cmwk9jdvuknt97",
955 # "type_name": "tosca.nodes.sdn.l3ac",
956 # "template_name": "ac1",
959 # "type_name": "string"
962 # "type_name": "string"
965 # "type_name": "string"
968 # "type_name": "string"
973 # "name": "Standard",
974 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
980 # "type_name": "tosca.capabilities.Node"
984 # "type_name": "tosca.capabilities.sdn.ac"
989 # "target_node_id": "pe1_e58ekps6m45g6w9egs9lue2j7",
990 # "target_capability_name": "feature"
993 # "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
994 # "target_capability_name": "feature"
999 # "id": "vpn_ie0xim076f7cje67fvrrq9tg1",
1000 # "type_name": "tosca.nodes.sdn.underlayVPN",
1001 # "template_name": "vpn",
1004 # "type_name": "string"
1007 # "type_name": "string"
1010 # "type_name": "string"
1013 # "type_name": "string"
1018 # "name": "Standard",
1019 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
1024 # "name": "feature",
1025 # "type_name": "tosca.capabilities.Node"
1028 # "relationships": [
1030 # "target_node_id": "ac1_jqows1ai0j0cmwk9jdvuknt97",
1031 # "target_capability_name": "feature"
1034 # "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
1035 # "target_capability_name": "feature"
1040 # "id": "pe1_e58ekps6m45g6w9egs9lue2j7",
1041 # "type_name": "tosca.nodes.sdn.l3pe",
1042 # "template_name": "pe1",
1045 # "type_name": "string"
1050 # "name": "Standard",
1051 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
1056 # "name": "feature",
1057 # "type_name": "tosca.capabilities.Node"
1061 # "type_name": "tosca.capabilities.sdn.pe"
1066 # "id": "pe2_go3vo1ctxr1vlbl0ij8stbtj6",
1067 # "type_name": "tosca.nodes.sdn.l3pe",
1068 # "template_name": "pe2",
1071 # "type_name": "string"
1076 # "name": "Standard",
1077 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
1082 # "name": "feature",
1083 # "type_name": "tosca.capabilities.Node"
1087 # "type_name": "tosca.capabilities.sdn.pe"
1093 # "node_type_name": "tosca.nodes.sdn.ext.NS.ns_underlayervpn"
1097 # "type_name": "string",
1098 # "description": "ac2_ipofunderlayvpn"
1101 # "type_name": "string",
1102 # "description": "ac2_routeofunderlayvpn"
1105 # "type_name": "string",
1106 # "description": "serviceTypeofunderlayvpn"
1109 # "type_name": "string",
1110 # "description": "descriptionofunderlayvpn"
1113 # "type_name": "string",
1114 # "description": "pe2_idofunderlayvpn"
1117 # "type_name": "string",
1118 # "description": "ac1_routeofunderlayvpn"
1121 # "type_name": "integer",
1122 # "description": "ac1_svlanofunderlayvpn"
1125 # "type_name": "string",
1126 # "description": "Nameofunderlayervpn"
1129 # "type_name": "string",
1130 # "description": "ac1_ipofunderlayvpn"
1133 # "type_name": "string",
1134 # "description": "ac2_portofunderlayvpn"
1137 # "type_name": "string",
1138 # "description": "pe1_idofunderlayvpn"
1141 # "type_name": "string",
1142 # "description": "technologyofunderlayvpn"
1145 # "type_name": "string",
1146 # "description": "ac1_portofunderlayvpn"
1149 # "type_name": "integer",
1150 # "description": "ac2_svlanofunderlayvpn"
1153 # "type_name": "string",
1154 # "description": "topologyofunderlayvpn"