2016-11-17 56 views
0

我正在运行以下代码。捕获弹性图像时出错

` 
RestApiClient client = new RestApiClient(baseUrl).withCredentials(userName, apiKey); 
Account.Service service = Account.service(client); 
service.withMask().hardware(); 
service.withMask().hardware().fullyQualifiedDomainName(); 
service.withMask().hardware().id(); 
Account account = service.getObject(); 
String hwname="bmtest.domain.com"; 
Hardware hw1=null; 
for(Hardware h : account.getHardware()){ 
if(h.getFullyQualifiedDomainName().equalsIgnoreCase(hwname)) { 
     hw1 = h; } 
    } 
    Hardware.Service svc= Hardware.service(client); 
    svc=hw1.asService(client); 
    try{ Template template = new Template(); 
     template.setName(hw1.getFullyQualifiedDomainName()+"-HWImg-1"); 
    template.setDescription("Image of "+hw1.getFullyQualifiedDomainName()); 
    System.out.println("Starting Image capture"); 
    svc.captureImage(template);` 

但得到以下错误:

`Starting Image capture 
com.softlayer.api.ApiException$Internal: Failed to determine the version of the operating system running on bmtest3rhel6.domain.com via SSH. Please ensure that a firewall is not restricting access to port 22, that your SSH server's configuration allows root login, and that the root credentials we have on file are valid. You can verify and update these credentials in the <i>Software</i> section of <a href="/Hardware/view/385236">your server's page</a>.(code: SoftLayer_Exception_Public, status: 500) 
    at com.softlayer.api.ApiException.fromError(ApiException.java:16) 
    at com.softlayer.api.RestApiClient$ServiceProxy.logAndHandleResponse(RestApiClient.java:258) 
    at com.softlayer.api.RestApiClient$ServiceProxy.invokeService(RestApiClient.java:300) 
    at com.softlayer.api.RestApiClient$ServiceProxy.invoke(RestApiClient.java:466) 
    at com.sun.proxy.$Proxy7.captureImage(Unknown Source) 
    at com.ibm.adn.servlet.TestBMSuspend.test(TestBMSuspend.java:91) 
    at com.ibm.adn.servlet.TestBMSuspend.main(TestBMSuspend.java:103) 
` 

这种特殊baremetal启动并运行。我可以使用root登录它,也打开了22端口的ssh。 仍然有相同的错误重复。

裸机有RHEL 6.7,它在SL网站上提到,可以使用Flex图像捕获。

请让我知道任何额外的事情,我应该做的这项工作。

回答

0

我审查了代码,它工作正常。

您可以查看的一件事是检查您是否使用可访问硬件的用户名和api密钥。

检查是否允许您在控制门户中与您的用户一起拍摄柔性图像,如果可能,请使用相同的用户凭据(即用户名和api密钥)运行脚本。

如果这些建议不起作用,我建议您在SoftLayer上打开一张票以获得进一步的帮助。

+0

谢谢佩德罗。 我在裸机上尝试了这种方法,它允许捕获图像通过软层UI。而且我只能捕捉其中一台服务器的图像。其他人抛出了同样的错误。 –

+0

我一直在研究这一点,并发现ADN帐户不允许创建柔性图像。 –