本文整理汇总了Python中SoftLayer.CCIManager._get_ids_from_ip方法的典型用法代码示例。如果您正苦于以下问题:Python CCIManager._get_ids_from_ip方法的具体用法?Python CCIManager._get_ids_from_ip怎么用?Python CCIManager._get_ids_from_ip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoftLayer.CCIManager
的用法示例。
在下文中一共展示了CCIManager._get_ids_from_ip方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CCITests
# 需要导入模块: from SoftLayer import CCIManager [as 别名]
# 或者: from SoftLayer.CCIManager import _get_ids_from_ip [as 别名]
class CCITests(unittest.TestCase):
def setUp(self):
self.client = FixtureClient()
self.cci = CCIManager(self.client)
def test_list_instances(self):
mcall = call(mask=ANY, filter={})
service = self.client['Account']
list_expected_ids = [100, 104]
hourly_expected_ids = [104]
monthly_expected_ids = [100]
results = self.cci.list_instances(hourly=True, monthly=True)
service.getVirtualGuests.assert_has_calls(mcall)
for result in results:
self.assertIn(result['id'], list_expected_ids)
result = self.cci.list_instances(hourly=False, monthly=False)
service.getVirtualGuests.assert_has_calls(mcall)
for result in results:
self.assertIn(result['id'], list_expected_ids)
results = self.cci.list_instances(hourly=False, monthly=True)
service.getMonthlyVirtualGuests.assert_has_calls(mcall)
for result in results:
self.assertIn(result['id'], monthly_expected_ids)
results = self.cci.list_instances(hourly=True, monthly=False)
service.getHourlyVirtualGuests.assert_has_calls(mcall)
for result in results:
self.assertIn(result['id'], hourly_expected_ids)
def test_list_instances_with_filters(self):
self.cci.list_instances(
hourly=True,
monthly=True,
tags=['tag1', 'tag2'],
cpus=2,
memory=1024,
hostname='hostname',
domain='example.com',
local_disk=True,
datacenter='dal05',
nic_speed=100,
public_ip='1.2.3.4',
private_ip='4.3.2.1',
)
service = self.client['Account']
service.getVirtualGuests.assert_has_calls(call(
filter={
'virtualGuests': {
'datacenter': {
'name': {'operation': '_= dal05'}},
'domain': {'operation': '_= example.com'},
'tagReferences': {
'tag': {'name': {
'operation': 'in',
'options': [{
'name': 'data', 'value': ['tag1', 'tag2']}]}}},
'maxCpu': {'operation': 2},
'localDiskFlag': {'operation': True},
'maxMemory': {'operation': 1024},
'hostname': {'operation': '_= hostname'},
'networkComponents': {'maxSpeed': {'operation': 100}},
'primaryIpAddress': {'operation': '_= 1.2.3.4'},
'primaryBackendIpAddress': {'operation': '_= 4.3.2.1'}
}},
mask=ANY,
))
def test_resolve_ids_ip(self):
service = self.client['Account']
_id = self.cci._get_ids_from_ip('172.16.240.2')
self.assertEqual(_id, [100, 104])
_id = self.cci._get_ids_from_ip('nope')
self.assertEqual(_id, [])
# Now simulate a private IP test
service.getVirtualGuests.side_effect = [[], [{'id': 99}]]
_id = self.cci._get_ids_from_ip('10.0.1.87')
self.assertEqual(_id, [99])
def test_resolve_ids_hostname(self):
_id = self.cci._get_ids_from_hostname('cci-test1')
self.assertEqual(_id, [100, 104])
def test_get_instance(self):
result = self.cci.get_instance(100)
self.client['Virtual_Guest'].getObject.assert_called_once_with(
id=100, mask=ANY)
self.assertEqual(Virtual_Guest.getObject, result)
def test_get_create_options(self):
results = self.cci.get_create_options()
self.assertEqual(Virtual_Guest.getCreateObjectOptions, results)
#.........这里部分代码省略.........