diff options
| author | Naveed Massjouni <naveedm9@gmail.com> | 2011-05-02 21:37:59 +0000 |
|---|---|---|
| committer | Tarmac <> | 2011-05-02 21:37:59 +0000 |
| commit | c069337734e99d5833b5a1814e33ffb1fbb5fff6 (patch) | |
| tree | 9532691439aa3459b4819899bae6565102d884bb /nova/api | |
| parent | e4538af1a6e4b9796da3f4d7c3484084d3b72463 (diff) | |
| parent | 2463fc66e363e13bf955e1ebb9b370f8e901d328 (diff) | |
Added support in the nova openstack api for requests with local hrefs, e.g., "imageRef":"2"
Previously, it only supported "imageRef":"http://foo.com/images/2".
The 1.1 api spec defines both approaches.
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/common.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/nova/api/openstack/common.py b/nova/api/openstack/common.py index 65ed1e143..32cd689ca 100644 --- a/nova/api/openstack/common.py +++ b/nova/api/openstack/common.py @@ -15,6 +15,7 @@ # License for the specific language governing permissions and limitations # under the License. +import re from urlparse import urlparse import webob @@ -130,10 +131,16 @@ def get_image_id_from_image_hash(image_service, context, image_hash): def get_id_from_href(href): """Return the id portion of a url as an int. - Given: http://www.foo.com/bar/123?q=4 + Given: 'http://www.foo.com/bar/123?q=4' + Returns: 123 + + In order to support local hrefs, the href argument can be just an id: + Given: '123' Returns: 123 """ + if re.match(r'\d+$', str(href)): + return int(href) try: return int(urlparse(href).path.split('/')[-1]) except: |
