summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@gmail.com>2011-06-29 09:49:49 -0700
committerVishvananda Ishaya <vishvananda@gmail.com>2011-06-29 09:49:49 -0700
commit5686488517f702bd4ba714edeea89ea1993ac220 (patch)
treeda6ae903a728955ceebffd1b80dbe705cc1ffdf8 /nova/api
parent0bfa9aad9c1f74ca962351d90265e5fb56156841 (diff)
Allow a port name in the server ref for image create
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/images.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py
index d43340e10..22c79e2e9 100644
--- a/nova/api/openstack/images.py
+++ b/nova/api/openstack/images.py
@@ -208,9 +208,14 @@ class ControllerV11(Controller):
msg = _("Expected serverRef attribute on server entity.")
raise webob.exc.HTTPBadRequest(explanation=msg)
- head, tail = os.path.split(server_ref)
-
- if head and head != os.path.join(req.application_url, 'servers'):
+ head, _sep, tail = server_ref.rpartition('/')
+
+ url, _sep, version = req.application_url.rpartition('/')
+ long_url = '%s:%s/%s' % (url, FLAGS.osapi_port, version)
+ valid_urls = ['%s/servers' % req.application_url,
+ '%s/servers' % long_url]
+ if head and head not in valid_urls:
+ LOG.warn(head)
msg = _("serverRef must match request url")
raise webob.exc.HTTPBadRequest(explanation=msg)