当前位置: 首页>>代码示例>>Python>>正文


Python LoadBalancer.create方法代码示例

本文整理汇总了Python中hm.model.load_balancer.LoadBalancer.create方法的典型用法代码示例。如果您正苦于以下问题:Python LoadBalancer.create方法的具体用法?Python LoadBalancer.create怎么用?Python LoadBalancer.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在hm.model.load_balancer.LoadBalancer的用法示例。


在下文中一共展示了LoadBalancer.create方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_destroy

# 需要导入模块: from hm.model.load_balancer import LoadBalancer [as 别名]
# 或者: from hm.model.load_balancer.LoadBalancer import create [as 别名]
 def test_destroy(self):
     LoadBalancer.create('fake', 'my-lb', {'LB_ID': 'xxx'})
     db_lb = LoadBalancer.find('my-lb')
     self.assertEqual(db_lb.id, 'xxx')
     db_lb.destroy()
     db_lb = LoadBalancer.find('my-lb')
     self.assertIsNone(db_lb)
开发者ID:digideskio,项目名称:hm,代码行数:9,代码来源:test_load_balancer.py

示例2: test_destroy_ignores_manager_exception

# 需要导入模块: from hm.model.load_balancer import LoadBalancer [as 别名]
# 或者: from hm.model.load_balancer.LoadBalancer import create [as 别名]
 def test_destroy_ignores_manager_exception(self, log):
     LoadBalancer.create('fake', 'my-lb', {'LB_ID': 'explode'})
     db_lb = LoadBalancer.find('my-lb')
     self.assertEqual(db_lb.id, 'explode')
     db_lb.destroy()
     self.assertEqual(log.call_args, call("Error trying to destroy load balancer name: 'my-lb' "
                                          "id: 'explode' in 'fake': failure to destroy"))
     db_lb = LoadBalancer.find('my-lb')
     self.assertIsNone(db_lb)
开发者ID:digideskio,项目名称:hm,代码行数:11,代码来源:test_load_balancer.py

示例3: run

# 需要导入模块: from hm.model.load_balancer import LoadBalancer [as 别名]
# 或者: from hm.model.load_balancer.LoadBalancer import create [as 别名]
 def run(self, config, name):
     self.init_config(config)
     healthcheck_timeout = int(self._get_conf("RPAAS_HEALTHCHECK_TIMEOUT", 600))
     host = Host.create(self.host_manager_name, name, self.config)
     lb = None
     try:
         lb = LoadBalancer.create(self.lb_manager_name, name, self.config)
         lb.add_host(host)
         self.nginx_manager.wait_healthcheck(host.dns_name, timeout=healthcheck_timeout)
         self.hc.create(name)
         self.hc.add_url(name, host.dns_name)
         self.storage.remove_task(name)
     except:
         exc_info = sys.exc_info()
         rollback = self._get_conf("RPAAS_ROLLBACK_ON_ERROR", "0") in ("True", "true", "1")
         if not rollback:
             raise
         try:
             if lb is not None:
                 lb.destroy()
         except Exception as e:
             logging.error("Error in rollback trying to destroy load balancer: {}".format(e))
         try:
             host.destroy()
         except Exception as e:
             logging.error("Error in rollback trying to destroy host: {}".format(e))
         try:
             self.hc.destroy(name)
         except Exception as e:
             logging.error("Error in rollback trying to remove healthcheck: {}".format(e))
         raise exc_info[0], exc_info[1], exc_info[2]
开发者ID:carriercomm,项目名称:rpaas,代码行数:33,代码来源:tasks.py

示例4: test_remove_host

# 需要导入模块: from hm.model.load_balancer import LoadBalancer [as 别名]
# 或者: from hm.model.load_balancer.LoadBalancer import create [as 别名]
 def test_remove_host(self):
     h1 = Host('x', 'x.me.com')
     h2 = Host('y', 'y.me.com')
     lb = LoadBalancer.create('fake', 'my-lb', {'LB_ID': 'explode'})
     lb.add_host(h1)
     lb.add_host(h2)
     lb.remove_host(h1)
     self.assertItemsEqual(lb.hosts, [h2])
     db_lb = LoadBalancer.find('my-lb')
     self.assertItemsEqual([h.to_json() for h in db_lb.hosts], [h2.to_json()])
开发者ID:digideskio,项目名称:hm,代码行数:12,代码来源:test_load_balancer.py

示例5: test_add_host

# 需要导入模块: from hm.model.load_balancer import LoadBalancer [as 别名]
# 或者: from hm.model.load_balancer.LoadBalancer import create [as 别名]
 def test_add_host(self):
     h1 = Host('x', 'x.me.com')
     h2 = Host('y', 'y.me.com')
     conf = {'LB_ID': 'explode'}
     lb = LoadBalancer.create('fake', 'my-lb', conf)
     lb.add_host(h1)
     lb.add_host(h2)
     self.assertItemsEqual(lb.hosts, [h1, h2])
     db_lb = LoadBalancer.find('my-lb', conf)
     self.assertEqual(db_lb.hosts[0].config, conf)
     self.assertEqual(db_lb.hosts[1].config, conf)
     self.assertItemsEqual([h.to_json() for h in db_lb.hosts], [h1.to_json(), h2.to_json()])
开发者ID:digideskio,项目名称:hm,代码行数:14,代码来源:test_load_balancer.py

示例6: test_create

# 需要导入模块: from hm.model.load_balancer import LoadBalancer [as 别名]
# 或者: from hm.model.load_balancer.LoadBalancer import create [as 别名]
 def test_create(self):
     conf = {'LB_ID': 'xxx'}
     lb = LoadBalancer.create('fake', 'my-lb', conf=conf)
     self.assertEqual(lb.id, 'xxx')
     self.assertEqual(lb.name, 'my-lb')
     self.assertEqual(lb.manager, 'fake')
     self.assertEqual(lb.extra, 'something')
     self.assertEqual(lb.config, conf)
     db_lb = LoadBalancer.find('my-lb', conf=conf)
     self.assertEqual(db_lb.id, 'xxx')
     self.assertEqual(db_lb.name, 'my-lb')
     self.assertEqual(db_lb.manager, 'fake')
     self.assertEqual(db_lb.extra, 'something')
     self.assertEqual(db_lb.config, conf)
开发者ID:digideskio,项目名称:hm,代码行数:16,代码来源:test_load_balancer.py

示例7: _add_host

# 需要导入模块: from hm.model.load_balancer import LoadBalancer [as 别名]
# 或者: from hm.model.load_balancer.LoadBalancer import create [as 别名]
 def _add_host(self, name, lb=None):
     healthcheck_timeout = int(self._get_conf("RPAAS_HEALTHCHECK_TIMEOUT", 600))
     created_lb = None
     try:
         if not lb:
             lb = created_lb = LoadBalancer.create(self.lb_manager_name, name, self.config)
             self.hc.create(name)
         config = copy.deepcopy(self.config)
         if hasattr(lb, 'dsr') and lb.dsr:
             config["HOST_TAGS"] = config["HOST_TAGS"] + ",dsr_ip:{}".format(lb.address)
         host = Host.create(self.host_manager_name, name, config)
         lb.add_host(host)
         self.nginx_manager.wait_healthcheck(host.dns_name, timeout=healthcheck_timeout)
         acls = self.consul_manager.find_acl_network(name)
         if acls:
             acl_host = acls.pop()
             for dst in acl_host['destination']:
                 self.acl_manager.add_acl(name, host.dns_name, dst)
         self.hc.add_url(name, host.dns_name)
     except:
         exc_info = sys.exc_info()
         rollback = self._get_conf("RPAAS_ROLLBACK_ON_ERROR", "0") in ("True", "true", "1")
         if not rollback:
             raise
         try:
             if created_lb is not None:
                 created_lb.destroy()
         except Exception as e:
             logging.error("Error in rollback trying to destroy load balancer: {}".format(e))
         try:
             if created_lb is not None:
                 self._delete_host(name, host)
             else:
                 self._delete_host(name, host, lb)
         except Exception as e:
             logging.error("Error in rollback trying to destroy host: {}".format(e))
         try:
             if lb and len(lb.hosts) == 0:
                 self.hc.destroy(name)
         except Exception as e:
             logging.error("Error in rollback trying to remove healthcheck: {}".format(e))
         raise exc_info[0], exc_info[1], exc_info[2]
     finally:
         self.storage.remove_task(name)
开发者ID:tsuru,项目名称:rpaas,代码行数:46,代码来源:tasks.py

示例8: test_create_duplicated

# 需要导入模块: from hm.model.load_balancer import LoadBalancer [as 别名]
# 或者: from hm.model.load_balancer.LoadBalancer import create [as 别名]
 def test_create_duplicated(self):
     lb = LoadBalancer.create('fake', 'my-lb', {'LB_ID': 'xxx'})
     self.assertEqual(lb.id, 'xxx')
     self.assertEqual(lb.name, 'my-lb')
     with self.assertRaises(pymongo.errors.DuplicateKeyError):
         LoadBalancer.create('fake', 'my-lb', {'LB_ID': 'xxx'})
开发者ID:digideskio,项目名称:hm,代码行数:8,代码来源:test_load_balancer.py


注:本文中的hm.model.load_balancer.LoadBalancer.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。