|
@@ -6,12 +6,12 @@ import cn.hutool.http.HttpRequest;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.cloud.host.CloudHostConfig;
|
|
|
|
|
-import com.cloud.host.PoolInfoEnum;
|
|
|
|
|
-import com.ecloud.sdk.ecs.v1.Client;
|
|
|
|
|
-import com.ecloud.sdk.ecs.v1.model.VmRebootPath;
|
|
|
|
|
-import com.ecloud.sdk.ecs.v1.model.VmRebootRequest;
|
|
|
|
|
-import com.ecloud.sdk.ecs.v1.model.VmRebootResponse;
|
|
|
|
|
|
|
+//import com.cloud.host.CloudHostConfig;
|
|
|
|
|
+//import com.cloud.host.PoolInfoEnum;
|
|
|
|
|
+//import com.ecloud.sdk.ecs.v1.Client;
|
|
|
|
|
+//import com.ecloud.sdk.ecs.v1.model.VmRebootPath;
|
|
|
|
|
+//import com.ecloud.sdk.ecs.v1.model.VmRebootRequest;
|
|
|
|
|
+//import com.ecloud.sdk.ecs.v1.model.VmRebootResponse;
|
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.redis.RedisCache;
|
|
import com.fs.common.core.redis.RedisCache;
|
|
|
import com.fs.common.utils.CloudHostUtils;
|
|
import com.fs.common.utils.CloudHostUtils;
|
|
@@ -1381,48 +1381,48 @@ public class QwUserServiceImpl implements IQwUserService
|
|
|
return R.ok(status.toString());
|
|
return R.ok(status.toString());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
|
- public R restartCloudHost(String IP) {
|
|
|
|
|
- // 调用SDK必须要的参数
|
|
|
|
|
- String serverId = "";
|
|
|
|
|
- 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);
|
|
|
|
|
- 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(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();
|
|
|
|
|
- requestBuilder.vmRebootPath(vmRebootPath);
|
|
|
|
|
- VmRebootRequest request = requestBuilder.build();
|
|
|
|
|
- VmRebootResponse result = client.vmReboot(request);
|
|
|
|
|
- System.out.println(result);
|
|
|
|
|
-
|
|
|
|
|
- if(!VmRebootResponse.StateEnum.OK.equals(result.getState())){
|
|
|
|
|
- return R.error(501,"重启主机异常," + result.getErrorMessage()).put("errMsg", result);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return R.ok();
|
|
|
|
|
- } else {
|
|
|
|
|
- logger.error("重启云主机异常,获取主机信息异常,serverId:{},poolId:{},accessKey:{},secretKey:{}", serverId, poolId, accessKey, secretKey);
|
|
|
|
|
- return R.error(400,"重启云主机异常,获取主机信息异常");
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// @Override
|
|
|
|
|
+// public R restartCloudHost(String IP) {
|
|
|
|
|
+// // 调用SDK必须要的参数
|
|
|
|
|
+// String serverId = "";
|
|
|
|
|
+// 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);
|
|
|
|
|
+// 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(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();
|
|
|
|
|
+// requestBuilder.vmRebootPath(vmRebootPath);
|
|
|
|
|
+// VmRebootRequest request = requestBuilder.build();
|
|
|
|
|
+// VmRebootResponse result = client.vmReboot(request);
|
|
|
|
|
+// System.out.println(result);
|
|
|
|
|
+//
|
|
|
|
|
+// if(!VmRebootResponse.StateEnum.OK.equals(result.getState())){
|
|
|
|
|
+// return R.error(501,"重启主机异常," + result.getErrorMessage()).put("errMsg", result);
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// return R.ok();
|
|
|
|
|
+// } else {
|
|
|
|
|
+// logger.error("重启云主机异常,获取主机信息异常,serverId:{},poolId:{},accessKey:{},secretKey:{}", serverId, poolId, accessKey, secretKey);
|
|
|
|
|
+// return R.error(400,"重启云主机异常,获取主机信息异常");
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public List<QwUser> getQwUserInfo(QwFsUserParam param) {
|
|
public List<QwUser> getQwUserInfo(QwFsUserParam param) {
|