Bläddra i källkod

Merge remote-tracking branch 'origin/master'

ct 1 dag sedan
förälder
incheckning
4216647e5f

+ 8 - 8
fs-company/src/main/java/com/fs/company/controller/qw/QwUserController.java

@@ -924,14 +924,14 @@ public class QwUserController extends BaseController
         return R.ok();
     }
 
-    /**
-     * 重启云主机
-     * @return
-     */
-    @PutMapping("/restartHost")
-    public R restartCloudHost(@RequestParam String serverIp) {
-        return qwUserService.restartCloudHost(serverIp);
-    }
+//    /**
+//     * 重启云主机
+//     * @return
+//     */
+//    @PutMapping("/restartHost")
+//    public R restartCloudHost(@RequestParam String serverIp) {
+//        return qwUserService.restartCloudHost(serverIp);
+//    }
     @PostMapping("/updateSendType")
     public R updateSendType(@RequestBody UpdateSendTypeVo vo) {
         return qwUserService.updateSendType(vo);

+ 5 - 5
fs-service/pom.xml

@@ -285,11 +285,11 @@
         </dependency>
 
         <!-- 移动云ECS SDK -->
-        <dependency>
-            <groupId>com.ecloud.sdk</groupId>
-            <artifactId>ecloud-sdk-ecs</artifactId>
-            <version>1.1.26</version>
-        </dependency>
+<!--        <dependency>-->
+<!--            <groupId>com.ecloud.sdk</groupId>-->
+<!--            <artifactId>ecloud-sdk-ecs</artifactId>-->
+<!--            <version>1.1.26</version>-->
+<!--        </dependency>-->
 
     </dependencies>
 

+ 13 - 13
fs-service/src/main/java/com/cloud/host/CloudHostConfig.java

@@ -1,7 +1,7 @@
 package com.cloud.host;
 
-import com.ecloud.sdk.config.Config;
-import com.ecloud.sdk.ecs.v1.Client;
+//import com.ecloud.sdk.config.Config;
+//import com.ecloud.sdk.ecs.v1.Client;
 import org.springframework.context.annotation.Configuration;
 
 @Configuration
@@ -14,16 +14,16 @@ public class CloudHostConfig {
      * @param poolId
      * @return Client
      */
-    public static Client createClient(String accessKey, String secretKey, String poolId) {
-        Config config = new Config();
-        config.setAccessKey(accessKey);
-        config.setSecretKey(secretKey);
-        config.setPoolId(poolId);
-        // 默认连接超时时间为60秒
-        config.setConnectTimeout(60);
-        // 默认响应超时时间为120秒
-        config.setReadTimeout(120);
-        return new Client(config);
-    }
+//    public static Client createClient(String accessKey, String secretKey, String poolId) {
+//        Config config = new Config();
+//        config.setAccessKey(accessKey);
+//        config.setSecretKey(secretKey);
+//        config.setPoolId(poolId);
+//        // 默认连接超时时间为60秒
+//        config.setConnectTimeout(60);
+//        // 默认响应超时时间为120秒
+//        config.setReadTimeout(120);
+//        return new Client(config);
+//    }
 
 }

+ 6 - 6
fs-service/src/main/java/com/fs/qw/service/IQwUserService.java

@@ -168,12 +168,12 @@ public interface IQwUserService
     List<Long> selectQwUserListByCuDeptIdList(QwSop qwSop);
 
 
-    /**
-     * 重启云主机
-     * @param IP 服务器ip
-     * @return
-     */
-    R restartCloudHost(String IP);
+//    /**
+//     * 重启云主机
+//     * @param IP 服务器ip
+//     * @return
+//     */
+//    R restartCloudHost(String IP);
 
     /**
      * 获取企微用户信息

+ 48 - 48
fs-service/src/main/java/com/fs/qw/service/impl/QwUserServiceImpl.java

@@ -6,12 +6,12 @@ import cn.hutool.http.HttpRequest;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 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.redis.RedisCache;
 import com.fs.common.utils.CloudHostUtils;
@@ -1381,48 +1381,48 @@ public class QwUserServiceImpl implements IQwUserService
         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
     public List<QwUser> getQwUserInfo(QwFsUserParam param) {

+ 1 - 1
fs-service/src/main/resources/application-config-druid-gzzdy.yml

@@ -64,7 +64,7 @@ fs :
   h5CommonApi: http://172.16.16.7:7771
   jwt:
     # 加密秘钥
-    secret: f4e2e52034348f86b67cde581c0f9eb5
+    secret: f4e2e52034348f86b6d81e581c0f9eb5
     # token有效时长,7天,单位秒
     expire: 31536000
     header: AppToken