我使用pythonapi创建vsi,当我试图从现有的图像模板创建vsi时遇到了一个问题。我的Python版本是3.6.3,我在windows7上运行Python脚本。你知道吗
您的文档(http://softlayer-python.readthedocs.io/en/latest/api/managers/vs.html)显示:
os_code (string) – The operating system to use. Cannot be specified if image_id is specified.
image_id (int) – The ID of the image to load onto the server. Cannot be specified if os_code is specified.
在python脚本中指定没有os\u代码的image\u id时,出现以下错误:
Traceback (most recent call last):
File "C:\Users\ods\Documents\slenv\lib\site-packages\SoftLayer\transports.py", line 173, in __call__
result = utils.xmlrpc_client.loads(resp.content)[0][0]
File "c:\users\ods\appdata\local\programs\python\python36\Lib\xmlrpc\client.py", line 1021, in loads
return u.close(), u.getmethodname()
File "c:\users\ods\appdata\local\programs\python\python36\Lib\xmlrpc\client.py", line 656, in close
raise Fault(**self._stack[0])
xmlrpc.client.Fault: <Fault SoftLayer_Exception_MissingCreationProperty: "The property 'operatingSystemReferenceCode' must be set to create an instance of 'SoftLayer_Virtual_Guest'.">
在处理上述异常时,发生了另一个异常:
Traceback (most recent call last):
File "C:\Users\ods\Documents\slenv\", line 66, in <module>
create_vsi()
File "C:\Users\ods\Documents\slenv\", line 50, in create_vsi
ssh_keys=ssh_keys)
File "C:\Users\ods\Documents\slenv\lib\site-packages\SoftLayer\managers\vs.py", line 514, in verify_create_instance
return self.guest.generateOrderTemplate(create_options)
File "C:\Users\ods\Documents\slenv\lib\site-packages\SoftLayer\API.py", line 392, in call_handler
return self(name, *args, **kwargs)
File "C:\Users\ods\Documents\slenv\lib\site-packages\SoftLayer\API.py", line 360, in call
return self.client.call(self.name, name, *args, **kwargs)
File "C:\Users\ods\Documents\slenv\lib\site-packages\SoftLayer\API.py", line 263, in call
return self.transport(request)
File "C:\Users\ods\Documents\slenv\lib\site-packages\SoftLayer\transports.py", line 195, in __call__
raise _ex(ex.faultCode, ex.faultString)
SoftLayer.exceptions.SoftLayerAPIError: SoftLayerAPIError(SoftLayer_Exception_MissingCreationProperty): The property 'operatingSystemReferenceCode' must be set to create an instance of 'SoftLayer_Virtual_Guest'.
所以我修改了我的脚本来指定操作系统代码和图像id,然后我就可以成功地创建一个vsi,但是图像模板没有加载到vsi中。你知道吗
你能帮个忙吗?谢谢。你知道吗
以下是我用来实际创建vsi或只是尝试试运行的python脚本,供您参考:
文档中有一个问题,图像id不是INT类型。方法create\u实例调用Softlayer_Virtual_Guest::createObject方法,此方法使用映像的全局标识符而不是其id
要知道全局标识符,可以使用SLCLI或这里描述的方法get\u imagehttp://softlayer-python.readthedocs.io/en/latest/api/managers/image.html
您可以使用以下python代码来测试它,用您自己的数据更改options变量中的值。你知道吗
相关问题 更多 >
编程相关推荐