示例#1
0
 def _flavor_id_from_req_data(self, data):
     try:
         flavor_ref = data["server"]["flavorRef"]
     except (TypeError, KeyError):
         msg = _("Missing flavorRef attribute")
         raise webob.exc.HTTPBadRequest(explanation=msg)
     try:
         return common.get_id_from_href(flavor_ref)
     except ValueError:
         msg = _("Invalid flavorRef provided.")
         raise webob.exc.HTTPBadRequest(explanation=msg)
示例#2
0
 def _get_image(self, request, instance):
     image_ref = instance["image_ref"]
     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 ""