js_v(client_data, schema)
#print "Input data: ", str(client_data)
return True, client_data
- except js_e.ValidationError, exc:
+ except js_e.ValidationError as exc:
print "validate_in error, jsonschema exception ", exc.message, "at", exc.path
return False, ("validate_in error, jsonschema exception ", exc.message, "at", exc.path)
'''Adds a tenant flavor to VIM'''
'''Returns the flavor identifier'''
try:
+ new_flavor_dict = flavor_data.copy()
+ new_flavor_dict["name"] = flavor_data["name"][:64]
self._get_my_tenant()
- payload_req = json.dumps({'flavor': flavor_data})
+ payload_req = json.dumps({'flavor': new_flavor_dict})
url = self.url+'/'+self.tenant+'/flavors'
self.logger.info("Adding a new VIM flavor POST %s", url)
vim_response = requests.post(url, headers = self.headers_req, data=payload_req)
''' Adds a tenant image to VIM, returns image_id'''
try:
self._get_my_tenant()
- new_image_dict={'name': image_dict['name']}
+ new_image_dict={'name': image_dict['name'][:64]}
if image_dict.get('description'):
new_image_dict['description'] = image_dict['description']
if image_dict.get('metadata'):
payload_req = vm_data
try:
vim_response = requests.post(self.url+'/'+self.tenant+'/servers', headers = self.headers_req, data=payload_req)
- except requests.exceptions.RequestException, e:
+ except requests.exceptions.RequestException as e:
print "new_vminstancefromJSON Exception: ", e.args
return -vimconn.HTTP_Not_Found, str(e.args[0])
print vim_response
#TODO ip, security groups
Returns the instance identifier
'''
+ self.logger.debug("new_vminstance input: image='%s' flavor='%s' nics='%s'", image_id, flavor_id, str(net_list))
try:
self._get_my_tenant()
# net_list = []
if net.get("model"): net_dict["model"] = net["model"]
if net.get("mac_address"): net_dict["mac_address"] = net["mac_address"]
virtio_net_list.append(net_dict)
- payload_dict={ "name": name,
+ payload_dict={ "name": name[:64],
"description": description,
"imageRef": image_id,
"flavorRef": flavor_id,
url=self.url+'/hosts'
try:
vim_response = requests.get(url)
- except requests.exceptions.RequestException, e:
+ except requests.exceptions.RequestException as e:
print "get_hosts_info Exception: ", e.args
return -vimconn.HTTP_Not_Found, str(e.args[0])
print "vim get", url, "response:", vim_response.status_code, vim_response.json()
url=self.url+'/hosts/'+host['id']
try:
vim_response = requests.get(url)
- except requests.exceptions.RequestException, e:
+ except requests.exceptions.RequestException as e:
print "get_hosts_info Exception: ", e.args
return -vimconn.HTTP_Not_Found, str(e.args[0])
print "vim get", url, "response:", vim_response.status_code, vim_response.json()
url=self.url+'/hosts'
try:
vim_response = requests.get(url)
- except requests.exceptions.RequestException, e:
+ except requests.exceptions.RequestException as e:
print "get_hosts Exception: ", e.args
return -vimconn.HTTP_Not_Found, str(e.args[0])
print "vim get", url, "response:", vim_response.status_code, vim_response.json()
url=self.url+'/' + vim_tenant + '/servers?hostId='+host['id']
try:
vim_response = requests.get(url)
- except requests.exceptions.RequestException, e:
+ except requests.exceptions.RequestException as e:
print "get_hosts Exception: ", e.args
return -vimconn.HTTP_Not_Found, str(e.args[0])
print "vim get", url, "response:", vim_response.status_code, vim_response.json()
url=self.url+'/processor_ranking'
try:
vim_response = requests.get(url)
- except requests.exceptions.RequestException, e:
+ except requests.exceptions.RequestException as e:
print "get_processor_rankings Exception: ", e.args
return -vimconn.HTTP_Not_Found, str(e.args[0])
print "vim get", url, "response:", vim_response.status_code, vim_response.json()
payload_req = port_data
try:
vim_response = requests.post(self.url_admin+'/ports', headers = self.headers_req, data=payload_req)
- except requests.exceptions.RequestException, e:
+ except requests.exceptions.RequestException as e:
self.logger.error("new_external_port Exception: ", str(e))
return -vimconn.HTTP_Not_Found, str(e.args[0])
print vim_response
payload_req = '{"network":{"name": "' + net_name + '","shared":true,"type": "' + net_type + '"}}'
try:
vim_response = requests.post(self.url+'/networks', headers = self.headers_req, data=payload_req)
- except requests.exceptions.RequestException, e:
+ except requests.exceptions.RequestException as e:
self.logger.error( "new_external_network Exception: ", e.args)
return -vimconn.HTTP_Not_Found, str(e.args[0])
print vim_response
url= self.url
try:
vim_response = requests.put(url +'/ports/'+port_id, headers = self.headers_req, data=payload_req)
- except requests.exceptions.RequestException, e:
+ except requests.exceptions.RequestException as e:
print "connect_port_network Exception: ", e.args
return -vimconn.HTTP_Not_Found, str(e.args[0])
print vim_response