Compare commits
3 Commits
aeb319b039
...
c81027e127
Author | SHA1 | Date |
---|---|---|
yuemian | c81027e127 | |
yuemian | 0636f385bc | |
yuemian | 2110cc845d |
|
@ -298,4 +298,14 @@ public class ImageController {
|
||||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||||
return imageService.copy(bean, 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,19 +21,19 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author zhangdi
|
* @author yuemian
|
||||||
* @since 2018/7/2
|
* @since 2024/09/02
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/v1/physical/servers")
|
@RequestMapping("/v1/physical/servers")
|
||||||
@Tag(name = "命名规则")
|
@Tag(name = "物理机")
|
||||||
public class PhysicalServerController {
|
public class PhysicalServerController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PhysicalServerService physicalServerService;
|
private PhysicalServerService physicalServerService;
|
||||||
|
|
||||||
|
|
||||||
@Operation(tags = {"CMC", "CSC"}, summary = "获取命名规则列表")
|
@Operation(tags = {"CMC", "CSC"}, summary = "获取物理机列表")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public GeneralResult<GridBean<PhysicalServer>> list(Pager pager,
|
public GeneralResult<GridBean<PhysicalServer>> list(Pager pager,
|
||||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||||
|
@ -41,7 +41,7 @@ public class PhysicalServerController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Operation(tags = {"CMC", "CSC"}, summary = "添加标签")
|
@Operation(tags = {"CMC", "CSC"}, summary = "添加物理机")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public GeneralResult<PhysicalServer> create(@RequestBody PhysicalServer physicalServer,
|
public GeneralResult<PhysicalServer> create(@RequestBody PhysicalServer physicalServer,
|
||||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||||
|
@ -49,7 +49,7 @@ public class PhysicalServerController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Operation(tags = {"CMC", "CSC"}, summary = "修改标签")
|
@Operation(tags = {"CMC", "CSC"}, summary = "修改物理机")
|
||||||
@PutMapping("/{id}")
|
@PutMapping("/{id}")
|
||||||
public GeneralResult<PhysicalServer> modify(@PathVariable(value = Common.ID) Long id,
|
public GeneralResult<PhysicalServer> modify(@PathVariable(value = Common.ID) Long id,
|
||||||
@RequestBody PhysicalServer physicalServer,
|
@RequestBody PhysicalServer physicalServer,
|
||||||
|
@ -58,7 +58,7 @@ public class PhysicalServerController {
|
||||||
return physicalServerService.modify(physicalServer, context);
|
return physicalServerService.modify(physicalServer, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(tags = {"CMC", "CSC"}, summary = "删除标签")
|
@Operation(tags = {"CMC", "CSC"}, summary = "删除物理机")
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
public GeneralResult remove(@PathVariable(value = Common.ID) Long id,
|
public GeneralResult remove(@PathVariable(value = Common.ID) Long id,
|
||||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||||
|
@ -66,7 +66,7 @@ public class PhysicalServerController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Operation(tags = {"CMC", "CSC"}, summary = "查看标签详情")
|
@Operation(tags = {"CMC", "CSC"}, summary = "查看物理机详情")
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public GeneralResult<PhysicalServer> detail(@PathVariable(value = Common.ID) Long id) {
|
public GeneralResult<PhysicalServer> detail(@PathVariable(value = Common.ID) Long id) {
|
||||||
return physicalServerService.detail(id);
|
return physicalServerService.detail(id);
|
||||||
|
|
|
@ -425,4 +425,15 @@ public class VolumeController {
|
||||||
// 分页查询volume
|
// 分页查询volume
|
||||||
return volumeService.listByInstanceId(instanceId, resourceSize);
|
return volumeService.listByInstanceId(instanceId, resourceSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(tags = {"CMC", "CSC"}, summary = "查询物理机镜像")
|
||||||
|
@DeleteMapping("/v1/volumes/raids")
|
||||||
|
public GeneralResult listPhysical(@RequestParam(value = "vendorId") Long vendorId,
|
||||||
|
@RequestParam(value = "regionId") String regionId,
|
||||||
|
@RequestParam(value = "zoneId") String zoneId,
|
||||||
|
@RequestParam(value = "deviceType") String deviceType,
|
||||||
|
@RequestParam(value = "volumeType") String volumeType,
|
||||||
|
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||||
|
return volumeService.listVolumeRaid(vendorId, regionId, zoneId, deviceType, volumeType, context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,4 +91,18 @@ public class PhysicalServerModel {
|
||||||
|
|
||||||
private Boolean isDeleted;
|
private Boolean isDeleted;
|
||||||
|
|
||||||
|
private String hostname;
|
||||||
|
|
||||||
|
private String extIp;
|
||||||
|
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
private String vpcName;
|
||||||
|
|
||||||
|
private Long cycleCount;
|
||||||
|
|
||||||
|
private String cycleType;
|
||||||
|
|
||||||
|
private Long orderCount;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class TianyiFlavorProvider extends TianyiServerProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public GeneralResult listPhysical(String regionId, String azName) {
|
public GeneralResult listFlavorPhysical(String regionId, String azName) {
|
||||||
try {
|
try {
|
||||||
String apiUrl = "/v4/ebm/device-type-list";
|
String apiUrl = "/v4/ebm/device-type-list";
|
||||||
JSONObject body = new JSONObject();
|
JSONObject body = new JSONObject();
|
||||||
|
@ -96,4 +96,5 @@ public class TianyiFlavorProvider extends TianyiServerProvider {
|
||||||
return new GeneralResult(false, "查询物理机规格列表失败", e.getMessage());
|
return new GeneralResult(false, "查询物理机规格列表失败", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,4 +222,26 @@ public class TianyiImageProvider extends TianyiProvider {
|
||||||
return new GeneralResult(false, "根据jobId查询磁盘JOB状态信息失败", e.getMessage());
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,64 @@ public class TianyiPhysicalProvider extends TianyiProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*public GeneralResult create(PhysicalServerModel model) {
|
||||||
|
try {
|
||||||
|
String apiUrl = "/v4/ebm/create";
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("regionID", this.getRegionId());
|
||||||
|
jsonObject.put("azName", model.getZoneId());
|
||||||
|
jsonObject.put("name", model.getName());
|
||||||
|
jsonObject.put("hostname", model.getHostname());
|
||||||
|
jsonObject.put("description", model.getRemark());
|
||||||
|
jsonObject.put("deviceType", model.getDeviceType());
|
||||||
|
jsonObject.put("imageUUID", model.getImageUuid());
|
||||||
|
jsonObject.put("password", model.getPassword());
|
||||||
|
jsonObject.put("vpcID", model.getVpcUuid());
|
||||||
|
jsonObject.put("extIP", model.getExtIp());
|
||||||
|
jsonObject.put("systemVolumeRaidUUID", model.getSystemVolumeRaidId());
|
||||||
|
jsonObject.put("dataVolumeRaidUUID", model.getDataVolumeRaidId());
|
||||||
|
//网络数据
|
||||||
|
JSONObject object = new JSONObject();
|
||||||
|
object.put("title", model.getVpcName());
|
||||||
|
object.put("master", true);
|
||||||
|
object.put("subnetID", model.getSubnetUuid());
|
||||||
|
JSONArray networkCardList = new JSONArray();
|
||||||
|
networkCardList.add(object);
|
||||||
|
jsonObject.put("networkCardList", networkCardList);
|
||||||
|
//订购时长
|
||||||
|
if (model.getCycleCount() != null) {
|
||||||
|
jsonObject.put("cycleCount", model.getCycleCount());
|
||||||
|
}
|
||||||
|
jsonObject.put("cycleType", model.getName());
|
||||||
|
jsonObject.put("orderCount", model.getOrderCount());
|
||||||
|
Result result = doPost(apiUrl, jsonObject);
|
||||||
|
JSONObject returnObj = checkResult(result, "创建物理机");
|
||||||
|
List<JSONObject> resources = returnObj.getJSONArray("resources").toJavaList(JSONObject.class);
|
||||||
|
String resourceID = resources.get(0).getString("resourceID");
|
||||||
|
if (resourceID == null) {
|
||||||
|
return new GeneralResult(false, "创建物理机失败!");
|
||||||
|
}
|
||||||
|
Long startTime = System.currentTimeMillis();
|
||||||
|
while (true) {
|
||||||
|
sleepSomeTime(5000);
|
||||||
|
PhysicalServerModel physicalServerModel = (PhysicalServerModel) detail(resourceID, model.getRegionId(), false).getData();
|
||||||
|
if (null != physicalServerModel) {
|
||||||
|
return new GeneralResult<>(true, physicalServerModel, "success");
|
||||||
|
} else {
|
||||||
|
log.warn("根据ResourceId[{}]查询云主机信息返回空数据", resourceID);
|
||||||
|
}
|
||||||
|
Long endTime = System.currentTimeMillis();
|
||||||
|
// 等待三分钟
|
||||||
|
if (endTime - startTime > 15 * 60 * 1000) {
|
||||||
|
return GeneralResult.FAILED("查询资源详情超时!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("创建物理机失败 : " + e.getMessage(), e);
|
||||||
|
return GeneralResult.FAILED("创建物理机失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
public List<JSONObject> listZones(String regionId) {
|
public List<JSONObject> listZones(String regionId) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1500);
|
Thread.sleep(1500);
|
||||||
|
@ -116,4 +174,6 @@ public class TianyiPhysicalProvider extends TianyiProvider {
|
||||||
return new GeneralResult(false, "删除物理机失败", e.getMessage());
|
return new GeneralResult(false, "删除物理机失败", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -363,5 +363,28 @@ public class TianyiVolumeProvider extends TianyiProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GeneralResult listVolumeRaid(String regionId, String azName, String deviceType, String volumeType) {
|
||||||
|
try {
|
||||||
|
String apiUrl = "/v4/ebm/raid-type-list";
|
||||||
|
JSONObject body = new JSONObject();
|
||||||
|
body.put("regionID", this.getRegionId());
|
||||||
|
body.put("azName", azName);
|
||||||
|
body.put("deviceType", deviceType);
|
||||||
|
body.put("volumeType", volumeType);
|
||||||
|
|
||||||
|
Result result = doGet(apiUrl, null, body);
|
||||||
|
JSONObject returnObj = checkResult(result, "查询磁盘raid列表");
|
||||||
|
|
||||||
|
List<JSONObject> results = JSONArray.parseArray(returnObj.getString("results"), JSONObject.class);
|
||||||
|
if (ListTool.isEmpty(results)) {
|
||||||
|
return new GeneralResult(true, results, "磁盘raid列表为空");
|
||||||
|
}
|
||||||
|
return new GeneralResult(true, results, "查询磁盘raid列表成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("查询磁盘raid列表失败 : " + e);
|
||||||
|
return new GeneralResult(false, "查询磁盘raid列表失败", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,4 +217,7 @@ public interface ImageService {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
GeneralResult copy(Image bean, RequestContext context);
|
GeneralResult copy(Image bean, RequestContext context);
|
||||||
|
|
||||||
|
GeneralResult listPhysical(Long vendorId, String regionId, String zoneId, String deviceType, RequestContext context);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,4 +226,6 @@ public interface VolumeService {
|
||||||
public GeneralResult<GridBean<Volume>> listByVaults(Pager pager, RequestContext context);
|
public GeneralResult<GridBean<Volume>> listByVaults(Pager pager, RequestContext context);
|
||||||
|
|
||||||
public GeneralResult<List<Volume>> listByInstanceId(String instanceId, Long resourceSize);
|
public GeneralResult<List<Volume>> listByInstanceId(String instanceId, Long resourceSize);
|
||||||
|
|
||||||
|
public GeneralResult listVolumeRaid(Long vendorId, String regionId, String zoneId, String deviceType, String volumeType, RequestContext context);
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,7 +165,7 @@ public class FlavorServiceImpl implements FlavorService {
|
||||||
return GeneralResult.FAILED("云平台不存在");
|
return GeneralResult.FAILED("云平台不存在");
|
||||||
}
|
}
|
||||||
TianyiFlavorProvider flavorProvider = new TianyiFlavorProvider(butlerConfig.regionButler(vendor.getUuid(), regionId));
|
TianyiFlavorProvider flavorProvider = new TianyiFlavorProvider(butlerConfig.regionButler(vendor.getUuid(), regionId));
|
||||||
return flavorProvider.listPhysical(regionId, zoneId);
|
return flavorProvider.listFlavorPhysical(regionId, zoneId);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("查询物理机规格失败"+ e.getMessage(), e);
|
log.error("查询物理机规格失败"+ e.getMessage(), e);
|
||||||
return GeneralResult.FAILED("查询物理机规格失败"+ e.getMessage());
|
return GeneralResult.FAILED("查询物理机规格失败"+ e.getMessage());
|
||||||
|
|
|
@ -18,6 +18,7 @@ import com.bocloud.cmp.util.ResourceEventPublisher;
|
||||||
import com.bocloud.ctstack.plugin.config.ButlerConfig;
|
import com.bocloud.ctstack.plugin.config.ButlerConfig;
|
||||||
import com.bocloud.ctstack.plugin.domain.model.ImageModel;
|
import com.bocloud.ctstack.plugin.domain.model.ImageModel;
|
||||||
import com.bocloud.ctstack.plugin.entity.*;
|
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.provider.compute.TianyiImageProvider;
|
||||||
import com.bocloud.ctstack.plugin.repository.*;
|
import com.bocloud.ctstack.plugin.repository.*;
|
||||||
import com.bocloud.ctstack.plugin.service.ImageService;
|
import com.bocloud.ctstack.plugin.service.ImageService;
|
||||||
|
@ -1148,4 +1149,19 @@ public class ImageServiceImpl implements ImageService {
|
||||||
public GeneralResult copy(Image bean, RequestContext context) {
|
public GeneralResult copy(Image bean, RequestContext context) {
|
||||||
return new GeneralResult(false, "暂不支持");
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -24,6 +24,7 @@ import com.bocloud.ctstack.plugin.entity.ServerVolume;
|
||||||
import com.bocloud.ctstack.plugin.entity.Snapshot;
|
import com.bocloud.ctstack.plugin.entity.Snapshot;
|
||||||
import com.bocloud.ctstack.plugin.entity.Storage;
|
import com.bocloud.ctstack.plugin.entity.Storage;
|
||||||
import com.bocloud.ctstack.plugin.entity.Volume;
|
import com.bocloud.ctstack.plugin.entity.Volume;
|
||||||
|
import com.bocloud.ctstack.plugin.provider.common.TianyiFlavorProvider;
|
||||||
import com.bocloud.ctstack.plugin.provider.storage.TianyiVolumeProvider;
|
import com.bocloud.ctstack.plugin.provider.storage.TianyiVolumeProvider;
|
||||||
import com.bocloud.ctstack.plugin.provider.storage.TianyiVolumeSnapshotProvider;
|
import com.bocloud.ctstack.plugin.provider.storage.TianyiVolumeSnapshotProvider;
|
||||||
import com.bocloud.ctstack.plugin.repository.*;
|
import com.bocloud.ctstack.plugin.repository.*;
|
||||||
|
@ -1859,4 +1860,19 @@ public class VolumeServiceImpl implements VolumeService {
|
||||||
return new GeneralResult<>(false, e.getMessage());
|
return new GeneralResult<>(false, e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GeneralResult listVolumeRaid(Long vendorId, String regionId, String zoneId, String deviceType, String volumeType, RequestContext context) {
|
||||||
|
try {
|
||||||
|
CloudVendor vendor = cloudVendorRepository.query(vendorId);
|
||||||
|
if (vendor == null) {
|
||||||
|
return GeneralResult.FAILED("云平台不存在");
|
||||||
|
}
|
||||||
|
TianyiVolumeProvider volumeProvider = new TianyiVolumeProvider(butlerConfig.regionButler(vendor.getUuid(), regionId));
|
||||||
|
return volumeProvider.listVolumeRaid(regionId, zoneId, deviceType, volumeType);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("查询磁盘raid失败"+ e.getMessage(), e);
|
||||||
|
return GeneralResult.FAILED("查询磁盘raid失败"+ e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue