物理机列表查询接口
parent
3be319a59a
commit
b3ff2ed7e1
|
@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,8 +43,9 @@ public class PhysicalServerController {
|
||||||
|
|
||||||
@Operation(tags = {"CMC", "CSC"}, summary = "获取物理机列表")
|
@Operation(tags = {"CMC", "CSC"}, summary = "获取物理机列表")
|
||||||
@GetMapping(value = "/listAll")
|
@GetMapping(value = "/listAll")
|
||||||
public GeneralResult listAll() {
|
public GeneralResult listAll(@RequestParam(value = "regionId") String regionId,
|
||||||
return physicalServerService.listAll();
|
@RequestParam(value = "regionId") String zoneId) {
|
||||||
|
return physicalServerService.listAll(regionId, zoneId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,6 @@ public class TianyiPhysicalProvider extends TianyiProvider {
|
||||||
if (!CollectionUtils.isEmpty(zoneList)) {
|
if (!CollectionUtils.isEmpty(zoneList)) {
|
||||||
List<JSONObject> results = new ArrayList<>();
|
List<JSONObject> results = new ArrayList<>();
|
||||||
for (JSONObject zone : zoneList) {
|
for (JSONObject zone : zoneList) {
|
||||||
log.info("zoneName:" + zone.getString("name"));
|
|
||||||
String apiUrl = "/v4/ebm/list";
|
String apiUrl = "/v4/ebm/list";
|
||||||
JSONObject body = new JSONObject();
|
JSONObject body = new JSONObject();
|
||||||
body.put("regionID", this.getRegionId());
|
body.put("regionID", this.getRegionId());
|
||||||
|
@ -216,4 +215,32 @@ public class TianyiPhysicalProvider extends TianyiProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GeneralResult<List<PhysicalServerModel>> listAll(String regionId, String zoneId) {
|
||||||
|
try {
|
||||||
|
List<PhysicalServerModel> physicalModels = new ArrayList<>();
|
||||||
|
String apiUrl = "/v4/ebm/list";
|
||||||
|
JSONObject body = new JSONObject();
|
||||||
|
body.put("regionID", regionId);
|
||||||
|
body.put("azName", zoneId);
|
||||||
|
body.put("pageNo", 1);
|
||||||
|
body.put("pageSize", this.PAGE_SIZE);
|
||||||
|
Result result = doGet(apiUrl, null, body);
|
||||||
|
log.info("物理机数据:" + JSON.toJSONString(result));
|
||||||
|
JSONObject returnObj = checkResult(result, "查询物理机列表");
|
||||||
|
List<JSONObject> results = new ArrayList<>();
|
||||||
|
results.addAll(JSONArray.parseArray(returnObj.getString("results"), JSONObject.class));
|
||||||
|
if (ListTool.isEmpty(results)) {
|
||||||
|
return new GeneralResult(true, results, "物理机列表为空");
|
||||||
|
}
|
||||||
|
for (JSONObject model : results) {
|
||||||
|
physicalModels.add(physcicalConvertor.convertModel(model));
|
||||||
|
}
|
||||||
|
log.info("results:" + JSON.toJSONString(physicalModels));
|
||||||
|
return new GeneralResult(true, physicalModels, "查询物理机列表成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("查询物理机列表失败 :", e);
|
||||||
|
return new GeneralResult(false, "查询物理机列表失败" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ public interface PhysicalServerService {
|
||||||
|
|
||||||
|
|
||||||
GeneralResult<GridBean<PhysicalServer>> list(Pager pager, RequestContext context);
|
GeneralResult<GridBean<PhysicalServer>> list(Pager pager, RequestContext context);
|
||||||
GeneralResult listAll();
|
GeneralResult listAll( String regionId, String zoneId);
|
||||||
|
|
||||||
|
|
||||||
GeneralResult<PhysicalServer> detail(Long id);
|
GeneralResult<PhysicalServer> detail(Long id);
|
||||||
|
|
|
@ -80,10 +80,10 @@ public class PhysicalServerServiceImpl implements PhysicalServerService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GeneralResult listAll() {
|
public GeneralResult listAll( String regionId, String zoneId) {
|
||||||
CloudVendor vendor = cloudVendorRepository.query(1L);
|
CloudVendor vendor = cloudVendorRepository.query(1L);
|
||||||
TianyiPhysicalProvider physicalProvider = new TianyiPhysicalProvider(butlerConfig.regionButler(vendor.getUuid(), "2022guizhou_syj"));
|
TianyiPhysicalProvider physicalProvider = new TianyiPhysicalProvider(butlerConfig.regionButler(vendor.getUuid(), "2022guizhou_syj"));
|
||||||
GeneralResult result = physicalProvider.list();
|
GeneralResult result = physicalProvider.listAll(regionId, zoneId);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue