Remove extended addresses from V2.1 update & rebuild
V2.1 server update and rebuild response contain 'OS-EXT-IPS:type' & 'OS-EXT-IPS-MAC:mac_addr' in address field which are new attributes compared to V2 response for those API. These new attributes are found during tempest testing by blocking additional properties in schema -https://review.openstack.org/#/c/156130/ V2.1 must be identical with V2 and must not contain any new attributes in response. This commit removes these new attributes from V2.1 API. Partially implements blueprint v2-on-v3-api Change-Id: Id5b210d7afe5c0a590abcbd42b9ff85b071a5c55
This commit is contained in:
parent
5208925c29
commit
e74b62f26f
|
@ -4,8 +4,6 @@
|
|||
"private": [
|
||||
{
|
||||
"addr": "192.168.0.3",
|
||||
"OS-EXT-IPS-MAC:mac_addr": "aa:bb:cc:dd:ee:ff",
|
||||
"OS-EXT-IPS:type": "fixed",
|
||||
"version": 4
|
||||
}
|
||||
]
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
"private": [
|
||||
{
|
||||
"addr": "192.168.0.3",
|
||||
"OS-EXT-IPS-MAC:mac_addr": "aa:bb:cc:dd:ee:ff",
|
||||
"OS-EXT-IPS:type": "fixed",
|
||||
"version": 4
|
||||
}
|
||||
]
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
"private": [
|
||||
{
|
||||
"addr": "192.168.0.3",
|
||||
"OS-EXT-IPS-MAC:mac_addr": "aa:bb:cc:dd:ee:ff",
|
||||
"OS-EXT-IPS:type": "fixed",
|
||||
"version": 4
|
||||
}
|
||||
]
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
"private": [
|
||||
{
|
||||
"addr": "192.168.0.3",
|
||||
"OS-EXT-IPS-MAC:mac_addr": "aa:bb:cc:dd:ee:ff",
|
||||
"OS-EXT-IPS:type": "fixed",
|
||||
"version": 4
|
||||
}
|
||||
]
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
"private": [
|
||||
{
|
||||
"addr": "192.168.0.3",
|
||||
"OS-EXT-IPS-MAC:mac_addr": "aa:bb:cc:dd:ee:ff",
|
||||
"OS-EXT-IPS:type": "fixed",
|
||||
"version": 4
|
||||
}
|
||||
]
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
"private": [
|
||||
{
|
||||
"addr": "192.168.0.3",
|
||||
"OS-EXT-IPS-MAC:mac_addr": "aa:bb:cc:dd:ee:ff",
|
||||
"OS-EXT-IPS:type": "fixed",
|
||||
"version": 4
|
||||
}
|
||||
]
|
||||
|
|
|
@ -727,7 +727,8 @@ class ServersController(wsgi.Controller):
|
|||
policy.enforce(ctxt, 'compute:update', instance)
|
||||
instance.update(update_dict)
|
||||
instance.save()
|
||||
return self._view_builder.show(req, instance)
|
||||
return self._view_builder.show(req, instance,
|
||||
extend_address=False)
|
||||
except exception.InstanceNotFound:
|
||||
msg = _("Instance could not be found")
|
||||
raise exc.HTTPNotFound(explanation=msg)
|
||||
|
@ -956,7 +957,7 @@ class ServersController(wsgi.Controller):
|
|||
|
||||
instance = self._get_server(context, req, id)
|
||||
|
||||
view = self._view_builder.show(req, instance)
|
||||
view = self._view_builder.show(req, instance, extend_address=False)
|
||||
|
||||
# Add on the admin_password attribute since the view doesn't do it
|
||||
# unless instance passwords are disabled
|
||||
|
|
|
@ -24,34 +24,38 @@ class ViewBuilder(common.ViewBuilder):
|
|||
|
||||
_collection_name = "addresses"
|
||||
|
||||
def basic(self, ip):
|
||||
def basic(self, ip, extend_address=False):
|
||||
"""Return a dictionary describing an IP address."""
|
||||
return {
|
||||
"version": ip["version"],
|
||||
"addr": ip["address"],
|
||||
}
|
||||
|
||||
def show(self, network, label):
|
||||
def show(self, network, label, extend_address=False):
|
||||
"""Returns a dictionary describing a network."""
|
||||
all_ips = itertools.chain(network["ips"], network["floating_ips"])
|
||||
return {label: [self.basic(ip) for ip in all_ips]}
|
||||
return {label: [self.basic(ip, extend_address) for ip in all_ips]}
|
||||
|
||||
def index(self, networks):
|
||||
def index(self, networks, extend_address=False):
|
||||
"""Return a dictionary describing a list of networks."""
|
||||
addresses = collections.OrderedDict()
|
||||
for label, network in networks.items():
|
||||
network_dict = self.show(network, label)
|
||||
network_dict = self.show(network, label, extend_address)
|
||||
addresses[label] = network_dict[label]
|
||||
return dict(addresses=addresses)
|
||||
|
||||
|
||||
class ViewBuilderV3(ViewBuilder):
|
||||
"""Models server addresses as a dictionary."""
|
||||
def basic(self, ip):
|
||||
def basic(self, ip, extend_address=False):
|
||||
"""Return a dictionary describing an IP address."""
|
||||
return {
|
||||
address = {
|
||||
"version": ip["version"],
|
||||
"addr": ip["address"],
|
||||
"OS-EXT-IPS:type": ip["type"],
|
||||
"OS-EXT-IPS-MAC:mac_addr": ip['mac_address'],
|
||||
}
|
||||
if extend_address:
|
||||
address.update({
|
||||
"OS-EXT-IPS:type": ip["type"],
|
||||
"OS-EXT-IPS-MAC:mac_addr": ip['mac_address'],
|
||||
})
|
||||
return address
|
||||
|
|
|
@ -170,10 +170,11 @@ class ViewBuilder(common.ViewBuilder):
|
|||
sha_hash = hashlib.sha224(project + host)
|
||||
return sha_hash.hexdigest()
|
||||
|
||||
def _get_addresses(self, request, instance):
|
||||
def _get_addresses(self, request, instance, extend_address=False):
|
||||
context = request.environ["nova.context"]
|
||||
networks = common.get_networks_for_instance(context, instance)
|
||||
return self._address_builder.index(networks)["addresses"]
|
||||
return self._address_builder.index(networks,
|
||||
extend_address)["addresses"]
|
||||
|
||||
def _get_image(self, request, instance):
|
||||
image_ref = instance["image_ref"]
|
||||
|
@ -246,7 +247,7 @@ class ViewBuilderV3(ViewBuilder):
|
|||
# use glance endpoint. We revert back it to use nova endpoint for v2.1.
|
||||
self._image_builder = views_images.ViewBuilder()
|
||||
|
||||
def show(self, request, instance):
|
||||
def show(self, request, instance, extend_address=True):
|
||||
"""Detailed view of a single instance."""
|
||||
server = {
|
||||
"server": {
|
||||
|
@ -264,7 +265,8 @@ class ViewBuilderV3(ViewBuilder):
|
|||
"flavor": self._get_flavor(request, instance),
|
||||
"created": timeutils.isotime(instance["created_at"]),
|
||||
"updated": timeutils.isotime(instance["updated_at"]),
|
||||
"addresses": self._get_addresses(request, instance),
|
||||
"addresses": self._get_addresses(request, instance,
|
||||
extend_address),
|
||||
"links": self._get_links(request,
|
||||
instance["uuid"],
|
||||
self._collection_name),
|
||||
|
|
|
@ -4,9 +4,7 @@
|
|||
"private": [
|
||||
{
|
||||
"addr": "%(ip)s",
|
||||
"version": 4,
|
||||
"OS-EXT-IPS-MAC:mac_addr": "aa:bb:cc:dd:ee:ff",
|
||||
"OS-EXT-IPS:type": "fixed"
|
||||
"version": 4
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
"private": [
|
||||
{
|
||||
"addr": "%(ip)s",
|
||||
"OS-EXT-IPS-MAC:mac_addr": "aa:bb:cc:dd:ee:ff",
|
||||
"OS-EXT-IPS:type": "fixed",
|
||||
"version": 4
|
||||
}
|
||||
]
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
"private": [
|
||||
{
|
||||
"addr": "192.168.0.3",
|
||||
"OS-EXT-IPS-MAC:mac_addr": "aa:bb:cc:dd:ee:ff",
|
||||
"OS-EXT-IPS:type": "fixed",
|
||||
"version": 4
|
||||
}
|
||||
]
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
"private": [
|
||||
{
|
||||
"addr": "192.168.0.3",
|
||||
"OS-EXT-IPS-MAC:mac_addr": "aa:bb:cc:dd:ee:ff",
|
||||
"OS-EXT-IPS:type": "fixed",
|
||||
"version": 4
|
||||
}
|
||||
]
|
||||
|
|
|
@ -4,9 +4,7 @@
|
|||
"private": [
|
||||
{
|
||||
"addr": "%(ip)s",
|
||||
"version": 4,
|
||||
"OS-EXT-IPS-MAC:mac_addr": "aa:bb:cc:dd:ee:ff",
|
||||
"OS-EXT-IPS:type": "fixed"
|
||||
"version": 4
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -4,9 +4,7 @@
|
|||
"private": [
|
||||
{
|
||||
"addr": "%(ip)s",
|
||||
"version": 4,
|
||||
"OS-EXT-IPS-MAC:mac_addr": "aa:bb:cc:dd:ee:ff",
|
||||
"OS-EXT-IPS:type": "fixed"
|
||||
"version": 4
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue