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 RESOURCE_MAP = {'Storage': 'volumn', 'Network': 'network', 'SubNetwork': 'subnet', 'Port': 'port',
26 'Flavour': 'flavor', 'Vm': 'vm'}
28 ROOT_URI = "api/vnflcm/v1/subscriptions/"
30 AUTH_TYPES = ["BASIC", "OAUTH2_CLIENT_CREDENTIALS", "TLS_CERT"]
34 OAUTH2_CLIENT_CREDENTIALS = "OAUTH2_CLIENT_CREDENTIALS"
36 LCCNNOTIFICATION = "VnfLcmOperationOccurrenceNotification"
39 "flavourId": "flavour_1",
40 "instantiationLevelId": "instantiationLevel_1",
43 "id": "extVirtualLink_1",
44 "vimConnectionId": "vimConnection_1",
45 "resourceProviderId": "resourceProvider_1",
46 "resourceId": "resource_1",
47 "resourceSubnetId": "resourceSubnet_1",
53 "cpInstanceId": "cpInstance_1",
54 "linkPortId": "linkPort_1",
57 "layerProtocol": "IP_OVER_ETHERNET",
59 "macAddress": "00:f3:43:20:a2:a3",
63 "fixedAddresses": ["192.168.104.2", ],
64 "numDynamicAddresses": 0,
66 "subnetId": "subnet_1",
78 "id": "extLinkPort_1",
80 "vimConnectionId": "vimConnection_1",
81 "resourceProviderId": "resourceProvider_1",
82 "resourceId": "resource_1",
83 "vimLevelResourceType": "vimLevelResourceType_1",
89 "extManagedVirtualLinks": [
91 "id": 'extManagedVirtualLink_1',
92 "virtualLinkDescId": 'virtualLinkDesc_1',
93 "vimConnectionId": 'vimConnection_1',
94 "resourceProviderId": 'resourceProvider_1',
95 "resourceId": 'resource_1',
98 "vimConnectionInfo": [
100 "id": 'vimConnection_1',
104 "apiVersion": "apiVersion_1",
105 "protocolType": "http"
108 "tenant": "tenant_vCPE",
110 "password": "vCPE_321",
115 "localizationLanguage": "en_US",
116 "additionalParams": {
129 'domain_type': u'CN',
130 'version': u'v4.14.10',
131 'vmnumber_overquota_alarm': False,
134 'vnfd_version': u'V00000001',
135 'id': u'sss-vnf-template',
136 'name': u'sss-vnf-template'
141 "description": "vdu description",
143 "name": "vduinstname",
146 "support_scaling": True,
149 "tenant": "tenantname",
150 "availability_zone": "zone1",
153 "local_affinity_antiaffinity_rule": [
155 "affinity_antiaffinity": "anti-affinity",
159 "affinity_antiaffinity": "affinity",
163 "inject_data_list": [
165 "file_name": "abc.xml",
166 "file_data": "<a>xxx</a><b>ssss</b>"
169 "storage_policy": "HIGH",
171 "manual_scale_select_vim": False,
173 "enabledelay": 600000,
176 "is_predefined": False,
177 "allow_scale_updown": False,
178 "inject_network_address": True,
179 "inner_hugepage_num": 100,
180 "inner_hugepage_size": "2048",
183 "image_file": u'sss',
190 "volume_storage_id": "volume_storage1",
191 "location": "/usr/data",
192 "device": "/dev/hda1"
202 "cpu_frequency": "1GHz",
203 "flavor_extra_specs": {
204 "hw: cpu_policy": "shared",
205 "hw: cpu_max_threads": 50,
206 "hw: cpu_sockets": 10,
207 "hw: cpu_max_sockets": 20,
208 "hw: cpu_max_cores": 8,
209 "hw: cpu_threads": 30,
210 "hw: numa_mem.0": 12288,
211 "hw: hugepage_num": 100,
212 "hw: high_performance": "dvs_high",
214 "hw: numa_cpus.0": "2,4,8",
215 "hw: numa_pci": True,
217 "pci_passthrough: alias": "ColetoCreek: 1",
218 "hw: mem_page_size": "large",
219 "hw: mem_paging_mechanism": "EPT"
231 "default_instances": 1
236 "implementation": "<implementationScript>",
238 "param1Name": "value1",
239 "paramNName": "valueN"
243 "implementation": "<implementationScript>",
245 "param1Name": "value1",
246 "paramNName": "valueN"
250 "implementation": "<implementationScript>",
252 "param1Name": "value1",
253 "paramNName": "valueN"
257 "implementation": "<implementationScript>",
259 "param1Name": "value1",
260 "paramNName": "valueN"
264 "implementation": "<implementationScript>",
266 "param1Name": "value1",
267 "paramNName": "valueN"
274 "artifact_name": "software_version_file",
275 "type": "tosca.artifacts.Deployment",
276 "file": "AppSoftwares/zte-cn-xgw-V5.16.11_NFV-version.zip",
285 "volume_storage_id": "volume_storage1",
290 "volume_name": "volumeStorage1",
291 "custom_volume_type": "type1",
293 "delete_on_termination_vm": True,
296 "tenant": "tenantname_1",
297 "availability_zone": "zone1"
299 "is_predefined": False,
312 'policy_id': u'policy_scale_sss-vnf-template',
314 'policy_file': '*-vnfd.zip/*-vnf-policy.xml'
323 'name': u'opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
325 'disk_format': u'VMDK',
326 'file_url': u'./zte-cn-sss-main-image/OMM/opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
327 'container_type': 'vm',
329 'hypervisor_type': 'kvm'
331 'image_file_id': u'opencos_sss_omm_img_release_20150723-1-disk1'
338 'disk_format': u'VMDK',
339 'file_url': u'./zte-cn-sss-main-image/NE/sss.vmdk',
340 'container_type': 'vm',
342 'hypervisor_type': 'kvm'
344 'image_file_id': u'sss'
352 "name": "umac_241_control",
353 "network_name": "umac_control",
354 "is_predefined": False,
356 "netmask": "255.255.255.0",
358 "network_type": "vlan",
359 "physical_network": "phynet01",
360 "segmentation_id": "30",
361 "vlan_transparent": False,
363 "cidr": "192.168.199.0/24",
365 "gateway_ip": "192.168.199.1",
366 "dhcp_enabled": False,
371 "start_ip": "192.168.199.2",
372 "end_ip": "192.168.199.254",
375 "destination": "10.43.26.0/24",
376 "nexthop": "10.41.23.1"
381 "tenant": "tenantname_1"
385 "route_id": "router01",
386 "route_external": False
395 "mac_address": "00:d9:00:82:11:e1",
396 "ip_address:": "192.168.1.21",
397 "ip_range_start": "192.168.1.20",
398 "ip_range_end": "192.168.1.29",
399 "floating_ip_address": {
400 "external_network": "extnet01",
401 "ip_address": "10.43.53.23"
403 "service_ip_address": "192.168.1.23",
406 "vnic_type": "normal",
407 "allowed_address_pairs": [
409 "ip": "192.168.1.13",
410 "mac": "00:f3:43:20:a2:a3"
415 "macbond": "00:d9:00:82:11:d1",
416 "sfc_encapsulation": "",
418 "gateway_ip": "192.168.199.1",
419 "netmask": "255.255.255.0",
420 "interface_name": "fe-01-02",
422 "function": "control"
434 c1_data_get_tenant_id = {
438 "name": "chinamobile"
444 c2_data_create_volume = {
445 "id": "4bd3e9eb-cd8b-456a-8589-910836a0ab31",
448 "vimId": "vim_volume_1",
449 "vimName": "vim_volume_1",
450 "tenantId": "vim_volume_1",
452 "availabilityZone": "availabilityZone",
453 "status": "availuable",
454 "createTime": "2015-12-02T06:39:40.000000",
460 c3_data_get_volume = {
461 "status": "available",
465 "device": "/dev/vdc",
466 "serverId": "3030e666-528e-4954-88f5-cc21dab1262b",
467 "volumeId": "4bd3e9eb-cd8b-456a-8589-910836a0ab31",
469 "id": "4bd3e9eb-cd8b-456a-8589-910836a0ab31"
472 "createTime": "2015-12-02T06:39:40.000000",
474 "id": "4bd3e9eb-cd8b-456a-8589-910836a0ab31",
479 c4_data_create_network = {
484 "id": "3c9eebdbbfd345658269340b9ea6fb73",
486 "tenantId": "tenant1",
487 "networkName": "ommnet",
489 "vlanTransparent": True,
490 "networkType": "vlan",
491 "segmentationId": 202,
492 "physicalNetwork": "ctrl",
493 "routerExternal": False
497 c5_data_create_subnet = {
502 "id": "d62019d3-bc6e-4319-9c1d-6722fc136a23",
503 "tenantId": "tenant1",
504 "networkId": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
505 "networkName": "networkName",
507 "cidr": "10.43.35.0/24",
510 "gatewayIp": "10.43.35.1",
511 "dnsNameservers": [],
514 "start": "192.168.199.2",
515 "end": "192.168.199.254"
522 c6_data_create_port = {
527 "id": " 872019d3-bc6e-4319-9c1d-6722fc136afg",
528 "tenantId": "tenant1",
530 "networkId": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
531 "networkName": "networkName",
532 "subnetId": "d62019d3-bc6e-4319-9c1d-6722fc136a23",
533 "subnetName": "subnet1",
534 "macAddress": "212.12.61.23",
536 "vnicType": "normal",
541 c7_data_create_flavor = {
545 "id": "142019d3-bc6e-4319-9c1d-6722fc136afg",
546 "tenantId": "tenant1",
554 "extraSpecs": "testtt"
558 c8_data_list_image = {
564 "id": "5e2757c1-f846-4727-915c-9a872553ed75",
572 c9_data_create_vm = {
574 "id": "3c9eebdbbfd345658269340b9ea6fb73",
578 "tenantId": "tenant1",
581 "volumeArray": "dfdf",
582 "availabilityZone": "fdvfdv",
583 "flavorId": "fdvfdv",
584 "metadata": "fdvfdv",
585 "securityGroups": "fdvfdv",
586 "serverGroup": "fdvfdv",
593 "id": "3c9eebdbbfd345658269340b9ea6fb73",
597 "tenantId": "tenant1",
604 "volume_storage_id": "test",
608 "tenant": "chinamobile",
609 "availability_zone": "test",
611 "volume_name": "test",
612 "custom_volume_type": "test",
615 "image_file": "test",
624 "tenant": "chinamobile",
627 "networkName": "test",
628 "networkType": "test",
629 "physicalNetwork": "test",
630 "vlanTransparent": "test",
631 "segmentationId": "1",
633 "dhcpEnabled": "test",
638 "connectivity_type": {
639 "layer_protocol": "ipv4",
641 "dns_nameservers": "test",
642 "host_routes": "test",
644 "route_external": "test",
651 "networkId": "", # TODO
652 "subnetId": "", # TODO
656 "mac_address": "test",
661 "fixed_ip_address": "test"
676 "tenant": "chinamobile",
677 "availability_zone": "test",
685 "type": "tosca.nodes.nfv.Vdu.Compute",
688 "num_virtual_cpu": "16",
691 "virtual_mem_size": "8000 MB",
692 "vdu_memory_requirements": {
693 "memoryPageSize": "8 MB",
698 "type_of_storage": "ephemeral",
699 "size_of_storage": "10 GB",
701 "type": "tosca.nodes.nfv.Vdu.Compute",
704 "artifact_name": "sw_image",
710 "volume_storage_id": "test",
717 "local_storages": [],
725 "description": "pe1_idofunderlayvpn"
729 "description": "pe2_idofunderlayvpn"
733 "description": "serviceTypeofunderlayvpn"
737 "description": "descriptionofunderlayvpn"
741 "description": "ac2_routeofunderlayvpn"
745 "description": "ac1_routeofunderlayvpn"
749 "description": "ac1_svlanofunderlayvpn"
753 "description": "ac2_ipofunderlayvpn"
757 "description": "ac1_ipofunderlayvpn"
761 "description": "ac2_portofunderlayvpn"
765 "description": "topologyofunderlayvpn"
769 "description": "technologyofunderlayvpn"
773 "description": "ac1_portofunderlayvpn"
777 "description": "ac2_svlanofunderlayvpn"
781 "description": "Nameofunderlayervpn"
786 "name": "underlayervpn",
787 "csarVersion": "1.0",
789 "csarProvider": "huawei",
792 "id": "ns_underlayervpn_1_0"
798 "csarId": "vOpenNAT",
800 "csarName": "vOpenNAT.csar",
801 "vnfdModel": json.dumps(vnfdModel),
802 "vnfdProvider": "Intel",
803 "vnfdId": "openNAT_1.0",
804 "downloadUrl": "http://10.96.33.39:8806/static/catalog/vOpenNAT/vOpenNAT.csar",
805 "vnfVersion": "v1.0",
806 "vnfdVersion": "v1.0",
807 "vnfPackageId": "vOpenNAT"
816 # "designer": "sdno",
817 # "name": "underlayervpn",
818 # "csarVersion": "1.0",
819 # "csarType": "SSAR",
820 # "csarProvider": "huawei",
823 # "id": "ns_underlayervpn_1_0"
827 # "id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
828 # "type_name": "tosca.nodes.sdn.l3ac",
829 # "template_name": "ac2",
832 # "type_name": "string"
835 # "type_name": "string"
838 # "type_name": "string"
841 # "type_name": "string"
846 # "name": "Standard",
847 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
853 # "type_name": "tosca.capabilities.Node"
857 # "type_name": "tosca.capabilities.sdn.ac"
862 # "target_node_id": "pe2_go3vo1ctxr1vlbl0ij8stbtj6",
863 # "target_capability_name": "feature"
866 # "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
867 # "target_capability_name": "feature"
872 # "id": "ac1_jqows1ai0j0cmwk9jdvuknt97",
873 # "type_name": "tosca.nodes.sdn.l3ac",
874 # "template_name": "ac1",
877 # "type_name": "string"
880 # "type_name": "string"
883 # "type_name": "string"
886 # "type_name": "string"
891 # "name": "Standard",
892 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
898 # "type_name": "tosca.capabilities.Node"
902 # "type_name": "tosca.capabilities.sdn.ac"
907 # "target_node_id": "pe1_e58ekps6m45g6w9egs9lue2j7",
908 # "target_capability_name": "feature"
911 # "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
912 # "target_capability_name": "feature"
917 # "id": "vpn_ie0xim076f7cje67fvrrq9tg1",
918 # "type_name": "tosca.nodes.sdn.underlayVPN",
919 # "template_name": "vpn",
922 # "type_name": "string"
925 # "type_name": "string"
928 # "type_name": "string"
931 # "type_name": "string"
936 # "name": "Standard",
937 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
943 # "type_name": "tosca.capabilities.Node"
948 # "target_node_id": "ac1_jqows1ai0j0cmwk9jdvuknt97",
949 # "target_capability_name": "feature"
952 # "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
953 # "target_capability_name": "feature"
958 # "id": "pe1_e58ekps6m45g6w9egs9lue2j7",
959 # "type_name": "tosca.nodes.sdn.l3pe",
960 # "template_name": "pe1",
963 # "type_name": "string"
968 # "name": "Standard",
969 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
975 # "type_name": "tosca.capabilities.Node"
979 # "type_name": "tosca.capabilities.sdn.pe"
984 # "id": "pe2_go3vo1ctxr1vlbl0ij8stbtj6",
985 # "type_name": "tosca.nodes.sdn.l3pe",
986 # "template_name": "pe2",
989 # "type_name": "string"
994 # "name": "Standard",
995 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
1000 # "name": "feature",
1001 # "type_name": "tosca.capabilities.Node"
1005 # "type_name": "tosca.capabilities.sdn.pe"
1011 # "node_type_name": "tosca.nodes.sdn.ext.NS.ns_underlayervpn"
1015 # "type_name": "string",
1016 # "description": "ac2_ipofunderlayvpn"
1019 # "type_name": "string",
1020 # "description": "ac2_routeofunderlayvpn"
1023 # "type_name": "string",
1024 # "description": "serviceTypeofunderlayvpn"
1027 # "type_name": "string",
1028 # "description": "descriptionofunderlayvpn"
1031 # "type_name": "string",
1032 # "description": "pe2_idofunderlayvpn"
1035 # "type_name": "string",
1036 # "description": "ac1_routeofunderlayvpn"
1039 # "type_name": "integer",
1040 # "description": "ac1_svlanofunderlayvpn"
1043 # "type_name": "string",
1044 # "description": "Nameofunderlayervpn"
1047 # "type_name": "string",
1048 # "description": "ac1_ipofunderlayvpn"
1051 # "type_name": "string",
1052 # "description": "ac2_portofunderlayvpn"
1055 # "type_name": "string",
1056 # "description": "pe1_idofunderlayvpn"
1059 # "type_name": "string",
1060 # "description": "technologyofunderlayvpn"
1063 # "type_name": "string",
1064 # "description": "ac1_portofunderlayvpn"
1067 # "type_name": "integer",
1068 # "description": "ac2_svlanofunderlayvpn"
1071 # "type_name": "string",
1072 # "description": "topologyofunderlayvpn"