物理机可用镜像查询
parent
2110cc845d
commit
0636f385bc
|
@ -298,4 +298,14 @@ public class ImageController {
|
|||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return imageService.copy(bean, context);
|
||||
}
|
||||
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "查询物理机镜像")
|
||||
@DeleteMapping("/listPhysical")
|
||||
public GeneralResult listPhysical(@RequestParam(value = "vendorId") Long vendorId,
|
||||
@RequestParam(value = "regionId") String regionId,
|
||||
@RequestParam(value = "zoneId") String zoneId,
|
||||
@RequestParam(value = "deviceType") String deviceType,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return imageService.listPhysical(vendorId, regionId, zoneId, deviceType, context);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -222,4 +222,26 @@ public class TianyiImageProvider extends TianyiProvider {
|
|||
return new GeneralResult(false, "根据jobId查询磁盘JOB状态信息失败", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public GeneralResult listImgaePhysical(String regionId, String azName, String deviceType) {
|
||||
try {
|
||||
String apiUrl = "/v4/ebm/image-list";
|
||||
JSONObject body = new JSONObject();
|
||||
body.put("regionID", this.getRegionId());
|
||||
body.put("azName", azName);
|
||||
body.put("deviceType", deviceType);
|
||||
|
||||
Result result = doGet(apiUrl, null, body);
|
||||
JSONObject returnObj = checkResult(result, "查询物理机镜像列表");
|
||||
|
||||
List<JSONObject> results = JSONArray.parseArray(returnObj.getString("results"), JSONObject.class);
|
||||
if (ListTool.isEmpty(results)) {
|
||||
return new GeneralResult(true, results, "物理机镜像列表为空");
|
||||
}
|
||||
return new GeneralResult(true, results, "查询物理机镜像列表成功");
|
||||
} catch (Exception e) {
|
||||
log.error("查询物理机镜像列表失败 : " + e);
|
||||
return new GeneralResult(false, "查询物理机镜像列表失败", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -217,4 +217,7 @@ public interface ImageService {
|
|||
* @return
|
||||
*/
|
||||
GeneralResult copy(Image bean, RequestContext context);
|
||||
|
||||
GeneralResult listPhysical(Long vendorId, String regionId, String zoneId, String deviceType, RequestContext context);
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import com.bocloud.cmp.util.ResourceEventPublisher;
|
|||
import com.bocloud.ctstack.plugin.config.ButlerConfig;
|
||||
import com.bocloud.ctstack.plugin.domain.model.ImageModel;
|
||||
import com.bocloud.ctstack.plugin.entity.*;
|
||||
import com.bocloud.ctstack.plugin.provider.common.TianyiFlavorProvider;
|
||||
import com.bocloud.ctstack.plugin.provider.compute.TianyiImageProvider;
|
||||
import com.bocloud.ctstack.plugin.repository.*;
|
||||
import com.bocloud.ctstack.plugin.service.ImageService;
|
||||
|
@ -1148,4 +1149,19 @@ public class ImageServiceImpl implements ImageService {
|
|||
public GeneralResult copy(Image bean, RequestContext context) {
|
||||
return new GeneralResult(false, "暂不支持");
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeneralResult listPhysical(Long vendorId, String regionId, String zoneId, String deviceType, RequestContext context) {
|
||||
try {
|
||||
CloudVendor vendor = cloudVendorRepository.query(vendorId);
|
||||
if (vendor == null) {
|
||||
return GeneralResult.FAILED("云平台不存在");
|
||||
}
|
||||
TianyiImageProvider imageProvider = new TianyiImageProvider(butlerConfig.regionButler(vendor.getUuid(), regionId));
|
||||
return imageProvider.listImgaePhysical(regionId, zoneId, deviceType);
|
||||
} catch (Exception e) {
|
||||
log.error("查询物理机镜像失败"+ e.getMessage(), e);
|
||||
return GeneralResult.FAILED("查询物理机镜像失败"+ e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue