本文整理汇总了Python中SoftLayer.CCIManager.capture方法的典型用法代码示例。如果您正苦于以下问题:Python CCIManager.capture方法的具体用法?Python CCIManager.capture怎么用?Python CCIManager.capture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoftLayer.CCIManager
的用法示例。
在下文中一共展示了CCIManager.capture方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from SoftLayer import CCIManager [as 别名]
# 或者: from SoftLayer.CCIManager import capture [as 别名]
def execute(self, args):
cci = CCIManager(self.client)
cci_id = resolve_id(cci.resolve_ids, args.get('<identifier>'), 'CCI')
if args['--all']:
additional_disks = True
else:
additional_disks = False
capture = cci.capture(cci_id,
args.get('--name'),
additional_disks,
args.get('--note'))
table = KeyValueTable(['Name', 'Value'])
table.align['Name'] = 'r'
table.align['Value'] = 'l'
table.add_row(['cci_id', capture['guestId']])
table.add_row(['date', capture['createDate'][:10]])
table.add_row(['time', capture['createDate'][11:19]])
table.add_row(['transaction', transaction_status(capture)])
table.add_row(['transaction_id', capture['id']])
table.add_row(['all_disks', additional_disks])
return table
示例2: CCITests
# 需要导入模块: from SoftLayer import CCIManager [as 别名]
# 或者: from SoftLayer.CCIManager import capture [as 别名]
#.........这里部分代码省略.........
def test_generate_multi_disk(self):
data = self.cci._generate_create_dict(
cpus=1,
memory=1,
hostname='test',
domain='example.com',
os_code="STRING",
disks=[50, 70, 100]
)
assert_data = {
'blockDevices': [
{"device": "0", "diskImage": {"capacity": 50}},
{"device": "2", "diskImage": {"capacity": 70}},
{"device": "3", "diskImage": {"capacity": 100}}]
}
self.assertTrue(data.get('blockDevices'))
self.assertEqual(data['blockDevices'], assert_data['blockDevices'])
def test_change_port_speed_public(self):
cci_id = 1
speed = 100
self.cci.change_port_speed(cci_id, True, speed)
service = self.client['Virtual_Guest']
f = service.setPublicNetworkInterfaceSpeed
f.assert_called_once_with(speed, id=cci_id)
def test_change_port_speed_private(self):
cci_id = 2
speed = 10
self.cci.change_port_speed(cci_id, False, speed)
service = self.client['Virtual_Guest']
f = service.setPrivateNetworkInterfaceSpeed
f.assert_called_once_with(speed, id=cci_id)
def test_edit(self):
# Test editing user data
service = self.client['Virtual_Guest']
self.cci.edit(100, userdata='my data')
service.setUserMetadata.assert_called_once_with(['my data'], id=100)
# Now test a blank edit
self.assertTrue(self.cci.edit, 100)
# Finally, test a full edit
args = {
'hostname': 'new-host',
'domain': 'new.sftlyr.ws',
'notes': 'random notes',
}
self.cci.edit(100, **args)
service.editObject.assert_called_once_with(args, id=100)
def test_captures(self):
archive = self.client['Virtual_Guest'].createArchiveTransaction
# capture only the OS disk
self.cci.capture(1, 'a')
archive.called_once_with('a', [{"device": 0}], "", id=1)
archive.reset()
# capture all the disks, minus the swap
# make sure the data is carried along with it
self.cci.capture(1, 'a', additional_disks=True)
archive.called_once_with('a', [{"device": 0, "uuid": 1},
{"device": 2, "uuid": 2}], "", id=1)
def test_upgrade(self):
# Testing Upgrade
orderClient = self.client['Product_Order']
# test single upgrade
self.cci.upgrade(1, cpus=4, public=False)
orderClient.placeOrder.called_once_with(1, cpus=4, public=False)
# Now test a blank upgrade
self.cci.upgrade(1)
self.assertTrue(self.cci.upgrade, 1)
# Testing all parameters Upgrade
self.cci.upgrade(1, cpus=4, memory=2, nic_speed=1000, public=True)
args = {'cpus': 4, 'memory': 2, 'nic_speed': 1000, 'public': 1000}
orderClient.placeOrder.called_once_with(1, **args)
def test_get_item_id_for_upgrade(self):
item_id = 0
package_items = self.client['Product_Package'].getItems(id=46)
for item in package_items:
if ((item['categories'][0]['id'] == 3)
and (item.get('capacity') == '2')):
item_id = item['prices'][0]['id']
break
self.assertEqual(1133, item_id)