本文整理汇总了Python中utils.api.rest_api函数的典型用法代码示例。如果您正苦于以下问题:Python rest_api函数的具体用法?Python rest_api怎么用?Python rest_api使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rest_api函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: num_host
def num_host(self):
provider = rest_api().collections.providers.find_by(name=self.name)[0]
num_host = 0
for host in rest_api().collections.hosts:
if host["ems_id"] == provider.id:
num_host += 1
return num_host
示例2: num_cluster
def num_cluster(self):
provider = rest_api().collections.providers.find_by(name=self.name)[0]
num_cluster = 0
for cluster in rest_api().collections.clusters:
if cluster["ems_id"] == provider.id:
num_cluster += 1
return num_cluster
示例3: refresh_provider_relationships
def refresh_provider_relationships(self, from_list_view=False):
# from_list_view is ignored as it is included here for sake of compatibility with UI call.
col = rest_api().collections.providers.find_by(name=self.name)
try:
col[0].action.refresh()
except IndexError:
raise Exception("Provider collection empty")
示例4: __init__
def __init__(self, name, provider):
self.name = name
self._short_name = self.name.split('in')[0].strip()
self.provider = provider
col = rest_api().collections
self._id = [cl.id for cl in col.clusters.all if cl.name == self._short_name
and cl.ems_id == self.provider.id][-1]
示例5: __init__
def __init__(self, name, provider, appliance=None):
Navigatable.__init__(self, appliance=appliance)
self.name = name
self._short_name = self.name.split('in')[0].strip()
self.provider = provider
self.quad_name = 'cluster'
col = rest_api().collections
self._id = [cl.id for cl in col.clusters.all if cl.name == self._short_name
and cl.ems_id == self.provider.id][-1]
示例6: __init__
def __init__(self, name=None, provider_key=None):
self.name = name
self._short_name = self.name.split('in')[0].strip()
col = rest_api().collections
cluster = [cl for cl in col.clusters.all if cl.name == self._short_name][-1]
self._cluster_id = cluster.id
provider_id = cluster.ems_id
# fixme: to remove this part when provider_key becomes mandatory field
if not provider_key:
provider_name = [pr.name for pr in col.providers.all if pr.id == provider_id][-1]
provider_key = get_provider_key(provider_name)
self.provider = get_crud(provider_key)
示例7: id
def id(self):
"""
returns current provider id using rest api
"""
return rest_api().collections.providers.find_by(name=self.name)[0].id
示例8: get_collection_via_rest
def get_collection_via_rest(self):
return rest_api().collections.vms
示例9: get_vm_via_rest
def get_vm_via_rest(self):
return rest_api().collections.vms.get(name=self.name)
示例10: last_refresh_date
def last_refresh_date(self):
try:
col = rest_api().collections.providers.find_by(name=self.name)[0]
return col.last_refresh_date
except AttributeError:
return None
示例11: refresh_provider_relationships
def refresh_provider_relationships(self, from_list_view=False):
# from_list_view is ignored as it is included here for sake of compatibility with UI call.
col = rest_api().collections.providers.find_by(name=self.name)[0]
col.action.refresh()