本文整理匯總了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(
#.........這裏部分代碼省略.........