本文整理汇总了Python中nova.api.openstack.common.get_id_from_href函数的典型用法代码示例。如果您正苦于以下问题:Python get_id_from_href函数的具体用法?Python get_id_from_href怎么用?Python get_id_from_href使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_id_from_href函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _action_rebuild
def _action_rebuild(self, info, request, instance_id):
context = request.environ['nova.context']
instance_id = int(instance_id)
try:
image_ref = info["rebuild"]["imageRef"]
except (KeyError, TypeError):
msg = _("Could not parse imageRef from request.")
LOG.debug(msg)
return faults.Fault(exc.HTTPBadRequest(explanation=msg))
image_id = common.get_id_from_href(image_ref)
personalities = info["rebuild"].get("personality", [])
metadata = info["rebuild"].get("metadata", {})
self._validate_metadata(metadata)
self._decode_personalities(personalities)
try:
self.compute_api.rebuild(context, instance_id, image_id, metadata,
personalities)
except exception.BuildInProgress:
msg = _("Instance %d is currently being rebuilt.") % instance_id
LOG.debug(msg)
return faults.Fault(exc.HTTPConflict(explanation=msg))
response = exc.HTTPAccepted()
response.empty_body = True
return response
开发者ID:termie,项目名称:nova-migration-demo,代码行数:29,代码来源:servers.py
示例2: show
def show(self, request, image):
"""Return a dictionary with image details."""
image_dict = {
"id": image.get("id"),
"name": image.get("name"),
"minRam": int(image.get("min_ram") or 0),
"minDisk": int(image.get("min_disk") or 0),
"metadata": image.get("properties", {}),
"created": self._format_date(image.get("created_at")),
"updated": self._format_date(image.get("updated_at")),
"status": self._get_status(image),
"progress": self._get_progress(image),
"links": self._get_links(request, image["id"]),
}
server_ref = image.get("properties", {}).get("instance_ref")
if server_ref is not None:
image_dict["server"] = {
"id": common.get_id_from_href(server_ref),
"links": [{
"rel": "self",
"href": server_ref,
},
{
"rel": "bookmark",
"href": common.remove_version_from_href(server_ref),
}],
}
return dict(image=image_dict)
开发者ID:BillTheBest,项目名称:nova,代码行数:31,代码来源:images.py
示例3: _flavor_id_from_req_data
def _flavor_id_from_req_data(self, data):
try:
flavor_ref = data['server']['flavor_ref']
except (TypeError, KeyError):
msg = _("Missing flavor_ref attribute")
raise exc.HTTPBadRequest(explanation=msg)
return common.get_id_from_href(flavor_ref)
开发者ID:ewindisch,项目名称:nova,代码行数:8,代码来源:servers.py
示例4: _get_image
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 ""
开发者ID:bigswitch,项目名称:nova,代码行数:8,代码来源:servers.py
示例5: _build_flavor
def _build_flavor(self, response, inst):
if inst.get("instance_type", None):
flavor_id = inst["instance_type"]["flavorid"]
flavor_ref = self.flavor_builder.generate_href(flavor_id)
flavor_bookmark = self.flavor_builder.generate_bookmark(flavor_id)
response["flavor"] = {
"id": str(common.get_id_from_href(flavor_ref)),
"links": [{"rel": "bookmark", "href": flavor_bookmark}],
}
开发者ID:gagupta,项目名称:nova,代码行数:9,代码来源:servers.py
示例6: _get_flavor
def _get_flavor(self, request, instance):
flavor_id = instance["instance_type"]["flavorid"]
flavor_ref = self._flavor_builder._get_href_link(request, flavor_id)
flavor_bookmark = self._flavor_builder._get_bookmark_link(request,
flavor_id)
return {
"id": str(common.get_id_from_href(flavor_ref)),
"links": [{
"rel": "bookmark",
"href": flavor_bookmark,
}],
}
开发者ID:BillTheBest,项目名称:nova,代码行数:12,代码来源:servers.py
示例7: _build_server
def _build_server(self, image, image_obj):
try:
serverRef = image_obj["properties"]["instance_ref"]
image["server"] = {
"id": common.get_id_from_href(serverRef),
"links": [
{"rel": "self", "href": serverRef},
{"rel": "bookmark", "href": common.remove_version_from_href(serverRef)},
],
}
except KeyError:
return
开发者ID:nicopal,项目名称:nova,代码行数:12,代码来源:images.py
示例8: _action_resize
def _action_resize(self, input_dict, req, id):
""" Resizes a given instance to the flavor size requested """
try:
if 'resize' in input_dict and 'flavorRef' in input_dict['resize']:
flavor_ref = input_dict['resize']['flavorRef']
flavor_id = common.get_id_from_href(flavor_ref)
self.compute_api.resize(req.environ['nova.context'], id,
flavor_id)
else:
LOG.exception(_("Missing 'flavorRef' argument for resize"))
return faults.Fault(exc.HTTPUnprocessableEntity())
except Exception, e:
LOG.exception(_("Error in resize %s"), e)
return faults.Fault(exc.HTTPBadRequest())
开发者ID:kavanista,项目名称:nova,代码行数:14,代码来源:servers.py
示例9: _build_image
def _build_image(self, response, inst):
if 'image_ref' in dict(inst):
image_href = inst['image_ref']
image_id = str(common.get_id_from_href(image_href))
_bookmark = self.image_builder.generate_bookmark(image_id)
response['image'] = {
"id": image_id,
"links": [
{
"rel": "bookmark",
"href": _bookmark,
},
]
}
开发者ID:apowers,项目名称:openstack-nova,代码行数:14,代码来源:servers.py
示例10: _build_server
def _build_server(self, image, image_obj):
try:
serverRef = image_obj['properties']['instance_ref']
image['server'] = {
"id": common.get_id_from_href(serverRef),
"links": [
{
"rel": "self",
"href": serverRef,
},
{
"rel": "bookmark",
"href": common.remove_version_from_href(serverRef),
},
]
}
except KeyError:
return
开发者ID:sateesh-chodapuneedi,项目名称:nova,代码行数:18,代码来源:images.py
示例11: test_get_id_from_href_with_uuid_url_query
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)
开发者ID:Charu-Sharma,项目名称:nova,代码行数:5,代码来源:test_common.py
示例12: test_get_id_from_href_with_int_url_query
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)
开发者ID:Charu-Sharma,项目名称:nova,代码行数:5,代码来源:test_common.py
示例13: test_get_id_from_href_with_int
def test_get_id_from_href_with_int(self):
fixture = '45'
actual = common.get_id_from_href(fixture)
expected = '45'
self.assertEqual(actual, expected)
开发者ID:Charu-Sharma,项目名称:nova,代码行数:5,代码来源:test_common.py
示例14: _flavor_id_from_req_data
def _flavor_id_from_req_data(self, data):
flavor_ref = data['server']['flavorRef']
return common.get_id_from_href(flavor_ref)
开发者ID:EdLeafe,项目名称:nova,代码行数:3,代码来源:servers.py
示例15: test_get_id_from_href_int
def test_get_id_from_href_int(self):
fixture = 1
self.assertEqual(fixture, common.get_id_from_href(fixture))
开发者ID:YouthSun,项目名称:nova,代码行数:3,代码来源:test_common.py
示例16: test_get_id_from_href_with_int_url
def test_get_id_from_href_with_int_url(self):
fixture = "http://www.testsite.com/dir/45"
actual = common.get_id_from_href(fixture)
expected = "45"
self.assertEqual(actual, expected)
开发者ID:cyx1231st,项目名称:nova,代码行数:5,代码来源:test_common.py
示例17: test_get_id_from_href
def test_get_id_from_href(self):
fixture = 'http://www.testsite.com/dir/45'
actual = common.get_id_from_href(fixture)
expected = 45
self.assertEqual(actual, expected)
开发者ID:kavanista,项目名称:nova,代码行数:5,代码来源:test_common.py
示例18: _build_image
def _build_image(self, response, inst):
if inst.get("image_ref", None):
image_href = inst["image_ref"]
image_id = str(common.get_id_from_href(image_href))
_bookmark = self.image_builder.generate_bookmark(image_id)
response["image"] = {"id": image_id, "links": [{"rel": "bookmark", "href": _bookmark}]}
开发者ID:gagupta,项目名称:nova,代码行数:6,代码来源:servers.py
示例19: test_get_id_from_href_with_uuid
def test_get_id_from_href_with_uuid(self):
fixture = 'abc123'
actual = common.get_id_from_href(fixture)
expected = 'abc123'
self.assertEqual(actual, expected)
开发者ID:Charu-Sharma,项目名称:nova,代码行数:5,代码来源:test_common.py
示例20: _image_id_from_req_data
def _image_id_from_req_data(self, data):
href = data['server']['imageRef']
return common.get_id_from_href(href)
开发者ID:termie,项目名称:nova-migration-demo,代码行数:3,代码来源:servers.py
注:本文中的nova.api.openstack.common.get_id_from_href函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论