Пример #1
0
 def _flavor_id_from_req_data(self, data):
     try:
         flavor_ref = data['server']['flavorRef']
     except (TypeError, KeyError):
         msg = _("Missing flavorRef attribute")
         raise exc.HTTPBadRequest(explanation=msg)
     try:
         return common.get_id_from_href(flavor_ref)
     except ValueError:
         msg = _("Invalid flavorRef provided.")
         raise exc.HTTPBadRequest(explanation=msg)
Пример #2
0
 def _flavor_id_from_req_data(self, data):
     try:
         flavor_ref = data['server']['flavorRef']
     except (TypeError, KeyError):
         msg = _("Missing flavorRef attribute")
         raise exc.HTTPBadRequest(explanation=msg)
     try:
         return common.get_id_from_href(flavor_ref)
     except ValueError:
         msg = _("Invalid flavorRef provided.")
         raise exc.HTTPBadRequest(explanation=msg)
Пример #3
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 ""
Пример #4
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 ""
Пример #5
0
 def test_get_id_from_href_with_uuid(self):
     fixture = 'abc123'
     actual = common.get_id_from_href(fixture)
     expected = 'abc123'
     self.assertEqual(actual, expected)
Пример #6
0
 def test_get_id_from_href_with_uuid_url_query(self):
     fixture = 'http://www.testsite.com/dir/abc123?asdf=jkl'
     actual = common.get_id_from_href(fixture)
     expected = "abc123"
     self.assertEqual(actual, expected)
Пример #7
0
 def test_get_id_from_href_with_int_url_query(self):
     fixture = 'http://www.testsite.com/dir/45?asdf=jkl'
     actual = common.get_id_from_href(fixture)
     expected = '45'
     self.assertEqual(actual, expected)
Пример #8
0
 def test_get_id_from_href_with_int(self):
     fixture = '45'
     actual = common.get_id_from_href(fixture)
     expected = '45'
     self.assertEqual(actual, expected)
Пример #9
0
 def test_get_id_from_href_with_uuid(self):
     fixture = 'abc123'
     actual = common.get_id_from_href(fixture)
     expected = 'abc123'
     self.assertEqual(actual, expected)
Пример #10
0
 def test_get_id_from_href_with_uuid_url_query(self):
     fixture = 'http://www.testsite.com/dir/abc123?asdf=jkl'
     actual = common.get_id_from_href(fixture)
     expected = "abc123"
     self.assertEqual(actual, expected)
Пример #11
0
 def test_get_id_from_href_with_int_url_query(self):
     fixture = 'http://www.testsite.com/dir/45?asdf=jkl'
     actual = common.get_id_from_href(fixture)
     expected = '45'
     self.assertEqual(actual, expected)
Пример #12
0
 def test_get_id_from_href_with_int(self):
     fixture = '45'
     actual = common.get_id_from_href(fixture)
     expected = '45'
     self.assertEqual(actual, expected)
Пример #13
0
 def _flavor_id_from_req_data(self, data):
     flavor_ref = data['server']['flavorRef']
     return common.get_id_from_href(flavor_ref)
Пример #14
0
 def _flavor_id_from_req_data(self, data):
     flavor_ref = data['server']['flavorRef']
     return common.get_id_from_href(flavor_ref)