本文整理汇总了Python中SoftLayer.CCIManager.edit方法的典型用法代码示例。如果您正苦于以下问题:Python CCIManager.edit方法的具体用法?Python CCIManager.edit怎么用?Python CCIManager.edit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoftLayer.CCIManager
的用法示例。
在下文中一共展示了CCIManager.edit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_put
# 需要导入模块: from SoftLayer import CCIManager [as 别名]
# 或者: from SoftLayer.CCIManager import edit [as 别名]
def on_put(self, req, resp, tenant_id, server_id):
client = req.env["sl_client"]
cci = CCIManager(client)
body = json.loads(req.stream.read().decode())
if "name" in lookup(body, "server"):
if lookup(body, "server", "name").strip() == "":
return bad_request(resp, message="Server name is blank")
cci.edit(server_id, hostname=lookup(body, "server", "name"))
instance = cci.get_instance(server_id, mask=get_virtual_guest_mask())
results = get_server_details_dict(self.app, req, instance)
resp.body = {"server": results}
示例2: execute
# 需要导入模块: from SoftLayer import CCIManager [as 别名]
# 或者: from SoftLayer.CCIManager import edit [as 别名]
def execute(self, args):
data = {}
if args['--userdata'] and args['--userfile']:
raise ArgumentError('[-u | --userdata] not allowed with '
'[-F | --userfile]')
if args['--userfile']:
if not os.path.exists(args['--userfile']):
raise ArgumentError(
'File does not exist [-u | --userfile] = %s'
% args['--userfile'])
if args.get('--userdata'):
data['userdata'] = args['--userdata']
elif args.get('--userfile'):
with open(args['--userfile'], 'r') as userfile:
data['userdata'] = userfile.read()
data['hostname'] = args.get('--hostname')
data['domain'] = args.get('--domain')
cci = CCIManager(self.client)
cci_id = resolve_id(cci.resolve_ids, args.get('<identifier>'), 'CCI')
if not cci.edit(cci_id, **data):
raise CLIAbort("Failed to update CCI")
示例3: on_put
# 需要导入模块: from SoftLayer import CCIManager [as 别名]
# 或者: from SoftLayer.CCIManager import edit [as 别名]
def on_put(self, req, resp, tenant_id, server_id):
client = req.env['sl_client']
cci = CCIManager(client)
body = json.loads(req.stream.read().decode())
if 'name' in lookup(body, 'server'):
if lookup(body, 'server', 'name').strip() == '':
return bad_request(resp, message='Server name is blank')
cci.edit(server_id, hostname=lookup(body, 'server', 'name'))
instance = cci.get_instance(server_id,
mask=get_virtual_guest_mask())
results = get_server_details_dict(self.app, req, instance)
resp.body = {'server': results}
示例4: CCITests
# 需要导入模块: from SoftLayer import CCIManager [as 别名]
# 或者: from SoftLayer.CCIManager import edit [as 别名]
#.........这里部分代码省略.........
assert_data = {
'startCpus': 1,
'maxMemory': 1,
'hostname': 'test',
'domain': 'example.com',
'localDiskFlag': True,
'operatingSystemReferenceCode': "STRING",
'hourlyBillingFlag': True,
'sshKeys': [{'id': 543}],
}
self.assertEqual(data, assert_data)
def test_generate_no_disks(self):
data = self.cci._generate_create_dict(
cpus=1,
memory=1,
hostname='test',
domain='example.com',
os_code="STRING"
)
self.assertEqual(data.get('blockDevices'), None)
def test_generate_single_disk(self):
data = self.cci._generate_create_dict(
cpus=1,
memory=1,
hostname='test',
domain='example.com',
os_code="STRING",
disks=[50]
)
assert_data = {
'blockDevices': [
{"device": "0", "diskImage": {"capacity": 50}}]
}
self.assertTrue(data.get('blockDevices'))
self.assertEqual(data['blockDevices'], assert_data['blockDevices'])
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)