Authored by qinchao

修正qcloud的cvm主机,状态为过期的不显示

@@ -390,7 +390,7 @@ public class HostInfoServiceImpl implements IHostInfoService { @@ -390,7 +390,7 @@ public class HostInfoServiceImpl implements IHostInfoService {
390 logger.info("delete ip from database , ipList is {} ,cloudType is {} ,", oldIpList, cloudType); 390 logger.info("delete ip from database , ipList is {} ,cloudType is {} ,", oldIpList, cloudType);
391 for(String ip : oldIpList){ 391 for(String ip : oldIpList){
392 try{ 392 try{
393 - //删除数据--暂时屏蔽 393 + //删除数据
394 hostInfoMapper.deleteByIp(ip); 394 hostInfoMapper.deleteByIp(ip);
395 }catch (Exception e){ 395 }catch (Exception e){
396 logger.error("delete ip error ! ip is {} : {}", ip , cloudType); 396 logger.error("delete ip error ! ip is {} : {}", ip , cloudType);
@@ -200,6 +200,10 @@ public class QcloudClientFactory { @@ -200,6 +200,10 @@ public class QcloudClientFactory {
200 String hostid=jo.getString("InstanceId"); 200 String hostid=jo.getString("InstanceId");
201 String hostname=jo.getString("InstanceName"); 201 String hostname=jo.getString("InstanceName");
202 String ip=jo.getJSONArray("PrivateIpAddresses").size()>0?jo.getJSONArray("PrivateIpAddresses").getString(0):""; 202 String ip=jo.getJSONArray("PrivateIpAddresses").size()>0?jo.getJSONArray("PrivateIpAddresses").getString(0):"";
  203 + String restrictState=jo.getString("RestrictState"); ///状态,不要EXPIRED状态的主机,NORMAL表示正常状态的实例 ,EXPIRED:表示过期的实例 ,PROTECTIVELY_ISOLATED:表示被安全隔离的实例。
  204 + if("EXPIRED".equalsIgnoreCase(restrictState)){
  205 + continue;
  206 + }
203 if(!instanceIDs.contains(hostid)){ 207 if(!instanceIDs.contains(hostid)){
204 instanceIDs.add(hostid); 208 instanceIDs.add(hostid);
205 Host host=new Host(DataCenter.qcloud,hostid, ip, hostname); 209 Host host=new Host(DataCenter.qcloud,hostid, ip, hostname);
@@ -229,6 +233,10 @@ public class QcloudClientFactory { @@ -229,6 +233,10 @@ public class QcloudClientFactory {
229 String hostid=jo.getString("InstanceId"); 233 String hostid=jo.getString("InstanceId");
230 String hostname=jo.getString("InstanceName"); 234 String hostname=jo.getString("InstanceName");
231 String ip=jo.getJSONArray("PrivateIpAddresses").size()>0?jo.getJSONArray("PrivateIpAddresses").getString(0):""; 235 String ip=jo.getJSONArray("PrivateIpAddresses").size()>0?jo.getJSONArray("PrivateIpAddresses").getString(0):"";
  236 + String restrictState=jo.getString("RestrictState"); ///状态,不要EXPIRED状态的主机,NORMAL表示正常状态的实例 ,EXPIRED:表示过期的实例 ,PROTECTIVELY_ISOLATED:表示被安全隔离的实例。
  237 + if("EXPIRED".equalsIgnoreCase(restrictState)){
  238 + continue;
  239 + }
232 if(!instanceIDs.contains(hostid)){ 240 if(!instanceIDs.contains(hostid)){
233 instanceIDs.add(hostid); 241 instanceIDs.add(hostid);
234 Host host=new Host(DataCenter.qcloud,hostid, ip, hostname); 242 Host host=new Host(DataCenter.qcloud,hostid, ip, hostname);