- 浏览: 59653 次
- 性别:
- 来自: 新加坡
文章分类
最新评论
package com.savvis.spirits.domain;
import javax.persistence.*;
import static javax.persistence.GenerationType.IDENTITY;
@Entity
@Table(name = "validation_message")
public class ValidationMessageMapping implements java.io.Serializable {
private Integer id;
private String mwCase;
private String mwType;
private String message;
private String apiMessage;
private Integer moduleCode;
private Integer categorymoduleCode;
private Integer componentmoduleCode;
private Integer errorCode;
private Integer httpCode;
private String status;
public ValidationMessageMapping() {
}
public ValidationMessageMapping(Integer id, String mwCase, String apiMessage, String message, Integer moduleCode, Integer httpCode, String mwType, Integer categorymoduleCode, Integer componentmoduleCode, String status) {
this.id = id;
this.mwCase = mwCase;
this.apiMessage = apiMessage;
this.message = message;
this.moduleCode = moduleCode;
this.httpCode = httpCode;
this.mwType = mwType;
this.categorymoduleCode = categorymoduleCode;
this.componentmoduleCode = componentmoduleCode;
this.status = status;
}
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
@Column(name = "mw_case", length = 200, nullable = false)
public String getMwCase() {
return mwCase;
}
public void setMwCase(String mwCase) {
this.mwCase = mwCase;
}
@Column(name = "mw_type", length = 200)
public String getMwType() {
return mwType;
}
public void setMwType(String mwType) {
this.mwType = mwType;
}
@Column(name = "message", nullable = false)
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
@Column(name = "api_message")
public String getApiMessage() {
return apiMessage;
}
public void setApiMessage(String apiMessage) {
this.apiMessage = apiMessage;
}
@Column(name = "module_code", length = 10, nullable = false)
public Integer getModuleCode() {
return moduleCode;
}
public void setModuleCode(Integer moduleCode) {
this.moduleCode = moduleCode;
}
@Column(name = "category_code", length = 10, nullable = false)
public Integer getCategorymoduleCode() {
return categorymoduleCode;
}
public void setCategorymoduleCode(Integer categorymoduleCode) {
this.categorymoduleCode = categorymoduleCode;
}
@Column(name = "component_code", length = 10, nullable = false)
public Integer getComponentmoduleCode() {
return componentmoduleCode;
}
public void setComponentmoduleCode(Integer componentmoduleCode) {
this.componentmoduleCode = componentmoduleCode;
}
@Column(name = "error_code", length = 10, nullable = false)
public Integer geterrorCode() {
return errorCode;
}
public void seterrorCode(Integer errorCode) {
this.errorCode = errorCode;
}
@Column(name = "http_code", length = 10)
public Integer gethttpCode() {
return httpCode;
}
public void sethttpCode(Integer httpCode) {
this.httpCode = httpCode;
}
@Column(name = "status", length = 50)
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
@Override
public String toString() {
return "ValidationMessageMapping{" +
"id=" + id +
", mwCase='" + mwCase + '\'' +
", message='" + message + '\'' +
", apiMessage='" + apiMessage + '\'' +
", modulemoduleCode=" + moduleCode +
", httpCode=" + httpCode +
", categorymoduleCode=" + categorymoduleCode +
", componentmoduleCode=" + componentmoduleCode +
", errorCode=" + errorCode +
", mwType='" + mwType + '\'' +
'}';
}
}
********************************************
package com.savvis.spirits.services.queue.process;
import com.savvis.spirits.businessmodel.servicedesign.Compute;
import com.savvis.spirits.businessmodel.servicedesign.Computes;
import com.savvis.spirits.businessmodel.servicedesign.Drive;
import com.savvis.spirits.businessmodel.servicedesign.VPDCServiceDesign;
import com.savvis.spirits.common.exceptions.SystemException;
import com.savvis.spirits.common.utils.MWConstants;
import com.savvis.spirits.common.utils.MWUtil;
import com.savvis.spirits.dao.VpdcDetailDAO;
import com.savvis.spirits.dao.VpdcQueueProcessDAO;
import com.savvis.spirits.dao.VpdcQueueProcessResultDAO;
import com.savvis.spirits.domain.*;
import com.savvis.spirits.domain.enums.OperationEnum;
import com.savvis.spirits.domain.enums.VpdcQueueProcessStatusEnum;
import com.savvis.spirits.integration.schemas.queueprocess.*;
import com.savvis.spirits.services.xml.parser.ObjectConverter;
import com.savvis.spirits.vcloud.header.VCloudHeader;
import com.savvis.spirits.vcloud.header.VCloudHeaderHolder;
import com.savvis.spirits.vcloud.header.VCloudUser;
import com.savvis.spirits.vcloud.helper.VpdcTemplateHelper;
import com.savvis.spirits.vcloud.proxy.RestProxyAuthenticationService;
import com.savvis.spirits.vcloud.wrapper.VCloudHelper;
import com.savvis.spirits.yfilesconverter.YFilesConverter;
import com.savvis.spirits.yfilesconverter.dataobjects.*;
import java.util.*;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.oxm.jaxb.Jaxb2Marshaller;
import org.springframework.stereotype.Service;
import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName;
import javax.xml.transform.Result;
import javax.xml.transform.stream.StreamResult;
import java.io.*;
/**
* Created by IntelliJ IDEA.
* User: ramesh.rajaram
* Date: Jan 12, 2011
* Time: 1:36:38 PM
* To change this template use File | Settings | File Templates.
*/
@Service("vpdcQueueProcessPreEngine")
public class VPDCQueueProcessPreEngine {
private static final Logger log = Logger.getLogger(VPDCQueueProcessPreEngine.class);
@Autowired
VpdcDetailDAO vpdcDetailDAO;
@Autowired
private ObjectConverter objectConverter;
@Autowired
VpdcQueueProcessDAO vpdcQueueProcessDAO;
@Autowired
VpdcQueueProcessResultDAO vpdcQueueProcessResultDAO;
@Autowired
private RestProxyAuthenticationService restProxyAuthenticationService;
@Autowired
@Qualifier("marshaller")
protected Jaxb2Marshaller marshaller;
@Autowired
private VpdcTemplateHelper vpdcTemplateHelper;
public VPDCQueueProcessPreEngine() {
}
public VPDCQueueProcessPreEngine(Object inputRequest, String vpdcCompType) {
addToQueue(inputRequest, vpdcCompType);
}
public TaskInfo addToQueue(Object inputRequest, String vpdcCompType) {
VCloudHeader vCloudHeader = VCloudHeaderHolder.getVcloudHeader();
VCloudUser vCloudUser = restProxyAuthenticationService.getVCloudUser(vCloudHeader.getToken());
//insert record to VPDCQueueProcess
VpdcQueueProcess vpdcQueueProcess = new VpdcQueueProcess();
vpdcQueueProcess.setCreatedBy(vCloudUser.getUserId());
vpdcQueueProcess.setCreateTime(new Date());
vpdcQueueProcess.setProcessType(vpdcCompType);
vpdcQueueProcess.setStatus(VpdcQueueProcessStatusEnum.QUEUED);
vpdcQueueProcess.setInput(convertRequestResponseToString(inputRequest));
TaskInfo taskInfo = new TaskInfo();
taskInfo.setProcessType(vpdcCompType);
taskInfo.setTaskStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
if (inputRequest instanceof VMOperationRequest) {
putVMOperationRequestInQueue(inputRequest, vpdcQueueProcess, taskInfo);
} else if (inputRequest instanceof ChangeTemplateRequest) {
putChangeTemplateRequestInQueue(inputRequest, vpdcQueueProcess, taskInfo);
} else if (inputRequest instanceof CloneVCloudTemplateRequest) {
putCloneVCloudTemplateRequestInQueue(inputRequest, vpdcQueueProcess, taskInfo);
} else if (inputRequest instanceof SaveVCloudTemplateRequest) {
putSaveVCloudTemplateRequestInQueue(inputRequest, vpdcQueueProcess, taskInfo);
} else if (inputRequest instanceof InstantiateVCloudTemplateRequest) {
putInstantiateVCloudTemplateRequestInQueue(inputRequest, vpdcQueueProcess, taskInfo);
} else if (inputRequest instanceof FirewallRequest) {
putFWOperationRequestInQueue(inputRequest, vpdcQueueProcess, taskInfo);
} else if (inputRequest instanceof CloneVCloudvAppRequest) {
putCloneVCloudvAppRequestInQueue(inputRequest, vpdcQueueProcess, taskInfo);
} else if (inputRequest instanceof CloneVCloudMultiplevAppRequest) {
putCloneVCloudMultiplevAppRequestInQueue(inputRequest, vpdcQueueProcess, taskInfo);
} else if (inputRequest instanceof DetachVCloudVMDKRequest) {
putDetachVMDKRequestInQueue(inputRequest, vpdcQueueProcess, taskInfo);
} else if (inputRequest instanceof DeleteVCloudVMDKRequest) {
putDeleteVMDKRequestInQueue(inputRequest, vpdcQueueProcess, taskInfo);
} else if (inputRequest instanceof AttachVCloudVMDKRequest) {
putAttachVMDKRequestInQueue(inputRequest, vpdcQueueProcess, taskInfo);
} else if (inputRequest instanceof CloneVCloudVMDKRequest) {
putCloneVMDKRequestInQueue(inputRequest, vpdcQueueProcess, taskInfo);
}
vpdcQueueProcess.setOutput(convertRequestResponseToString(new JAXBElement<TaskInfo>(new QName("http://www.savvis.com/spirits/services/schemas/queueprocess/types", "TaskInfo"), TaskInfo.class, taskInfo)));
vpdcQueueProcessDAO.update(vpdcQueueProcess);
return taskInfo;
}
private void putVMOperationRequestInQueue(Object inputRequest, VpdcQueueProcess vpdcQueueProcess, TaskInfo taskInfo) {
List<TaskResultInfo> taskResultInfoList = new ArrayList<TaskResultInfo>();
YFilesConverter yFilesConverter = new YFilesConverter();
int nextGuiId = 0;
VMOperationRequest request = (VMOperationRequest) inputRequest;
vpdcQueueProcess.setBillingSiteId(request.getBillingsiteId());
vpdcQueueProcess.setVpdcId(request.getVpdcId());
vpdcQueueProcess.setProcessName("VMOperation");
vpdcQueueProcess.setProcessIdentifier("01");
VpdcDetail vpdcDetail = vpdcDetailDAO.findVpdcDtlLatestByVpdcId(request.getVpdcId());
if (null != vpdcDetail) {
vpdcQueueProcess.setProcessOwnerName(vpdcDetail.getVpdcName());
taskInfo.setOwnerReference(vpdcDetail.getVpdcName());
if (MWUtil.isNotEmptyString(vpdcDetail.getTransientYfiles())) { // todo for what
yFilesConverter.loadGraphML(new ByteArrayInputStream(vpdcDetail.getTransientYfiles().getBytes()));
nextGuiId = yFilesConverter.getNewServerGuiId();
vpdcDetail.setTransientYfiles(yFilesConverter.getGraphML());
} else {
yFilesConverter.loadGraphML(new ByteArrayInputStream(vpdcDetail.getGuiXml().getBytes()));
nextGuiId = yFilesConverter.getNewServerGuiId();
vpdcQueueProcess.setGuiXml(yFilesConverter.getGraphML());
}
vpdcDetailDAO.update(vpdcDetail);
}
vpdcQueueProcessDAO.save(vpdcQueueProcess);
taskInfo.setProcessId(vpdcQueueProcess.getProcessId() + "");
taskInfo.setOrgId(request.getBillingsiteId());
taskInfo.setOwnerId(request.getVpdcId() + "");
taskInfo.setProcessName("VMOperation");
for (VCloudCompute vCloudCompute : request.getVcloudComputes().getCompute()) {
TaskResultInfo taskResultInfo = new TaskResultInfo();
taskResultInfo.setResultReference(vCloudCompute.getCustHostName());
taskResultInfo.setResultStatus("queued");
VpdcQueueProcessResult vpdcQueueProcessResult = new VpdcQueueProcessResult();
vpdcQueueProcessResult.setVpdcQueueProcess(vpdcQueueProcess);
vpdcQueueProcessResult.setProcessResultName(vCloudCompute.getCustHostName());
vpdcQueueProcessResult.setProcessResultStatus("queued");
if (VMAction.ADD.equals(vCloudCompute.getAction())) {
vpdcQueueProcessResult.setProcessResultId(nextGuiId);
taskResultInfo.setResultReferenceId(nextGuiId + "");
nextGuiId++;
} else {
vpdcQueueProcessResult.setProcessResultId(Integer.parseInt(vCloudCompute.getGuiId()));
taskResultInfo.setResultReferenceId(vCloudCompute.getGuiId());
}
vpdcQueueProcessResultDAO.save(vpdcQueueProcessResult);
taskResultInfo.setResultId(vpdcQueueProcessResult.getId() + "");
taskResultInfoList.add(taskResultInfo);
}
taskInfo.getTaskResultInfo().addAll(taskResultInfoList);
}
private void putChangeTemplateRequestInQueue(Object inputRequest, VpdcQueueProcess vpdcQueueProcess, TaskInfo taskInfo) {
List<TaskResultInfo> taskResultInfoList = new ArrayList<TaskResultInfo>();
ChangeTemplateRequest request = (ChangeTemplateRequest) inputRequest;
vpdcQueueProcess.setBillingSiteId(request.getBillingSiteId());
vpdcQueueProcess.setVpdcId(request.getVpdcId());
vpdcQueueProcess.setProcessName("ChangeTemplate");
vpdcQueueProcess.setProcessIdentifier("04");
VpdcDetail vpdcDetail = vpdcDetailDAO.findVpdcDtlLatestByVpdcId(request.getVpdcId());
if (null != vpdcDetail) {
vpdcQueueProcess.setProcessOwnerName(vpdcDetail.getVpdcName());
taskInfo.setOwnerReference(vpdcDetail.getVpdcName());
}
vpdcQueueProcessDAO.save(vpdcQueueProcess);
taskInfo.setProcessId(vpdcQueueProcess.getProcessId() + "");
taskInfo.setOrgId(request.getBillingSiteId());
taskInfo.setOwnerId(request.getVpdcId() + "");
taskInfo.setProcessName("ChangeTemplate");
if (null != request.getTemplate()) {
TaskResultInfo taskResultInfo = new TaskResultInfo();
taskResultInfo.setResultReference(request.getTemplate().getVAppTemplateCustHostName());
taskResultInfo.setResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
VpdcQueueProcessResult vpdcQueueProcessResult = new VpdcQueueProcessResult();
vpdcQueueProcessResult.setVpdcQueueProcess(vpdcQueueProcess);
vpdcQueueProcessResult.setProcessResultName(request.getTemplate().getVAppTemplateCustHostName());
vpdcQueueProcessResult.setProcessResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
vpdcQueueProcessResult.setProcessResultId(request.getTemplate().getTemplateId());
taskResultInfo.setResultReferenceId(request.getTemplate().getTemplateId() + "");
vpdcQueueProcessResultDAO.save(vpdcQueueProcessResult);
taskResultInfo.setResultId(vpdcQueueProcessResult.getId() + "");
taskResultInfoList.add(taskResultInfo);
}
taskInfo.getTaskResultInfo().addAll(taskResultInfoList);
}
private void putCloneVCloudTemplateRequestInQueue(Object inputRequest, VpdcQueueProcess vpdcQueueProcess, TaskInfo taskInfo) {
List<TaskResultInfo> taskResultInfoList = new ArrayList<TaskResultInfo>();
CloneVCloudTemplateRequest request = (CloneVCloudTemplateRequest) inputRequest;
vpdcQueueProcess.setProcessName("CloneVCloudTemplate");
vpdcQueueProcess.setProcessIdentifier("04");
VpdcDetail repoVpdcDetail = vpdcTemplateHelper.validateSourceAndTargetVpdc(request.getSourceVpdcId(), request.getTargetVpdcId());
if (null != repoVpdcDetail) {
vpdcQueueProcess.setBillingSiteId(repoVpdcDetail.getVpdc().getBillingsiteId());
vpdcQueueProcess.setVpdcId(repoVpdcDetail.getVpdc().getId());
taskInfo.setOrgId(repoVpdcDetail.getVpdc().getBillingsiteId());
taskInfo.setOwnerId(repoVpdcDetail.getVpdc().getId() + "");
}
VpdcDetail targetVpdcDetail = vpdcDetailDAO.findVpdcDtlLatestByVpdcId(request.getTargetVpdcId());
if (null != targetVpdcDetail) {
vpdcQueueProcess.setProcessOwnerName(targetVpdcDetail.getVpdcName());
taskInfo.setOwnerReference(targetVpdcDetail.getVpdcName());
}
vpdcQueueProcessDAO.save(vpdcQueueProcess);
taskInfo.setProcessId(vpdcQueueProcess.getProcessId() + "");
taskInfo.setProcessName("CloneVCloudTemplate");
TaskResultInfo taskResultInfo = new TaskResultInfo();
taskResultInfo.setResultReference(request.getTemplateName());
taskResultInfo.setResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
VpdcQueueProcessResult vpdcQueueProcessResult = new VpdcQueueProcessResult();
vpdcQueueProcessResult.setVpdcQueueProcess(vpdcQueueProcess);
vpdcQueueProcessResult.setProcessResultName(request.getTemplateName());
vpdcQueueProcessResult.setProcessResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
//todo
vpdcQueueProcessResult.setProcessResultId(0);
taskResultInfo.setResultReferenceId("");
vpdcQueueProcessResultDAO.save(vpdcQueueProcessResult);
taskResultInfo.setResultId(vpdcQueueProcessResult.getId() + "");
taskResultInfoList.add(taskResultInfo);
taskInfo.getTaskResultInfo().addAll(taskResultInfoList);
}
private void putSaveVCloudTemplateRequestInQueue(Object inputRequest, VpdcQueueProcess vpdcQueueProcess, TaskInfo taskInfo) {
List<TaskResultInfo> taskResultInfoList = new ArrayList<TaskResultInfo>();
SaveVCloudTemplateRequest request = (SaveVCloudTemplateRequest) inputRequest;
vpdcQueueProcess.setProcessName("SaveVCloudTemplate");
vpdcQueueProcess.setProcessIdentifier("04");
VpdcDetail repoVpdcDetail = vpdcTemplateHelper.validateSourceAndTargetVpdc(request.getSourceVpdcId(), request.getTargetVpdcId());
if (null != repoVpdcDetail) {
vpdcQueueProcess.setBillingSiteId(repoVpdcDetail.getVpdc().getBillingsiteId());
vpdcQueueProcess.setVpdcId(repoVpdcDetail.getVpdc().getId());
taskInfo.setOrgId(repoVpdcDetail.getVpdc().getBillingsiteId());
taskInfo.setOwnerId(repoVpdcDetail.getVpdc().getId() + "");
}
VpdcDetail targetVpdcDetail = vpdcDetailDAO.findVpdcDtlLatestByVpdcId(request.getTargetVpdcId());
if (null != targetVpdcDetail) {
vpdcQueueProcess.setProcessOwnerName(targetVpdcDetail.getVpdcName());
taskInfo.setOwnerReference(targetVpdcDetail.getVpdcName());
}
vpdcQueueProcessDAO.save(vpdcQueueProcess);
taskInfo.setProcessId(vpdcQueueProcess.getProcessId() + "");
taskInfo.setProcessName("SaveVCloudTemplate");
TaskResultInfo taskResultInfo = new TaskResultInfo();
taskResultInfo.setResultReference(request.getTemplateName());
taskResultInfo.setResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
VpdcQueueProcessResult vpdcQueueProcessResult = new VpdcQueueProcessResult();
vpdcQueueProcessResult.setVpdcQueueProcess(vpdcQueueProcess);
vpdcQueueProcessResult.setProcessResultName(request.getTemplateName());
vpdcQueueProcessResult.setProcessResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
//todo
vpdcQueueProcessResult.setProcessResultId(0);
taskResultInfo.setResultReferenceId("");
vpdcQueueProcessResultDAO.save(vpdcQueueProcessResult);
taskResultInfo.setResultId(vpdcQueueProcessResult.getId() + "");
taskResultInfoList.add(taskResultInfo);
taskInfo.getTaskResultInfo().addAll(taskResultInfoList);
}
private void putInstantiateVCloudTemplateRequestInQueue(Object inputRequest, VpdcQueueProcess vpdcQueueProcess, TaskInfo taskInfo) {
List<TaskResultInfo> taskResultInfoList = new ArrayList<TaskResultInfo>();
InstantiateVCloudTemplateRequest request = (InstantiateVCloudTemplateRequest) inputRequest;
List<InstantiateTemplateInfo> templateInfoListFromVCloud = request.getInstantiateTemplateList();
vpdcQueueProcess.setProcessName("InstantiateVCloudTemplate");
vpdcQueueProcess.setProcessIdentifier("04");
int targetVpdcId = request.getInstantiateTemplateList().get(0).getTargetVpdcId();
int sourceVpdcId = request.getInstantiateTemplateList().get(0).getSourceVpdcId();
VpdcDetail repoVpdcDetail = vpdcTemplateHelper.validateSourceAndTargetVpdc(sourceVpdcId, targetVpdcId);
if (null != repoVpdcDetail) {
vpdcQueueProcess.setBillingSiteId(repoVpdcDetail.getVpdc().getBillingsiteId());
vpdcQueueProcess.setVpdcId(repoVpdcDetail.getVpdc().getId());
taskInfo.setOrgId(repoVpdcDetail.getVpdc().getBillingsiteId());
taskInfo.setOwnerId(repoVpdcDetail.getVpdc().getId() + "");
}
YFilesConverter yFilesConverter = new YFilesConverter();
int nextGuiId = 0;
VpdcDetail targetVpdcDetail = vpdcDetailDAO.findVpdcDtlLatestByVpdcId(targetVpdcId);
if (null != targetVpdcDetail) {
vpdcQueueProcess.setProcessOwnerName(targetVpdcDetail.getVpdcName());
taskInfo.setOwnerReference(targetVpdcDetail.getVpdcName());
if (MWUtil.isNotEmptyString(targetVpdcDetail.getTransientYfiles())) {
yFilesConverter.loadGraphML(new ByteArrayInputStream(targetVpdcDetail.getTransientYfiles().getBytes()));
nextGuiId = yFilesConverter.getNewServerGuiId();
targetVpdcDetail.setTransientYfiles(yFilesConverter.getGraphML());
} else {
yFilesConverter.loadGraphML(new ByteArrayInputStream(targetVpdcDetail.getGuiXml().getBytes()));
nextGuiId = yFilesConverter.getNewServerGuiId();
targetVpdcDetail.setGuiXml(yFilesConverter.getGraphML());
}
vpdcDetailDAO.update(targetVpdcDetail);
}
vpdcQueueProcessDAO.save(vpdcQueueProcess);
taskInfo.setProcessId(vpdcQueueProcess.getProcessId() + "");
taskInfo.setProcessName("InstantiateVCloudTemplate");
for (InstantiateTemplateInfo templateInfoFromVCloud : templateInfoListFromVCloud) {
TaskResultInfo taskResultInfo = new TaskResultInfo();
taskResultInfo.setResultReference(templateInfoFromVCloud.getTargetComputeName());
taskResultInfo.setResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
VpdcQueueProcessResult vpdcQueueProcessResult = new VpdcQueueProcessResult();
vpdcQueueProcessResult.setVpdcQueueProcess(vpdcQueueProcess);
vpdcQueueProcessResult.setProcessResultName(templateInfoFromVCloud.getTargetComputeName());
vpdcQueueProcessResult.setProcessResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
vpdcQueueProcessResult.setProcessResultId(nextGuiId);
taskResultInfo.setResultReferenceId(nextGuiId + "");
nextGuiId++;
vpdcQueueProcessResultDAO.save(vpdcQueueProcessResult);
taskResultInfo.setResultId(vpdcQueueProcessResult.getId() + "");
taskResultInfoList.add(taskResultInfo);
}
taskInfo.getTaskResultInfo().addAll(taskResultInfoList);
}
private void putCloneVCloudvAppRequestInQueue(Object inputRequest, VpdcQueueProcess vpdcQueueProcess, TaskInfo taskInfo) {
List<TaskResultInfo> taskResultInfoList = new ArrayList<TaskResultInfo>();
YFilesConverter yFilesConverter = new YFilesConverter();
int nextGuiId = 0;
CloneVCloudvAppRequest request = (CloneVCloudvAppRequest) inputRequest;
vpdcQueueProcess.setBillingSiteId(request.getSourceBillingSiteid());
vpdcQueueProcess.setVpdcId(request.getSourceVpdcId());
vpdcQueueProcess.setProcessName("CloneVCloudvApp");
vpdcQueueProcess.setProcessIdentifier("04");
VpdcDetail vpdcDetail = vpdcDetailDAO.findVpdcDtlLatestByVpdcId(request.getSourceVpdcId());
if (null != vpdcDetail) {
vpdcQueueProcess.setProcessOwnerName(vpdcDetail.getVpdcName());
taskInfo.setOwnerReference(vpdcDetail.getVpdcName());
setGuiXML(vpdcDetail, vpdcQueueProcess, request);
if (MWUtil.isNotEmptyString(vpdcDetail.getTransientYfiles())) {
yFilesConverter.loadGraphML(new ByteArrayInputStream(vpdcDetail.getTransientYfiles().getBytes()));
nextGuiId = yFilesConverter.getNewServerGuiId();
vpdcDetail.setTransientYfiles(yFilesConverter.getGraphML());
} else {
yFilesConverter.loadGraphML(new ByteArrayInputStream(vpdcDetail.getGuiXml().getBytes()));
nextGuiId = yFilesConverter.getNewServerGuiId();
vpdcQueueProcess.setGuiXml(yFilesConverter.getGraphML());
}
vpdcDetailDAO.update(vpdcDetail);
}
vpdcQueueProcessDAO.save(vpdcQueueProcess);
taskInfo.setProcessId(vpdcQueueProcess.getProcessId() + "");
taskInfo.setOrgId(request.getTargetBillingSiteid());
taskInfo.setOwnerId(request.getTargetVpdcId() + "");
taskInfo.setProcessName("CloneVCloudvApp");
TaskResultInfo taskResultInfo = new TaskResultInfo();
taskResultInfo.setResultStatus("queued");
VpdcQueueProcessResult vpdcQueueProcessResult = new VpdcQueueProcessResult();
vpdcQueueProcessResult.setVpdcQueueProcess(vpdcQueueProcess);
vpdcQueueProcessResult.setProcessResultStatus("queued");
vpdcQueueProcessResultDAO.save(vpdcQueueProcessResult);
taskResultInfo.setResultId(vpdcQueueProcessResult.getId() + "");
taskResultInfoList.add(taskResultInfo);
taskInfo.getTaskResultInfo().addAll(taskResultInfoList);
}
private void putCloneVCloudMultiplevAppRequestInQueue(Object inputRequest, VpdcQueueProcess vpdcQueueProcess, TaskInfo taskInfo) {
List<TaskResultInfo> taskResultInfoList = new ArrayList<TaskResultInfo>();
YFilesConverter yFilesConverter = new YFilesConverter();
int nextGuiId = 0;
CloneVCloudMultiplevAppRequest request = (CloneVCloudMultiplevAppRequest) inputRequest;
List<CloneVCloudMultiplevAppsInfo> cloneVCloudMultiplevAppsInfoList = request.getTargetvApps();
for (int i = 0; i < cloneVCloudMultiplevAppsInfoList.size(); i++) {
vpdcQueueProcess.setBillingSiteId(cloneVCloudMultiplevAppsInfoList.get(i).getSourceBillingSiteid());
vpdcQueueProcess.setVpdcId(cloneVCloudMultiplevAppsInfoList.get(i).getSourceVpdcId());
vpdcQueueProcess.setProcessName("CloneVCloudMultiplevApp");
vpdcQueueProcess.setProcessIdentifier("05");
VpdcDetail vpdcDetail = vpdcDetailDAO.findVpdcDtlLatestByVpdcId(cloneVCloudMultiplevAppsInfoList.get(i).getSourceVpdcId());
if (null != vpdcDetail) {
vpdcQueueProcess.setProcessOwnerName(vpdcDetail.getVpdcName());
taskInfo.setOwnerReference(vpdcDetail.getVpdcName());
setGuiXML(vpdcDetail, vpdcQueueProcess, request);
if (MWUtil.isNotEmptyString(vpdcDetail.getTransientYfiles())) {
yFilesConverter.loadGraphML(new ByteArrayInputStream(vpdcDetail.getTransientYfiles().getBytes()));
nextGuiId = yFilesConverter.getNewServerGuiId();
vpdcDetail.setTransientYfiles(yFilesConverter.getGraphML());
} else {
yFilesConverter.loadGraphML(new ByteArrayInputStream(vpdcDetail.getGuiXml().getBytes()));
nextGuiId = yFilesConverter.getNewServerGuiId();
vpdcQueueProcess.setGuiXml(yFilesConverter.getGraphML());
}
vpdcDetailDAO.update(vpdcDetail);
}
vpdcQueueProcessDAO.save(vpdcQueueProcess);
taskInfo.setProcessId(vpdcQueueProcess.getProcessId() + "");
taskInfo.setOrgId(cloneVCloudMultiplevAppsInfoList.get(i).getTargetBillingSiteid());
taskInfo.setOwnerId(cloneVCloudMultiplevAppsInfoList.get(i).getTargetVpdcId() + "");
taskInfo.setProcessName("CloneVCloudMultiplevApp");
TaskResultInfo taskResultInfo = new TaskResultInfo();
taskResultInfo.setResultStatus("queued");
VpdcQueueProcessResult vpdcQueueProcessResult = new VpdcQueueProcessResult();
vpdcQueueProcessResult.setVpdcQueueProcess(vpdcQueueProcess);
vpdcQueueProcessResult.setProcessResultStatus("queued");
vpdcQueueProcessResultDAO.save(vpdcQueueProcessResult);
taskResultInfo.setResultId(vpdcQueueProcessResult.getId() + "");
taskResultInfoList.add(taskResultInfo);
taskInfo.getTaskResultInfo().addAll(taskResultInfoList);
}
}
/**
* Method convertRequestResponseToString ...
*
* @param request of type Object
* @return String
*/
public String convertRequestResponseToString(Object request) {
StringBuilder design = new StringBuilder();
try {
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
Result result = new StreamResult(outStream);
marshaller.marshal(request, result);
ByteArrayInputStream metaDataInput = new ByteArrayInputStream(outStream.toByteArray());
InputStreamReader reader = new InputStreamReader(metaDataInput);
BufferedReader bReader = new BufferedReader(reader);
String readLine = "";
while ((readLine = bReader.readLine()) != null) {
design.append(readLine).append("\n");
}
} catch (IOException ex) {
log.error("IOException occured in VPDCQueueProcessPreEngine.convertRequestResponseToString:" + ex.getMessage(), ex);
} catch (Exception ex) {
log.error("Exception occured in VPDCQueueProcessPreEngine.convertRequestResponseToString:" + ex.getMessage(), ex);
}
return design.toString();
}
private void putFWOperationRequestInQueue(Object inputRequest, VpdcQueueProcess vpdcQueueProcess, TaskInfo taskInfo) {
List<TaskResultInfo> taskResultInfoList = new ArrayList<TaskResultInfo>();
YFilesConverter yFilesConverter = new YFilesConverter();
FirewallRequest request = (FirewallRequest) inputRequest;
vpdcQueueProcess.setBillingSiteId(request.getBillingsiteId());
vpdcQueueProcess.setVpdcId(request.getVpdcId());
vpdcQueueProcess.setProcessName("FWOperation");
vpdcQueueProcess.setProcessIdentifier("03");
VpdcDetail vpdcDetail = vpdcDetailDAO.findVpdcDtlLatestByVpdcId(request.getVpdcId());
if (null != vpdcDetail) {
vpdcQueueProcess.setProcessOwnerName(vpdcDetail.getVpdcName());
taskInfo.setOwnerReference(vpdcDetail.getVpdcName());
setGuiXML(vpdcDetail, vpdcQueueProcess, request);
}
vpdcQueueProcessDAO.save(vpdcQueueProcess);
taskInfo.setProcessId(vpdcQueueProcess.getProcessId() + "");
taskInfo.setOrgId(request.getBillingsiteId());
taskInfo.setOwnerId(request.getVpdcId() + "");
if (null != request.getPfwRules().getPfwRules() && request.getPfwRules().getPfwRules().size() > 0) {
taskInfo.setProcessName("PFWOperation");
for (VCloudFirewallRule vCloudFirewallRule : request.getPfwRules().getPfwRules()) {
TaskResultInfo taskResultInfo = new TaskResultInfo();
taskResultInfo.setResultReference("");
taskResultInfo.setResultStatus("queued");
VpdcQueueProcessResult vpdcQueueProcessResult = new VpdcQueueProcessResult();
vpdcQueueProcessResult.setVpdcQueueProcess(vpdcQueueProcess);
vpdcQueueProcessResult.setProcessResultName("");
vpdcQueueProcessResult.setProcessResultStatus("queued");
vpdcQueueProcessResult.setProcessResultId(0);
vpdcQueueProcessResultDAO.save(vpdcQueueProcessResult);
taskResultInfo.setResultId(vpdcQueueProcessResult.getId() + "");
taskResultInfoList.add(taskResultInfo);
}
}
if (null != request.getPfwRules().getPfwRules() && request.getStwfRules().getStwfRules().size() > 0) {
taskInfo.setProcessName("STFWOperation");
for (VCloudFirewallRule vCloudFirewallRule : request.getStwfRules().getStwfRules()) {
TaskResultInfo taskResultInfo = new TaskResultInfo();
taskResultInfo.setResultReference("");
taskResultInfo.setResultStatus("queued");
VpdcQueueProcessResult vpdcQueueProcessResult = new VpdcQueueProcessResult();
vpdcQueueProcessResult.setVpdcQueueProcess(vpdcQueueProcess);
vpdcQueueProcessResult.setProcessResultName("");
vpdcQueueProcessResult.setProcessResultStatus("queued");
vpdcQueueProcessResult.setProcessResultId(0);
vpdcQueueProcessResultDAO.save(vpdcQueueProcessResult);
taskResultInfo.setResultId(vpdcQueueProcessResult.getId() + "");
taskResultInfoList.add(taskResultInfo);
}
}
taskInfo.getTaskResultInfo().addAll(taskResultInfoList);
}
private void setGuiXML(VpdcDetail vpdcDetail, VpdcQueueProcess vpdcQueueProcess, CloneVCloudMultiplevAppRequest request) {
}
private void setGuiXML(VpdcDetail vpdcDetail, VpdcQueueProcess vpdcQueueProcess, CloneVCloudvAppRequest request) {
migrationDHCPInfo(vpdcDetail, vpdcQueueProcess, request.getSourceVpdcId());
}
private void migrationDHCPInfo(VpdcDetail vpdcDetail, VpdcQueueProcess vpdcQueueProcess, int VpdcId) {
Map<Integer, String[]> cloneVMInfo = getClonedVMInfo(vpdcDetail.getId(), VpdcId);
List<Integer> guiIdList = new ArrayList<Integer>();
String apiName = Thread.currentThread().getStackTrace()[1].getMethodName();
String vpdcFinalXML = vpdcDetail.getDesignFinalXml().replaceAll("(\r\n|\r|\n|\n\r)", "");
VPDCServiceDesign vpdcServiceDesign = objectConverter.convertStringToDesign(vpdcFinalXML);
// retrieve a list of VMs defined inside yfiles
Computes computes = vpdcServiceDesign.getComputes();
for (Compute compute : computes.getCompute()) {
guiIdList.add(compute.getGuiId());
if (null != cloneVMInfo.get(compute.getGuiId()) && MWConstants.TRUE.equalsIgnoreCase(vpdcDetail.getVpdc().getUseDhcpForCloneTemplate())) {
compute.setDhcp(true);
} else {
compute.setDhcp(false);
// compute.sets
}
}
if (MWUtil.isNotEmptyString(vpdcDetail.getGuiXml())) {
YFilesConverter yFilesConverter = new YFilesConverter();
yFilesConverter.loadGraphML(new ByteArrayInputStream(vpdcDetail.getGuiXml().getBytes()));
VPDCSpec vpdcSpec = yFilesConverter.getVPDCSpec();
List<ServerDataObject> serverList = vpdcSpec.getServers();
for (ServerDataObject vm : serverList) {
if (guiIdList.contains(vm.getGuiId())) {
if (null != cloneVMInfo.get(vm.getGuiId()) && MWConstants.TRUE.equalsIgnoreCase(vpdcDetail.getVpdc().getUseDhcpForCloneTemplate())) {
vm.setDHCP(true);
} else {
vm.setDHCP(false);
}
yFilesConverter.updateCustomObject(vm);
}
}
vpdcQueueProcess.setGuiXml(yFilesConverter.getGraphML());
}
}
private Map<Integer, String[]> getClonedVMInfo(int vpdcSessionId,int vpdcId) {
Map<Integer,String[]> cloneVMInfo = new HashMap<Integer,String[]>();
VpdcDetail vpdcDetail = null;
List<VpdcDetail> vpdcDetails = null;
if (0 == vpdcId && 0 != vpdcSessionId) {
vpdcDetail = vpdcDetailDAO.findById(vpdcSessionId);
vpdcDetails = vpdcDetailDAO.findVpdcDetailByVpdcIdAndOperation(vpdcDetail.getVpdc().getId(), OperationEnum.CloneVM);
} else if (0 != vpdcId && 0 == vpdcSessionId) {
vpdcDetails = vpdcDetailDAO.findVpdcDetailByVpdcIdAndOperation(vpdcId, OperationEnum.CloneVM);
}
if(!vpdcDetails.isEmpty()) {
for (VpdcDetail detail : vpdcDetails) {
YFilesConverter yFilesConverter = new YFilesConverter();
yFilesConverter.loadGraphML(new ByteArrayInputStream(detail.getGuiXml().getBytes()));
if (detail.getSpecXml() != null) {
for (String custHostName : getClonedVMFromSpecXML(detail.getSpecXml())) {
ServerDataObject serverDataObject = VCloudHelper.getInstance().getYComputeByComputeCustHostName(yFilesConverter.
getVPDCSpec(), custHostName);
cloneVMInfo.put(serverDataObject.getGuiId(),
new String[]{custHostName, serverDataObject.getNodeStatus()});
}
}
}
}
log.info("The return CloneVM info is : " + cloneVMInfo.toString());
return cloneVMInfo;
}
private List<String> getClonedVMFromSpecXML(String specXML){
XMLEventReader eventReader = null;
List<String> cloneVMInfo = new ArrayList<String>();
StringReader stringReader = new StringReader(specXML);
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
String apiName = Thread.currentThread().getStackTrace()[1].getMethodName();
try {
boolean inTargetCompute = false;
eventReader = inputFactory.createXMLEventReader(stringReader);
while (eventReader.hasNext()) {
XMLEvent event = eventReader.nextEvent();
if (event.isStartElement()) {
StartElement startElement = event.asStartElement();
String localPart = startElement.getName().getLocalPart();
if ("targetCompute".equals(localPart)) {
inTargetCompute = true;
} else if (inTargetCompute && "custHostname".equals(localPart)) {
cloneVMInfo.add(eventReader.getElementText());
inTargetCompute = false;
}
}
}
} catch (Exception e) {
throw new SystemException(e.getMessage(), e);
} finally {
if (eventReader != null) {
try {
eventReader.close();
} catch (Exception e) {
}
}
}
return cloneVMInfo;
}
private void setGuiXML(VpdcDetail vpdcDetail, VpdcQueueProcess vpdcQueueProcess, FirewallRequest request) {
log.info("create a new gui xml for getFirewall api");
YFilesConverter yFilesConverter = new YFilesConverter();
List<FWRule> pfwRules = null;
List<SFWRule> stfwRules = null;
List<VCloudFirewallRule> vCloudPfwRules = null;
List<VCloudFirewallRule> vCloudStfwRules = null;
if (MWUtil.isNotEmptyString(vpdcDetail.getGuiXml())) {
yFilesConverter.loadGraphML(new ByteArrayInputStream(vpdcDetail.getGuiXml().getBytes()));
VPDCSpec vpdcSpec = yFilesConverter.getVPDCSpec();
PerimeterFWDataObject perimeterFWDataObject = vpdcSpec.getPerimeterFW();
SFWDataObject sfwDataObject = vpdcSpec.getServerTierFW();
if (null != vpdcSpec && null != vpdcSpec.getPerimeterFW().getFwRules() && vpdcSpec.getPerimeterFW().getFwRules().size() > 0) {
pfwRules = perimeterFWDataObject.getFwRules();
}
if (null != vpdcSpec && null != vpdcSpec.getServerTierFW().getSFwRules() && vpdcSpec.getServerTierFW().getSFwRules().size() > 0) {
stfwRules = sfwDataObject.getSFwRules();
}
vCloudPfwRules = request.getPfwRules().getPfwRules();
vCloudStfwRules = request.getStwfRules().getStwfRules();
if (null != vCloudPfwRules && vCloudStfwRules.size() > 0) {
for (VCloudFirewallRule vCloudFirewallRule : vCloudPfwRules) {
FWRule fwRule = new FWRule();
fwRule.setAction(vCloudFirewallRule.getAction().toString());
fwRule.setDestination(vCloudFirewallRule.getDestination());
fwRule.setDestinationPort(vCloudFirewallRule.getDestinationPort());
fwRule.setLog(vCloudFirewallRule.getLog().toString());
fwRule.setNodeStatus(vCloudFirewallRule.getStatus());
fwRule.setProtocol(vCloudFirewallRule.getProtocol());
fwRule.setSource(vCloudFirewallRule.getSource());
pfwRules.add(fwRule);
}
}
if (null != vCloudStfwRules && vCloudStfwRules.size() > 0) {
for (VCloudFirewallRule vCloudFirewallRule : vCloudStfwRules) {
SFWRule fwRule = new SFWRule();
fwRule.setAction(vCloudFirewallRule.getAction().toString());
fwRule.setDestination(vCloudFirewallRule.getDestination());
fwRule.setDestinationPort(vCloudFirewallRule.getDestinationPort());
fwRule.setLog(vCloudFirewallRule.getLog().toString());
fwRule.setNodeStatus(vCloudFirewallRule.getStatus());
fwRule.setProtocol(vCloudFirewallRule.getProtocol());
fwRule.setSource(vCloudFirewallRule.getSource());
stfwRules.add(fwRule);
}
}
perimeterFWDataObject.setFwRules(pfwRules);
sfwDataObject.setSFwRules(stfwRules);
yFilesConverter.updateCustomObject(perimeterFWDataObject);
yFilesConverter.updateCustomObject(sfwDataObject);
String newGuiXML = yFilesConverter.getGraphML();
log.info("new gui xml generated++++++++" + newGuiXML);
vpdcQueueProcess.setGuiXml(newGuiXML);
}
}
private void putDetachVMDKRequestInQueue(Object inputRequest, VpdcQueueProcess vpdcQueueProcess, TaskInfo taskInfo) {
List<TaskResultInfo> taskResultInfoList = new ArrayList<TaskResultInfo>();
DetachVCloudVMDKRequest request = (DetachVCloudVMDKRequest) inputRequest;
vpdcQueueProcess.setBillingSiteId(request.getSourceBillingSiteid());
vpdcQueueProcess.setVpdcId(request.getSourceVpdcId());
vpdcQueueProcess.setProcessName("DetachVCloudVMDK");
vpdcQueueProcess.setProcessIdentifier("02");
VpdcDetail vpdcDetail = vpdcDetailDAO.findVpdcDtlLatestByVpdcId(request.getSourceVpdcId());
if (null != vpdcDetail) {
vpdcQueueProcess.setProcessOwnerName(vpdcDetail.getVpdcName());
taskInfo.setOwnerReference(vpdcDetail.getVpdcName());
}
vpdcQueueProcessDAO.save(vpdcQueueProcess);
taskInfo.setProcessId(String.valueOf(vpdcQueueProcess.getProcessId()));
taskInfo.setOrgId(request.getSourceBillingSiteid());
taskInfo.setOwnerId(String.valueOf(request.getSourceVpdcId()));
taskInfo.setProcessName("DetachVCloudVMDK");
TaskResultInfo taskResultInfo = new TaskResultInfo();
taskResultInfo.setResultReference(request.getLabelName());
taskResultInfo.setResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
VpdcQueueProcessResult vpdcQueueProcessResult = new VpdcQueueProcessResult();
vpdcQueueProcessResult.setVpdcQueueProcess(vpdcQueueProcess);
vpdcQueueProcessResult.setProcessResultName(request.getLabelName());
vpdcQueueProcessResult.setProcessResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
vpdcQueueProcessResult.setProcessResultId(request.getSourceVMDKciid());
taskResultInfo.setResultReferenceId(String.valueOf(request.getSourceVMDKciid()));
vpdcQueueProcessResultDAO.save(vpdcQueueProcessResult);
taskResultInfo.setResultId(String.valueOf(vpdcQueueProcessResult.getId()));
taskResultInfoList.add(taskResultInfo);
taskInfo.getTaskResultInfo().addAll(taskResultInfoList);
}
private void putAttachVMDKRequestInQueue(Object inputRequest, VpdcQueueProcess vpdcQueueProcess, TaskInfo taskInfo) {
List<TaskResultInfo> taskResultInfoList = new ArrayList<TaskResultInfo>();
AttachVCloudVMDKRequest request = (AttachVCloudVMDKRequest) inputRequest;
vpdcQueueProcess.setBillingSiteId(request.getSourceBillingSiteid());
vpdcQueueProcess.setVpdcId(request.getSourceVpdcId());
vpdcQueueProcess.setProcessName("AttachVCloudVMDK");
vpdcQueueProcess.setProcessIdentifier("02");
VpdcDetail vpdcDetail = vpdcDetailDAO.findVpdcDtlLatestByVpdcId(request.getSourceVpdcId());
if (null != vpdcDetail) {
vpdcQueueProcess.setProcessOwnerName(vpdcDetail.getVpdcName());
taskInfo.setOwnerReference(vpdcDetail.getVpdcName());
}
vpdcQueueProcessDAO.save(vpdcQueueProcess);
taskInfo.setProcessId(String.valueOf(vpdcQueueProcess.getProcessId()));
taskInfo.setOrgId(request.getSourceBillingSiteid());
taskInfo.setOwnerId(String.valueOf(request.getSourceVpdcId()));
taskInfo.setProcessName("AttachVCloudVMDK");
TaskResultInfo taskResultInfo = new TaskResultInfo();
taskResultInfo.setResultReference(request.getTargetMountPointName());
taskResultInfo.setResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
VpdcQueueProcessResult vpdcQueueProcessResult = new VpdcQueueProcessResult();
vpdcQueueProcessResult.setVpdcQueueProcess(vpdcQueueProcess);
vpdcQueueProcessResult.setProcessResultName(request.getTargetMountPointName());
vpdcQueueProcessResult.setProcessResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
vpdcQueueProcessResult.setProcessResultId(request.getSourceVMDKciid());
taskResultInfo.setResultReferenceId(String.valueOf(request.getSourceVMDKciid()));
vpdcQueueProcessResultDAO.save(vpdcQueueProcessResult);
taskResultInfo.setResultId(String.valueOf(vpdcQueueProcessResult.getId()));
taskResultInfoList.add(taskResultInfo);
taskInfo.getTaskResultInfo().addAll(taskResultInfoList);
}
private void putDeleteVMDKRequestInQueue(Object inputRequest, VpdcQueueProcess vpdcQueueProcess, TaskInfo taskInfo) {
String driveName = "";
List<TaskResultInfo> taskResultInfoList = new ArrayList<TaskResultInfo>();
DeleteVCloudVMDKRequest request = (DeleteVCloudVMDKRequest) inputRequest;
vpdcQueueProcess.setBillingSiteId(request.getSourceBillingSiteid());
vpdcQueueProcess.setVpdcId(request.getSourceVpdcId());
vpdcQueueProcess.setProcessName("DeleteVCloudVMDK");
vpdcQueueProcess.setProcessIdentifier("02");
VpdcDetail vpdcDetail = vpdcDetailDAO.findVpdcDtlLatestByVpdcId(request.getSourceVpdcId());
if (null != vpdcDetail) {
vpdcQueueProcess.setProcessOwnerName(vpdcDetail.getVpdcName());
taskInfo.setOwnerReference(vpdcDetail.getVpdcName());
String vpdcFinalXML = vpdcDetail.getDesignFinalXml().replaceAll("(\r\n|\r|\n|\n\r)", "");
Drive drive = objectConverter.getDriveByVMDKCiIdFromFinal(request.getSourceVMDKciid(), vpdcFinalXML);
driveName = drive.getMount();
}
vpdcQueueProcessDAO.save(vpdcQueueProcess);
taskInfo.setProcessId(String.valueOf(vpdcQueueProcess.getProcessId()));
taskInfo.setOrgId(request.getSourceBillingSiteid());
taskInfo.setOwnerId(String.valueOf(request.getSourceVpdcId()));
taskInfo.setProcessName("DeleteVCloudVMDK");
TaskResultInfo taskResultInfo = new TaskResultInfo();
taskResultInfo.setResultReference(String.valueOf(request.getSourceVMDKciid()));
taskResultInfo.setResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
VpdcQueueProcessResult vpdcQueueProcessResult = new VpdcQueueProcessResult();
vpdcQueueProcessResult.setVpdcQueueProcess(vpdcQueueProcess);
vpdcQueueProcessResult.setProcessResultName(driveName);
vpdcQueueProcessResult.setProcessResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
vpdcQueueProcessResult.setProcessResultId(request.getSourceVMDKciid());
taskResultInfo.setResultReferenceId(String.valueOf(request.getSourceVMDKciid()));
vpdcQueueProcessResultDAO.save(vpdcQueueProcessResult);
taskResultInfo.setResultId(String.valueOf(vpdcQueueProcessResult.getId()));
taskResultInfoList.add(taskResultInfo);
taskInfo.getTaskResultInfo().addAll(taskResultInfoList);
}
private void putCloneVMDKRequestInQueue(Object inputRequest, VpdcQueueProcess vpdcQueueProcess, TaskInfo taskInfo) {
List<TaskResultInfo> taskResultInfoList = new ArrayList<TaskResultInfo>();
CloneVCloudVMDKRequest request = (CloneVCloudVMDKRequest) inputRequest;
vpdcQueueProcess.setBillingSiteId(request.getSourceBillingSiteid());
vpdcQueueProcess.setVpdcId(request.getSourceVpdcId());
vpdcQueueProcess.setProcessName("CloneVCloudVMDK");
vpdcQueueProcess.setProcessIdentifier("02");
VpdcDetail vpdcDetail = vpdcDetailDAO.findVpdcDtlLatestByVpdcId(request.getSourceVpdcId());
if (null != vpdcDetail) {
vpdcQueueProcess.setProcessOwnerName(vpdcDetail.getVpdcName());
taskInfo.setOwnerReference(vpdcDetail.getVpdcName());
}
vpdcQueueProcessDAO.save(vpdcQueueProcess);
taskInfo.setProcessId(String.valueOf(vpdcQueueProcess.getProcessId()));
taskInfo.setOrgId(request.getSourceBillingSiteid());
taskInfo.setOwnerId(String.valueOf(request.getSourceVpdcId()));
taskInfo.setProcessName("CloneVCloudVMDK");
TaskResultInfo taskResultInfo = new TaskResultInfo();
taskResultInfo.setResultReference(request.getLabelName());
taskResultInfo.setResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
VpdcQueueProcessResult vpdcQueueProcessResult = new VpdcQueueProcessResult();
vpdcQueueProcessResult.setVpdcQueueProcess(vpdcQueueProcess);
vpdcQueueProcessResult.setProcessResultName(request.getLabelName());
vpdcQueueProcessResult.setProcessResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
vpdcQueueProcessResultDAO.save(vpdcQueueProcessResult);
taskResultInfo.setResultId(String.valueOf(vpdcQueueProcessResult.getId()));
taskResultInfoList.add(taskResultInfo);
taskInfo.getTaskResultInfo().addAll(taskResultInfoList);
}
}
import javax.persistence.*;
import static javax.persistence.GenerationType.IDENTITY;
@Entity
@Table(name = "validation_message")
public class ValidationMessageMapping implements java.io.Serializable {
private Integer id;
private String mwCase;
private String mwType;
private String message;
private String apiMessage;
private Integer moduleCode;
private Integer categorymoduleCode;
private Integer componentmoduleCode;
private Integer errorCode;
private Integer httpCode;
private String status;
public ValidationMessageMapping() {
}
public ValidationMessageMapping(Integer id, String mwCase, String apiMessage, String message, Integer moduleCode, Integer httpCode, String mwType, Integer categorymoduleCode, Integer componentmoduleCode, String status) {
this.id = id;
this.mwCase = mwCase;
this.apiMessage = apiMessage;
this.message = message;
this.moduleCode = moduleCode;
this.httpCode = httpCode;
this.mwType = mwType;
this.categorymoduleCode = categorymoduleCode;
this.componentmoduleCode = componentmoduleCode;
this.status = status;
}
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
@Column(name = "mw_case", length = 200, nullable = false)
public String getMwCase() {
return mwCase;
}
public void setMwCase(String mwCase) {
this.mwCase = mwCase;
}
@Column(name = "mw_type", length = 200)
public String getMwType() {
return mwType;
}
public void setMwType(String mwType) {
this.mwType = mwType;
}
@Column(name = "message", nullable = false)
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
@Column(name = "api_message")
public String getApiMessage() {
return apiMessage;
}
public void setApiMessage(String apiMessage) {
this.apiMessage = apiMessage;
}
@Column(name = "module_code", length = 10, nullable = false)
public Integer getModuleCode() {
return moduleCode;
}
public void setModuleCode(Integer moduleCode) {
this.moduleCode = moduleCode;
}
@Column(name = "category_code", length = 10, nullable = false)
public Integer getCategorymoduleCode() {
return categorymoduleCode;
}
public void setCategorymoduleCode(Integer categorymoduleCode) {
this.categorymoduleCode = categorymoduleCode;
}
@Column(name = "component_code", length = 10, nullable = false)
public Integer getComponentmoduleCode() {
return componentmoduleCode;
}
public void setComponentmoduleCode(Integer componentmoduleCode) {
this.componentmoduleCode = componentmoduleCode;
}
@Column(name = "error_code", length = 10, nullable = false)
public Integer geterrorCode() {
return errorCode;
}
public void seterrorCode(Integer errorCode) {
this.errorCode = errorCode;
}
@Column(name = "http_code", length = 10)
public Integer gethttpCode() {
return httpCode;
}
public void sethttpCode(Integer httpCode) {
this.httpCode = httpCode;
}
@Column(name = "status", length = 50)
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
@Override
public String toString() {
return "ValidationMessageMapping{" +
"id=" + id +
", mwCase='" + mwCase + '\'' +
", message='" + message + '\'' +
", apiMessage='" + apiMessage + '\'' +
", modulemoduleCode=" + moduleCode +
", httpCode=" + httpCode +
", categorymoduleCode=" + categorymoduleCode +
", componentmoduleCode=" + componentmoduleCode +
", errorCode=" + errorCode +
", mwType='" + mwType + '\'' +
'}';
}
}
********************************************
package com.savvis.spirits.services.queue.process;
import com.savvis.spirits.businessmodel.servicedesign.Compute;
import com.savvis.spirits.businessmodel.servicedesign.Computes;
import com.savvis.spirits.businessmodel.servicedesign.Drive;
import com.savvis.spirits.businessmodel.servicedesign.VPDCServiceDesign;
import com.savvis.spirits.common.exceptions.SystemException;
import com.savvis.spirits.common.utils.MWConstants;
import com.savvis.spirits.common.utils.MWUtil;
import com.savvis.spirits.dao.VpdcDetailDAO;
import com.savvis.spirits.dao.VpdcQueueProcessDAO;
import com.savvis.spirits.dao.VpdcQueueProcessResultDAO;
import com.savvis.spirits.domain.*;
import com.savvis.spirits.domain.enums.OperationEnum;
import com.savvis.spirits.domain.enums.VpdcQueueProcessStatusEnum;
import com.savvis.spirits.integration.schemas.queueprocess.*;
import com.savvis.spirits.services.xml.parser.ObjectConverter;
import com.savvis.spirits.vcloud.header.VCloudHeader;
import com.savvis.spirits.vcloud.header.VCloudHeaderHolder;
import com.savvis.spirits.vcloud.header.VCloudUser;
import com.savvis.spirits.vcloud.helper.VpdcTemplateHelper;
import com.savvis.spirits.vcloud.proxy.RestProxyAuthenticationService;
import com.savvis.spirits.vcloud.wrapper.VCloudHelper;
import com.savvis.spirits.yfilesconverter.YFilesConverter;
import com.savvis.spirits.yfilesconverter.dataobjects.*;
import java.util.*;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.oxm.jaxb.Jaxb2Marshaller;
import org.springframework.stereotype.Service;
import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName;
import javax.xml.transform.Result;
import javax.xml.transform.stream.StreamResult;
import java.io.*;
/**
* Created by IntelliJ IDEA.
* User: ramesh.rajaram
* Date: Jan 12, 2011
* Time: 1:36:38 PM
* To change this template use File | Settings | File Templates.
*/
@Service("vpdcQueueProcessPreEngine")
public class VPDCQueueProcessPreEngine {
private static final Logger log = Logger.getLogger(VPDCQueueProcessPreEngine.class);
@Autowired
VpdcDetailDAO vpdcDetailDAO;
@Autowired
private ObjectConverter objectConverter;
@Autowired
VpdcQueueProcessDAO vpdcQueueProcessDAO;
@Autowired
VpdcQueueProcessResultDAO vpdcQueueProcessResultDAO;
@Autowired
private RestProxyAuthenticationService restProxyAuthenticationService;
@Autowired
@Qualifier("marshaller")
protected Jaxb2Marshaller marshaller;
@Autowired
private VpdcTemplateHelper vpdcTemplateHelper;
public VPDCQueueProcessPreEngine() {
}
public VPDCQueueProcessPreEngine(Object inputRequest, String vpdcCompType) {
addToQueue(inputRequest, vpdcCompType);
}
public TaskInfo addToQueue(Object inputRequest, String vpdcCompType) {
VCloudHeader vCloudHeader = VCloudHeaderHolder.getVcloudHeader();
VCloudUser vCloudUser = restProxyAuthenticationService.getVCloudUser(vCloudHeader.getToken());
//insert record to VPDCQueueProcess
VpdcQueueProcess vpdcQueueProcess = new VpdcQueueProcess();
vpdcQueueProcess.setCreatedBy(vCloudUser.getUserId());
vpdcQueueProcess.setCreateTime(new Date());
vpdcQueueProcess.setProcessType(vpdcCompType);
vpdcQueueProcess.setStatus(VpdcQueueProcessStatusEnum.QUEUED);
vpdcQueueProcess.setInput(convertRequestResponseToString(inputRequest));
TaskInfo taskInfo = new TaskInfo();
taskInfo.setProcessType(vpdcCompType);
taskInfo.setTaskStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
if (inputRequest instanceof VMOperationRequest) {
putVMOperationRequestInQueue(inputRequest, vpdcQueueProcess, taskInfo);
} else if (inputRequest instanceof ChangeTemplateRequest) {
putChangeTemplateRequestInQueue(inputRequest, vpdcQueueProcess, taskInfo);
} else if (inputRequest instanceof CloneVCloudTemplateRequest) {
putCloneVCloudTemplateRequestInQueue(inputRequest, vpdcQueueProcess, taskInfo);
} else if (inputRequest instanceof SaveVCloudTemplateRequest) {
putSaveVCloudTemplateRequestInQueue(inputRequest, vpdcQueueProcess, taskInfo);
} else if (inputRequest instanceof InstantiateVCloudTemplateRequest) {
putInstantiateVCloudTemplateRequestInQueue(inputRequest, vpdcQueueProcess, taskInfo);
} else if (inputRequest instanceof FirewallRequest) {
putFWOperationRequestInQueue(inputRequest, vpdcQueueProcess, taskInfo);
} else if (inputRequest instanceof CloneVCloudvAppRequest) {
putCloneVCloudvAppRequestInQueue(inputRequest, vpdcQueueProcess, taskInfo);
} else if (inputRequest instanceof CloneVCloudMultiplevAppRequest) {
putCloneVCloudMultiplevAppRequestInQueue(inputRequest, vpdcQueueProcess, taskInfo);
} else if (inputRequest instanceof DetachVCloudVMDKRequest) {
putDetachVMDKRequestInQueue(inputRequest, vpdcQueueProcess, taskInfo);
} else if (inputRequest instanceof DeleteVCloudVMDKRequest) {
putDeleteVMDKRequestInQueue(inputRequest, vpdcQueueProcess, taskInfo);
} else if (inputRequest instanceof AttachVCloudVMDKRequest) {
putAttachVMDKRequestInQueue(inputRequest, vpdcQueueProcess, taskInfo);
} else if (inputRequest instanceof CloneVCloudVMDKRequest) {
putCloneVMDKRequestInQueue(inputRequest, vpdcQueueProcess, taskInfo);
}
vpdcQueueProcess.setOutput(convertRequestResponseToString(new JAXBElement<TaskInfo>(new QName("http://www.savvis.com/spirits/services/schemas/queueprocess/types", "TaskInfo"), TaskInfo.class, taskInfo)));
vpdcQueueProcessDAO.update(vpdcQueueProcess);
return taskInfo;
}
private void putVMOperationRequestInQueue(Object inputRequest, VpdcQueueProcess vpdcQueueProcess, TaskInfo taskInfo) {
List<TaskResultInfo> taskResultInfoList = new ArrayList<TaskResultInfo>();
YFilesConverter yFilesConverter = new YFilesConverter();
int nextGuiId = 0;
VMOperationRequest request = (VMOperationRequest) inputRequest;
vpdcQueueProcess.setBillingSiteId(request.getBillingsiteId());
vpdcQueueProcess.setVpdcId(request.getVpdcId());
vpdcQueueProcess.setProcessName("VMOperation");
vpdcQueueProcess.setProcessIdentifier("01");
VpdcDetail vpdcDetail = vpdcDetailDAO.findVpdcDtlLatestByVpdcId(request.getVpdcId());
if (null != vpdcDetail) {
vpdcQueueProcess.setProcessOwnerName(vpdcDetail.getVpdcName());
taskInfo.setOwnerReference(vpdcDetail.getVpdcName());
if (MWUtil.isNotEmptyString(vpdcDetail.getTransientYfiles())) { // todo for what
yFilesConverter.loadGraphML(new ByteArrayInputStream(vpdcDetail.getTransientYfiles().getBytes()));
nextGuiId = yFilesConverter.getNewServerGuiId();
vpdcDetail.setTransientYfiles(yFilesConverter.getGraphML());
} else {
yFilesConverter.loadGraphML(new ByteArrayInputStream(vpdcDetail.getGuiXml().getBytes()));
nextGuiId = yFilesConverter.getNewServerGuiId();
vpdcQueueProcess.setGuiXml(yFilesConverter.getGraphML());
}
vpdcDetailDAO.update(vpdcDetail);
}
vpdcQueueProcessDAO.save(vpdcQueueProcess);
taskInfo.setProcessId(vpdcQueueProcess.getProcessId() + "");
taskInfo.setOrgId(request.getBillingsiteId());
taskInfo.setOwnerId(request.getVpdcId() + "");
taskInfo.setProcessName("VMOperation");
for (VCloudCompute vCloudCompute : request.getVcloudComputes().getCompute()) {
TaskResultInfo taskResultInfo = new TaskResultInfo();
taskResultInfo.setResultReference(vCloudCompute.getCustHostName());
taskResultInfo.setResultStatus("queued");
VpdcQueueProcessResult vpdcQueueProcessResult = new VpdcQueueProcessResult();
vpdcQueueProcessResult.setVpdcQueueProcess(vpdcQueueProcess);
vpdcQueueProcessResult.setProcessResultName(vCloudCompute.getCustHostName());
vpdcQueueProcessResult.setProcessResultStatus("queued");
if (VMAction.ADD.equals(vCloudCompute.getAction())) {
vpdcQueueProcessResult.setProcessResultId(nextGuiId);
taskResultInfo.setResultReferenceId(nextGuiId + "");
nextGuiId++;
} else {
vpdcQueueProcessResult.setProcessResultId(Integer.parseInt(vCloudCompute.getGuiId()));
taskResultInfo.setResultReferenceId(vCloudCompute.getGuiId());
}
vpdcQueueProcessResultDAO.save(vpdcQueueProcessResult);
taskResultInfo.setResultId(vpdcQueueProcessResult.getId() + "");
taskResultInfoList.add(taskResultInfo);
}
taskInfo.getTaskResultInfo().addAll(taskResultInfoList);
}
private void putChangeTemplateRequestInQueue(Object inputRequest, VpdcQueueProcess vpdcQueueProcess, TaskInfo taskInfo) {
List<TaskResultInfo> taskResultInfoList = new ArrayList<TaskResultInfo>();
ChangeTemplateRequest request = (ChangeTemplateRequest) inputRequest;
vpdcQueueProcess.setBillingSiteId(request.getBillingSiteId());
vpdcQueueProcess.setVpdcId(request.getVpdcId());
vpdcQueueProcess.setProcessName("ChangeTemplate");
vpdcQueueProcess.setProcessIdentifier("04");
VpdcDetail vpdcDetail = vpdcDetailDAO.findVpdcDtlLatestByVpdcId(request.getVpdcId());
if (null != vpdcDetail) {
vpdcQueueProcess.setProcessOwnerName(vpdcDetail.getVpdcName());
taskInfo.setOwnerReference(vpdcDetail.getVpdcName());
}
vpdcQueueProcessDAO.save(vpdcQueueProcess);
taskInfo.setProcessId(vpdcQueueProcess.getProcessId() + "");
taskInfo.setOrgId(request.getBillingSiteId());
taskInfo.setOwnerId(request.getVpdcId() + "");
taskInfo.setProcessName("ChangeTemplate");
if (null != request.getTemplate()) {
TaskResultInfo taskResultInfo = new TaskResultInfo();
taskResultInfo.setResultReference(request.getTemplate().getVAppTemplateCustHostName());
taskResultInfo.setResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
VpdcQueueProcessResult vpdcQueueProcessResult = new VpdcQueueProcessResult();
vpdcQueueProcessResult.setVpdcQueueProcess(vpdcQueueProcess);
vpdcQueueProcessResult.setProcessResultName(request.getTemplate().getVAppTemplateCustHostName());
vpdcQueueProcessResult.setProcessResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
vpdcQueueProcessResult.setProcessResultId(request.getTemplate().getTemplateId());
taskResultInfo.setResultReferenceId(request.getTemplate().getTemplateId() + "");
vpdcQueueProcessResultDAO.save(vpdcQueueProcessResult);
taskResultInfo.setResultId(vpdcQueueProcessResult.getId() + "");
taskResultInfoList.add(taskResultInfo);
}
taskInfo.getTaskResultInfo().addAll(taskResultInfoList);
}
private void putCloneVCloudTemplateRequestInQueue(Object inputRequest, VpdcQueueProcess vpdcQueueProcess, TaskInfo taskInfo) {
List<TaskResultInfo> taskResultInfoList = new ArrayList<TaskResultInfo>();
CloneVCloudTemplateRequest request = (CloneVCloudTemplateRequest) inputRequest;
vpdcQueueProcess.setProcessName("CloneVCloudTemplate");
vpdcQueueProcess.setProcessIdentifier("04");
VpdcDetail repoVpdcDetail = vpdcTemplateHelper.validateSourceAndTargetVpdc(request.getSourceVpdcId(), request.getTargetVpdcId());
if (null != repoVpdcDetail) {
vpdcQueueProcess.setBillingSiteId(repoVpdcDetail.getVpdc().getBillingsiteId());
vpdcQueueProcess.setVpdcId(repoVpdcDetail.getVpdc().getId());
taskInfo.setOrgId(repoVpdcDetail.getVpdc().getBillingsiteId());
taskInfo.setOwnerId(repoVpdcDetail.getVpdc().getId() + "");
}
VpdcDetail targetVpdcDetail = vpdcDetailDAO.findVpdcDtlLatestByVpdcId(request.getTargetVpdcId());
if (null != targetVpdcDetail) {
vpdcQueueProcess.setProcessOwnerName(targetVpdcDetail.getVpdcName());
taskInfo.setOwnerReference(targetVpdcDetail.getVpdcName());
}
vpdcQueueProcessDAO.save(vpdcQueueProcess);
taskInfo.setProcessId(vpdcQueueProcess.getProcessId() + "");
taskInfo.setProcessName("CloneVCloudTemplate");
TaskResultInfo taskResultInfo = new TaskResultInfo();
taskResultInfo.setResultReference(request.getTemplateName());
taskResultInfo.setResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
VpdcQueueProcessResult vpdcQueueProcessResult = new VpdcQueueProcessResult();
vpdcQueueProcessResult.setVpdcQueueProcess(vpdcQueueProcess);
vpdcQueueProcessResult.setProcessResultName(request.getTemplateName());
vpdcQueueProcessResult.setProcessResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
//todo
vpdcQueueProcessResult.setProcessResultId(0);
taskResultInfo.setResultReferenceId("");
vpdcQueueProcessResultDAO.save(vpdcQueueProcessResult);
taskResultInfo.setResultId(vpdcQueueProcessResult.getId() + "");
taskResultInfoList.add(taskResultInfo);
taskInfo.getTaskResultInfo().addAll(taskResultInfoList);
}
private void putSaveVCloudTemplateRequestInQueue(Object inputRequest, VpdcQueueProcess vpdcQueueProcess, TaskInfo taskInfo) {
List<TaskResultInfo> taskResultInfoList = new ArrayList<TaskResultInfo>();
SaveVCloudTemplateRequest request = (SaveVCloudTemplateRequest) inputRequest;
vpdcQueueProcess.setProcessName("SaveVCloudTemplate");
vpdcQueueProcess.setProcessIdentifier("04");
VpdcDetail repoVpdcDetail = vpdcTemplateHelper.validateSourceAndTargetVpdc(request.getSourceVpdcId(), request.getTargetVpdcId());
if (null != repoVpdcDetail) {
vpdcQueueProcess.setBillingSiteId(repoVpdcDetail.getVpdc().getBillingsiteId());
vpdcQueueProcess.setVpdcId(repoVpdcDetail.getVpdc().getId());
taskInfo.setOrgId(repoVpdcDetail.getVpdc().getBillingsiteId());
taskInfo.setOwnerId(repoVpdcDetail.getVpdc().getId() + "");
}
VpdcDetail targetVpdcDetail = vpdcDetailDAO.findVpdcDtlLatestByVpdcId(request.getTargetVpdcId());
if (null != targetVpdcDetail) {
vpdcQueueProcess.setProcessOwnerName(targetVpdcDetail.getVpdcName());
taskInfo.setOwnerReference(targetVpdcDetail.getVpdcName());
}
vpdcQueueProcessDAO.save(vpdcQueueProcess);
taskInfo.setProcessId(vpdcQueueProcess.getProcessId() + "");
taskInfo.setProcessName("SaveVCloudTemplate");
TaskResultInfo taskResultInfo = new TaskResultInfo();
taskResultInfo.setResultReference(request.getTemplateName());
taskResultInfo.setResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
VpdcQueueProcessResult vpdcQueueProcessResult = new VpdcQueueProcessResult();
vpdcQueueProcessResult.setVpdcQueueProcess(vpdcQueueProcess);
vpdcQueueProcessResult.setProcessResultName(request.getTemplateName());
vpdcQueueProcessResult.setProcessResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
//todo
vpdcQueueProcessResult.setProcessResultId(0);
taskResultInfo.setResultReferenceId("");
vpdcQueueProcessResultDAO.save(vpdcQueueProcessResult);
taskResultInfo.setResultId(vpdcQueueProcessResult.getId() + "");
taskResultInfoList.add(taskResultInfo);
taskInfo.getTaskResultInfo().addAll(taskResultInfoList);
}
private void putInstantiateVCloudTemplateRequestInQueue(Object inputRequest, VpdcQueueProcess vpdcQueueProcess, TaskInfo taskInfo) {
List<TaskResultInfo> taskResultInfoList = new ArrayList<TaskResultInfo>();
InstantiateVCloudTemplateRequest request = (InstantiateVCloudTemplateRequest) inputRequest;
List<InstantiateTemplateInfo> templateInfoListFromVCloud = request.getInstantiateTemplateList();
vpdcQueueProcess.setProcessName("InstantiateVCloudTemplate");
vpdcQueueProcess.setProcessIdentifier("04");
int targetVpdcId = request.getInstantiateTemplateList().get(0).getTargetVpdcId();
int sourceVpdcId = request.getInstantiateTemplateList().get(0).getSourceVpdcId();
VpdcDetail repoVpdcDetail = vpdcTemplateHelper.validateSourceAndTargetVpdc(sourceVpdcId, targetVpdcId);
if (null != repoVpdcDetail) {
vpdcQueueProcess.setBillingSiteId(repoVpdcDetail.getVpdc().getBillingsiteId());
vpdcQueueProcess.setVpdcId(repoVpdcDetail.getVpdc().getId());
taskInfo.setOrgId(repoVpdcDetail.getVpdc().getBillingsiteId());
taskInfo.setOwnerId(repoVpdcDetail.getVpdc().getId() + "");
}
YFilesConverter yFilesConverter = new YFilesConverter();
int nextGuiId = 0;
VpdcDetail targetVpdcDetail = vpdcDetailDAO.findVpdcDtlLatestByVpdcId(targetVpdcId);
if (null != targetVpdcDetail) {
vpdcQueueProcess.setProcessOwnerName(targetVpdcDetail.getVpdcName());
taskInfo.setOwnerReference(targetVpdcDetail.getVpdcName());
if (MWUtil.isNotEmptyString(targetVpdcDetail.getTransientYfiles())) {
yFilesConverter.loadGraphML(new ByteArrayInputStream(targetVpdcDetail.getTransientYfiles().getBytes()));
nextGuiId = yFilesConverter.getNewServerGuiId();
targetVpdcDetail.setTransientYfiles(yFilesConverter.getGraphML());
} else {
yFilesConverter.loadGraphML(new ByteArrayInputStream(targetVpdcDetail.getGuiXml().getBytes()));
nextGuiId = yFilesConverter.getNewServerGuiId();
targetVpdcDetail.setGuiXml(yFilesConverter.getGraphML());
}
vpdcDetailDAO.update(targetVpdcDetail);
}
vpdcQueueProcessDAO.save(vpdcQueueProcess);
taskInfo.setProcessId(vpdcQueueProcess.getProcessId() + "");
taskInfo.setProcessName("InstantiateVCloudTemplate");
for (InstantiateTemplateInfo templateInfoFromVCloud : templateInfoListFromVCloud) {
TaskResultInfo taskResultInfo = new TaskResultInfo();
taskResultInfo.setResultReference(templateInfoFromVCloud.getTargetComputeName());
taskResultInfo.setResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
VpdcQueueProcessResult vpdcQueueProcessResult = new VpdcQueueProcessResult();
vpdcQueueProcessResult.setVpdcQueueProcess(vpdcQueueProcess);
vpdcQueueProcessResult.setProcessResultName(templateInfoFromVCloud.getTargetComputeName());
vpdcQueueProcessResult.setProcessResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
vpdcQueueProcessResult.setProcessResultId(nextGuiId);
taskResultInfo.setResultReferenceId(nextGuiId + "");
nextGuiId++;
vpdcQueueProcessResultDAO.save(vpdcQueueProcessResult);
taskResultInfo.setResultId(vpdcQueueProcessResult.getId() + "");
taskResultInfoList.add(taskResultInfo);
}
taskInfo.getTaskResultInfo().addAll(taskResultInfoList);
}
private void putCloneVCloudvAppRequestInQueue(Object inputRequest, VpdcQueueProcess vpdcQueueProcess, TaskInfo taskInfo) {
List<TaskResultInfo> taskResultInfoList = new ArrayList<TaskResultInfo>();
YFilesConverter yFilesConverter = new YFilesConverter();
int nextGuiId = 0;
CloneVCloudvAppRequest request = (CloneVCloudvAppRequest) inputRequest;
vpdcQueueProcess.setBillingSiteId(request.getSourceBillingSiteid());
vpdcQueueProcess.setVpdcId(request.getSourceVpdcId());
vpdcQueueProcess.setProcessName("CloneVCloudvApp");
vpdcQueueProcess.setProcessIdentifier("04");
VpdcDetail vpdcDetail = vpdcDetailDAO.findVpdcDtlLatestByVpdcId(request.getSourceVpdcId());
if (null != vpdcDetail) {
vpdcQueueProcess.setProcessOwnerName(vpdcDetail.getVpdcName());
taskInfo.setOwnerReference(vpdcDetail.getVpdcName());
setGuiXML(vpdcDetail, vpdcQueueProcess, request);
if (MWUtil.isNotEmptyString(vpdcDetail.getTransientYfiles())) {
yFilesConverter.loadGraphML(new ByteArrayInputStream(vpdcDetail.getTransientYfiles().getBytes()));
nextGuiId = yFilesConverter.getNewServerGuiId();
vpdcDetail.setTransientYfiles(yFilesConverter.getGraphML());
} else {
yFilesConverter.loadGraphML(new ByteArrayInputStream(vpdcDetail.getGuiXml().getBytes()));
nextGuiId = yFilesConverter.getNewServerGuiId();
vpdcQueueProcess.setGuiXml(yFilesConverter.getGraphML());
}
vpdcDetailDAO.update(vpdcDetail);
}
vpdcQueueProcessDAO.save(vpdcQueueProcess);
taskInfo.setProcessId(vpdcQueueProcess.getProcessId() + "");
taskInfo.setOrgId(request.getTargetBillingSiteid());
taskInfo.setOwnerId(request.getTargetVpdcId() + "");
taskInfo.setProcessName("CloneVCloudvApp");
TaskResultInfo taskResultInfo = new TaskResultInfo();
taskResultInfo.setResultStatus("queued");
VpdcQueueProcessResult vpdcQueueProcessResult = new VpdcQueueProcessResult();
vpdcQueueProcessResult.setVpdcQueueProcess(vpdcQueueProcess);
vpdcQueueProcessResult.setProcessResultStatus("queued");
vpdcQueueProcessResultDAO.save(vpdcQueueProcessResult);
taskResultInfo.setResultId(vpdcQueueProcessResult.getId() + "");
taskResultInfoList.add(taskResultInfo);
taskInfo.getTaskResultInfo().addAll(taskResultInfoList);
}
private void putCloneVCloudMultiplevAppRequestInQueue(Object inputRequest, VpdcQueueProcess vpdcQueueProcess, TaskInfo taskInfo) {
List<TaskResultInfo> taskResultInfoList = new ArrayList<TaskResultInfo>();
YFilesConverter yFilesConverter = new YFilesConverter();
int nextGuiId = 0;
CloneVCloudMultiplevAppRequest request = (CloneVCloudMultiplevAppRequest) inputRequest;
List<CloneVCloudMultiplevAppsInfo> cloneVCloudMultiplevAppsInfoList = request.getTargetvApps();
for (int i = 0; i < cloneVCloudMultiplevAppsInfoList.size(); i++) {
vpdcQueueProcess.setBillingSiteId(cloneVCloudMultiplevAppsInfoList.get(i).getSourceBillingSiteid());
vpdcQueueProcess.setVpdcId(cloneVCloudMultiplevAppsInfoList.get(i).getSourceVpdcId());
vpdcQueueProcess.setProcessName("CloneVCloudMultiplevApp");
vpdcQueueProcess.setProcessIdentifier("05");
VpdcDetail vpdcDetail = vpdcDetailDAO.findVpdcDtlLatestByVpdcId(cloneVCloudMultiplevAppsInfoList.get(i).getSourceVpdcId());
if (null != vpdcDetail) {
vpdcQueueProcess.setProcessOwnerName(vpdcDetail.getVpdcName());
taskInfo.setOwnerReference(vpdcDetail.getVpdcName());
setGuiXML(vpdcDetail, vpdcQueueProcess, request);
if (MWUtil.isNotEmptyString(vpdcDetail.getTransientYfiles())) {
yFilesConverter.loadGraphML(new ByteArrayInputStream(vpdcDetail.getTransientYfiles().getBytes()));
nextGuiId = yFilesConverter.getNewServerGuiId();
vpdcDetail.setTransientYfiles(yFilesConverter.getGraphML());
} else {
yFilesConverter.loadGraphML(new ByteArrayInputStream(vpdcDetail.getGuiXml().getBytes()));
nextGuiId = yFilesConverter.getNewServerGuiId();
vpdcQueueProcess.setGuiXml(yFilesConverter.getGraphML());
}
vpdcDetailDAO.update(vpdcDetail);
}
vpdcQueueProcessDAO.save(vpdcQueueProcess);
taskInfo.setProcessId(vpdcQueueProcess.getProcessId() + "");
taskInfo.setOrgId(cloneVCloudMultiplevAppsInfoList.get(i).getTargetBillingSiteid());
taskInfo.setOwnerId(cloneVCloudMultiplevAppsInfoList.get(i).getTargetVpdcId() + "");
taskInfo.setProcessName("CloneVCloudMultiplevApp");
TaskResultInfo taskResultInfo = new TaskResultInfo();
taskResultInfo.setResultStatus("queued");
VpdcQueueProcessResult vpdcQueueProcessResult = new VpdcQueueProcessResult();
vpdcQueueProcessResult.setVpdcQueueProcess(vpdcQueueProcess);
vpdcQueueProcessResult.setProcessResultStatus("queued");
vpdcQueueProcessResultDAO.save(vpdcQueueProcessResult);
taskResultInfo.setResultId(vpdcQueueProcessResult.getId() + "");
taskResultInfoList.add(taskResultInfo);
taskInfo.getTaskResultInfo().addAll(taskResultInfoList);
}
}
/**
* Method convertRequestResponseToString ...
*
* @param request of type Object
* @return String
*/
public String convertRequestResponseToString(Object request) {
StringBuilder design = new StringBuilder();
try {
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
Result result = new StreamResult(outStream);
marshaller.marshal(request, result);
ByteArrayInputStream metaDataInput = new ByteArrayInputStream(outStream.toByteArray());
InputStreamReader reader = new InputStreamReader(metaDataInput);
BufferedReader bReader = new BufferedReader(reader);
String readLine = "";
while ((readLine = bReader.readLine()) != null) {
design.append(readLine).append("\n");
}
} catch (IOException ex) {
log.error("IOException occured in VPDCQueueProcessPreEngine.convertRequestResponseToString:" + ex.getMessage(), ex);
} catch (Exception ex) {
log.error("Exception occured in VPDCQueueProcessPreEngine.convertRequestResponseToString:" + ex.getMessage(), ex);
}
return design.toString();
}
private void putFWOperationRequestInQueue(Object inputRequest, VpdcQueueProcess vpdcQueueProcess, TaskInfo taskInfo) {
List<TaskResultInfo> taskResultInfoList = new ArrayList<TaskResultInfo>();
YFilesConverter yFilesConverter = new YFilesConverter();
FirewallRequest request = (FirewallRequest) inputRequest;
vpdcQueueProcess.setBillingSiteId(request.getBillingsiteId());
vpdcQueueProcess.setVpdcId(request.getVpdcId());
vpdcQueueProcess.setProcessName("FWOperation");
vpdcQueueProcess.setProcessIdentifier("03");
VpdcDetail vpdcDetail = vpdcDetailDAO.findVpdcDtlLatestByVpdcId(request.getVpdcId());
if (null != vpdcDetail) {
vpdcQueueProcess.setProcessOwnerName(vpdcDetail.getVpdcName());
taskInfo.setOwnerReference(vpdcDetail.getVpdcName());
setGuiXML(vpdcDetail, vpdcQueueProcess, request);
}
vpdcQueueProcessDAO.save(vpdcQueueProcess);
taskInfo.setProcessId(vpdcQueueProcess.getProcessId() + "");
taskInfo.setOrgId(request.getBillingsiteId());
taskInfo.setOwnerId(request.getVpdcId() + "");
if (null != request.getPfwRules().getPfwRules() && request.getPfwRules().getPfwRules().size() > 0) {
taskInfo.setProcessName("PFWOperation");
for (VCloudFirewallRule vCloudFirewallRule : request.getPfwRules().getPfwRules()) {
TaskResultInfo taskResultInfo = new TaskResultInfo();
taskResultInfo.setResultReference("");
taskResultInfo.setResultStatus("queued");
VpdcQueueProcessResult vpdcQueueProcessResult = new VpdcQueueProcessResult();
vpdcQueueProcessResult.setVpdcQueueProcess(vpdcQueueProcess);
vpdcQueueProcessResult.setProcessResultName("");
vpdcQueueProcessResult.setProcessResultStatus("queued");
vpdcQueueProcessResult.setProcessResultId(0);
vpdcQueueProcessResultDAO.save(vpdcQueueProcessResult);
taskResultInfo.setResultId(vpdcQueueProcessResult.getId() + "");
taskResultInfoList.add(taskResultInfo);
}
}
if (null != request.getPfwRules().getPfwRules() && request.getStwfRules().getStwfRules().size() > 0) {
taskInfo.setProcessName("STFWOperation");
for (VCloudFirewallRule vCloudFirewallRule : request.getStwfRules().getStwfRules()) {
TaskResultInfo taskResultInfo = new TaskResultInfo();
taskResultInfo.setResultReference("");
taskResultInfo.setResultStatus("queued");
VpdcQueueProcessResult vpdcQueueProcessResult = new VpdcQueueProcessResult();
vpdcQueueProcessResult.setVpdcQueueProcess(vpdcQueueProcess);
vpdcQueueProcessResult.setProcessResultName("");
vpdcQueueProcessResult.setProcessResultStatus("queued");
vpdcQueueProcessResult.setProcessResultId(0);
vpdcQueueProcessResultDAO.save(vpdcQueueProcessResult);
taskResultInfo.setResultId(vpdcQueueProcessResult.getId() + "");
taskResultInfoList.add(taskResultInfo);
}
}
taskInfo.getTaskResultInfo().addAll(taskResultInfoList);
}
private void setGuiXML(VpdcDetail vpdcDetail, VpdcQueueProcess vpdcQueueProcess, CloneVCloudMultiplevAppRequest request) {
}
private void setGuiXML(VpdcDetail vpdcDetail, VpdcQueueProcess vpdcQueueProcess, CloneVCloudvAppRequest request) {
migrationDHCPInfo(vpdcDetail, vpdcQueueProcess, request.getSourceVpdcId());
}
private void migrationDHCPInfo(VpdcDetail vpdcDetail, VpdcQueueProcess vpdcQueueProcess, int VpdcId) {
Map<Integer, String[]> cloneVMInfo = getClonedVMInfo(vpdcDetail.getId(), VpdcId);
List<Integer> guiIdList = new ArrayList<Integer>();
String apiName = Thread.currentThread().getStackTrace()[1].getMethodName();
String vpdcFinalXML = vpdcDetail.getDesignFinalXml().replaceAll("(\r\n|\r|\n|\n\r)", "");
VPDCServiceDesign vpdcServiceDesign = objectConverter.convertStringToDesign(vpdcFinalXML);
// retrieve a list of VMs defined inside yfiles
Computes computes = vpdcServiceDesign.getComputes();
for (Compute compute : computes.getCompute()) {
guiIdList.add(compute.getGuiId());
if (null != cloneVMInfo.get(compute.getGuiId()) && MWConstants.TRUE.equalsIgnoreCase(vpdcDetail.getVpdc().getUseDhcpForCloneTemplate())) {
compute.setDhcp(true);
} else {
compute.setDhcp(false);
// compute.sets
}
}
if (MWUtil.isNotEmptyString(vpdcDetail.getGuiXml())) {
YFilesConverter yFilesConverter = new YFilesConverter();
yFilesConverter.loadGraphML(new ByteArrayInputStream(vpdcDetail.getGuiXml().getBytes()));
VPDCSpec vpdcSpec = yFilesConverter.getVPDCSpec();
List<ServerDataObject> serverList = vpdcSpec.getServers();
for (ServerDataObject vm : serverList) {
if (guiIdList.contains(vm.getGuiId())) {
if (null != cloneVMInfo.get(vm.getGuiId()) && MWConstants.TRUE.equalsIgnoreCase(vpdcDetail.getVpdc().getUseDhcpForCloneTemplate())) {
vm.setDHCP(true);
} else {
vm.setDHCP(false);
}
yFilesConverter.updateCustomObject(vm);
}
}
vpdcQueueProcess.setGuiXml(yFilesConverter.getGraphML());
}
}
private Map<Integer, String[]> getClonedVMInfo(int vpdcSessionId,int vpdcId) {
Map<Integer,String[]> cloneVMInfo = new HashMap<Integer,String[]>();
VpdcDetail vpdcDetail = null;
List<VpdcDetail> vpdcDetails = null;
if (0 == vpdcId && 0 != vpdcSessionId) {
vpdcDetail = vpdcDetailDAO.findById(vpdcSessionId);
vpdcDetails = vpdcDetailDAO.findVpdcDetailByVpdcIdAndOperation(vpdcDetail.getVpdc().getId(), OperationEnum.CloneVM);
} else if (0 != vpdcId && 0 == vpdcSessionId) {
vpdcDetails = vpdcDetailDAO.findVpdcDetailByVpdcIdAndOperation(vpdcId, OperationEnum.CloneVM);
}
if(!vpdcDetails.isEmpty()) {
for (VpdcDetail detail : vpdcDetails) {
YFilesConverter yFilesConverter = new YFilesConverter();
yFilesConverter.loadGraphML(new ByteArrayInputStream(detail.getGuiXml().getBytes()));
if (detail.getSpecXml() != null) {
for (String custHostName : getClonedVMFromSpecXML(detail.getSpecXml())) {
ServerDataObject serverDataObject = VCloudHelper.getInstance().getYComputeByComputeCustHostName(yFilesConverter.
getVPDCSpec(), custHostName);
cloneVMInfo.put(serverDataObject.getGuiId(),
new String[]{custHostName, serverDataObject.getNodeStatus()});
}
}
}
}
log.info("The return CloneVM info is : " + cloneVMInfo.toString());
return cloneVMInfo;
}
private List<String> getClonedVMFromSpecXML(String specXML){
XMLEventReader eventReader = null;
List<String> cloneVMInfo = new ArrayList<String>();
StringReader stringReader = new StringReader(specXML);
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
String apiName = Thread.currentThread().getStackTrace()[1].getMethodName();
try {
boolean inTargetCompute = false;
eventReader = inputFactory.createXMLEventReader(stringReader);
while (eventReader.hasNext()) {
XMLEvent event = eventReader.nextEvent();
if (event.isStartElement()) {
StartElement startElement = event.asStartElement();
String localPart = startElement.getName().getLocalPart();
if ("targetCompute".equals(localPart)) {
inTargetCompute = true;
} else if (inTargetCompute && "custHostname".equals(localPart)) {
cloneVMInfo.add(eventReader.getElementText());
inTargetCompute = false;
}
}
}
} catch (Exception e) {
throw new SystemException(e.getMessage(), e);
} finally {
if (eventReader != null) {
try {
eventReader.close();
} catch (Exception e) {
}
}
}
return cloneVMInfo;
}
private void setGuiXML(VpdcDetail vpdcDetail, VpdcQueueProcess vpdcQueueProcess, FirewallRequest request) {
log.info("create a new gui xml for getFirewall api");
YFilesConverter yFilesConverter = new YFilesConverter();
List<FWRule> pfwRules = null;
List<SFWRule> stfwRules = null;
List<VCloudFirewallRule> vCloudPfwRules = null;
List<VCloudFirewallRule> vCloudStfwRules = null;
if (MWUtil.isNotEmptyString(vpdcDetail.getGuiXml())) {
yFilesConverter.loadGraphML(new ByteArrayInputStream(vpdcDetail.getGuiXml().getBytes()));
VPDCSpec vpdcSpec = yFilesConverter.getVPDCSpec();
PerimeterFWDataObject perimeterFWDataObject = vpdcSpec.getPerimeterFW();
SFWDataObject sfwDataObject = vpdcSpec.getServerTierFW();
if (null != vpdcSpec && null != vpdcSpec.getPerimeterFW().getFwRules() && vpdcSpec.getPerimeterFW().getFwRules().size() > 0) {
pfwRules = perimeterFWDataObject.getFwRules();
}
if (null != vpdcSpec && null != vpdcSpec.getServerTierFW().getSFwRules() && vpdcSpec.getServerTierFW().getSFwRules().size() > 0) {
stfwRules = sfwDataObject.getSFwRules();
}
vCloudPfwRules = request.getPfwRules().getPfwRules();
vCloudStfwRules = request.getStwfRules().getStwfRules();
if (null != vCloudPfwRules && vCloudStfwRules.size() > 0) {
for (VCloudFirewallRule vCloudFirewallRule : vCloudPfwRules) {
FWRule fwRule = new FWRule();
fwRule.setAction(vCloudFirewallRule.getAction().toString());
fwRule.setDestination(vCloudFirewallRule.getDestination());
fwRule.setDestinationPort(vCloudFirewallRule.getDestinationPort());
fwRule.setLog(vCloudFirewallRule.getLog().toString());
fwRule.setNodeStatus(vCloudFirewallRule.getStatus());
fwRule.setProtocol(vCloudFirewallRule.getProtocol());
fwRule.setSource(vCloudFirewallRule.getSource());
pfwRules.add(fwRule);
}
}
if (null != vCloudStfwRules && vCloudStfwRules.size() > 0) {
for (VCloudFirewallRule vCloudFirewallRule : vCloudStfwRules) {
SFWRule fwRule = new SFWRule();
fwRule.setAction(vCloudFirewallRule.getAction().toString());
fwRule.setDestination(vCloudFirewallRule.getDestination());
fwRule.setDestinationPort(vCloudFirewallRule.getDestinationPort());
fwRule.setLog(vCloudFirewallRule.getLog().toString());
fwRule.setNodeStatus(vCloudFirewallRule.getStatus());
fwRule.setProtocol(vCloudFirewallRule.getProtocol());
fwRule.setSource(vCloudFirewallRule.getSource());
stfwRules.add(fwRule);
}
}
perimeterFWDataObject.setFwRules(pfwRules);
sfwDataObject.setSFwRules(stfwRules);
yFilesConverter.updateCustomObject(perimeterFWDataObject);
yFilesConverter.updateCustomObject(sfwDataObject);
String newGuiXML = yFilesConverter.getGraphML();
log.info("new gui xml generated++++++++" + newGuiXML);
vpdcQueueProcess.setGuiXml(newGuiXML);
}
}
private void putDetachVMDKRequestInQueue(Object inputRequest, VpdcQueueProcess vpdcQueueProcess, TaskInfo taskInfo) {
List<TaskResultInfo> taskResultInfoList = new ArrayList<TaskResultInfo>();
DetachVCloudVMDKRequest request = (DetachVCloudVMDKRequest) inputRequest;
vpdcQueueProcess.setBillingSiteId(request.getSourceBillingSiteid());
vpdcQueueProcess.setVpdcId(request.getSourceVpdcId());
vpdcQueueProcess.setProcessName("DetachVCloudVMDK");
vpdcQueueProcess.setProcessIdentifier("02");
VpdcDetail vpdcDetail = vpdcDetailDAO.findVpdcDtlLatestByVpdcId(request.getSourceVpdcId());
if (null != vpdcDetail) {
vpdcQueueProcess.setProcessOwnerName(vpdcDetail.getVpdcName());
taskInfo.setOwnerReference(vpdcDetail.getVpdcName());
}
vpdcQueueProcessDAO.save(vpdcQueueProcess);
taskInfo.setProcessId(String.valueOf(vpdcQueueProcess.getProcessId()));
taskInfo.setOrgId(request.getSourceBillingSiteid());
taskInfo.setOwnerId(String.valueOf(request.getSourceVpdcId()));
taskInfo.setProcessName("DetachVCloudVMDK");
TaskResultInfo taskResultInfo = new TaskResultInfo();
taskResultInfo.setResultReference(request.getLabelName());
taskResultInfo.setResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
VpdcQueueProcessResult vpdcQueueProcessResult = new VpdcQueueProcessResult();
vpdcQueueProcessResult.setVpdcQueueProcess(vpdcQueueProcess);
vpdcQueueProcessResult.setProcessResultName(request.getLabelName());
vpdcQueueProcessResult.setProcessResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
vpdcQueueProcessResult.setProcessResultId(request.getSourceVMDKciid());
taskResultInfo.setResultReferenceId(String.valueOf(request.getSourceVMDKciid()));
vpdcQueueProcessResultDAO.save(vpdcQueueProcessResult);
taskResultInfo.setResultId(String.valueOf(vpdcQueueProcessResult.getId()));
taskResultInfoList.add(taskResultInfo);
taskInfo.getTaskResultInfo().addAll(taskResultInfoList);
}
private void putAttachVMDKRequestInQueue(Object inputRequest, VpdcQueueProcess vpdcQueueProcess, TaskInfo taskInfo) {
List<TaskResultInfo> taskResultInfoList = new ArrayList<TaskResultInfo>();
AttachVCloudVMDKRequest request = (AttachVCloudVMDKRequest) inputRequest;
vpdcQueueProcess.setBillingSiteId(request.getSourceBillingSiteid());
vpdcQueueProcess.setVpdcId(request.getSourceVpdcId());
vpdcQueueProcess.setProcessName("AttachVCloudVMDK");
vpdcQueueProcess.setProcessIdentifier("02");
VpdcDetail vpdcDetail = vpdcDetailDAO.findVpdcDtlLatestByVpdcId(request.getSourceVpdcId());
if (null != vpdcDetail) {
vpdcQueueProcess.setProcessOwnerName(vpdcDetail.getVpdcName());
taskInfo.setOwnerReference(vpdcDetail.getVpdcName());
}
vpdcQueueProcessDAO.save(vpdcQueueProcess);
taskInfo.setProcessId(String.valueOf(vpdcQueueProcess.getProcessId()));
taskInfo.setOrgId(request.getSourceBillingSiteid());
taskInfo.setOwnerId(String.valueOf(request.getSourceVpdcId()));
taskInfo.setProcessName("AttachVCloudVMDK");
TaskResultInfo taskResultInfo = new TaskResultInfo();
taskResultInfo.setResultReference(request.getTargetMountPointName());
taskResultInfo.setResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
VpdcQueueProcessResult vpdcQueueProcessResult = new VpdcQueueProcessResult();
vpdcQueueProcessResult.setVpdcQueueProcess(vpdcQueueProcess);
vpdcQueueProcessResult.setProcessResultName(request.getTargetMountPointName());
vpdcQueueProcessResult.setProcessResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
vpdcQueueProcessResult.setProcessResultId(request.getSourceVMDKciid());
taskResultInfo.setResultReferenceId(String.valueOf(request.getSourceVMDKciid()));
vpdcQueueProcessResultDAO.save(vpdcQueueProcessResult);
taskResultInfo.setResultId(String.valueOf(vpdcQueueProcessResult.getId()));
taskResultInfoList.add(taskResultInfo);
taskInfo.getTaskResultInfo().addAll(taskResultInfoList);
}
private void putDeleteVMDKRequestInQueue(Object inputRequest, VpdcQueueProcess vpdcQueueProcess, TaskInfo taskInfo) {
String driveName = "";
List<TaskResultInfo> taskResultInfoList = new ArrayList<TaskResultInfo>();
DeleteVCloudVMDKRequest request = (DeleteVCloudVMDKRequest) inputRequest;
vpdcQueueProcess.setBillingSiteId(request.getSourceBillingSiteid());
vpdcQueueProcess.setVpdcId(request.getSourceVpdcId());
vpdcQueueProcess.setProcessName("DeleteVCloudVMDK");
vpdcQueueProcess.setProcessIdentifier("02");
VpdcDetail vpdcDetail = vpdcDetailDAO.findVpdcDtlLatestByVpdcId(request.getSourceVpdcId());
if (null != vpdcDetail) {
vpdcQueueProcess.setProcessOwnerName(vpdcDetail.getVpdcName());
taskInfo.setOwnerReference(vpdcDetail.getVpdcName());
String vpdcFinalXML = vpdcDetail.getDesignFinalXml().replaceAll("(\r\n|\r|\n|\n\r)", "");
Drive drive = objectConverter.getDriveByVMDKCiIdFromFinal(request.getSourceVMDKciid(), vpdcFinalXML);
driveName = drive.getMount();
}
vpdcQueueProcessDAO.save(vpdcQueueProcess);
taskInfo.setProcessId(String.valueOf(vpdcQueueProcess.getProcessId()));
taskInfo.setOrgId(request.getSourceBillingSiteid());
taskInfo.setOwnerId(String.valueOf(request.getSourceVpdcId()));
taskInfo.setProcessName("DeleteVCloudVMDK");
TaskResultInfo taskResultInfo = new TaskResultInfo();
taskResultInfo.setResultReference(String.valueOf(request.getSourceVMDKciid()));
taskResultInfo.setResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
VpdcQueueProcessResult vpdcQueueProcessResult = new VpdcQueueProcessResult();
vpdcQueueProcessResult.setVpdcQueueProcess(vpdcQueueProcess);
vpdcQueueProcessResult.setProcessResultName(driveName);
vpdcQueueProcessResult.setProcessResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
vpdcQueueProcessResult.setProcessResultId(request.getSourceVMDKciid());
taskResultInfo.setResultReferenceId(String.valueOf(request.getSourceVMDKciid()));
vpdcQueueProcessResultDAO.save(vpdcQueueProcessResult);
taskResultInfo.setResultId(String.valueOf(vpdcQueueProcessResult.getId()));
taskResultInfoList.add(taskResultInfo);
taskInfo.getTaskResultInfo().addAll(taskResultInfoList);
}
private void putCloneVMDKRequestInQueue(Object inputRequest, VpdcQueueProcess vpdcQueueProcess, TaskInfo taskInfo) {
List<TaskResultInfo> taskResultInfoList = new ArrayList<TaskResultInfo>();
CloneVCloudVMDKRequest request = (CloneVCloudVMDKRequest) inputRequest;
vpdcQueueProcess.setBillingSiteId(request.getSourceBillingSiteid());
vpdcQueueProcess.setVpdcId(request.getSourceVpdcId());
vpdcQueueProcess.setProcessName("CloneVCloudVMDK");
vpdcQueueProcess.setProcessIdentifier("02");
VpdcDetail vpdcDetail = vpdcDetailDAO.findVpdcDtlLatestByVpdcId(request.getSourceVpdcId());
if (null != vpdcDetail) {
vpdcQueueProcess.setProcessOwnerName(vpdcDetail.getVpdcName());
taskInfo.setOwnerReference(vpdcDetail.getVpdcName());
}
vpdcQueueProcessDAO.save(vpdcQueueProcess);
taskInfo.setProcessId(String.valueOf(vpdcQueueProcess.getProcessId()));
taskInfo.setOrgId(request.getSourceBillingSiteid());
taskInfo.setOwnerId(String.valueOf(request.getSourceVpdcId()));
taskInfo.setProcessName("CloneVCloudVMDK");
TaskResultInfo taskResultInfo = new TaskResultInfo();
taskResultInfo.setResultReference(request.getLabelName());
taskResultInfo.setResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
VpdcQueueProcessResult vpdcQueueProcessResult = new VpdcQueueProcessResult();
vpdcQueueProcessResult.setVpdcQueueProcess(vpdcQueueProcess);
vpdcQueueProcessResult.setProcessResultName(request.getLabelName());
vpdcQueueProcessResult.setProcessResultStatus(VpdcQueueProcessStatusEnum.QUEUED.name());
vpdcQueueProcessResultDAO.save(vpdcQueueProcessResult);
taskResultInfo.setResultId(String.valueOf(vpdcQueueProcessResult.getId()));
taskResultInfoList.add(taskResultInfo);
taskInfo.getTaskResultInfo().addAll(taskResultInfoList);
}
}
发表评论
-
logs
2011-01-20 18:16 786[root@cussl07m01mw01test logs]# ... -
vcloud.properties
2011-01-20 11:22 837... -
Using Maven
2011-01-06 11:25 558Using Maven 1, use mvn site:ru ... -
The step of doc deploy
2010-12-30 17:13 727login as: slabtrog slabtrog@10. ... -
wonderland
2010-12-17 16:17 754[1:32 pm]<guanwee> can u ...
相关推荐
ta_lib-0.5.1-cp312-cp312-win32.whl
课程设计 在线实时的斗兽棋游戏,时间赶,粗暴的使用jQuery + websoket 实现实时H5对战游戏 + java.zip课程设计
ta_lib-0.5.1-cp310-cp310-win_amd64.whl
基于springboot+vue物流系统源码数据库文档.zip
GEE训练教程——Landsat5、8和Sentinel-2、DEM和各2哦想指数下载
知识图谱
333498005787635解决keil下载失败的文件.zip
【微信机器人原理与实现】 微信机器人是通过模拟微信客户端的行为,自动处理消息、发送消息的程序。在Python中实现微信机器人的主要库是WeChatBot,它提供了丰富的接口,允许开发者方便地进行微信消息的接收与发送。这个项目标题中的"基于python实现的微信机器人源码"指的是使用Python编程语言编写的微信机器人程序。 1. **Python基础**:Python是一种高级编程语言,以其简洁的语法和强大的功能深受开发者喜爱。在实现微信机器人时,你需要熟悉Python的基本语法、数据类型、函数、类以及异常处理等概念。 2. **微信API与WeChatBot库**:微信为开发者提供了微信公共平台和微信开放平台,可以获取到必要的API来实现机器人功能。WeChatBot库是Python中一个用于微信开发的第三方库,它封装了微信的API,简化了消息处理的流程。使用WeChatBot,开发者可以快速搭建起一个微信机器人。 3. **微信OAuth2.0授权**:为了能够接入微信,首先需要通过OAuth2.0协议获取用户的授权。用户授权后,机器人可以获取到微信用户的身份信息,从而进行
基于springboot实验室研究生信息管理系统源码数据库文档.zip
张力控制,色标跟踪,多轴同步,电子凸轮,横切等工艺控制案例。
在Python编程环境中,处理Microsoft Word文档是一项常见的任务。Python提供了几个库来实现这一目标,如`python-docx`,它可以让我们创建、修改和操作.docx文件。本教程将重点介绍如何利用Python进行Word文档的合并、格式转换以及转换为PDF。 1. **合并Word文档(merge4docx)** 合并多个Word文档是一项实用的功能,特别是在处理大量报告或文档集合时。在Python中,可以使用`python-docx`库实现。我们需要导入`docx`模块,然后读取每个文档并将其内容插入到主文档中。以下是一个基本示例: ```python from docx import Document def merge4docx(file_list, output_file): main_doc = Document() for file in file_list: doc = Document(file) for paragraph in doc.paragraphs: main_doc.add_paragraph(paragraph.text) m
基于springboot+Javaweb的二手图书交易系统源码数据库文档.zip
基于springboot餐品美食论坛源码数据库文档.zip
基于springboot亚运会志愿者管理系统源码数据库文档.zip
使用WPF的数据样式绑定,切换对象数据值来完成控件动态切换背景渐变动画效果。 使用动画样式渲染比线程修改性能消耗更低更稳定
基于SpringBoot的企业客源关系管理系统源码数据库文档.zip
基于springboot+vue的桂林旅游网站系统源码数据库文档.zip
基于springboot嗨玩旅游网站源码数据库文档.zip
基于springboot的流浪动物管理系统源码数据库文档.zip
基于springboot课件通中小学教学课件共享平台源码数据库文档.zip