Rectify request body, final patch
Change-Id: I647dab11054ad7ff385576687de69d2f7d6e521c Signed-off-by: Zhijiang Hu <hu.zhijiang@zte.com.cn>
This commit is contained in:
parent
759e70e09d
commit
b3303a87b0
@ -610,9 +610,7 @@ def sort_interfaces_by_pci(networks, host_detail):
|
||||
:param interfaces: interfaces info of the host
|
||||
:return:
|
||||
"""
|
||||
interfaces = eval(host_detail.get('interfaces', None)) \
|
||||
if isinstance(host_detail, unicode) else \
|
||||
host_detail.get('interfaces', None)
|
||||
interfaces = host_detail.get('interfaces', None)
|
||||
if not interfaces:
|
||||
LOG.info("This host has no interfaces info.")
|
||||
return host_detail
|
||||
|
@ -250,7 +250,7 @@ class API(driver.DeploymentDriver):
|
||||
neutron_backend_meta = {}
|
||||
if role_meta.get('neutron_backends_array', None):
|
||||
neutron_backend_metas = list(
|
||||
eval(role_meta.get('neutron_backends_array')))
|
||||
role_meta.get('neutron_backends_array'))
|
||||
for neutron_backend_meta_tmp in neutron_backend_metas:
|
||||
neutron_backend_meta['neutron_backends_type'] =\
|
||||
neutron_backend_meta_tmp['sdn_controller_type']
|
||||
|
@ -13,7 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import ast
|
||||
from oslo_log import log as logging
|
||||
|
||||
from webob import exc
|
||||
@ -97,9 +96,6 @@ def valid_ip_ranges(ip_ranges, cidr=None):
|
||||
LOG.error(msg)
|
||||
raise exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
if not isinstance(ip_ranges, list):
|
||||
ip_ranges = ast.literal_eval(ip_ranges)
|
||||
|
||||
last_ip_range_end = 0
|
||||
int_ip_ranges_list = list()
|
||||
sorted_int_ip_ranges_list = list()
|
||||
@ -213,9 +209,6 @@ def valid_vlan_id(vlan_id):
|
||||
LOG.error(msg)
|
||||
raise exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
if not isinstance(vlan_id, int):
|
||||
vlan_id = ast.literal_eval(vlan_id)
|
||||
|
||||
if not (vlan_id >= 1 and vlan_id <= 4094):
|
||||
msg = "vlan id must be a integer between 1~4094"
|
||||
LOG.error(msg)
|
||||
|
@ -584,7 +584,7 @@ class Controller(controller.BaseController):
|
||||
'host_template %s.') % (
|
||||
host_id, host_template['host_template_name']))
|
||||
raise HTTPBadRequest(explanation=msg)
|
||||
host_template_used['interfaces'] = str(host_template_interfaces)
|
||||
host_template_used['interfaces'] = host_template_interfaces
|
||||
try:
|
||||
host_template = registry.update_host_metadata(
|
||||
req.context, host_id, host_template_used)
|
||||
|
@ -569,15 +569,6 @@ class Controller(controller.BaseController):
|
||||
template_content = json.loads(template_cluster['content'])
|
||||
template_content_cluster = template_content['cluster']
|
||||
template_content_cluster['name'] = cluster_name
|
||||
template_content_cluster['networking_parameters'] = str(
|
||||
template_content_cluster['networking_parameters'])
|
||||
template_content_cluster['logic_networks'] = str(
|
||||
template_content_cluster['logic_networks'])
|
||||
template_content_cluster['logic_networks'] = \
|
||||
template_content_cluster[
|
||||
'logic_networks'].replace("\'true\'", "True")
|
||||
template_content_cluster['routers'] = str(
|
||||
template_content_cluster['routers'])
|
||||
|
||||
if template_cluster['hosts']:
|
||||
template_hosts = json.loads(template_cluster['hosts'])
|
||||
@ -636,8 +627,6 @@ class Controller(controller.BaseController):
|
||||
req.context, cluster_id, **params)
|
||||
template_content_networks = template_content['networks']
|
||||
for template_content_network in template_content_networks:
|
||||
template_content_network['ip_ranges'] = str(
|
||||
template_content_network['ip_ranges'])
|
||||
network_exist = 'false'
|
||||
for network in networks:
|
||||
if template_content_network['name'] == network['name']:
|
||||
|
@ -824,8 +824,6 @@ def stash_conf_values():
|
||||
|
||||
|
||||
def get_host_min_mac(host_interfaces):
|
||||
if not isinstance(host_interfaces, list):
|
||||
host_interfaces = eval(host_interfaces)
|
||||
macs = [interface['mac'] for interface in host_interfaces
|
||||
if interface['type'] == 'ether' and interface['mac']]
|
||||
min_mac = min(macs)
|
||||
@ -1078,15 +1076,10 @@ def is_ip_ranges_equal(ip_ranges1, ip_ranges2):
|
||||
|
||||
def get_dvs_interfaces(host_interfaces):
|
||||
dvs_interfaces = []
|
||||
if not isinstance(host_interfaces, list):
|
||||
host_interfaces = eval(host_interfaces)
|
||||
for interface in host_interfaces:
|
||||
if not isinstance(interface, dict):
|
||||
interface = eval(interface)
|
||||
if ('vswitch_type' in interface and
|
||||
interface['vswitch_type'] == 'dvs'):
|
||||
dvs_interfaces.append(interface)
|
||||
|
||||
return dvs_interfaces
|
||||
|
||||
|
||||
|
@ -218,11 +218,10 @@ class TemplateManager(base.ManagerWithFind):
|
||||
else:
|
||||
msg = 'create() got an unexpected keyword argument \'%s\''
|
||||
raise TypeError(msg % field)
|
||||
hdrs = self._template_meta_to_headers(fields)
|
||||
|
||||
resp, body = self.client.post('/v1/template',
|
||||
headers=None,
|
||||
data=hdrs)
|
||||
data=fields)
|
||||
return_request_id = kwargs.get('return_req_id', None)
|
||||
if return_request_id is not None:
|
||||
return_request_id.append(resp.headers.get(OS_REQ_ID_HDR, None))
|
||||
@ -240,7 +239,6 @@ class TemplateManager(base.ManagerWithFind):
|
||||
|
||||
TODO(bcwaldon): document accepted params
|
||||
"""
|
||||
hdrs = {}
|
||||
fields = {}
|
||||
for field in kwargs:
|
||||
if field in UPDATE_PARAMS:
|
||||
@ -251,9 +249,8 @@ class TemplateManager(base.ManagerWithFind):
|
||||
msg = 'update() got an unexpected keyword argument \'%s\''
|
||||
raise TypeError(msg % field)
|
||||
|
||||
hdrs.update(self._template_meta_to_headers(fields))
|
||||
url = '/v1/template/%s' % base.getid(template_id)
|
||||
resp, body = self.client.put(url, headers=None, data=hdrs)
|
||||
resp, body = self.client.put(url, headers=None, data=fields)
|
||||
return_request_id = kwargs.get('return_req_id', None)
|
||||
if return_request_id is not None:
|
||||
return_request_id.append(resp.headers.get(OS_REQ_ID_HDR, None))
|
||||
@ -274,8 +271,7 @@ class TemplateManager(base.ManagerWithFind):
|
||||
raise TypeError(msg % field)
|
||||
|
||||
url = '/v1/export_db_to_json'
|
||||
hdrs = self._template_meta_to_headers(fields)
|
||||
resp, body = self.client.post(url, headers=None, data=hdrs)
|
||||
resp, body = self.client.post(url, headers=None, data=fields)
|
||||
return Template(
|
||||
self, self._format_template_meta_for_user(body['template']))
|
||||
|
||||
@ -292,8 +288,7 @@ class TemplateManager(base.ManagerWithFind):
|
||||
raise TypeError(msg % field)
|
||||
|
||||
url = '/v1/import_json_to_template'
|
||||
hdrs = self._template_meta_to_headers(fields)
|
||||
resp, body = self.client.post(url, headers=None, data=hdrs)
|
||||
resp, body = self.client.post(url, headers=None, data=fields)
|
||||
return Template(
|
||||
self, self._format_template_meta_for_user(body['template']))
|
||||
|
||||
@ -310,8 +305,7 @@ class TemplateManager(base.ManagerWithFind):
|
||||
raise TypeError(msg % field)
|
||||
|
||||
url = '/v1/import_template_to_db'
|
||||
hdrs = self._template_meta_to_headers(fields)
|
||||
resp, body = self.client.post(url, headers=None, data=hdrs)
|
||||
resp, body = self.client.post(url, headers=None, data=fields)
|
||||
return Template(
|
||||
self, self._format_template_meta_for_user(body['template']))
|
||||
|
||||
@ -326,14 +320,12 @@ class TemplateManager(base.ManagerWithFind):
|
||||
raise TypeError(msg % field)
|
||||
|
||||
url = '/v1/host_to_template'
|
||||
hdrs = self._template_meta_to_headers(fields)
|
||||
resp, body = self.client.post(url, headers=None, data=hdrs)
|
||||
resp, body = self.client.post(url, headers=None, data=fields)
|
||||
return Template(
|
||||
self, self._format_template_meta_for_user(body['host_template']))
|
||||
|
||||
def template_to_host(self, **kwargs):
|
||||
"""Update host with template"""
|
||||
hdrs = {}
|
||||
fields = {}
|
||||
for field in kwargs:
|
||||
if field in CREATE_PARAMS:
|
||||
@ -343,9 +335,8 @@ class TemplateManager(base.ManagerWithFind):
|
||||
else:
|
||||
msg = 'update() got an unexpected keyword argument \'%s\''
|
||||
raise TypeError(msg % field)
|
||||
hdrs.update(self._template_meta_to_headers(fields))
|
||||
url = '/v1/template_to_host'
|
||||
resp, body = self.client.put(url, headers=None, data=hdrs)
|
||||
resp, body = self.client.put(url, headers=None, data=fields)
|
||||
return_request_id = kwargs.get('return_req_id', None)
|
||||
if return_request_id is not None:
|
||||
return_request_id.append(resp.headers.get(OS_REQ_ID_HDR, None))
|
||||
@ -402,7 +393,6 @@ class TemplateManager(base.ManagerWithFind):
|
||||
raise TypeError(msg % field)
|
||||
|
||||
url = '/v1/host_template'
|
||||
hdrs = self._template_meta_to_headers(fields)
|
||||
resp, body = self.client.put(url, headers=None, data=hdrs)
|
||||
resp, body = self.client.put(url, headers=None, data=fields)
|
||||
return Template(
|
||||
self, self._format_template_meta_for_user(body['host_template']))
|
||||
|
@ -101,6 +101,5 @@ class UninstallManager(base.ManagerWithFind):
|
||||
if "cluster_id" in fields:
|
||||
url = '/v1/uninstall/%s' % fields['cluster_id']
|
||||
|
||||
hdrs = self._uninstall_meta_to_headers(fields)
|
||||
resp, body = self.client.post(url, headers=None, data=hdrs)
|
||||
resp, body = self.client.post(url, headers=None, data=fields)
|
||||
return Uninstall(self, self._format_uninstall_meta_for_user(body))
|
||||
|
@ -105,6 +105,5 @@ class UpdateManager(base.ManagerWithFind):
|
||||
if "cluster_id" in fields:
|
||||
url = '/v1/update/%s' % fields['cluster_id']
|
||||
|
||||
hdrs = self._Update_meta_to_headers(fields)
|
||||
resp, body = self.client.post(url, headers=None, data=hdrs)
|
||||
return Update(self, self._format_update_meta_for_user(body))
|
||||
resp, body = self.client.post(url, headers=None, data=fields)
|
||||
return Update(self, self._format_update_meta_for_user(body))
|
||||
|
@ -163,11 +163,9 @@ class VersionPatchManager(base.ManagerWithFind):
|
||||
msg = 'create() got an unexpected keyword argument \'%s\''
|
||||
raise TypeError(msg % field)
|
||||
|
||||
hdrs = self._version_meta_to_headers(fields)
|
||||
|
||||
resp, body = self.client.post('/v1/version_patchs',
|
||||
headers=None,
|
||||
data=hdrs)
|
||||
data=fields)
|
||||
return_request_id = kwargs.get('return_req_id', None)
|
||||
if return_request_id is not None:
|
||||
return_request_id.append(resp.headers.get(OS_REQ_ID_HDR, None))
|
||||
@ -188,7 +186,6 @@ class VersionPatchManager(base.ManagerWithFind):
|
||||
|
||||
TODO(bcwaldon): document accepted params
|
||||
"""
|
||||
hdrs = {}
|
||||
fields = {}
|
||||
for field in kwargs:
|
||||
if field in CREATE_PARAMS:
|
||||
@ -196,10 +193,8 @@ class VersionPatchManager(base.ManagerWithFind):
|
||||
elif field == 'return_req_id':
|
||||
continue
|
||||
|
||||
hdrs.update(self._version_meta_to_headers(fields))
|
||||
|
||||
url = '/v1/version_patchs/%s' % base.getid(version_patch)
|
||||
resp, body = self.client.put(url, headers=None, data=hdrs)
|
||||
resp, body = self.client.put(url, headers=None, data=fields)
|
||||
return_request_id = kwargs.get('return_req_id', None)
|
||||
if return_request_id is not None:
|
||||
return_request_id.append(resp.headers.get(OS_REQ_ID_HDR, None))
|
||||
@ -285,11 +280,9 @@ class VersionPatchManager(base.ManagerWithFind):
|
||||
msg = 'create() got an unexpected keyword argument \'%s\''
|
||||
raise TypeError(msg % field)
|
||||
|
||||
hdrs = self._version_meta_to_headers(fields)
|
||||
|
||||
resp, body = self.client.post('/v1/patch_history',
|
||||
headers=None,
|
||||
data=hdrs)
|
||||
data=fields)
|
||||
return_request_id = kwargs.get('return_req_id', None)
|
||||
if return_request_id is not None:
|
||||
return_request_id.append(resp.headers.get(OS_REQ_ID_HDR, None))
|
||||
|
@ -238,11 +238,9 @@ class VersionManager(base.ManagerWithFind):
|
||||
msg = 'create() got an unexpected keyword argument \'%s\''
|
||||
raise TypeError(msg % field)
|
||||
|
||||
hdrs = self._version_meta_to_headers(fields)
|
||||
|
||||
resp, body = self.client.post('/v1/versions',
|
||||
headers=None,
|
||||
data=hdrs)
|
||||
data=fields)
|
||||
return_request_id = kwargs.get('return_req_id', None)
|
||||
if return_request_id is not None:
|
||||
return_request_id.append(resp.headers.get(OS_REQ_ID_HDR, None))
|
||||
@ -263,17 +261,15 @@ class VersionManager(base.ManagerWithFind):
|
||||
|
||||
TODO(bcwaldon): document accepted params
|
||||
"""
|
||||
hdrs = {}
|
||||
fields = {}
|
||||
for field in kwargs:
|
||||
if field in CREATE_PARAMS:
|
||||
fields[field] = kwargs[field]
|
||||
elif field == 'return_req_id':
|
||||
continue
|
||||
hdrs.update(self._version_meta_to_headers(fields))
|
||||
|
||||
url = '/v1/versions/%s' % base.getid(version)
|
||||
resp, body = self.client.put(url, headers=None, data=hdrs)
|
||||
resp, body = self.client.put(url, headers=None, data=fields)
|
||||
return_request_id = kwargs.get('return_req_id', None)
|
||||
if return_request_id is not None:
|
||||
return_request_id.append(resp.headers.get(OS_REQ_ID_HDR, None))
|
||||
|
Loading…
Reference in New Issue
Block a user