Kill make_image_dict

make_image_dict function was from glance. It is used for
convert image response body which do not need by daisy.

Change-Id: I41e83c6847b5b8caa87572969355018f41c798b3
Signed-off-by: Zhijiang Hu <hu.zhijiang@zte.com.cn>
This commit is contained in:
Zhijiang Hu 2017-08-24 05:16:45 -04:00
parent 3b3cae1065
commit 4186419374
9 changed files with 0 additions and 244 deletions

View File

@ -223,8 +223,6 @@ class Controller(object):
try:
service_disk_data = self.db_api.service_disk_add(
req.context, service_disk_data)
# service_disk_data = dict(service_disk=make_image_dict(
# service_disk_data))
msg = (_LI("Successfully created node %s") %
service_disk_data["id"])
LOG.info(msg)

View File

@ -298,7 +298,6 @@ class Controller(object):
LOG.error(msg)
return exc.HTTPBadRequest(msg)
# host_data = dict(host=make_image_dict(host_data))
msg = (_LI("Successfully created node %s") %
host_data["id"])
LOG.info(msg)
@ -582,7 +581,6 @@ class Controller(object):
else:
discover_host_data = self.db_api.discover_host_update(
req.context, discover_host_id, discover_host_data)
# host_data = dict(host=make_image_dict(host_data))
msg = (_LI("Successfully created node %s") %
discover_host_data["id"])
LOG.info(msg)
@ -964,7 +962,6 @@ class Controller(object):
try:
component_data = self.db_api.component_add(
req.context, component_data)
# host_data = dict(host=make_image_dict(host_data))
msg = (_LI("Successfully created component %s") %
component_data["id"])
LOG.info(msg)
@ -1159,7 +1156,6 @@ class Controller(object):
try:
print service_data
service_data = self.db_api.service_add(req.context, service_data)
# host_data = dict(host=make_image_dict(host_data))
msg = (_LI("Successfully created service %s") %
service_data["id"])
LOG.info(msg)
@ -1353,7 +1349,6 @@ class Controller(object):
try:
print role_data
role_data = self.db_api.role_add(req.context, role_data)
# host_data = dict(host=make_image_dict(host_data))
msg = (_LI("Successfully created role %s") %
role_data["id"])
LOG.info(msg)
@ -1799,38 +1794,6 @@ class Controller(object):
return config_interface_meta
def _limit_locations(image):
locations = image.pop('locations', [])
image['location_data'] = locations
image['location'] = None
for loc in locations:
if loc['status'] == 'active':
image['location'] = loc['url']
break
def make_image_dict(image):
"""Create a dict representation of an image which we can use to
serialize the image.
"""
def _fetch_attrs(d, attrs):
return dict([(a, d[a]) for a in attrs
if a in d.keys()])
# TODO(sirp): should this be a dict, or a list of dicts?
# A plain dict is more convenient, but list of dicts would provide
# access to created_at, etc
properties = dict((p['name'], p['value'])
for p in image['properties'] if not p['deleted'])
image_dict = _fetch_attrs(image, daisy.db.IMAGE_ATTRS)
image_dict['properties'] = properties
_limit_locations(image_dict)
return image_dict
def create_resource():
"""Images resource factory method."""
deserializer = wsgi.JSONRequestDeserializer()

View File

@ -265,7 +265,6 @@ class Controller(object):
try:
network_data = self.db_api.network_add(req.context, network_data)
# network_data = dict(network=make_image_dict(network_data))
msg = (_LI("Successfully created node %s") %
network_data["id"])
LOG.info(msg)
@ -427,38 +426,6 @@ class Controller(object):
raise
def _limit_locations(image):
locations = image.pop('locations', [])
image['location_data'] = locations
image['location'] = None
for loc in locations:
if loc['status'] == 'active':
image['location'] = loc['url']
break
def make_image_dict(image):
"""Create a dict representation of an image which we can use to
serialize the image.
"""
def _fetch_attrs(d, attrs):
return dict([(a, d[a]) for a in attrs
if a in d.keys()])
# TODO(sirp): should this be a dict, or a list of dicts?
# A plain dict is more convenient, but list of dicts would provide
# access to created_at, etc
properties = dict((p['name'], p['value'])
for p in image['properties'] if not p['deleted'])
image_dict = _fetch_attrs(image, daisy.db.IMAGE_ATTRS)
image_dict['properties'] = properties
_limit_locations(image_dict)
return image_dict
def create_resource():
"""Images resource factory method."""
deserializer = wsgi.JSONRequestDeserializer()

View File

@ -299,7 +299,6 @@ class Controller(object):
try:
template_data = self.db_api.template_destroy(
req.context, template_id)
# template_data = dict(template=make_image_dict(template_data))
msg = (_LI("Successfully deleted template %s") % template_id)
LOG.info(msg)
if 'template' not in template_data:
@ -362,8 +361,6 @@ class Controller(object):
try:
template_data = self.db_api.template_get(req.context, template_id)
# service_disk_data = dict(service_disk=make_image_dict(
# service_disk_data))
msg = (
_LI("Successfully get template information:%s") %
template_id)
@ -412,8 +409,6 @@ class Controller(object):
try:
template_data = self.db_api.host_template_add(
req.context, template_data)
# service_disk_data = dict(service_disk=make_image_dict(
# service_disk_data))
msg = (_LI("Successfully created node %s") %
template_data["id"])
LOG.info(msg)
@ -458,8 +453,6 @@ class Controller(object):
try:
template_data = self.db_api.host_template_update(
req.context, template_id, template_data)
# service_disk_data = dict(service_disk=make_image_dict(
# service_disk_data))
msg = (_LI("Successfully updated template %s") %
template_data["id"])
LOG.info(msg)
@ -502,8 +495,6 @@ class Controller(object):
try:
template_data = self.db_api.host_template_destroy(
req.context, template_id)
# service_disk_data = dict(service_disk=make_image_dict(
# service_disk_data))
msg = (_LI("Successfully deleted template %s") % template_id)
LOG.info(msg)
if 'template' not in template_data:
@ -570,8 +561,6 @@ class Controller(object):
try:
template_data = self.db_api.host_template_get(
req.context, template_id)
# service_disk_data = dict(service_disk=make_image_dict(
# service_disk_data))
msg = (
_LI("Successfully get template information:%s") %
template_id)

View File

@ -333,38 +333,6 @@ class Controller(object):
return template_config
def _limit_locations(image):
locations = image.pop('locations', [])
image['location_data'] = locations
image['location'] = None
for loc in locations:
if loc['status'] == 'active':
image['location'] = loc['url']
break
def make_image_dict(image):
"""Create a dict representation of an image which we can use to
serialize the image.
"""
def _fetch_attrs(d, attrs):
return dict([(a, d[a]) for a in attrs
if a in d.keys()])
# TODO(sirp): should this be a dict, or a list of dicts?
# A plain dict is more convenient, but list of dicts would provide
# access to created_at, etc
properties = dict((p['name'], p['value'])
for p in image['properties'] if not p['deleted'])
image_dict = _fetch_attrs(image, daisy.db.IMAGE_ATTRS)
image_dict['properties'] = properties
_limit_locations(image_dict)
return image_dict
def create_resource():
"""Images resource factory method."""
deserializer = wsgi.JSONRequestDeserializer()

View File

@ -286,38 +286,6 @@ class Controller(object):
return template_func
def _limit_locations(image):
locations = image.pop('locations', [])
image['location_data'] = locations
image['location'] = None
for loc in locations:
if loc['status'] == 'active':
image['location'] = loc['url']
break
def make_image_dict(image):
"""Create a dict representation of an image which we can use to
serialize the image.
"""
def _fetch_attrs(d, attrs):
return dict([(a, d[a]) for a in attrs
if a in d.keys()])
# TODO(sirp): should this be a dict, or a list of dicts?
# A plain dict is more convenient, but list of dicts would provide
# access to created_at, etc
properties = dict((p['name'], p['value'])
for p in image['properties'] if not p['deleted'])
image_dict = _fetch_attrs(image, daisy.db.IMAGE_ATTRS)
image_dict['properties'] = properties
_limit_locations(image_dict)
return image_dict
def create_resource():
"""Images resource factory method."""
deserializer = wsgi.JSONRequestDeserializer()

View File

@ -240,38 +240,6 @@ class Controller(object):
return template_service
def _limit_locations(image):
locations = image.pop('locations', [])
image['location_data'] = locations
image['location'] = None
for loc in locations:
if loc['status'] == 'active':
image['location'] = loc['url']
break
def make_image_dict(image):
"""Create a dict representation of an image which we can use to
serialize the image.
"""
def _fetch_attrs(d, attrs):
return dict([(a, d[a]) for a in attrs
if a in d.keys()])
# TODO(sirp): should this be a dict, or a list of dicts?
# A plain dict is more convenient, but list of dicts would provide
# access to created_at, etc
properties = dict((p['name'], p['value'])
for p in image['properties'] if not p['deleted'])
image_dict = _fetch_attrs(image, daisy.db.IMAGE_ATTRS)
image_dict['properties'] = properties
_limit_locations(image_dict)
return image_dict
def create_resource():
"""Images resource factory method."""
deserializer = wsgi.JSONRequestDeserializer()

View File

@ -399,38 +399,6 @@ class Controller(object):
raise
def _limit_locations(image):
locations = image.pop('locations', [])
image['location_data'] = locations
image['location'] = None
for loc in locations:
if loc['status'] == 'active':
image['location'] = loc['url']
break
def make_image_dict(image):
"""Create a dict representation of an image which we can use to
serialize the image.
"""
def _fetch_attrs(d, attrs):
return dict([(a, d[a]) for a in attrs
if a in d.keys()])
# TODO(sirp): should this be a dict, or a list of dicts?
# A plain dict is more convenient, but list of dicts would provide
# access to created_at, etc
properties = dict((p['name'], p['value'])
for p in image['properties'] if not p['deleted'])
image_dict = _fetch_attrs(image, daisy.db.IMAGE_ATTRS)
image_dict['properties'] = properties
_limit_locations(image_dict)
return image_dict
def create_resource():
"""Images resource factory method."""
deserializer = wsgi.JSONRequestDeserializer()

View File

@ -237,7 +237,6 @@ class Controller(object):
try:
version_data = self.db_api.version_add(req.context, version_data)
# version_data = dict(version=make_image_dict(version_data))
msg = (_LI("Successfully created node %s") %
version_data["id"])
LOG.info(msg)
@ -383,38 +382,6 @@ class Controller(object):
raise
def _limit_locations(image):
locations = image.pop('locations', [])
image['location_data'] = locations
image['location'] = None
for loc in locations:
if loc['status'] == 'active':
image['location'] = loc['url']
break
def make_image_dict(image):
"""Create a dict representation of an image which we can use to
serialize the image.
"""
def _fetch_attrs(d, attrs):
return dict([(a, d[a]) for a in attrs
if a in d.keys()])
# TODO(sirp): should this be a dict, or a list of dicts?
# A plain dict is more convenient, but list of dicts would provide
# access to created_at, etc
properties = dict((p['name'], p['value'])
for p in image['properties'] if not p['deleted'])
image_dict = _fetch_attrs(image, daisy.db.IMAGE_ATTRS)
image_dict['properties'] = properties
_limit_locations(image_dict)
return image_dict
def create_resource():
"""Images resource factory method."""
deserializer = wsgi.JSONRequestDeserializer()