summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
Diffstat (limited to 'share')
-rw-r--r--share/newton_base/openoapi/flavor.py88
-rw-r--r--share/newton_base/openoapi/hosts.py16
-rwxr-xr-xshare/newton_base/openoapi/hypervisor.py24
-rw-r--r--share/newton_base/openoapi/image.py36
-rw-r--r--share/newton_base/openoapi/limits.py13
-rw-r--r--share/newton_base/openoapi/network.py31
-rw-r--r--share/newton_base/openoapi/server.py27
-rw-r--r--share/newton_base/openoapi/vport.py13
-rw-r--r--share/newton_base/registration/registration.py10
9 files changed, 206 insertions, 52 deletions
diff --git a/share/newton_base/openoapi/flavor.py b/share/newton_base/openoapi/flavor.py
index d50b1941..1124aec4 100644
--- a/share/newton_base/openoapi/flavor.py
+++ b/share/newton_base/openoapi/flavor.py
@@ -51,7 +51,11 @@ class Flavors(APIView):
extraSpecs.append(spec)
def get(self, request, vimid="", tenantid="", flavorid=""):
- logger.debug("Flavors--get::> %s" % request.data)
+ logger.info("vimid, tenantid, flavorid = %s,%s,%s" % (vimid, tenantid, flavorid))
+ if request.data:
+ logger.debug("With data = %s" % request.data)
+ pass
+
try:
# prepare request resource to vim instance
query = VimDriverUtils.get_query_part(request)
@@ -109,9 +113,11 @@ class Flavors(APIView):
}
content.update(vim_dict)
+ logger.info("response with status = %s" % resp.status_code)
return Response(data=content, status=resp.status_code)
except VimDriverNewtonException as e:
+ logger.error("response with status = %s" % e.status_code)
return Response(data={'error': e.content}, status=e.status_code)
except HttpError as e:
logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
@@ -123,16 +129,22 @@ class Flavors(APIView):
def _get_flavor_extra_specs(self, sess, flavorid):
if flavorid:
- logger.debug("Flavors--get_extra_specs::> %s" % flavorid)
# prepare request resource to vim instance
req_resouce = "/flavors/%s/os-extra_specs" % flavorid
+ logger.info("making request with URI:%s" % req_resouce)
+
resp = sess.get(req_resouce, endpoint_filter=self.service)
+
+ logger.info("request returns with status %s" % resp.status_code)
+ if resp.status_code == status.HTTP_200_OK:
+ logger.debug("with content:%s" % resp.json())
+ pass
+
return resp
return {}
def _get_flavor(self, sess, request, flavorid=""):
- logger.debug("Flavors--get basic")
if sess:
# prepare request resource to vim instance
req_resouce = "/flavors"
@@ -145,11 +157,24 @@ class Flavors(APIView):
if query:
req_resouce += "?%s" % query
- return sess.get(req_resouce, endpoint_filter=self.service)
+ logger.info("making request with URI:%s" % req_resouce)
+
+ resp = sess.get(req_resouce, endpoint_filter=self.service)
+
+ logger.info("request returns with status %s" % resp.status_code)
+ if resp.status_code == status.HTTP_200_OK:
+ logger.debug("with content:%s" % resp.json())
+ pass
+
+ return resp
return {}
def post(self, request, vimid="", tenantid="", flavorid=""):
- logger.debug("Flavors--post::> %s" % request.data)
+ logger.info("vimid, tenantid, flavorid = %s,%s,%s" % (vimid, tenantid, flavorid))
+ if request.data:
+ logger.debug("With data = %s" % request.data)
+ pass
+
sess = None
resp = None
resp_body = None
@@ -202,8 +227,7 @@ class Flavors(APIView):
if extraSpecs:
extra_specs={}
self._convert_extra_specs(extraSpecs, extra_specs, False)
-# logger.debug("extraSpecs:%s" % extraSpecs)
-# logger.debug("extra_specs:%s" % extra_specs)
+
extraResp = self._create_flavor_extra_specs(sess, extra_specs, flavorid)
if extraResp.status_code == 200:
#combine the response body and return
@@ -227,6 +251,7 @@ class Flavors(APIView):
resp_body.update(vim_dict)
return Response(data=resp_body, status=resp.status_code)
except VimDriverNewtonException as e:
+ logger.error("response with status = %s" % e.status_code)
if sess and resp and resp.status_code == 200:
self._delete_flavor(sess, flavorid)
@@ -244,7 +269,6 @@ class Flavors(APIView):
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def _create_flavor(self, sess, request):
- logger.debug("Flavors--create::> %s" % request.data)
# prepare request resource to vim instance
req_resouce = "/flavors"
@@ -253,11 +277,18 @@ class Flavors(APIView):
VimDriverUtils.replace_key_by_mapping(flavor,
self.keys_mapping, True)
req_body = json.JSONEncoder().encode({"flavor": flavor})
- return sess.post(req_resouce, data=req_body,
+
+ logger.info("making request with URI:%s" % req_resouce)
+ logger.debug("with data:%s" % req_body)
+
+ resp = sess.post(req_resouce, data=req_body,
endpoint_filter=self.service)
+ logger.info("request returns with status %s" % resp.status_code)
+
+ return resp
+
def _create_flavor_extra_specs(self, sess, extraspecs, flavorid):
- logger.debug("Flavors extra_specs--post::> %s" % extraspecs)
# prepare request resource to vim instance
req_resouce = "/flavors"
if flavorid:
@@ -269,11 +300,22 @@ class Flavors(APIView):
req_body = json.JSONEncoder().encode({"extra_specs": extraspecs})
- return sess.post(req_resouce, data=req_body,
+ logger.info("making request with URI:%s" % req_resouce)
+ logger.debug("with data:%s" % req_body)
+
+ resp = sess.post(req_resouce, data=req_body,
endpoint_filter=self.service)
+ logger.info("request returns with status %s" % resp.status_code)
+
+ return resp
+
def delete(self, request, vimid="", tenantid="", flavorid=""):
- logger.debug("Flavors--delete::> %s" % request.data)
+ logger.info("vimid, tenantid, flavorid = %s,%s,%s" % (vimid, tenantid, flavorid))
+ if request.data:
+ logger.debug("With data = %s" % request.data)
+ pass
+
try:
# prepare request resource to vim instance
vim = VimDriverUtils.get_vim_info(vimid)
@@ -288,6 +330,7 @@ class Flavors(APIView):
#return results
return Response(status=resp.status_code)
except VimDriverNewtonException as e:
+ logger.error("response with status = %s" % e.status_code)
return Response(data={'error': e.content}, status=e.status_code)
except HttpError as e:
logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
@@ -298,8 +341,6 @@ class Flavors(APIView):
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def _delete_flavor_extra_specs(self, sess, flavorid):
- logger.debug("Flavors--delete extra::> %s" % flavorid)
-
#delete extra specs one by one
resp = self._get_flavor_extra_specs(sess, flavorid)
extra_specs = resp.json()
@@ -310,7 +351,6 @@ class Flavors(APIView):
return resp
def _delete_flavor_one_extra_spec(self, sess, flavorid, extra_spec_key):
- logger.debug("Flavors--delete 1 extra::> %s" % extra_spec_key)
# prepare request resource to vim instance
try:
req_resouce = "/flavors"
@@ -322,7 +362,14 @@ class Flavors(APIView):
content="internal bug in deleting flavor extra specs: %s" % extra_spec_key,
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR)
- return sess.delete(req_resouce, endpoint_filter=self.service)
+ logger.info("making request with URI:%s" % req_resouce)
+
+ resp = sess.delete(req_resouce, endpoint_filter=self.service)
+
+ logger.info("request returns with status %s" % resp.status_code)
+
+ return resp
+
except HttpError as e:
logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
return Response(data=e.response.json(), status=e.http_status)
@@ -332,7 +379,6 @@ class Flavors(APIView):
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def _delete_flavor(self, sess, flavorid):
- logger.debug("Flavors--delete basic::> %s" % flavorid)
# prepare request resource to vim instance
req_resouce = "/flavors"
if flavorid:
@@ -342,4 +388,10 @@ class Flavors(APIView):
content="internal bug in deleting flavor",
status_code=500)
- return sess.delete(req_resouce, endpoint_filter=self.service)
+ logger.info("making request with URI:%s" % req_resouce)
+
+ resp = sess.delete(req_resouce, endpoint_filter=self.service)
+
+ logger.info("request returns with status %s" % resp.status_code)
+
+ return resp
diff --git a/share/newton_base/openoapi/hosts.py b/share/newton_base/openoapi/hosts.py
index 60debf54..2d50886f 100644
--- a/share/newton_base/openoapi/hosts.py
+++ b/share/newton_base/openoapi/hosts.py
@@ -38,7 +38,10 @@ class Hosts(APIView):
]
def get(self, request, vimid="", tenantid="", hostname=""):
- logger.debug("Hosts--get::> %s" % request.data)
+ logger.info("vimid, tenantid, hostname = %s,%s,%s" % (vimid, tenantid, hostname))
+ if request.data:
+ logger.debug("With data = %s" % request.data)
+ pass
try:
#prepare request resource to vim instance
req_resouce = "/os-hosts"
@@ -47,7 +50,14 @@ class Hosts(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
+
+ logger.info("making request with URI:%s" % req_resouce)
resp = sess.get(req_resouce, endpoint_filter=self.service)
+ logger.info("request returns with status %s" % resp.status_code)
+ if resp.status_code == status.HTTP_200_OK:
+ logger.debug("with content:%s" % resp.json())
+ pass
+
content = resp.json()
vim_dict = {
"vimName": vim["name"],
@@ -72,8 +82,12 @@ class Hosts(APIView):
self.host_keys_mapping)
content["host"].append(res['resource'])
+ logger.info("response with status = %s" % resp.status_code)
+
return Response(data=content, status=resp.status_code)
+
except VimDriverNewtonException as e:
+ logger.error("response with status = %s" % e.status_code)
return Response(data={'error': e.content}, status=e.status_code)
except HttpError as e:
logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
diff --git a/share/newton_base/openoapi/hypervisor.py b/share/newton_base/openoapi/hypervisor.py
index 147fbc44..e9201307 100755
--- a/share/newton_base/openoapi/hypervisor.py
+++ b/share/newton_base/openoapi/hypervisor.py
@@ -37,14 +37,22 @@ class Hypervisors(APIView):
("container_format", "containerFormat")
]
-
+
def get(self, request, vimid="", tenantid="", hypervisorid=""):
- logger.debug("hypervisors--get::> %s" % request.data)
+ logger.info("vimid, tenantid, hypervisorid = %s,%s,%s" % (vimid, tenantid, hypervisorid))
+ if request.data:
+ logger.debug("With data = %s" % request.data)
+ pass
+
try:
query = VimDriverUtils.get_query_part(request)
content, status_code = self.get_hypervisors(query, vimid, tenantid, hypervisorid)
+
+ logger.info("response with status = %s" % resp.status_code)
+
return Response(data=content, status=status_code)
except VimDriverNewtonException as e:
+ logger.error("response with status = %s" % e.status_code)
return Response(data={'error': e.content}, status=e.status_code)
except HttpError as e:
logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
@@ -54,16 +62,24 @@ class Hypervisors(APIView):
return Response(data={'error': str(e)},
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
-
+
def get_hypervisors(self, query="", vimid="", tenantid="", hypervisorid=""):
- logger.debug("hypervisors--get::> %s" % hypervisorid)
req_resource = "/os-hypervisors"
vim = VimDriverUtils.get_vim_info(vimid)
vim["domain"] = "Default"
sess = VimDriverUtils.get_session(vim, tenantid)
+
+ logger.info("making request with URI:%s" % req_resouce)
+
resp = sess.get(req_resource, endpoint_filter = self.service)
+
+ logger.info("request returns with status %s" % resp.status_code)
+ if resp.status_code == status.HTTP_200_OK:
+ logger.debug("with content:%s" % resp.json())
+ pass
+
content = resp.json()
return content, resp.status_code
diff --git a/share/newton_base/openoapi/image.py b/share/newton_base/openoapi/image.py
index 965b2c3f..7a18bdbd 100644
--- a/share/newton_base/openoapi/image.py
+++ b/share/newton_base/openoapi/image.py
@@ -49,7 +49,7 @@ class imageThread (threading.Thread):
running_thread_lock.release()
def transfer_image(self, vimid, tenantid, imageid, imagefd):
- logger.debug("Images--transfer_image::> %s" % (imageid))
+ logger.info("vimid, tenantid, imageid, imagefd = %s,%s,%s,%s" % (vimid, tenantid, imageid, imagefd))
try:
# prepare request resource to vim instance
req_resouce = "v2/images/%s/file" % imageid
@@ -58,11 +58,12 @@ class imageThread (threading.Thread):
sess = VimDriverUtils.get_session(vim, tenantid)
#open imageurl
+ logger.info("making image put request with URI:%s" % req_resouce)
resp = sess.put(req_resouce, endpoint_filter=self.service, data=imagefd.read(),
headers={"Content-Type": "application/octet-stream",
"Accept": ""})
- logger.debug("response status code of transfer_image %s" % resp.status_code)
+ logger.info("response status code of transfer_image %s" % resp.status_code)
return None
except HttpError as e:
logger.error("transfer_image, HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
@@ -82,13 +83,14 @@ class Images(APIView):
]
def get(self, request, vimid="", tenantid="", imageid=""):
- logger.debug("Images--get::> %s" % request.data)
+ logger.info("vimid, tenantid, imageid = %s,%s,%s" % (vimid, tenantid, imageid))
try:
# prepare request resource to vim instance
query = VimDriverUtils.get_query_part(request)
content, status_code = self.get_images(query, vimid, tenantid, imageid)
return Response(data=content, status=status_code)
except VimDriverNewtonException as e:
+ logger.error("response with status = %s" % e.status_code)
return Response(data={'error': e.content}, status=e.status_code)
except HttpError as e:
logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
@@ -99,8 +101,7 @@ class Images(APIView):
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def get_images(self, query="", vimid="", tenantid="", imageid=""):
- logger.debug("Images--get_images::> %s" % imageid)
-
+ logger.info("vimid, tenantid, imageid, query = %s,%s,%s,%s" % (vimid, tenantid, imageid, query))
# prepare request resource to vim instance
req_resouce = "v2/images"
if imageid:
@@ -110,7 +111,14 @@ class Images(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
+
+ logger.info("making request with URI:%s" % req_resouce)
resp = sess.get(req_resouce, endpoint_filter=self.service)
+ logger.info("request returns with status %s" % resp.status_code)
+ if resp.status_code == status.HTTP_200_OK:
+ logger.debug("with content:%s" % resp.json())
+ pass
+
content = resp.json()
vim_dict = {
"vimName": vim["name"],
@@ -134,7 +142,10 @@ class Images(APIView):
return content, resp.status_code
def post(self, request, vimid="", tenantid="", imageid=""):
- logger.debug("Images--post::> %s" % request.data)
+ logger.info("vimid, tenantid, imageid = %s,%s,%s" % (vimid, tenantid, imageid))
+ if request.data:
+ logger.debug("With data = %s" % request.data)
+ pass
try:
#check if created already: check name
query = "name=%s" % request.data["name"]
@@ -173,6 +184,9 @@ class Images(APIView):
self.keys_mapping, True)
#req_body = json.JSONEncoder().encode({"image": image})
req_body = json.JSONEncoder().encode(image)
+
+ logger.info("making request with URI:%s" % req_resouce)
+ logger.debug("with data:%s" % req_body)
resp = sess.post(req_resouce, data=req_body,
endpoint_filter=self.service)
#resp_body = resp.json()["image"]
@@ -197,9 +211,10 @@ class Images(APIView):
tmp_thread.start()
else:
logger.debug("resp.status_code: %s" % resp.status_code)
-
+ logger.info("request returns with status %s" % resp.status_code)
return Response(data=resp_body, status=resp.status_code)
except VimDriverNewtonException as e:
+ logger.error("response with status = %s" % e.status_code)
return Response(data={'error': e.content}, status=e.status_code)
except urllib.error.URLError as e:
return Response(data={'error': 'image is not accessible:%s' % str(e)},
@@ -213,7 +228,7 @@ class Images(APIView):
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def delete(self, request, vimid="", tenantid="", imageid=""):
- logger.debug("Images--delete::> %s" % request.data)
+ logger.info("vimid, tenantid, imageid = %s,%s,%s" % (vimid, tenantid, imageid))
try:
# prepare request resource to vim instance
req_resouce = "v2/images"
@@ -222,9 +237,14 @@ class Images(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
+
+ logger.info("making request with URI:%s" % req_resouce)
resp = sess.delete(req_resouce, endpoint_filter=self.service)
+ logger.info("request returns with status %s" % resp.status_code)
+
return Response(status=resp.status_code)
except VimDriverNewtonException as e:
+ logger.error("response with status = %s" % e.status_code)
return Response(data={'error': e.content}, status=e.status_code)
except HttpError as e:
logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
diff --git a/share/newton_base/openoapi/limits.py b/share/newton_base/openoapi/limits.py
index 3302fdba..5789dfd4 100644
--- a/share/newton_base/openoapi/limits.py
+++ b/share/newton_base/openoapi/limits.py
@@ -37,14 +37,19 @@ class Limits(APIView):
'interface': 'public'}
def get(self, request, vimid="", tenantid=""):
- logger.debug("Limits--get::> %s" % request.data)
+ logger.info("vimid, tenantid = %s,%s" % (vimid, tenantid))
+ if request.data:
+ logger.debug("With data = %s" % request.data)
+ pass
try:
#get limits first
# prepare request resource to vim instance
req_resouce = "/limits"
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
+ logger.info("making request with URI:%s" % req_resouce)
resp = sess.get(req_resouce, endpoint_filter=self.service)
+ logger.info("request returns with status %s" % resp.status_code)
content = resp.json()
content_all =content['limits']['absolute']
@@ -58,19 +63,25 @@ class Limits(APIView):
#now get quota
# prepare request resource to vim instance
req_resouce = "/v2.0/quotas/%s" % tenantid
+ logger.info("making request with URI:%s" % req_resouce)
resp = sess.get(req_resouce, endpoint_filter=self.service_network)
+ logger.info("request returns with status %s" % resp.status_code)
content = resp.json()
content_all.update(content['quota'])
#now get volume limits
# prepare request resource to vim instance
req_resouce = "/limits"
+ logger.info("making request with URI:%s" % req_resouce)
resp = sess.get(req_resouce, endpoint_filter=self.service_volume)
+ logger.info("request returns with status %s" % resp.status_code)
content = resp.json()
content_all.update(content['limits']['absolute'])
+ logger.info("response with status = %s" % resp.status_code)
return Response(data=content_all, status=resp.status_code)
except VimDriverNewtonException as e:
+ logger.error("response with status = %s" % e.status_code)
return Response(data={'error': e.content}, status=e.status_code)
except HttpError as e:
logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
diff --git a/share/newton_base/openoapi/network.py b/share/newton_base/openoapi/network.py
index 253ac89f..b780ab42 100644
--- a/share/newton_base/openoapi/network.py
+++ b/share/newton_base/openoapi/network.py
@@ -39,13 +39,18 @@ class Networks(APIView):
]
def get(self, request, vimid="", tenantid="", networkid=""):
- logger.debug("Networks--get::> %s" % request.data)
+ logger.info("vimid, tenantid, networkid = %s,%s,%s" % (vimid, tenantid, networkid))
+ if request.data:
+ logger.debug("With data = %s" % request.data)
+ pass
try:
query = VimDriverUtils.get_query_part(request)
content, status_code = self.get_networks(query, vimid, tenantid, networkid)
+ logger.info("response with status = %s" % status_code)
return Response(data=content, status=status_code)
except VimDriverNewtonException as e:
+ logger.error("response with status = %s" % e.status_code)
return Response(data={'error': e.content}, status=e.status_code)
except HttpError as e:
logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
@@ -56,7 +61,6 @@ class Networks(APIView):
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def get_networks(self, query, vimid="", tenantid="", networkid=""):
- logger.debug("Networks--get_networks::> %s" % networkid)
# prepare request resource to vim instance
req_resouce = "v2.0/networks"
@@ -68,7 +72,12 @@ class Networks(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
+ logger.info("making request with URI:%s" % req_resouce)
resp = sess.get(req_resouce, endpoint_filter=self.service)
+ logger.info("request returns with status %s" % resp.status_code)
+ if resp.status_code == status.HTTP_200_OK:
+ logger.debug("with content:%s" % resp.json())
+ pass
content = resp.json()
vim_dict = {
"vimName": vim["name"],
@@ -92,7 +101,10 @@ class Networks(APIView):
return content, resp.status_code
def post(self, request, vimid="", tenantid="", networkid=""):
- logger.debug("Networks--post::> %s" % request.data)
+ logger.info("vimid, tenantid, networkid = %s,%s,%s" % (vimid, tenantid, networkid))
+ if request.data:
+ logger.debug("With data = %s" % request.data)
+ pass
try:
#check if created already: check name
query = "name=%s" % request.data["name"]
@@ -119,8 +131,13 @@ class Networks(APIView):
VimDriverUtils.replace_key_by_mapping(network,
self.keys_mapping, True)
req_body = json.JSONEncoder().encode({"network": network})
+
+ logger.info("making request with URI:%s" % req_resouce)
+ logger.debug("with data:%s" % req_body)
resp = sess.post(req_resouce, data=req_body,
endpoint_filter=self.service)
+ logger.info("request returns with status %s" % resp.status_code)
+
resp_body = resp.json()["network"]
VimDriverUtils.replace_key_by_mapping(resp_body, self.keys_mapping)
vim_dict = {
@@ -132,6 +149,7 @@ class Networks(APIView):
resp_body.update(vim_dict)
return Response(data=resp_body, status=resp.status_code)
except VimDriverNewtonException as e:
+ logger.error("response with status = %s" % e.status_code)
return Response(data={'error': e.content}, status=e.status_code)
except HttpError as e:
logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
@@ -142,7 +160,7 @@ class Networks(APIView):
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def delete(self, request, vimid="", tenantid="", networkid=""):
- logger.debug("Networks--delete::> %s" % request.data)
+ logger.info("vimid, tenantid, networkid = %s,%s,%s" % (vimid, tenantid, networkid))
try:
# prepare request resource to vim instance
req_resouce = "v2.0/networks"
@@ -154,9 +172,14 @@ class Networks(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
+
+ logger.info("making delete request with URI:%s" % req_resouce)
resp = sess.delete(req_resouce, endpoint_filter=self.service)
+ logger.info("request returns with status %s" % resp.status_code)
+
return Response(status=resp.status_code)
except VimDriverNewtonException as e:
+ logger.error("response with status = %s" % e.status_code)
return Response(data={'error': e.content}, status=e.status_code)
except HttpError as e:
logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
diff --git a/share/newton_base/openoapi/server.py b/share/newton_base/openoapi/server.py
index 95eab2bf..d21917a4 100644
--- a/share/newton_base/openoapi/server.py
+++ b/share/newton_base/openoapi/server.py
@@ -336,13 +336,30 @@ class Servers(APIView):
contextarray = server.pop("contextArray", None)
volumearray = server.pop("volumeArray", None)
+ userdata = server.pop("userdata", None)
if contextarray:
- # now set "contextArray" array
- personalities = []
+ user_data = []
+ strUserData = ''
+ source_content = ""
+ dest_path = ""
for context in contextarray:
- personalities.append({"path": context["fileName"], "contents": context["fileData"]})
- if len(personalities) > 0:
- server["personality"] = personalities
+ if context["fileName"] == "source_path":
+ source_content = context["fileData"]
+ if context["fileName"] == "dest_path":
+ dest_path = context["fileData"]
+ if len(source_content) > 0:
+ user_data.append("#cloud-config\n")
+ user_data.append("write_files:\n")
+ user_data.append("- encoding: b64\n")
+ user_data.append(" content: " + source_content + "\n")
+ user_data.append(" owner: root:root\n")
+ user_data.append(" path: " + dest_path + "\n")
+ user_data.append(" permissions: '0644'\n")
+ user_data.append("\n")
+ user_data.append("runcmd:")
+ user_data.append("- " + userdata + "\n")
+ strUserData.join(user_data)
+ server["user_data"] = user_data
VimDriverUtils.replace_key_by_mapping(server,
self.keys_mapping, True)
diff --git a/share/newton_base/openoapi/vport.py b/share/newton_base/openoapi/vport.py
index 9656b5c0..e112d38c 100644
--- a/share/newton_base/openoapi/vport.py
+++ b/share/newton_base/openoapi/vport.py
@@ -147,12 +147,13 @@ class Vports(APIView):
tmpip = port.pop("ip", None)
tmpsubnet = port.pop("subnetId", None)
if tmpip and tmpsubnet:
- fixed_ip = {
- "ip_address": tmpip,
- "subnet_id": tmpsubnet,
- }
- port["fixed_ips"] = []
- port["fixed_ips"].append(fixed_ip)
+ port["fixed_ips"] = []
+ for one_tmpip in tmpip.split(','):
+ fixed_ip = {
+ "ip_address": one_tmpip,
+ "subnet_id": tmpsubnet,
+ }
+ port["fixed_ips"].append(fixed_ip)
VimDriverUtils.replace_key_by_mapping(port,
self.keys_mapping, True)
diff --git a/share/newton_base/registration/registration.py b/share/newton_base/registration/registration.py
index e5a84501..7513fd79 100644
--- a/share/newton_base/registration/registration.py
+++ b/share/newton_base/registration/registration.py
@@ -151,10 +151,10 @@ class Registry(APIView):
'flavor-disabled': flavor['OS-FLV-DISABLED:disabled'],
}
- if flavor.get('link') and len(flavor['link']) > 0:
- flavor_info['flavor-selflink'] = flavor['link'][0]['href'] or 'http://0.0.0.0',
+ 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',
+ flavor_info['flavor-selflink'] = 'http://0.0.0.0'
self._update_resoure(
cloud_owner, cloud_region_id, flavor['id'],
@@ -623,8 +623,8 @@ class Registry(APIView):
return
def post(self, request, vimid=""):
- self._logger.debug("Registration--post::data> %s" % request.data)
- self._logger.debug("Registration--post::vimid > %s" % vimid)
+ self._logger.info("registration with vimid: %s" % vimid)
+ self._logger.debug("with data: %s" % request.data)
try:
# populate proxy identity url