本文整理匯總了Python中marvin.integration.lib.base.LoadBalancerRule.create方法的典型用法代碼示例。如果您正苦於以下問題:Python LoadBalancerRule.create方法的具體用法?Python LoadBalancerRule.create怎麽用?Python LoadBalancerRule.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類marvin.integration.lib.base.LoadBalancerRule
的用法示例。
在下文中一共展示了LoadBalancerRule.create方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: create_LB_Rule
# 需要導入模塊: from marvin.integration.lib.base import LoadBalancerRule [as 別名]
# 或者: from marvin.integration.lib.base.LoadBalancerRule import create [as 別名]
def create_LB_Rule(self, public_ip, network, vmarray, services=None):
self.debug("Creating LB rule for IP address: %s" %
public_ip.ipaddress.ipaddress)
objservices = None
if services:
objservices = services
else:
objservices = self.services["lbrule"]
lb_rule = LoadBalancerRule.create(
self.apiclient,
objservices,
ipaddressid=public_ip.ipaddress.id,
accountid=self.account.name,
networkid=network.id,
vpcid=self.vpc.id,
domainid=self.account.domainid
)
self.debug("Adding virtual machines %s and %s to LB rule" % (vmarray[0], vmarray[1]))
lb_rule.assign(self.apiclient, vmarray)
self.debug("Adding NetworkACl rules to make NAT rule accessible")
nwacl_nat = NetworkACL.create(self.apiclient,
objservices,
networkid=network.id,
traffictype='Ingress'
)
self.debug('nwacl_nat=%s' % nwacl_nat.__dict__)
return lb_rule
示例2: create_LB_Rule
# 需要導入模塊: from marvin.integration.lib.base import LoadBalancerRule [as 別名]
# 或者: from marvin.integration.lib.base.LoadBalancerRule import create [as 別名]
def create_LB_Rule(self, public_ip, network, vmarray, services=None):
self.debug("Creating LB rule for IP address: %s" % public_ip.ipaddress.ipaddress)
objservices = None
if services:
objservices = services
else:
objservices = self.services["lbrule"]
lb_rule = LoadBalancerRule.create(
self.apiclient,
objservices,
ipaddressid=public_ip.ipaddress.id,
accountid=self.account.name,
networkid=network.id,
vpcid=self.vpc.id,
domainid=self.account.domainid,
)
self.debug("Adding virtual machines %s and %s to LB rule" % (vmarray))
lb_rule.assign(self.apiclient, vmarray)
return lb_rule