本文整理汇总了Python中profitbricks.client.ProfitBricksService.delete_nic方法的典型用法代码示例。如果您正苦于以下问题:Python ProfitBricksService.delete_nic方法的具体用法?Python ProfitBricksService.delete_nic怎么用?Python ProfitBricksService.delete_nic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类profitbricks.client.ProfitBricksService
的用法示例。
在下文中一共展示了ProfitBricksService.delete_nic方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestNIC
# 需要导入模块: from profitbricks.client import ProfitBricksService [as 别名]
# 或者: from profitbricks.client.ProfitBricksService import delete_nic [as 别名]
class TestNIC(unittest.TestCase):
def setUp(self):
self.nic = ProfitBricksService(
username='username', password='password')
def test_list_nics(self):
nics = self.nic.list_nics(
datacenter_id=datacenter_id,
server_id=server_id)
self.assertEqual(len(nics), 4)
self.assertEqual(nics['items'][0]['id'], nic_id)
self.assertEqual(nics['items'][0]['properties']['name'], 'nic1')
self.assertEqual(
nics['items'][0]['properties']['mac'], 'AB:21:23:09:78:C2')
self.assertEqual(nics['items'][0]['properties']['dhcp'], 'true')
self.assertEqual(nics['items'][0]['properties']['lan'], 1)
def test_get_nic(self):
nic = self.nic.get_nic(
datacenter_id=datacenter_id,
server_id=server_id,
nic_id=nic_id)
self.assertEqual(nic['id'], nic_id)
self.assertEqual(nic['properties']['name'], 'nic1')
self.assertEqual(nic['properties']['mac'], 'AB:21:23:09:78:C2')
self.assertEqual(nic['properties']['dhcp'], 'true')
self.assertEqual(nic['properties']['lan'], 1)
def test_delete_nic(self):
nic = self.nic.delete_nic(
datacenter_id=datacenter_id,
server_id=server_id,
nic_id=nic_id)
self.assertTrue(nic)
def test_update_nic(self):
nic = self.nic.update_nic(
datacenter_id=datacenter_id,
server_id=server_id,
nic_id=nic_id,
ips=['10.2.2.3', '10.2.3.4'])
self.assertEqual(nic['id'], nic_id)
self.assertEqual(nic['properties']['name'], 'nic1')
self.assertEqual(nic['properties']['mac'], 'AB:21:23:09:78:C2')
self.assertEqual(nic['properties']['dhcp'], 'true')
self.assertEqual(nic['properties']['lan'], 1)
def test_create_complex(self):
fwrule1 = FirewallRule(
name='Open SSH port',
protocol='TCP',
source_mac='01:23:45:67:89:00',
port_range_start=22
)
fwrule2 = FirewallRule(
name='Allow PING',
protocol='ICMP',
icmp_type=8,
icmp_code=0
)
fw_rules = [fwrule1, fwrule2]
i = NIC(
name='nic1',
ips=['10.2.2.3', '10.2.3.4'],
dhcp='true',
lan=1,
firewall_active=True,
firewall_rules=fw_rules
)
response = self.nic.create_nic(
datacenter_id=datacenter_id,
server_id=server_id, nic=i)
self.assertEqual(response['id'], nic_id)
self.assertEqual(response['properties']['name'], 'nic1')
self.assertEqual(
response['properties']['mac'], 'AB:21:23:09:78:C2')
self.assertEqual(response['properties']['dhcp'], 'true')
self.assertEqual(response['properties']['lan'], 1)
self.assertListEqual(
response['properties']['ips'], ['10.2.2.3'])
def test_create_simple(self):
i = NIC(
name='nic1',
ips=['10.2.2.3', '10.2.3.4'],
dhcp='true',
lan=1,
firewall_active=True
)
response = self.nic.create_nic(
#.........这里部分代码省略.........