物理机磁盘raid查询
parent
0636f385bc
commit
c81027e127
|
@ -21,19 +21,19 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author zhangdi
|
||||
* @since 2018/7/2
|
||||
* @author yuemian
|
||||
* @since 2024/09/02
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/v1/physical/servers")
|
||||
@Tag(name = "命名规则")
|
||||
@Tag(name = "物理机")
|
||||
public class PhysicalServerController {
|
||||
|
||||
@Autowired
|
||||
private PhysicalServerService physicalServerService;
|
||||
|
||||
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "获取命名规则列表")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "获取物理机列表")
|
||||
@GetMapping
|
||||
public GeneralResult<GridBean<PhysicalServer>> list(Pager pager,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
|
@ -41,15 +41,15 @@ public class PhysicalServerController {
|
|||
}
|
||||
|
||||
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "添加标签")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "添加物理机")
|
||||
@PostMapping
|
||||
public GeneralResult<PhysicalServer> create(@RequestBody PhysicalServer physicalServer,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return physicalServerService.create(physicalServer, context);
|
||||
}
|
||||
|
||||
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "修改标签")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "修改物理机")
|
||||
@PutMapping("/{id}")
|
||||
public GeneralResult<PhysicalServer> modify(@PathVariable(value = Common.ID) Long id,
|
||||
@RequestBody PhysicalServer physicalServer,
|
||||
|
@ -58,7 +58,7 @@ public class PhysicalServerController {
|
|||
return physicalServerService.modify(physicalServer, context);
|
||||
}
|
||||
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "删除标签")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "删除物理机")
|
||||
@DeleteMapping("/{id}")
|
||||
public GeneralResult remove(@PathVariable(value = Common.ID) Long id,
|
||||
@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}")
|
||||
public GeneralResult<PhysicalServer> detail(@PathVariable(value = Common.ID) Long id) {
|
||||
return physicalServerService.detail(id);
|
||||
|
|
|
@ -425,4 +425,15 @@ public class VolumeController {
|
|||
// 分页查询volume
|
||||
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 String hostname;
|
||||
|
||||
private String extIp;
|
||||
|
||||
private String password;
|
||||
|
||||
private String vpcName;
|
||||
|
||||
private Long cycleCount;
|
||||
|
||||
private String cycleType;
|
||||
|
||||
private Long orderCount;
|
||||
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
|
@ -116,4 +174,6 @@ public class TianyiPhysicalProvider extends TianyiProvider {
|
|||
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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -226,4 +226,6 @@ public interface VolumeService {
|
|||
public GeneralResult<GridBean<Volume>> listByVaults(Pager pager, RequestContext context);
|
||||
|
||||
public GeneralResult<List<Volume>> listByInstanceId(String instanceId, Long resourceSize);
|
||||
|
||||
public GeneralResult listVolumeRaid(Long vendorId, String regionId, String zoneId, String deviceType, String volumeType, RequestContext context);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import com.bocloud.ctstack.plugin.entity.ServerVolume;
|
|||
import com.bocloud.ctstack.plugin.entity.Snapshot;
|
||||
import com.bocloud.ctstack.plugin.entity.Storage;
|
||||
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.TianyiVolumeSnapshotProvider;
|
||||
import com.bocloud.ctstack.plugin.repository.*;
|
||||
|
@ -1859,4 +1860,19 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
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