示例#1
0
 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
0
 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
0
 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
示例#4
0
 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
示例#5
0
 def get_vm_via_rest(self):
     # Try except block, because instances collection isn't available on 5.4
     try:
         instance = rest_api().collections.instances.get(name=self.name)
     except AttributeError:
         raise Exception("Collection instances isn't available")
     return instance
示例#6
0
 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")
示例#7
0
 def get_vm_via_rest(self):
     # Try except block, because instances collection isn't available on 5.4
     try:
         instance = rest_api().collections.instances.get(name=self.name)
     except AttributeError:
         raise Exception("Collection instances isn't available")
     return instance
示例#8
0
 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")
示例#9
0
    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]
示例#10
0
    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]
示例#11
0
    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)
示例#12
0
 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
 def get_collection_via_rest(self):
     return rest_api().collections.vms
 def get_vm_via_rest(self):
     return rest_api().collections.vms.get(name=self.name)
示例#15
0
 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
示例#16
0
 def get_collection_via_rest(self):
     return rest_api().collections.instances
示例#17
0
 def get_vm_via_rest(self):
     return rest_api().collections.vms.get(name=self.name)
示例#18
0
 def id(self):
     """
     returns current provider id using rest api
     """
     return rest_api().collections.providers.find_by(name=self.name)[0].id
示例#19
0
 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()