Skip to content

Commit

Permalink
Merge branch 'lianq_0715' into lianq_0630
Browse files Browse the repository at this point in the history
  • Loading branch information
lianqiang-git committed Jul 9, 2021
2 parents f6498c3 + c3836df commit 4580c9f
Show file tree
Hide file tree
Showing 51 changed files with 2,931 additions and 436 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import javax.annotation.PostConstruct;
import java.io.IOException;
import java.net.Inet4Address;
import java.net.InetAddress;
Expand All @@ -25,8 +28,14 @@
**/
@SpringBootApplication
public class VcenterDeployerApplication {
@Value(value = "${deployer.port}")
private int port;
private static int template;
protected static final Logger LOGGER = LoggerFactory.getLogger(VcenterDeployerApplication.class);

@PostConstruct
public void init() {
template = this.port;
}
public static void main(String[] args) {
try {
KeytookUtil.genKey();
Expand All @@ -42,7 +51,7 @@ public static void main(String[] args) {
List<String> hosts = getLocalIp();
StringBuffer buffer = new StringBuffer();
for (String host : hosts) {
buffer.append("\r\n").append("https://").append(host).append(":8443");
buffer.append("\r\n").append("https://").append(host).append(":" + template);
}
LOGGER.info("Use either URL that vCenter can access to open page: {}", buffer.toString());
} catch (SocketException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@ public class DmeIndicatorConstants {
*/
public static final String COUNTER_ID_CONTROLLER_RESPONSETIME = "1125908496842762";

/**
* FILE SYSTEM CONTROLLER OPS
*/
public static final String COUNTER_ID_CONTROLLER_OPS = "1125908496842773";

/**
* IOPS
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package com.huawei.dmestore.model;

import java.io.Serializable;
import java.util.List;

/**
* @author yc
* @Title:
* @Description:
* @date 2021/5/2810:41
*/
public class CreateVmfsResponse02 implements Serializable {
private static final long serialVersionUID = 8718802610431878776L;

private int successNo;
private int failNo;
private List<String> connectionResult ;
private int partialSuccess;

public CreateVmfsResponse02() {
}

public static long getSerialVersionUID() {
return serialVersionUID;
}

public int getSuccessNo() {
return successNo;
}

public void setSuccessNo(int successNo) {
this.successNo = successNo;
}

public int getFailNo() {
return failNo;
}

public void setFailNo(int failNo) {
this.failNo = failNo;
}

public List<String> getConnectionResult() {
return connectionResult;
}

public void setConnectionResult(List<String> connectionResult) {
this.connectionResult = connectionResult;
}

public int getPartialSuccess() {
return partialSuccess;
}

public void setPartialSuccess(int partialSuccess) {
this.partialSuccess = partialSuccess;
}

public CreateVmfsResponse02(int successNo, int failNo, List<String> connectionResult, int partialSuccess) {
this.successNo = successNo;
this.failNo = failNo;
this.connectionResult = connectionResult;
this.partialSuccess = partialSuccess;
}


@Override
public String toString() {
return "CreateVmfsResponse{" +
"successNo=" + successNo +
", failNo=" + failNo +
", connectionResult=" + connectionResult +
'}';
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.huawei.dmestore.model;

import java.io.Serializable;
import java.util.List;

/**
* @author yc
* @Title:
* @Description:
* @date 2021/7/115:20
*/
public class MountVmfsReturn implements Serializable {
private static final long serialVersionUID = -977833815757933935L;
private boolean flag;
private List<String> failedHost;
private String description;
public MountVmfsReturn(boolean flag) {
this.flag = flag;
}

public MountVmfsReturn(boolean flag, List<String> failedHost) {
this.flag = flag;
this.failedHost = failedHost;
}

public MountVmfsReturn(boolean flag, List<String> failedHost, String description) {
this.flag = flag;
this.failedHost = failedHost;
this.description = description;
}

public MountVmfsReturn(boolean flag, String description) {
this.flag = flag;
this.description = description;
}

public boolean isFlag() {
return flag;
}

public void setFlag(boolean flag) {
this.flag = flag;
}

public List<String> getFailedHost() {
return failedHost;
}

public void setFailedHost(List<String> failedHost) {
this.failedHost = failedHost;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -690,4 +690,21 @@ public String getRaidLevel() {
public void setRaidLevel(String raidLevel) {
this.raidLevel = raidLevel;
}

@Override
public String toString() {
return "StoragePool{" +
"storageName='" + storageName + '\'' +
", name='" + name + '\'' +
", id='" + id + '\'' +
", storagePoolId='" + storagePoolId + '\'' +
", storageInstanceId='" + storageInstanceId + '\'' +
", storageDeviceId='" + storageDeviceId + '\'' +
", mediaType='" + mediaType + '\'' +
", storageId='" + storageId + '\'' +
", diskPoolId='" + diskPoolId + '\'' +
", poolId='" + poolId + '\'' +
", serviceLevelName='" + serviceLevelName + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.huawei.dmestore.services.VmfsAccessService;
import com.google.gson.Gson;

import com.huawei.dmestore.utils.ToolUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -142,9 +143,8 @@ public ResponseBodyBean unmountVmfs(@RequestBody Map<String, Object> params) {
vmfsAccessService.unmountVmfs(params);
return success(null, "unmount vmfs success");
} catch (DmeException e) {
failureStr = "unmount vmfs failure:" + e.getMessage();
return failure(e.getMessage());
}
return failure(failureStr);
}

/**
Expand Down Expand Up @@ -277,19 +277,24 @@ public ResponseBodyBean queryDatastoreByName(@RequestParam("name") String name)
public ResponseBodyBean createvmfsNew(@RequestBody Map<String, Object> params) {
LOG.info("accessvmfs/createvmfsnew=={}", gson.toJson(params));
String failureStr = "";
CreateVmfsResponse02 result = new CreateVmfsResponse02();
try {
CreateVmfsResponse result = vmfsAccessService.createVmfsNew(params);
if (result.getSuccessNo() == 0) {
//CreateVmfsResponse result = vmfsAccessService.createVmfsNew(params);

result = vmfsAccessService.createVmfsNew1(params);
if (result.getSuccessNo() != 0 && result.getFailNo()==0 && result.getPartialSuccess() == 0
&& CollectionUtils.isEmpty(result.getConnectionResult())){
return success(result, "create vmfs success");
}else if (result.getSuccessNo() == 0 && result.getPartialSuccess() == 0) {
return failure("create vmfs failure!",result);
}else if (result.getFailNo() != 0 || !CollectionUtils.isEmpty(result.getConnectionResult())){
return partialSuccess(result,"create vmfs partial success!");
}else {
return success(result, "create vmfs success");
return partialSuccess(result,"create vmfs partial success!");
}
} catch (DmeException e) {
failureStr = "create vmfs failure:" + e.getMessage();
result.setFailNo(ToolUtils.getInt(params.get("count")));
}
return failure(failureStr);
return failure(failureStr,result);
}

/**
Expand All @@ -304,17 +309,21 @@ public ResponseBodyBean mountVmfsNew(@RequestBody Map<String, Object> params) {
LOG.info("accessvmfs/mountvmfs=={}", gson.toJson(params));
String failureStr = "";
try {
List<Map<String, String>> list = vmfsAccessService.mountVmfsNew(params);
if (!CollectionUtils.isEmpty(list)) {
return failure(DmeConstants.CODE_CONNECTIVITY_FAILURE,
"mount vmfs failure,connectivity of host or hostgroup on dme error!", list);
MountVmfsReturn res = vmfsAccessService.mountVmfsNew(params);
if (!res.isFlag()) {
return failure("mount vmfs failure : "+res.getDescription());
}else if (res.isFlag() && CollectionUtils.isEmpty(res.getFailedHost())) {
return success(null, "Mount vmfs success");
}else {
return partialSuccess(res.getFailedHost(),"Mount vmfs partial success : "+res.getDescription());

}
return success(null, "Mount vmfs success");
} catch (DmeException e) {
LOG.error("mount vmfs failure:", e);
failureStr = "mount vmfs failure:" + e.getMessage();
}
return failure(failureStr);

}

/**
Expand Down Expand Up @@ -369,5 +378,25 @@ public ResponseBodyBean queryCreationMethodByDatastore(@RequestParam("dataStoreO
return failure(e.getMessage());
}
}

/**
* queryVmfs
*
* @param clusterObjectId clusterObjectId
* @return ResponseBodyBean
* @throws Exception Exception
*/
@RequestMapping(value = "/queryMountableVmfsByClusterId", method = RequestMethod.GET)
public ResponseBodyBean queryMountableVmfsByClusterId(@RequestParam("clusterObjectId") String clusterObjectId,
@RequestParam("dataStoreType") String dataStoreType) throws Exception {
String failureStr = "";
try {
List<Map<String, String>> lists = vmfsAccessService.queryMountableVmfsByClusterId(clusterObjectId,dataStoreType);
LOG.info("listvmfs lists=={}", gson.toJson(lists));
return success(lists);
} catch (DmeException e) {
LOG.error("list vmfs failure:", e);
failureStr = "list vmfs failure:" + e.toString();
}
return failure(failureStr);
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
package com.huawei.dmestore.mvc;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.huawei.dmestore.exception.DmeException;
import com.huawei.dmestore.exception.DmeSqlException;
import com.huawei.dmestore.model.ClusterTree;
import com.huawei.dmestore.model.ResponseBodyBean;
import com.huawei.dmestore.services.VmwareAccessService;

import com.huawei.dmestore.utils.VCSDKUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

Expand All @@ -31,6 +37,9 @@ public class VmwareAccessController extends BaseController {
@Autowired
private VmwareAccessService vmwareAccessService;


private Gson gson = new Gson();

/**
* Access hosts
*
Expand Down Expand Up @@ -158,10 +167,15 @@ public ResponseBodyBean getDataStoresByClusterObjectId(@RequestParam("clusterObj
* @throws Exception when error
*/
@RequestMapping(value = "/getvmkernelipbyhostobjectid", method = RequestMethod.GET)
public ResponseBodyBean getVmKernelIpByHostObjectId(@RequestParam("hostObjectId") String hostObjectId) {
public ResponseBodyBean getVmKernelIpByHostObjectId(@RequestParam("hostObjectId") String hostObjectId,
@RequestParam(value = "datastoreObjectId", defaultValue = "") String datastoreObjectId) {
String failureStr = "";
try {
List<Map<String, String>> lists = vmwareAccessService.getVmKernelIpByHostObjectId(hostObjectId);
if (!StringUtils.isEmpty(datastoreObjectId)) {
List<Map<String, String>> latlists = vmwareAccessService.getNoMountedHostByDsObj(lists,datastoreObjectId);
return success(latlists);
}
return success(lists);
} catch (DmeException e) {
LOG.error("get vmkernel ip by hostobjectid failure:", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,7 @@ private List<String> initControllerIndicator(boolean isCurrent) {
indicators.add(DmeIndicatorConstants.COUNTER_ID_CONTROLLER_BANDWIDTH);
indicators.add(DmeIndicatorConstants.COUNTER_ID_CONTROLLER_CPUUSAGE);
indicators.add(DmeIndicatorConstants.COUNTER_ID_CONTROLLER_RESPONSETIME);
indicators.add(DmeIndicatorConstants.COUNTER_ID_CONTROLLER_OPS);
} else {
indicators.add(DmeIndicatorConstants.COUNTER_ID_CONTROLLER_READTHROUGHPUT);
indicators.add(DmeIndicatorConstants.COUNTER_ID_CONTROLLER_WRITETHROUGHPUT);
Expand Down
Loading

0 comments on commit 4580c9f

Please sign in to comment.