|
@@ -1316,25 +1316,28 @@ public class QwUserServiceImpl implements IQwUserService
|
|
|
|
|
|
@Override
|
|
|
public R restartCloudHost(String IP) {
|
|
|
+ // 调用SDK必须要的参数
|
|
|
String serverId = "";
|
|
|
-// String poolId = "";
|
|
|
+ String poolId = "";
|
|
|
+ String accessKey= "";
|
|
|
+ String secretKey ="";
|
|
|
try {
|
|
|
String bodyData = HttpRequest.get("http://watch.ylrzcloud.com/prod-api/server/getServerId?ipAddress="+IP)
|
|
|
.execute().body();
|
|
|
QwFsServerBindResult qwFsServerBindResult = JSON.parseObject(bodyData, QwFsServerBindResult.class);
|
|
|
- serverId = qwFsServerBindResult.getServerId();
|
|
|
-// poolId = PoolInfoEnum.getPoolIdByCityName(qwFsServerBindResult.getAddress());
|
|
|
+ if(qwFsServerBindResult.getData() != null){
|
|
|
+ QwFsServerBindResult.Data data = qwFsServerBindResult.getData();
|
|
|
+ serverId = data.getServerId();
|
|
|
+ poolId = PoolInfoEnum.getPoolIdByCityName(data.getCity() != null ? data.getCity().substring(0, data.getCity().length() - 1):"");
|
|
|
+ accessKey = data.getAccesskey();
|
|
|
+ secretKey = data.getSecretKey();
|
|
|
+ }
|
|
|
} catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
logger.error("获取主机信息异常,服务器IP:{}", IP);
|
|
|
}
|
|
|
|
|
|
- if(StringUtils.isNotEmpty(serverId) && StringUtils.isNotEmpty("CIDC-RP-34")){
|
|
|
- // todo 暂时写死,下周一等接口返回后,从接口中取
|
|
|
- String accessKey = "cba4f39ddfe04f06b4c939dfdf2f8186";
|
|
|
- String secretKey = "2d6fd124ce6a44a48eb654238f536404";
|
|
|
- String poolId = "CIDC-RP-34";
|
|
|
-
|
|
|
+ if(StringUtils.isNotEmpty(serverId) && StringUtils.isNotEmpty(poolId) && StringUtils.isNotEmpty(accessKey) && StringUtils.isNotEmpty(secretKey)){
|
|
|
Client client = CloudHostConfig.createClient(accessKey, secretKey, poolId);
|
|
|
VmRebootRequest.Builder requestBuilder = VmRebootRequest.builder();
|
|
|
VmRebootPath vmRebootPath = VmRebootPath.builder().serverId(serverId).build();
|
|
@@ -1344,12 +1347,13 @@ public class QwUserServiceImpl implements IQwUserService
|
|
|
System.out.println(result);
|
|
|
|
|
|
if(!VmRebootResponse.StateEnum.OK.equals(result.getState())){
|
|
|
- return R.error(501,"重启主机异常").put("errMsg", result);
|
|
|
+ return R.error(501,"重启主机异常," + result.getErrorMessage()).put("errMsg", result);
|
|
|
}
|
|
|
|
|
|
return R.ok();
|
|
|
} else {
|
|
|
- return R.error(400,"重启云主机异常,获取serverId或poolId异常");
|
|
|
+ logger.error("重启云主机异常,获取主机信息异常,serverId:{},poolId:{},accessKey:{},secretKey:{}", serverId, poolId, accessKey, secretKey);
|
|
|
+ return R.error(400,"重启云主机异常,获取主机信息异常");
|
|
|
}
|
|
|
}
|
|
|
|