summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-12-05 00:44:13 +0000
committerGerrit Code Review <review@openstack.org>2012-12-05 00:44:13 +0000
commit255692feea3eee12bfc763f75fc8f3dabdbe9ba5 (patch)
treed690cc690f581e40ca7e49c246a4e0b1cc07cb51 /nova/api
parentf35427693091bfca336207f2135f12b91348febb (diff)
parent1d00dfcfbb9bdeff358503fefefc7e6e7b4903eb (diff)
downloadnova-255692feea3eee12bfc763f75fc8f3dabdbe9ba5.tar.gz
nova-255692feea3eee12bfc763f75fc8f3dabdbe9ba5.tar.xz
nova-255692feea3eee12bfc763f75fc8f3dabdbe9ba5.zip
Merge "Boot from volume without image supplied"
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/compute/servers.py23
-rw-r--r--nova/api/openstack/compute/views/servers.py25
2 files changed, 34 insertions, 14 deletions
diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py
index 9c019f78f..68c5372c3 100644
--- a/nova/api/openstack/compute/servers.py
+++ b/nova/api/openstack/compute/servers.py
@@ -743,8 +743,7 @@ class Controller(wsgi.Controller):
self._validate_server_name(name)
name = name.strip()
- image_href = self._image_ref_from_req_data(body)
- image_href = self._image_uuid_from_href(image_href)
+ image_uuid = self._image_from_req_data(body)
personality = server_dict.get('personality')
config_drive = None
@@ -855,7 +854,7 @@ class Controller(wsgi.Controller):
(instances, resv_id) = self.compute_api.create(context,
inst_type,
- image_href,
+ image_uuid,
display_name=name,
display_description=name,
key_name=key_name,
@@ -1108,6 +1107,24 @@ class Controller(wsgi.Controller):
return image_uuid
+ def _image_from_req_data(self, data):
+ """
+ Get image data from the request or raise appropriate
+ exceptions
+
+ If no image is supplied - checks to see if there is
+ block devices set and proper extesions loaded.
+ """
+ image_ref = data['server'].get('imageRef')
+ bdm = data['server'].get('block_device_mapping')
+
+ if not image_ref and bdm and self.ext_mgr.is_loaded('os-volumes'):
+ return ''
+ else:
+ image_href = self._image_ref_from_req_data(data)
+ image_uuid = self._image_uuid_from_href(image_href)
+ return image_uuid
+
def _flavor_id_from_req_data(self, data):
try:
flavor_ref = data['server']['flavorRef']
diff --git a/nova/api/openstack/compute/views/servers.py b/nova/api/openstack/compute/views/servers.py
index b423b37d4..d281f6a61 100644
--- a/nova/api/openstack/compute/views/servers.py
+++ b/nova/api/openstack/compute/views/servers.py
@@ -164,17 +164,20 @@ class ViewBuilder(common.ViewBuilder):
def _get_image(self, request, instance):
image_ref = instance["image_ref"]
- image_id = str(common.get_id_from_href(image_ref))
- bookmark = self._image_builder._get_bookmark_link(request,
- image_id,
- "images")
- return {
- "id": image_id,
- "links": [{
- "rel": "bookmark",
- "href": bookmark,
- }],
- }
+ if image_ref:
+ image_id = str(common.get_id_from_href(image_ref))
+ bookmark = self._image_builder._get_bookmark_link(request,
+ image_id,
+ "images")
+ return {
+ "id": image_id,
+ "links": [{
+ "rel": "bookmark",
+ "href": bookmark,
+ }],
+ }
+ else:
+ return ""
def _get_flavor(self, request, instance):
instance_type = instance["instance_type"]