本文整理汇总了Python中marvin.lib.base.StaticNATRule.create方法的典型用法代码示例。如果您正苦于以下问题:Python StaticNATRule.create方法的具体用法?Python StaticNATRule.create怎么用?Python StaticNATRule.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类marvin.lib.base.StaticNATRule
的用法示例。
在下文中一共展示了StaticNATRule.create方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_01_firewall_rules_port_fw
# 需要导入模块: from marvin.lib.base import StaticNATRule [as 别名]
# 或者: from marvin.lib.base.StaticNATRule import create [as 别名]
def test_01_firewall_rules_port_fw(self):
""""Checking firewall rules deletion after static NAT disable"""
# Validate the following:
#1. Enable static NAT for a VM
#2. Open up some ports. At this point there will be new rows in the
# firewall_rules table.
#3. Disable static NAT for the VM.
#4. Check fire wall rules are deleted from firewall_rules table.
public_ip = self.public_ip.ipaddress
# Enable Static NAT for VM
StaticNATRule.enable(
self.apiclient,
public_ip.id,
self.virtual_machine.id
)
self.debug("Enabled static NAT for public IP ID: %s" %
public_ip.id)
#Create Static NAT rule, in fact it's firewall rule
nat_rule = StaticNATRule.create(
self.apiclient,
self.services["firewall_rule"],
public_ip.id
)
self.debug("Created Static NAT rule for public IP ID: %s" %
public_ip.id)
self.debug("Checking IP address")
ip_response = PublicIPAddress.list(
self.apiclient,
id = public_ip.id
)
self.assertEqual(
isinstance(ip_response, list),
True,
"Check ip response returns a valid list"
)
self.assertNotEqual(
len(ip_response),
0,
"Check static NAT Rule is created"
)
self.assertTrue(
ip_response[0].isstaticnat,
"IP is not static nat enabled"
)
self.assertEqual(
ip_response[0].virtualmachineid,
self.virtual_machine.id,
"IP is not binding with the VM"
)
self.debug("Checking Firewall rule")
firewall_response = FireWallRule.list(
self.apiclient,
ipaddressid = public_ip.id,
listall = True
)
self.assertEqual(
isinstance(firewall_response, list),
True,
"Check firewall response returns a valid list"
)
self.assertNotEqual(
len(firewall_response),
0,
"Check firewall rule is created"
)
self.assertEqual(
firewall_response[0].state,
"Active",
"Firewall rule is not active"
)
self.assertEqual(
firewall_response[0].ipaddressid,
public_ip.id,
"Firewall rule is not static nat related"
)
self.assertEqual(
firewall_response[0].startport,
str(self.services["firewall_rule"]["startport"]),
"Firewall rule is not with specific port"
)
self.debug("Removed the firewall rule")
nat_rule.delete(self.apiclient)
self.debug("Checking IP address, it should still existed")
ip_response = PublicIPAddress.list(
self.apiclient,
id = public_ip.id
)
self.assertEqual(
isinstance(ip_response, list),
True,
"Check ip response returns a valid list"
)
#.........这里部分代码省略.........