当前位置: 首页>>代码示例>>Python>>正文


Python CCIManager.reload_instance方法代码示例

本文整理汇总了Python中SoftLayer.CCIManager.reload_instance方法的典型用法代码示例。如果您正苦于以下问题:Python CCIManager.reload_instance方法的具体用法?Python CCIManager.reload_instance怎么用?Python CCIManager.reload_instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SoftLayer.CCIManager的用法示例。


在下文中一共展示了CCIManager.reload_instance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: execute

# 需要导入模块: from SoftLayer import CCIManager [as 别名]
# 或者: from SoftLayer.CCIManager import reload_instance [as 别名]
 def execute(self, args):
     cci = CCIManager(self.client)
     cci_id = resolve_id(cci.resolve_ids, args.get('<identifier>'), 'CCI')
     keys = []
     if args.get('--key'):
         for key in args.get('--key'):
             key_id = resolve_id(SshKeyManager(self.client).resolve_ids,
                                 key, 'SshKey')
             keys.append(key_id)
     if args['--really'] or no_going_back(cci_id):
         cci.reload_instance(cci_id, args['--postinstall'], keys)
     else:
         CLIAbort('Aborted')
开发者ID:TimurNurlygayanov,项目名称:softlayer-python,代码行数:15,代码来源:cci.py

示例2: CCITests

# 需要导入模块: from SoftLayer import CCIManager [as 别名]
# 或者: from SoftLayer.CCIManager import reload_instance [as 别名]

#.........这里部分代码省略.........
        ))

    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)

    def test_cancel_instance(self):
        self.cci.cancel_instance(1)
        self.client['Virtual_Guest'].deleteObject.assert_called_once_with(id=1)

    def test_reload_instance(self):
        post_uri = 'http://test.sftlyr.ws/test.sh'
        self.cci.reload_instance(1, post_uri=post_uri, ssh_keys=[1701])
        service = self.client['Virtual_Guest']
        f = service.reloadOperatingSystem
        f.assert_called_once_with('FORCE',
                                  {'customProvisionScriptUri': post_uri,
                                   'sshKeyIds': [1701]}, id=1)

    @patch('SoftLayer.managers.cci.CCIManager._generate_create_dict')
    def test_create_verify(self, create_dict):
        create_dict.return_value = {'test': 1, 'verify': 1}
        self.cci.verify_create_instance(test=1, verify=1)
        create_dict.assert_called_once_with(test=1, verify=1)
        f = self.client['Virtual_Guest'].generateOrderTemplate
        f.assert_called_once_with({'test': 1, 'verify': 1})

    @patch('SoftLayer.managers.cci.CCIManager._generate_create_dict')
    def test_create_instance(self, create_dict):
        create_dict.return_value = {'test': 1, 'verify': 1}
        self.cci.create_instance(test=1, verify=1)
        create_dict.assert_called_once_with(test=1, verify=1)
        self.client['Virtual_Guest'].createObject.assert_called_once_with(
            {'test': 1, 'verify': 1})

    def test_generate_os_and_image(self):
        self.assertRaises(
            ValueError,
            self.cci._generate_create_dict,
            cpus=1,
            memory=1,
            hostname='test',
            domain='example.com',
开发者ID:mattmarcum,项目名称:softlayer-python,代码行数:70,代码来源:cci_tests.py


注:本文中的SoftLayer.CCIManager.reload_instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。