summaryrefslogtreecommitdiffstats
path: root/windriver/titanium_cloud
diff options
context:
space:
mode:
Diffstat (limited to 'windriver/titanium_cloud')
-rw-r--r--windriver/titanium_cloud/extensions/views/extensions.py6
-rw-r--r--windriver/titanium_cloud/proxy/views/identityV3.py24
-rw-r--r--windriver/titanium_cloud/proxy/views/services.py20
-rw-r--r--windriver/titanium_cloud/registration/views/registration.py324
-rw-r--r--windriver/titanium_cloud/resource/views/capacity.py5
-rw-r--r--windriver/titanium_cloud/resource/views/infra_workload.py153
-rw-r--r--windriver/titanium_cloud/urls.py3
-rw-r--r--windriver/titanium_cloud/vesagent/vesagent_ctrl.py5
8 files changed, 198 insertions, 342 deletions
diff --git a/windriver/titanium_cloud/extensions/views/extensions.py b/windriver/titanium_cloud/extensions/views/extensions.py
index 5b857303..9360cbba 100644
--- a/windriver/titanium_cloud/extensions/views/extensions.py
+++ b/windriver/titanium_cloud/extensions/views/extensions.py
@@ -32,7 +32,8 @@ logger = logging.getLogger(__name__)
class Extensions(newton_extensions.Extensions):
def __init__(self):
- self._logger = logger
+ super(Extensions, self).__init__()
+ # self._logger = logger
self.proxy_prefix = settings.MULTICLOUD_PREFIX
@@ -76,7 +77,8 @@ class Extensions(newton_extensions.Extensions):
class APIv1Extensions(Extensions):
def __init__(self):
- self._logger = logger
+ super(APIv1Extensions, self).__init__()
+ # self._logger = logger
self.proxy_prefix = settings.MULTICLOUD_API_V1_PREFIX
diff --git a/windriver/titanium_cloud/proxy/views/identityV3.py b/windriver/titanium_cloud/proxy/views/identityV3.py
index e6dc16a7..85fec086 100644
--- a/windriver/titanium_cloud/proxy/views/identityV3.py
+++ b/windriver/titanium_cloud/proxy/views/identityV3.py
@@ -25,20 +25,23 @@ logger = logging.getLogger(__name__)
class Tokens(newton_identityV3.Tokens):
def __init__(self):
+ super(Tokens, self).__init__()
self.proxy_prefix = settings.MULTICLOUD_PREFIX
- self._logger = logger
+ # self._logger = logger
class TokensV2(newton_identityV3.TokensV2):
def __init__(self):
+ super(TokensV2, self).__init__()
self.proxy_prefix = settings.MULTICLOUD_PREFIX
- self._logger = logger
+ # self._logger = logger
class APIv1Tokens(Tokens):
def __init__(self):
+ super(APIv1Tokens, self).__init__()
self.proxy_prefix = settings.MULTICLOUD_API_V1_PREFIX
- self._logger = logger
+ # self._logger = logger
def get(self, request, cloud_owner="", cloud_region_id=""):
@@ -52,8 +55,8 @@ class APIv1Tokens(Tokens):
def post(self, request, cloud_owner="", cloud_region_id=""):
self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner,cloud_region_id))
- #self._logger.debug("META> %s" % request.META)
- #self._logger.debug("data> %s" % request.data)
+ # self._logger.debug("META> %s" % request.META)
+ # self._logger.debug("data> %s" % request.data)
vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
return super(APIv1Tokens,self).post(request, vimid)
@@ -61,14 +64,15 @@ class APIv1Tokens(Tokens):
class APIv1TokensV2(TokensV2):
def __init__(self):
+ super(APIv1TokensV2, self).__init__()
self.proxy_prefix = settings.MULTICLOUD_API_V1_PREFIX
- self._logger = logger
+ # self._logger = logger
def get(self, request, cloud_owner="", cloud_region_id=""):
self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner,cloud_region_id))
- #self._logger.debug("META> %s" % request.META)
- #self._logger.debug("data> %s" % request.data)
+ # self._logger.debug("META> %s" % request.META)
+ # self._logger.debug("data> %s" % request.data)
vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
return super(APIv1TokensV2,self).get(request, vimid)
@@ -76,8 +80,8 @@ class APIv1TokensV2(TokensV2):
def post(self, request, cloud_owner="", cloud_region_id=""):
self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner,cloud_region_id))
- #self._logger.debug("META> %s" % request.META)
- #self._logger.debug("data> %s" % request.data)
+ # self._logger.debug("META> %s" % request.META)
+ # self._logger.debug("data> %s" % request.data)
vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
return super(APIv1TokensV2,self).post(request, vimid)
diff --git a/windriver/titanium_cloud/proxy/views/services.py b/windriver/titanium_cloud/proxy/views/services.py
index 6f4ec326..2ea46630 100644
--- a/windriver/titanium_cloud/proxy/views/services.py
+++ b/windriver/titanium_cloud/proxy/views/services.py
@@ -27,7 +27,8 @@ logger = logging.getLogger(__name__)
class Services(newton_services.Services):
def __init__(self):
- self._logger = logger
+ super(Services, self).__init__()
+ # self._logger = logger
class GetTenants(newton_services.GetTenants):
@@ -36,7 +37,8 @@ class GetTenants(newton_services.GetTenants):
'''
def __init__(self):
- self._logger = logger
+ super(GetTenants, self).__init__()
+ # self._logger = logger
def get(self, request, vimid="", servicetype="identity", requri='v3/projects'):
self._logger.info("vimid: %s" % (vimid))
@@ -47,12 +49,13 @@ class GetTenants(newton_services.GetTenants):
class APIv1Services(Services):
def __init__(self):
- self._logger = logger
+ super(APIv1Services, self).__init__()
+ # self._logger = logger
def head(self, request, cloud_owner="", cloud_region_id="", servicetype="", requri=""):
self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
-# self._logger.info("servicetype, requri> %s,%s" % (servicetype, requri))
-# self._logger.debug("META, data> %s , %s" % (request.META, request.data))
+ # self._logger.info("servicetype, requri> %s,%s" % (servicetype, requri))
+ # self._logger.debug("META, data> %s , %s" % (request.META, request.data))
vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
return super(APIv1Services,self).head(request, vimid, servicetype, requri)
@@ -94,12 +97,13 @@ class APIv1GetTenants(GetTenants):
'''
def __init__(self):
- self._logger = logger
+ super(APIv1GetTenants, self).__init__()
+ # self._logger = logger
def head(self, request, cloud_owner="", cloud_region_id="", servicetype="identity", requri=""):
self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
-# self._logger.info("servicetype, requri> %s,%s" % (servicetype, requri))
-# self._logger.debug("META, data> %s , %s" % (request.META, request.data))
+ # self._logger.info("servicetype, requri> %s,%s" % (servicetype, requri))
+ # self._logger.debug("META, data> %s , %s" % (request.META, request.data))
vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
return super(APIv1GetTenants,self).head(request, vimid, servicetype, requri)
diff --git a/windriver/titanium_cloud/registration/views/registration.py b/windriver/titanium_cloud/registration/views/registration.py
index 4225ff3b..74b9603e 100644
--- a/windriver/titanium_cloud/registration/views/registration.py
+++ b/windriver/titanium_cloud/registration/views/registration.py
@@ -33,322 +33,10 @@ logger = logging.getLogger(__name__)
class Registry(newton_registration.Registry):
def __init__(self):
+ super(Registry, self).__init__()
self.proxy_prefix = settings.MULTICLOUD_PREFIX
self.aai_base_url = settings.AAI_BASE_URL
- self._logger = logger
-
- def _discover_flavors(self, vimid="", session=None, viminfo=None):
- try:
- cloud_owner, cloud_region_id = extsys.decode_vim_id(vimid)
- for flavor in self._get_list_resources(
- "/flavors/detail", "compute", session, viminfo, vimid,
- "flavors"):
- flavor_info = {
- 'flavor-id': flavor['id'],
- 'flavor-name': flavor['name'],
- 'flavor-vcpus': flavor['vcpus'],
- 'flavor-ram': flavor['ram'],
- 'flavor-disk': flavor['disk'],
- 'flavor-ephemeral': flavor['OS-FLV-EXT-DATA:ephemeral'],
- 'flavor-swap': flavor['swap'],
- 'flavor-is-public': flavor['os-flavor-access:is_public'],
- 'flavor-disabled': flavor['OS-FLV-DISABLED:disabled'],
- }
-
- if flavor.get('links') and len(flavor['links']) > 0:
- flavor_info['flavor-selflink'] = flavor['links'][0]['href'] or 'http://0.0.0.0'
- else:
- flavor_info['flavor-selflink'] = 'http://0.0.0.0'
-
- # add hpa capabilities
- if (flavor['name'].find('onap.') == 0):
- req_resouce = "/flavors/%s/os-extra_specs" % flavor['id']
- extraResp = self._get_list_resources(req_resouce, "compute", session, viminfo, vimid, "extra_specs")
-
- hpa_capabilities = self._get_hpa_capabilities(flavor, extraResp)
- flavor_info['hpa-capabilities'] = {'hpa-capability': hpa_capabilities}
-
- self._update_resoure(
- cloud_owner, cloud_region_id, flavor['id'],
- flavor_info, "flavor")
-
- except VimDriverNewtonException as e:
- self._logger.error("VimDriverNewtonException: status:%s, response:%s" % (e.http_status, e.content))
- return
- except HttpError as e:
- self._logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
- return
- except Exception as e:
- self._logger.error(traceback.format_exc())
- return
-
- def _get_hpa_capabilities(self, flavor, extra_specs):
- hpa_caps = []
-
- # Basic capabilties
- caps_dict = self._get_hpa_basic_capabilities(flavor)
- if len(caps_dict) > 0:
- self._logger.debug("basic_capabilities_info: %s" % caps_dict)
- hpa_caps.append(caps_dict)
-
- # cpupining capabilities
- caps_dict = self._get_cpupining_capabilities(extra_specs)
- if len(caps_dict) > 0:
- self._logger.debug("cpupining_capabilities_info: %s" % caps_dict)
- hpa_caps.append(caps_dict)
-
- # cputopology capabilities
- caps_dict = self._get_cputopology_capabilities(extra_specs)
- if len(caps_dict) > 0:
- self._logger.debug("cputopology_capabilities_info: %s" % caps_dict)
- hpa_caps.append(caps_dict)
-
- # hugepages capabilities
- caps_dict = self._get_hugepages_capabilities(extra_specs)
- if len(caps_dict) > 0:
- self._logger.debug("hugepages_capabilities_info: %s" % caps_dict)
- hpa_caps.append(caps_dict)
-
- # numa capabilities
- caps_dict = self._get_numa_capabilities(extra_specs)
- if len(caps_dict) > 0:
- self._logger.debug("numa_capabilities_info: %s" % caps_dict)
- hpa_caps.append(caps_dict)
-
- # storage capabilities
- caps_dict = self._get_storage_capabilities(flavor)
- if len(caps_dict) > 0:
- self._logger.debug("storage_capabilities_info: %s" % caps_dict)
- hpa_caps.append(caps_dict)
-
- # CPU instruction set extension capabilities
- caps_dict = self._get_instruction_set_capabilities(extra_specs)
- if len(caps_dict) > 0:
- self._logger.debug("instruction_set_capabilities_info: %s" % caps_dict)
- hpa_caps.append(caps_dict)
-
- # PCI passthrough capabilities
- caps_dict = self._get_pci_passthrough_capabilities(extra_specs)
- if len(caps_dict) > 0:
- self._logger.debug("pci_passthrough_capabilities_info: %s" % caps_dict)
- hpa_caps.append(caps_dict)
-
- # ovsdpdk capabilities
- caps_dict = self._get_ovsdpdk_capabilities(extra_specs)
- if len(caps_dict) > 0:
- self._logger.debug("ovsdpdk_capabilities_info: %s" % caps_dict)
- hpa_caps.append(caps_dict)
-
- return hpa_caps
-
- def _get_hpa_basic_capabilities(self, flavor):
- basic_capability = {}
- feature_uuid = uuid.uuid4()
-
- basic_capability['hpa-capability-id'] = str(feature_uuid)
- basic_capability['hpa-feature'] = 'basicCapabilities'
- basic_capability['architecture'] = 'generic'
- basic_capability['hpa-version'] = 'v1'
-
- basic_capability['hpa-feature-attributes'] = []
- basic_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'numVirtualCpu',
- 'hpa-attribute-value':
- '{{\"value\":\"{0}\"}}'.format(flavor['vcpus'])
- })
- basic_capability['hpa-feature-attributes'].append({'hpa-attribute-key':'virtualMemSize',
- 'hpa-attribute-value':
- '{{\"value\":\"{0}\",\"unit\":\"{1}\"}}'.format(flavor['ram'],"MB")
- })
-
- return basic_capability
-
- def _get_cpupining_capabilities(self, extra_specs):
- cpupining_capability = {}
- feature_uuid = uuid.uuid4()
-
- if extra_specs.has_key('hw:cpu_policy') or extra_specs.has_key('hw:cpu_thread_policy'):
- cpupining_capability['hpa-capability-id'] = str(feature_uuid)
- cpupining_capability['hpa-feature'] = 'cpuPinning'
- cpupining_capability['architecture'] = 'generic'
- cpupining_capability['hpa-version'] = 'v1'
-
- cpupining_capability['hpa-feature-attributes'] = []
- if extra_specs.has_key('hw:cpu_thread_policy'):
- cpupining_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'logicalCpuThreadPinningPolicy',
- 'hpa-attribute-value':
- '{{\"value\":\"{0}\"}}'.format(extra_specs['hw:cpu_thread_policy'])
- })
- if extra_specs.has_key('hw:cpu_policy'):
- cpupining_capability['hpa-feature-attributes'].append({'hpa-attribute-key':'logicalCpuPinningPolicy',
- 'hpa-attribute-value':
- '{{\"value\":\"{0}\"}}'.format(extra_specs['hw:cpu_policy'])
- })
-
- return cpupining_capability
-
- def _get_cputopology_capabilities(self, extra_specs):
- cputopology_capability = {}
- feature_uuid = uuid.uuid4()
-
- if extra_specs.has_key('hw:cpu_sockets') or extra_specs.has_key('hw:cpu_cores') or extra_specs.has_key('hw:cpu_threads'):
- cputopology_capability['hpa-capability-id'] = str(feature_uuid)
- cputopology_capability['hpa-feature'] = 'cpuTopology'
- cputopology_capability['architecture'] = 'generic'
- cputopology_capability['hpa-version'] = 'v1'
-
- cputopology_capability['hpa-feature-attributes'] = []
- if extra_specs.has_key('hw:cpu_sockets'):
- cputopology_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'numCpuSockets',
- 'hpa-attribute-value':
- '{{\"value\":\"{0}\"}}'.format(extra_specs['hw:cpu_sockets'])
- })
- if extra_specs.has_key('hw:cpu_cores'):
- cputopology_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'numCpuCores',
- 'hpa-attribute-value':
- '{{\"value\":\"{0}\"}}'.format(extra_specs['hw:cpu_cores'])
- })
- if extra_specs.has_key('hw:cpu_threads'):
- cputopology_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'numCpuThreads',
- 'hpa-attribute-value':
- '{{\"value\":\"{0}\"}}'.format(extra_specs['hw:cpu_threads'])
- })
-
- return cputopology_capability
-
- def _get_hugepages_capabilities(self, extra_specs):
- hugepages_capability = {}
- feature_uuid = uuid.uuid4()
-
- if extra_specs.has_key('hw:mem_page_size'):
- hugepages_capability['hpa-capability-id'] = str(feature_uuid)
- hugepages_capability['hpa-feature'] = 'hugePages'
- hugepages_capability['architecture'] = 'generic'
- hugepages_capability['hpa-version'] = 'v1'
-
- hugepages_capability['hpa-feature-attributes'] = []
- if extra_specs['hw:mem_page_size'] == 'large':
- hugepages_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'memoryPageSize',
- 'hpa-attribute-value':
- '{{\"value\":\"{0}\",\"unit\":\"{1}\"}}'.format(2,"MB")
- })
- elif extra_specs['hw:mem_page_size'] == 'small':
- hugepages_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'memoryPageSize',
- 'hpa-attribute-value':
- '{{\"value\":\"{0}\",\"unit\":\"{1}\"}}'.format(4,"KB")
- })
- elif extra_specs['hw:mem_page_size'] == 'any':
- self._logger.info("Currently HPA feature memoryPageSize did not support 'any' page!!")
- else :
- hugepages_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'memoryPageSize',
- 'hpa-attribute-value':
- '{{\"value\":\"{0}\",\"unit\":\"{1}\"}}'.format(extra_specs['hw:mem_page_size'],"KB")
- })
- return hugepages_capability
-
- def _get_numa_capabilities(self, extra_specs):
- numa_capability = {}
- feature_uuid = uuid.uuid4()
-
- if extra_specs.has_key('hw:numa_nodes'):
- numa_capability['hpa-capability-id'] = str(feature_uuid)
- numa_capability['hpa-feature'] = 'numa'
- numa_capability['architecture'] = 'generic'
- numa_capability['hpa-version'] = 'v1'
-
- numa_capability['hpa-feature-attributes'] = []
- numa_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'numaNodes',
- 'hpa-attribute-value':
- '{{\"value\":\"{0}\"}}'.format(extra_specs['hw:numa_nodes'] or 0)
- })
-
- for num in range(0, int(extra_specs['hw:numa_nodes'])):
- numa_cpu_node = "hw:numa_cpus.%s" % num
- numa_mem_node = "hw:numa_mem.%s" % num
- numacpu_key = "numaCpu-%s" % num
- numamem_key = "numaMem-%s" % num
-
- if extra_specs.has_key(numa_cpu_node) and extra_specs.has_key(numa_mem_node):
- numa_capability['hpa-feature-attributes'].append({'hpa-attribute-key': numacpu_key,
- 'hpa-attribute-value':
- '{{\"value\":\"{0}\"}}'.format(extra_specs[numa_cpu_node])
- })
- numa_capability['hpa-feature-attributes'].append({'hpa-attribute-key': numamem_key,
- 'hpa-attribute-value':
- '{{\"value\":\"{0}\",\"unit\":\"{1}\"}}'.format(extra_specs[numa_mem_node],"MB")
- })
-
- return numa_capability
-
- def _get_storage_capabilities(self, flavor):
- storage_capability = {}
- feature_uuid = uuid.uuid4()
-
- storage_capability['hpa-capability-id'] = str(feature_uuid)
- storage_capability['hpa-feature'] = 'localStorage'
- storage_capability['architecture'] = 'generic'
- storage_capability['hpa-version'] = 'v1'
-
- storage_capability['hpa-feature-attributes'] = []
- storage_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'diskSize',
- 'hpa-attribute-value':
- '{{\"value\":\"{0}\",\"unit\":\"{1}\"}}'.format(flavor['disk'] or 0,"GB")
- })
- storage_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'swapMemSize',
- 'hpa-attribute-value':
- '{{\"value\":\"{0}\",\"unit\":\"{1}\"}}'.format(flavor['swap'] or 0,"MB")
- })
- storage_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'ephemeralDiskSize',
- 'hpa-attribute-value':
- '{{\"value\":\"{0}\",\"unit\":\"{1}\"}}'.format(flavor['OS-FLV-EXT-DATA:ephemeral'] or 0,"GB")
- })
- return storage_capability
-
- def _get_instruction_set_capabilities(self, extra_specs):
- instruction_capability = {}
- feature_uuid = uuid.uuid4()
-
- if extra_specs.has_key('hw:capabilities:cpu_info:features'):
- instruction_capability['hpa-capability-id'] = str(feature_uuid)
- instruction_capability['hpa-feature'] = 'instructionSetExtensions'
- instruction_capability['architecture'] = 'Intel64'
- instruction_capability['hpa-version'] = 'v1'
-
- instruction_capability['hpa-feature-attributes'] = []
- instruction_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'instructionSetExtensions',
- 'hpa-attribute-value':
- '{{\"value\":\"{0}\"}}'.format(extra_specs['hw:capabilities:cpu_info:features'])
- })
- return instruction_capability
-
- def _get_pci_passthrough_capabilities(self, extra_specs):
- instruction_capability = {}
- feature_uuid = uuid.uuid4()
-
- if extra_specs.has_key('pci_passthrough:alias'):
- value1 = extra_specs['pci_passthrough:alias'].split(':')
- value2 = value1[0].split('-')
-
- instruction_capability['hpa-capability-id'] = str(feature_uuid)
- instruction_capability['hpa-feature'] = 'pciePassthrough'
- instruction_capability['architecture'] = str(value2[2])
- instruction_capability['hpa-version'] = 'v1'
-
-
- instruction_capability['hpa-feature-attributes'] = []
- instruction_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'pciCount',
- 'hpa-attribute-value':
- '{{\"value\":\"{0}\"}}'.format(value1[1])
- })
- instruction_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'pciVendorId',
- 'hpa-attribute-value':
- '{{\"value\":\"{0}\"}}'.format(value2[3])
- })
- instruction_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'pciDeviceId',
- 'hpa-attribute-value':
- '{{\"value\":\"{0}\"}}'.format(value2[4])
- })
-
- return instruction_capability
+ # self._logger = logger
def _get_ovsdpdk_capabilities(self, extra_specs):
instruction_capability = {}
@@ -366,13 +54,13 @@ class Registry(newton_registration.Registry):
})
return instruction_capability
-
class APIv1Registry(Registry):
def __init__(self):
+ super(APIv1Registry, self).__init__()
self.proxy_prefix = settings.MULTICLOUD_API_V1_PREFIX
self.aai_base_url = settings.AAI_BASE_URL
- self._logger = logger
+ # self._logger = logger
def _update_cloud_region(self, cloud_owner, cloud_region_id, openstack_region_id, viminfo, session=None):
@@ -506,10 +194,10 @@ class APIv1Registry(Registry):
#create cloud region with composed AAI cloud_region_id except for the one onboarded externally (e.g. ESR)
gen_cloud_region_id = cloud_region_id + "." + regionid if region_specified != regionid else cloud_region_id
self._update_cloud_region(cloud_owner, gen_cloud_region_id, regionid, viminfo)
- return super(RegistryV1, self).post(request, vimid)
+ return super(APIv1Registry, self).post(request, vimid)
else:
self._update_cloud_region(cloud_owner, cloud_region_id, region_specified, viminfo)
- return super(RegistryV1, self).post(request, vimid)
+ return super(APIv1Registry, self).post(request, vimid)
diff --git a/windriver/titanium_cloud/resource/views/capacity.py b/windriver/titanium_cloud/resource/views/capacity.py
index 1b4566c3..0619e83b 100644
--- a/windriver/titanium_cloud/resource/views/capacity.py
+++ b/windriver/titanium_cloud/resource/views/capacity.py
@@ -145,10 +145,11 @@ class CapacityCheck(APIView):
-class APIv1CapacityCheck(APIView):
+class APIv1CapacityCheck(CapacityCheck):
def __init__(self):
- self._logger = logger
+ super(APIv1CapacityCheck, self).__init__()
+ # self._logger = logger
def post(self, request, cloud_owner="", cloud_region_id=""):
self._logger.info("vimid, data> %s,%s, %s" % (cloud_owner, cloud_region_id, request.data))
diff --git a/windriver/titanium_cloud/resource/views/infra_workload.py b/windriver/titanium_cloud/resource/views/infra_workload.py
new file mode 100644
index 00000000..08efcfd1
--- /dev/null
+++ b/windriver/titanium_cloud/resource/views/infra_workload.py
@@ -0,0 +1,153 @@
+# Copyright (c) 2017-2018 Wind River Systems, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import logging
+import json
+import traceback
+
+from rest_framework import status
+
+from django.conf import settings
+from common.exceptions import VimDriverNewtonException
+from newton_base.util import VimDriverUtils
+
+from keystoneauth1.exceptions import HttpError
+from rest_framework import status
+from rest_framework.response import Response
+from rest_framework.views import APIView
+from common.msapi import extsys
+
+
+logger = logging.getLogger(__name__)
+
+
+class InfraWorkload(APIView):
+
+ def __init__(self):
+ self._logger = logger
+
+ def post(self, request, vimid=""):
+ self._logger.info("vimid, data: %s, %s" % (vimid, request.data))
+ self._logger.debug("META: %s" % request.META)
+
+ try :
+
+ # stub response
+ resp_template = {
+ "template_type": "heat",
+ "workload_id": "3095aefc-09fb-4bc7-b1f0-f21a304e864c",
+ "template_response":
+ {
+ "stack": {
+ "id": "3095aefc-09fb-4bc7-b1f0-f21a304e864c",
+ "links": [
+ {
+ "href": "http://192.168.123.200:8004/v1/eb1c63a4f77141548385f113a28f0f52/stacks/teststack/3095aefc-09fb-4bc7-b1f0-f21a304e864c",
+ "rel": "self"
+ }
+ ]
+ }
+ }
+ }
+
+ self._logger.info("RESP with data> result:%s" % resp_template)
+ return Response(data=resp_template, status=status.HTTP_201_CREATED)
+ except VimDriverNewtonException as e:
+ self._logger.error("Plugin exception> status:%s,error:%s"
+ % (e.status_code, e.content))
+ return Response(data={'error': e.content}, status=e.status_code)
+ except HttpError as e:
+ self._logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
+ return Response(data=e.response.json(), status=e.http_status)
+ except Exception as e:
+ self._logger.error(traceback.format_exc())
+ return Response(data={'error': str(e)},
+ status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+
+
+ def get(self, request, vimid=""):
+ self._logger.info("vimid: %s" % (vimid))
+ self._logger.debug("META: %s" % request.META)
+
+ try :
+
+ # stub response
+ resp_template = {
+ "template_type": "heat",
+ "workload_id": "3095aefc-09fb-4bc7-b1f0-f21a304e864c",
+ "workload_status": "CREATE_IN_PROCESS",
+ }
+
+ self._logger.info("RESP with data> result:%s" % resp_template)
+ return Response(data=resp_template, status=status.HTTP_200_OK)
+ except VimDriverNewtonException as e:
+ self._logger.error("Plugin exception> status:%s,error:%s"
+ % (e.status_code, e.content))
+ return Response(data={'error': e.content}, status=e.status_code)
+ except HttpError as e:
+ self._logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
+ return Response(data=e.response.json(), status=e.http_status)
+ except Exception as e:
+ self._logger.error(traceback.format_exc())
+ return Response(data={'error': str(e)},
+ status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+
+ def delete(self, request, vimid=""):
+ self._logger.info("vimid: %s" % (vimid))
+ self._logger.debug("META: %s" % request.META)
+
+ try :
+
+ # stub response
+ self._logger.info("RESP with data> result:%s" % "")
+ return Response(status=status.HTTP_204_NO_CONTENT)
+ except VimDriverNewtonException as e:
+ self._logger.error("Plugin exception> status:%s,error:%s"
+ % (e.status_code, e.content))
+ return Response(data={'error': e.content}, status=e.status_code)
+ except HttpError as e:
+ self._logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
+ return Response(data=e.response.json(), status=e.http_status)
+ except Exception as e:
+ self._logger.error(traceback.format_exc())
+ return Response(data={'error': str(e)},
+ status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+
+
+class APIv1InfraWorkload(InfraWorkload):
+
+ def __init__(self):
+ super(APIv1InfraWorkload, self).__init__()
+ # self._logger = logger
+
+ def post(self, request, cloud_owner="", cloud_region_id=""):
+ #self._logger.info("cloud owner, cloud region id, data: %s,%s, %s" % (cloud_owner, cloud_region_id, request.data))
+ #self._logger.debug("META: %s" % request.META)
+
+ vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+ return super(APIv1InfraWorkload, self).post(request, vimid)
+
+ def get(self, request, cloud_owner="", cloud_region_id=""):
+ #self._logger.info("cloud owner, cloud region id, data: %s,%s, %s" % (cloud_owner, cloud_region_id, request.data))
+ #self._logger.debug("META: %s" % request.META)
+
+ vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+ return super(APIv1InfraWorkload, self).get(request, vimid)
+
+ def delete(self, request, cloud_owner="", cloud_region_id=""):
+ #self._logger.info("cloud owner, cloud region id, data: %s,%s, %s" % (cloud_owner, cloud_region_id, request.data))
+ #self._logger.debug("META: %s" % request.META)
+
+ vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+ return super(APIv1InfraWorkload, self).delete(request, vimid)
diff --git a/windriver/titanium_cloud/urls.py b/windriver/titanium_cloud/urls.py
index d56be236..3be252a6 100644
--- a/windriver/titanium_cloud/urls.py
+++ b/windriver/titanium_cloud/urls.py
@@ -19,6 +19,7 @@ from newton_base.openoapi import tenants
from titanium_cloud.resource.views import capacity
from titanium_cloud.resource.views import events
from titanium_cloud.vesagent import vesagent_ctrl
+from titanium_cloud.resource.views import infra_workload
urlpatterns = [
url(r'^', include('titanium_cloud.swagger.urls')),
@@ -65,6 +66,8 @@ urlpatterns = [
# events.EventsCheck.as_view()),
url(r'^api/multicloud-titanium_cloud/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/vesagent/?$',
vesagent_ctrl.APIv1VesAgentCtrl.as_view()),
+ url(r'^api/multicloud-titanium_cloud/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/infra_workload/?$',
+ infra_workload.APIv1InfraWorkload.as_view()),
]
diff --git a/windriver/titanium_cloud/vesagent/vesagent_ctrl.py b/windriver/titanium_cloud/vesagent/vesagent_ctrl.py
index a85ce150..8bfa3c38 100644
--- a/windriver/titanium_cloud/vesagent/vesagent_ctrl.py
+++ b/windriver/titanium_cloud/vesagent/vesagent_ctrl.py
@@ -409,8 +409,9 @@ class VesAgentCtrl(APIView):
class APIv1VesAgentCtrl(VesAgentCtrl):
def __init__(self):
- self._logger = logger
- self.proxy_prefix = settings.MULTICLOUD_PREFIX
+ super(APIv1VesAgentCtrl, self).__init__()
+ # self._logger = logger
+ self.proxy_prefix = settings.MULTICLOUD_API_V1_PREFIX
def get(self, request, cloud_owner="", cloud_region_id=""):