コード例 #1
0
ファイル: load_balancer.py プロジェクト: carriercomm/hm
 def create(cls, manager_name, name, conf=None):
     manager = lb_managers.by_name(manager_name, conf)
     lb = manager.create_load_balancer(name)
     lb.manager = manager_name
     lb.config = conf
     model.storage(conf).store_load_balancer(lb)
     return lb
コード例 #2
0
 def create(cls, manager_name, name, conf=None):
     manager = lb_managers.by_name(manager_name, conf)
     lb = manager.create_load_balancer(name)
     lb.manager = manager_name
     lb.config = conf
     model.storage(conf).store_load_balancer(lb)
     return lb
コード例 #3
0
 def create(cls, manager_name, group, conf=None):
     manager = managers.by_name(manager_name, conf)
     alternative_id = cls._current_group_alternate(group, conf)
     host = manager.create_host(name=group, alternative_id=alternative_id)
     host.manager = manager_name
     host.group = group
     host.config = conf
     model.storage(conf).store_host(host)
     return host
コード例 #4
0
ファイル: host.py プロジェクト: carriercomm/hm
 def create(cls, manager_name, group, conf=None):
     manager = managers.by_name(manager_name, conf)
     alternative_id = cls._current_group_alternate(group, conf)
     host = manager.create_host(name=group, alternative_id=alternative_id)
     host.manager = manager_name
     host.group = group
     host.config = conf
     model.storage(conf).store_host(host)
     return host
コード例 #5
0
 def _current_group_alternate(cls, group, conf=None):
     alternates_count = int(config.get_config("HM_ALTERNATIVE_CONFIG_COUNT", 1, conf))
     hosts = model.storage(conf).list_hosts({'group': group})
     alterantives_map = collections.defaultdict(int)
     for host in hosts:
         alterantives_map[host.alternative_id] += 1
     min_alt_id = 0
     min_alt_count = None
     for i in xrange(alternates_count):
         if min_alt_count is None or alterantives_map[i] < min_alt_count:
             min_alt_id = i
             min_alt_count = alterantives_map[i]
     return min_alt_id
コード例 #6
0
ファイル: host.py プロジェクト: carriercomm/hm
 def _current_group_alternate(cls, group, conf=None):
     alternates_count = int(config.get_config("HM_ALTERNATIVE_CONFIG_COUNT", 1, conf))
     hosts = model.storage(conf).list_hosts({'group': group})
     alterantives_map = collections.defaultdict(int)
     for host in hosts:
         alterantives_map[host.alternative_id] += 1
     min_alt_id = 0
     min_alt_count = None
     for i in xrange(alternates_count):
         if min_alt_count is None or alterantives_map[i] < min_alt_count:
             min_alt_id = i
             min_alt_count = alterantives_map[i]
     return min_alt_id
コード例 #7
0
 def create(cls, manager_name, group, conf=None):
     manager = managers.by_name(manager_name, conf)
     alternative_id_error = []
     last_host_create_exception = None
     while True:
         try:
             alternative_id = cls._current_group_alternate(
                 group, conf, alternative_id_error)
         except Exception as e:
             if last_host_create_exception:
                 raise last_host_create_exception
             raise e
         try:
             host = manager.create_host(name=group,
                                        alternative_id=alternative_id)
             break
         except Exception as e:
             alternative_id_error.append(alternative_id)
             last_host_create_exception = e
     host.manager = manager_name
     host.group = group
     host.config = conf
     model.storage(conf).store_host(host)
     return host
コード例 #8
0
 def _current_group_alternate(cls, group, conf, alternative_id_error):
     alternates_count = range(
         int(config.get_config("HM_ALTERNATIVE_CONFIG_COUNT", 1, conf)))
     alternates_valid = list(
         set(alternates_count) - set(alternative_id_error))
     if len(alternates_valid) == 0:
         raise NoMoreHMAlternativesAvailable
     hosts = model.storage(conf).list_hosts({'group': group})
     alterantives_map = collections.defaultdict(int)
     for host in hosts:
         alterantives_map[host.alternative_id] += 1
     min_alt_count = None
     for i in alternates_valid:
         if min_alt_count is None or alterantives_map[i] < min_alt_count:
             min_alt_id = i
             min_alt_count = alterantives_map[i]
     return min_alt_id
コード例 #9
0
ファイル: load_balancer.py プロジェクト: carriercomm/hm
 def list(cls, filters=None, conf=None):
     return model.storage(conf).list_load_balancers(filters)
コード例 #10
0
ファイル: load_balancer.py プロジェクト: carriercomm/hm
 def find(cls, name, conf=None):
     return model.storage(conf).find_load_balancer(name)
コード例 #11
0
 def list(cls, filters=None, conf=None):
     return model.storage(conf).list_hosts(filters)
コード例 #12
0
 def find(cls, id, conf=None):
     return model.storage(conf).find_host(id)
コード例 #13
0
 def list(cls, filters=None, conf=None):
     return model.storage(conf).list_load_balancers(filters)
コード例 #14
0
 def find(cls, name, conf=None):
     return model.storage(conf).find_load_balancer(name)
コード例 #15
0
ファイル: host.py プロジェクト: carriercomm/hm
 def list(cls, filters=None, conf=None):
     return model.storage(conf).list_hosts(filters)
コード例 #16
0
ファイル: host.py プロジェクト: carriercomm/hm
 def find(cls, id, conf=None):
     return model.storage(conf).find_host(id)