本文整理汇总了Python中nova.compute.flavors.get_all_flavors_sorted_list函数的典型用法代码示例。如果您正苦于以下问题:Python get_all_flavors_sorted_list函数的具体用法?Python get_all_flavors_sorted_list怎么用?Python get_all_flavors_sorted_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_all_flavors_sorted_list函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_get_all_flavors_sorted_list_sort
def test_get_all_flavors_sorted_list_sort(self):
# Test default sort
all_flavors = flavors.get_all_flavors_sorted_list()
self.assertEqual(DEFAULT_FLAVORS, all_flavors)
# Test sorted by name
all_flavors = flavors.get_all_flavors_sorted_list(sort_key='name')
expected = sorted(DEFAULT_FLAVORS, key=lambda item: item['name'])
self.assertEqual(expected, all_flavors)
开发者ID:Acidburn0zzz,项目名称:nova,代码行数:9,代码来源:test_flavors.py
示例2: test_get_all_flavors_sorted_list_marker
def test_get_all_flavors_sorted_list_marker(self):
all_flavors = flavors.get_all_flavors_sorted_list()
# Set the 3rd result as the marker
marker_flavorid = all_flavors[2]["flavorid"]
marked_flavors = flavors.get_all_flavors_sorted_list(marker=marker_flavorid)
# We expect everything /after/ the 3rd result
expected_results = all_flavors[3:]
self.assertEqual(expected_results, marked_flavors)
开发者ID:newgoliath,项目名称:nova,代码行数:9,代码来源:test_flavors.py
示例3: test_get_all_flavors_sorted_list_marker
def test_get_all_flavors_sorted_list_marker(self):
"""Check results can be returned after marker"""
all_flavors = flavors.get_all_flavors_sorted_list()
# Set the 3rd result as the marker
marker_flavorid = all_flavors[2]['id']
marked_flavors = flavors.get_all_flavors_sorted_list(
marker=marker_flavorid)
# We expect everything /after/ the 3rd result
expected_results = all_flavors[3:]
self.assertEqual(expected_results, marked_flavors)
开发者ID:Charu-Sharma,项目名称:nova,代码行数:11,代码来源:test_flavors.py
示例4: test_get_all_flavors_sorted_list_marker
def test_get_all_flavors_sorted_list_marker(self):
all_flavors = flavors.get_all_flavors_sorted_list()
# Set the 3rd result as the marker
marker_flavorid = all_flavors[2].flavorid
marked_flavors = flavors.get_all_flavors_sorted_list(marker=marker_flavorid)
# We expect everything /after/ the 3rd result
expected_results = all_flavors[3:]
self.assertEqual(len(expected_results), len(marked_flavors))
for i in range(len(marked_flavors)):
f = marked_flavors[i]
self.assertIsInstance(f, objects.Flavor)
self.assertEqual(expected_results[i].flavorid, f.flavorid)
开发者ID:isyippee,项目名称:nova,代码行数:13,代码来源:test_flavors.py
示例5: test_get_all_flavors_sorted_list_sort
def test_get_all_flavors_sorted_list_sort(self):
# Test default sort
all_flavors = flavors.get_all_flavors_sorted_list()
self.assertEqual(len(DEFAULT_FLAVORS), len(all_flavors))
for i in range(len(all_flavors)):
f = all_flavors[i]
self.assertIsInstance(f, objects.Flavor)
self.assertEqual(DEFAULT_FLAVORS[i]['flavorid'], f.flavorid)
# Test sorted by name
all_flavors = flavors.get_all_flavors_sorted_list(sort_key='name')
expected = sorted(DEFAULT_FLAVORS, key=lambda item: item['name'])
self.assertEqual(len(expected), len(all_flavors))
for i in range(len(all_flavors)):
f = all_flavors[i]
self.assertIsInstance(f, objects.Flavor)
self.assertEqual(expected[i]['flavorid'], f.flavorid)
开发者ID:Milstein,项目名称:nova,代码行数:17,代码来源:test_flavors.py
示例6: _get_flavors
def _get_flavors(self, req):
"""Helper function that returns a list of flavor dicts."""
filters = {}
sort_key = req.params.get('sort_key') or 'flavorid'
sort_dir = req.params.get('sort_dir') or 'asc'
limit = req.params.get('limit') or None
marker = req.params.get('marker') or None
context = req.environ['nova.context']
if context.is_admin:
# Only admin has query access to all flavor types
filters['is_public'] = self._parse_is_public(
req.params.get('is_public', None))
else:
filters['is_public'] = True
filters['disabled'] = False
if 'min_ram' in req.params:
try:
filters['min_memory_mb'] = int(req.params['min_ram'])
except ValueError:
msg = _('Invalid min_ram filter [%s]') % req.params['min_ram']
raise webob.exc.HTTPBadRequest(explanation=msg)
if 'min_disk' in req.params:
try:
filters['min_root_gb'] = int(req.params['min_disk'])
except ValueError:
msg = (_('Invalid min_disk filter [%s]') %
req.params['min_disk'])
raise webob.exc.HTTPBadRequest(explanation=msg)
try:
limited_flavors = flavors.get_all_flavors_sorted_list(context,
filters=filters, sort_key=sort_key, sort_dir=sort_dir,
limit=limit, marker=marker)
except exception.MarkerNotFound:
msg = _('marker [%s] not found') % marker
raise webob.exc.HTTPBadRequest(explanation=msg)
return limited_flavors
开发者ID:tellesnobrega,项目名称:keystone_hierarchical_projects,代码行数:41,代码来源:flavors.py
示例7: _get_flavors
def _get_flavors(self, req):
"""Helper function that returns a list of flavor dicts."""
filters = {}
sort_key = req.params.get("sort_key") or "flavorid"
sort_dir = req.params.get("sort_dir") or "asc"
limit = req.params.get("limit") or None
marker = req.params.get("marker") or None
context = req.environ["nova.context"]
if context.is_admin:
# Only admin has query access to all flavor types
filters["is_public"] = self._parse_is_public(req.params.get("is_public", None))
else:
filters["is_public"] = True
filters["disabled"] = False
if "min_ram" in req.params:
try:
filters["min_memory_mb"] = int(req.params["min_ram"])
except ValueError:
msg = _("Invalid min_ram filter [%s]") % req.params["min_ram"]
raise webob.exc.HTTPBadRequest(explanation=msg)
if "min_disk" in req.params:
try:
filters["min_root_gb"] = int(req.params["min_disk"])
except ValueError:
msg = _("Invalid min_disk filter [%s]") % req.params["min_disk"]
raise webob.exc.HTTPBadRequest(explanation=msg)
try:
limited_flavors = flavors.get_all_flavors_sorted_list(
context, filters=filters, sort_key=sort_key, sort_dir=sort_dir, limit=limit, marker=marker
)
except exception.MarkerNotFound:
msg = _("marker [%s] not found") % marker
raise webob.exc.HTTPBadRequest(explanation=msg)
return limited_flavors
开发者ID:wputra,项目名称:MOS-centos,代码行数:39,代码来源:flavors.py
示例8: test_get_all_flavors_sorted_list_limit
def test_get_all_flavors_sorted_list_limit(self):
"""Check a limit can be applied to
flavors.get_all_flavors_sorted_list.
"""
limited_flavors = flavors.get_all_flavors_sorted_list(limit=2)
self.assertEqual(2, len(limited_flavors))
开发者ID:Charu-Sharma,项目名称:nova,代码行数:6,代码来源:test_flavors.py
示例9: test_get_all_flavors_sorted_list_limit
def test_get_all_flavors_sorted_list_limit(self):
limited_flavors = flavors.get_all_flavors_sorted_list(limit=2)
self.assertEqual(2, len(limited_flavors))
开发者ID:Acidburn0zzz,项目名称:nova,代码行数:3,代码来源:test_flavors.py
注:本文中的nova.compute.flavors.get_all_flavors_sorted_list函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论