mirror of https://github.com/apache/cloudstack.git
Removed a bunch of useless code
This commit is contained in:
parent
f551cf963e
commit
48ec23ce95
|
|
@ -1,66 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.async.BaseAsyncJobExecutor;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
public class AssignToLoadBalancerExecutor extends BaseAsyncJobExecutor {
|
||||
public static final Logger s_logger = Logger.getLogger(AssignToLoadBalancerExecutor.class.getName());
|
||||
|
||||
@Override
|
||||
public boolean execute() {
|
||||
/*
|
||||
if (getSyncSource() == null) {
|
||||
Gson gson = GsonHelper.getBuilder().create();
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
AsyncJobVO job = getJob();
|
||||
Type mapType = new TypeToken<Map<String, String>>() {}.getType();
|
||||
|
||||
Map<String, String> params = gson.fromJson(job.getCmdInfo(), mapType);
|
||||
for (Object paramObj : params.values()) {
|
||||
s_logger.error("%%% %%% deserialized param: " + paramObj);
|
||||
}
|
||||
LoadBalancerParam param = gson.fromJson(job.getCmdInfo(), LoadBalancerParam.class);
|
||||
asyncMgr.syncAsyncJobExecution(job.getId(), "Router", param.getDomainRouterId());
|
||||
|
||||
// always true if it does not have sync-source
|
||||
return true;
|
||||
} else {
|
||||
Gson gson = GsonHelper.getBuilder().create();
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
AsyncJobVO job = getJob();
|
||||
|
||||
LoadBalancerParam param = gson.fromJson(job.getCmdInfo(), LoadBalancerParam.class);
|
||||
// return asyncMgr.getExecutorContext().getNetworkMgr().executeAssignToLoadBalancer(this, param);
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobResult;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class AttachISOExecutor extends VMOperationExecutor {
|
||||
public static final Logger s_logger = Logger.getLogger(AttachISOExecutor.class.getName());
|
||||
|
||||
public boolean execute() {
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
AsyncJobVO job = getJob();
|
||||
Gson gson = GsonHelper.getBuilder().create();
|
||||
|
||||
/*
|
||||
if(getSyncSource() == null) {
|
||||
AttachISOParam param = gson.fromJson(job.getCmdInfo(), AttachISOParam.class);
|
||||
asyncMgr.syncAsyncJobExecution(job.getId(), "AttachISO", param.getVmId());
|
||||
|
||||
// always true if it does not have sync-source
|
||||
return true;
|
||||
} else {
|
||||
AttachISOParam param = gson.fromJson(job.getCmdInfo(), AttachISOParam.class);
|
||||
|
||||
long vmId = param.getVmId();
|
||||
long userId = param.getUserId();
|
||||
long isoId = param.getIsoId();
|
||||
boolean attach = param.isAttach();
|
||||
|
||||
// Build the success/failure messages
|
||||
String successMsg;
|
||||
String failureMsg;
|
||||
|
||||
if (attach) {
|
||||
successMsg = "Successfully inserted CD.";
|
||||
failureMsg = "Failed to insert CD. Please make sure an existing CD is not currently in use.";
|
||||
} else {
|
||||
successMsg = "Successfully ejected CD.";
|
||||
failureMsg = "Failed to eject CD. Please make sure an existing CD is not currently in use.";
|
||||
}
|
||||
|
||||
try {
|
||||
boolean result = asyncMgr.getExecutorContext().getManagementServer().attachISOToVM(vmId, userId, isoId, attach, param.getEventId());
|
||||
if (result)
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0, successMsg);
|
||||
else
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR, failureMsg);
|
||||
} catch(Exception e) {
|
||||
s_logger.warn("Unable to attach ISO: " + e.getMessage(), e);
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR, e.getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
public void processAnswer(VMOperationListener listener, long agentId, long seq, Answer answer) {
|
||||
}
|
||||
|
||||
public void processDisconnect(VMOperationListener listener, long agentId) {
|
||||
}
|
||||
|
||||
public void processTimeout(VMOperationListener listener, long agentId, long seq) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
public class AttachISOParam {
|
||||
private long vmId;
|
||||
private long userId;
|
||||
private long isoId;
|
||||
private boolean attach;
|
||||
private long eventId;
|
||||
|
||||
public AttachISOParam() {
|
||||
}
|
||||
|
||||
public AttachISOParam(long vmId, long userId, long isoId, boolean attach) {
|
||||
this.vmId = vmId;
|
||||
this.userId = userId;
|
||||
this.isoId = isoId;
|
||||
this.attach = attach;
|
||||
}
|
||||
|
||||
public long getVmId() {
|
||||
return vmId;
|
||||
}
|
||||
|
||||
public long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public long getIsoId() {
|
||||
return isoId;
|
||||
}
|
||||
|
||||
public boolean isAttach() {
|
||||
return attach;
|
||||
}
|
||||
|
||||
public void setEventId(long eventId) {
|
||||
this.eventId = eventId;
|
||||
}
|
||||
|
||||
public long getEventId() {
|
||||
return eventId;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,103 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
|
||||
public class AttachVolumeOperationResultObject {
|
||||
@Param(name="virtualmachineid")
|
||||
private Long virtualMachineId;
|
||||
|
||||
@Param(name="vmname")
|
||||
private String vmName;
|
||||
|
||||
@Param(name="vmdisplayname")
|
||||
private String vmDisplayName;
|
||||
|
||||
@Param(name="vmstate")
|
||||
private String vmState;
|
||||
|
||||
@Param(name="id")
|
||||
private Long volumeId;
|
||||
|
||||
@Param(name="name")
|
||||
private String volumeName;
|
||||
|
||||
@Param(name="storagetype")
|
||||
String storageType;
|
||||
|
||||
public AttachVolumeOperationResultObject() {
|
||||
}
|
||||
|
||||
public Long getVirtualMachineId() {
|
||||
return virtualMachineId;
|
||||
}
|
||||
|
||||
public void setVirtualMachineId(Long virtualMachineId) {
|
||||
this.virtualMachineId = virtualMachineId;
|
||||
}
|
||||
|
||||
public String getVmName() {
|
||||
return vmName;
|
||||
}
|
||||
|
||||
public void setVmName(String vmName) {
|
||||
this.vmName = vmName;
|
||||
}
|
||||
|
||||
public String getVmDisplayName() {
|
||||
return vmDisplayName;
|
||||
}
|
||||
|
||||
public void setVmDisplayName(String vmDisplayName) {
|
||||
this.vmDisplayName = vmDisplayName;
|
||||
}
|
||||
|
||||
public String getVmState() {
|
||||
return vmState;
|
||||
}
|
||||
|
||||
public void setVmState(String vmState) {
|
||||
this.vmState = vmState;
|
||||
}
|
||||
|
||||
public Long getVolumeId() {
|
||||
return volumeId;
|
||||
}
|
||||
|
||||
public void setVolumeId(Long volumeId) {
|
||||
this.volumeId = volumeId;
|
||||
}
|
||||
|
||||
public String getVolumeName() {
|
||||
return volumeName;
|
||||
}
|
||||
|
||||
public void setVolumeName(String volumeName) {
|
||||
this.volumeName = volumeName;
|
||||
}
|
||||
|
||||
public String getStorageType() {
|
||||
return storageType;
|
||||
}
|
||||
|
||||
public void setStorageType(String storageType) {
|
||||
this.storageType = storageType;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
package com.cloud.async.executor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobResult;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.async.BaseAsyncJobExecutor;
|
||||
import com.cloud.network.security.IngressRuleVO;
|
||||
import com.cloud.network.security.SecurityGroupRulesVO;
|
||||
import com.cloud.network.security.SecurityGroupVO;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class AuthorizeSecurityGroupIngressExecutor extends BaseAsyncJobExecutor {
|
||||
public static final Logger s_logger = Logger.getLogger(AuthorizeSecurityGroupIngressExecutor.class.getName());
|
||||
|
||||
@Override
|
||||
public boolean execute() {
|
||||
Gson gson = GsonHelper.getBuilder().create();
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
AsyncJobVO job = getJob();
|
||||
ManagementServer managementServer = asyncMgr.getExecutorContext().getManagementServer();
|
||||
SecurityGroupIngressParam param = gson.fromJson(job.getCmdInfo(), SecurityGroupIngressParam.class);
|
||||
AccountVO account = param.getAccount();
|
||||
|
||||
/*
|
||||
if (getSyncSource() == null) {
|
||||
SecurityGroupVO networkGroup = managementServer.findNetworkGroupByName(param.getAccount().getId(), param.getGroupName());
|
||||
if(networkGroup == null) {
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED,
|
||||
BaseCmd.PARAM_ERROR, "Unable to find network group " + param.getGroupName() + " for account " + account.getAccountName() + " (id: " + account.getId() + ")");
|
||||
} else {
|
||||
asyncMgr.syncAsyncJobExecution(job.getId(), "SecurityGroup", networkGroup.getId());
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
try {
|
||||
List<IngressRuleVO> addedRules = managementServer.authorizeNetworkGroupIngress(account, param.getGroupName(), param.getProtocol(), param.getStartPort(), param.getEndPort(), param.getCidrList(), param.getAuthorizedGroups());
|
||||
if ((addedRules != null) && !addedRules.isEmpty()) {
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0, composeResultObject(managementServer, account.getId(), param.getGroupName(), addedRules));
|
||||
} else {
|
||||
if (addedRules == null) {
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
"Failed to authorize network group ingress for group: " + param.getGroupName() + " for account: " + account.getAccountName() + " (id: " + account.getId() + ")");
|
||||
} else {
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.PARAM_ERROR,
|
||||
"Failed to authorize network group ingress for group: " + param.getGroupName() + ", ingress rules already exist.");
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
s_logger.warn("Failed to authorize network group ingress from group: " + param.getGroupName() + " for account: " + account.getAccountName() + " (id: " + account.getId() + ")", e);
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
"Failed to authorize network group ingress from group: " + param.getGroupName() + " for account: " + account.getAccountName() + " (id: " + account.getId() + ")");
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private SecurityGroupResultObject composeResultObject(ManagementServer ms, Long accountId, String groupName, List<IngressRuleVO> addedRules) {
|
||||
SecurityGroupVO networkGroup = ms.findNetworkGroupByName(accountId, groupName);
|
||||
List<SecurityGroupRulesVO> groupRules = new ArrayList<SecurityGroupRulesVO>();
|
||||
for (IngressRuleVO ingressRule : addedRules) {
|
||||
SecurityGroupRulesVO groupRule = new SecurityGroupRulesVO(networkGroup.getId(), networkGroup.getName(), networkGroup.getDescription(), networkGroup.getDomainId(),
|
||||
networkGroup.getAccountId(), networkGroup.getAccountName(), ingressRule.getId(), ingressRule.getStartPort(), ingressRule.getEndPort(),
|
||||
ingressRule.getProtocol(), ingressRule.getAllowedNetworkId(), ingressRule.getAllowedSecurityGroup(), ingressRule.getAllowedSecGrpAcct(),
|
||||
ingressRule.getAllowedSourceIpCidr());
|
||||
groupRules.add(groupRule);
|
||||
}
|
||||
List<SecurityGroupResultObject> results = SecurityGroupResultObject.transposeNetworkGroups(groupRules);
|
||||
if ((results != null) && !results.isEmpty()) {
|
||||
return results.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.cloud.vm.ConsoleProxyVO;
|
||||
|
||||
public class ConsoleProxyExecutorHelper {
|
||||
|
||||
public static ConsoleProxyOperationResultObject composeResultObject(ManagementServer managementServer, ConsoleProxyVO proxy) {
|
||||
ConsoleProxyOperationResultObject result = new ConsoleProxyOperationResultObject();
|
||||
result.setId(proxy.getId());
|
||||
result.setName(proxy.getName());
|
||||
result.setZoneId(proxy.getDataCenterId());
|
||||
result.setZoneName(managementServer.findDataCenterById(proxy.getDataCenterId()).getName());
|
||||
result.setDns1(proxy.getDns1());
|
||||
result.setDns2(proxy.getDns2());
|
||||
result.setNetworkDomain(proxy.getDomain());
|
||||
result.setGateway(proxy.getGateway());
|
||||
result.setPodId(proxy.getPodId());
|
||||
result.setHostId(proxy.getHostId());
|
||||
if(proxy.getHostId() != null)
|
||||
result.setHostName(managementServer.getHostBy(proxy.getHostId()).getName());
|
||||
|
||||
result.setPrivateIp(proxy.getPrivateIpAddress());
|
||||
result.setPrivateMac(proxy.getPrivateMacAddress());
|
||||
result.setPrivateNetmask(proxy.getPrivateNetmask());
|
||||
result.setPublicIp(proxy.getPublicIpAddress());
|
||||
result.setPublicMac(proxy.getPublicMacAddress());
|
||||
result.setPublicNetmask(proxy.getPublicNetmask());
|
||||
result.setTemplateId(proxy.getTemplateId());
|
||||
result.setCreated(proxy.getCreated());
|
||||
result.setActionSessions(proxy.getActiveSession());
|
||||
result.setState(proxy.getState().toString());
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,260 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
|
||||
public class ConsoleProxyOperationResultObject {
|
||||
|
||||
@Param(name="id")
|
||||
private long id;
|
||||
|
||||
@Param(name="name")
|
||||
private String name;
|
||||
|
||||
@Param(name="zoneid")
|
||||
private long zoneId;
|
||||
|
||||
@Param(name="zonename")
|
||||
private String zoneName;
|
||||
|
||||
@Param(name="dns1")
|
||||
private String dns1;
|
||||
|
||||
@Param(name="dns2")
|
||||
private String dns2;
|
||||
|
||||
@Param(name="networkdomain")
|
||||
private String networkDomain;
|
||||
|
||||
@Param(name="gateway")
|
||||
private String gateway;
|
||||
|
||||
@Param(name="podid")
|
||||
private long podId;
|
||||
|
||||
@Param(name="hostid")
|
||||
private Long hostId;
|
||||
|
||||
@Param(name="hostname")
|
||||
private String hostName;
|
||||
|
||||
@Param(name="privateip")
|
||||
private String privateIp;
|
||||
|
||||
@Param(name="privatemacaddress")
|
||||
private String privateMac;
|
||||
|
||||
@Param(name="privatenetmask")
|
||||
private String privateNetmask;
|
||||
|
||||
@Param(name="publicip")
|
||||
private String publicIp;
|
||||
|
||||
@Param(name="publicmacaddress")
|
||||
private String publicMac;
|
||||
|
||||
@Param(name="publicnetmask")
|
||||
private String publicNetmask;
|
||||
|
||||
@Param(name="templateid")
|
||||
private long templateId;
|
||||
|
||||
@Param(name="created")
|
||||
private Date created;
|
||||
|
||||
@Param(name="activeviewersessions")
|
||||
private int actionSessions;
|
||||
|
||||
@Param(name="state")
|
||||
private String state;
|
||||
|
||||
public ConsoleProxyOperationResultObject() {
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public void setZoneId(long zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
|
||||
public String getZoneName() {
|
||||
return zoneName;
|
||||
}
|
||||
|
||||
public void setZoneName(String zoneName) {
|
||||
this.zoneName = zoneName;
|
||||
}
|
||||
|
||||
public String getDns1() {
|
||||
return dns1;
|
||||
}
|
||||
|
||||
public void setDns1(String dns1) {
|
||||
this.dns1 = dns1;
|
||||
}
|
||||
|
||||
public String getDns2() {
|
||||
return dns2;
|
||||
}
|
||||
|
||||
public void setDns2(String dns2) {
|
||||
this.dns2 = dns2;
|
||||
}
|
||||
|
||||
public String getNetworkDomain() {
|
||||
return networkDomain;
|
||||
}
|
||||
|
||||
public void setNetworkDomain(String networkDomain) {
|
||||
this.networkDomain = networkDomain;
|
||||
}
|
||||
|
||||
public String getGateway() {
|
||||
return gateway;
|
||||
}
|
||||
|
||||
public void setGateway(String gateway) {
|
||||
this.gateway = gateway;
|
||||
}
|
||||
|
||||
public long getPodId() {
|
||||
return podId;
|
||||
}
|
||||
|
||||
public void setPodId(long podId) {
|
||||
this.podId = podId;
|
||||
}
|
||||
|
||||
public Long getHostId() {
|
||||
return hostId;
|
||||
}
|
||||
|
||||
public void setHostId(Long hostId) {
|
||||
this.hostId = hostId;
|
||||
}
|
||||
|
||||
public String getHostName() {
|
||||
return hostName;
|
||||
}
|
||||
|
||||
public void setHostName(String hostName) {
|
||||
this.hostName = hostName;
|
||||
}
|
||||
|
||||
public String getPrivateIp() {
|
||||
return privateIp;
|
||||
}
|
||||
|
||||
public void setPrivateIp(String privateIp) {
|
||||
this.privateIp = privateIp;
|
||||
}
|
||||
|
||||
public String getPrivateMac() {
|
||||
return privateMac;
|
||||
}
|
||||
|
||||
public void setPrivateMac(String privateMac) {
|
||||
this.privateMac = privateMac;
|
||||
}
|
||||
|
||||
public String getPrivateNetmask() {
|
||||
return privateNetmask;
|
||||
}
|
||||
|
||||
public void setPrivateNetmask(String privateNetmask) {
|
||||
this.privateNetmask = privateNetmask;
|
||||
}
|
||||
|
||||
public String getPublicIp() {
|
||||
return publicIp;
|
||||
}
|
||||
|
||||
public void setPublicIp(String publicIp) {
|
||||
this.publicIp = publicIp;
|
||||
}
|
||||
|
||||
public String getPublicMac() {
|
||||
return publicMac;
|
||||
}
|
||||
|
||||
public void setPublicMac(String publicMac) {
|
||||
this.publicMac = publicMac;
|
||||
}
|
||||
|
||||
public String getPublicNetmask() {
|
||||
return publicNetmask;
|
||||
}
|
||||
|
||||
public void setPublicNetmask(String publicNetmask) {
|
||||
this.publicNetmask = publicNetmask;
|
||||
}
|
||||
|
||||
public long getTemplateId() {
|
||||
return templateId;
|
||||
}
|
||||
|
||||
public void setTemplateId(long templateId) {
|
||||
this.templateId = templateId;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public int getActionSessions() {
|
||||
return actionSessions;
|
||||
}
|
||||
|
||||
public void setActionSessions(int actionSessions) {
|
||||
this.actionSessions = actionSessions;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,135 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobResult;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.async.BaseAsyncJobExecutor;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.domain.Domain;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.cloud.storage.VMTemplateHostVO;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.user.Account;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class CopyTemplateExecutor extends BaseAsyncJobExecutor {
|
||||
public static final Logger s_logger = Logger.getLogger(CopyTemplateExecutor.class.getName());
|
||||
|
||||
public boolean execute() {
|
||||
Gson gson = GsonHelper.getBuilder().create();
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
AsyncJobVO job = getJob();
|
||||
|
||||
CopyTemplateParam param = gson.fromJson(job.getCmdInfo(), CopyTemplateParam.class);
|
||||
|
||||
ManagementServer managementServer = asyncMgr.getExecutorContext().getManagementServer();
|
||||
|
||||
try {
|
||||
boolean success = managementServer.copyTemplate(param.getUserId(), param.getTemplateId(), param.getSourceZoneId(), param.getDestZoneId());
|
||||
|
||||
if (success) {
|
||||
VMTemplateVO template = managementServer.findTemplateById(param.getTemplateId());
|
||||
DataCenterVO destZone = managementServer.findDataCenterById(param.getDestZoneId());
|
||||
// VMTemplateHostVO templateHostRef = managementServer.findTemplateHostRef(param.getTemplateId(), destZone.getId());
|
||||
long guestOsId = template.getGuestOSId();
|
||||
Account owner = managementServer.findAccountById(template.getAccountId());
|
||||
|
||||
// DomainVO domain = managementServer.findDomainIdById(owner.getDomainId());
|
||||
// String guestOSName = managementServer.findGuestOSById(guestOsId).getName();
|
||||
// asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0, composeResultObject(template, templateHostRef, destZone,guestOSName, owner, domain));
|
||||
|
||||
} else {
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR, "Failed to copy template.");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Unable to copy template: " + e.getMessage(), e);
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR, e.getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void processAnswer(VMOperationListener listener, long agentId, long seq, Answer answer) {
|
||||
}
|
||||
|
||||
public void processDisconnect(VMOperationListener listener, long agentId) {
|
||||
}
|
||||
|
||||
public void processTimeout(VMOperationListener listener, long agentId, long seq) {
|
||||
}
|
||||
|
||||
private CopyTemplateResultObject composeResultObject(VMTemplateVO template, VMTemplateHostVO templateHostRef, DataCenterVO destZone, String guestOSName, Account owner, Domain domain) {
|
||||
CopyTemplateResultObject resultObject = new CopyTemplateResultObject();
|
||||
|
||||
|
||||
// If the user is an admin, add the template download status
|
||||
boolean isAdmin = false;
|
||||
|
||||
if(owner.getType() == Account.ACCOUNT_TYPE_ADMIN)
|
||||
isAdmin = true;
|
||||
|
||||
if (isAdmin || owner.getId() == template.getAccountId()) {
|
||||
// add download status
|
||||
if (templateHostRef.getDownloadState()!=Status.DOWNLOADED) {
|
||||
String templateStatus = "Processing";
|
||||
if (templateHostRef.getDownloadState() == VMTemplateHostVO.Status.DOWNLOAD_IN_PROGRESS) {
|
||||
if (templateHostRef.getDownloadPercent() == 100) {
|
||||
templateStatus = "Installing Template";
|
||||
} else {
|
||||
templateStatus = templateHostRef.getDownloadPercent() + "% Downloaded";
|
||||
}
|
||||
} else {
|
||||
templateStatus = templateHostRef.getErrorString();
|
||||
}
|
||||
resultObject.setTemplateStatus(templateStatus);
|
||||
} else if (templateHostRef.getDownloadState() == VMTemplateHostVO.Status.DOWNLOADED) {
|
||||
resultObject.setTemplateStatus("Download Complete");
|
||||
} else {
|
||||
resultObject.setTemplateStatus("Successfully Installed");
|
||||
}
|
||||
}
|
||||
|
||||
resultObject.setAccountName(owner.getAccountName());
|
||||
resultObject.setDomainId(owner.getDomainId());
|
||||
resultObject.setDomainName(domain.getName());
|
||||
resultObject.setId(template.getId());
|
||||
resultObject.setName(template.getName());
|
||||
resultObject.setDisplayText(template.getDisplayText());
|
||||
resultObject.setPublic(template.isPublicTemplate());
|
||||
resultObject.setOsTypeName(guestOSName);
|
||||
resultObject.setCreated(templateHostRef.getCreated());
|
||||
resultObject.setReady(templateHostRef != null && templateHostRef.getDownloadState() == Status.DOWNLOADED);
|
||||
resultObject.setFeatured(template.isFeatured());
|
||||
resultObject.setPasswordEnabled(template.getEnablePassword());
|
||||
resultObject.setFormat(template.getFormat());
|
||||
resultObject.setGuestOsId(template.getGuestOSId());
|
||||
resultObject.setZoneId(destZone.getId());
|
||||
resultObject.setZoneName(destZone.getName());
|
||||
return resultObject;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
public class CopyTemplateParam {
|
||||
|
||||
private long userId;
|
||||
private long templateId;
|
||||
private Long sourceZoneId;
|
||||
private Long destZoneId;
|
||||
private long eventId;
|
||||
|
||||
public CopyTemplateParam() {
|
||||
}
|
||||
|
||||
public CopyTemplateParam(long userId, long templateId, Long sourceZoneId, Long destZoneId, long eventId) {
|
||||
this.userId = userId;
|
||||
this.templateId = templateId;
|
||||
this.sourceZoneId = sourceZoneId;
|
||||
this.destZoneId = destZoneId;
|
||||
this.eventId = eventId;
|
||||
}
|
||||
|
||||
public long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public long getTemplateId() {
|
||||
return templateId;
|
||||
}
|
||||
|
||||
public Long getSourceZoneId() {
|
||||
return sourceZoneId;
|
||||
}
|
||||
|
||||
public Long getDestZoneId() {
|
||||
return destZoneId;
|
||||
}
|
||||
|
||||
public void setEventId(long eventId) {
|
||||
this.eventId = eventId;
|
||||
}
|
||||
|
||||
public long getEventId() {
|
||||
return eventId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,235 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
|
||||
public class CopyTemplateResultObject {
|
||||
@Param(name="id")
|
||||
private long id;
|
||||
|
||||
@Param(name="name")
|
||||
private String name;
|
||||
|
||||
@Param(name="displaytext")
|
||||
private String displayText;
|
||||
|
||||
@Param(name="ispublic", propName="public")
|
||||
private boolean isPublic;
|
||||
|
||||
// @Param(name="requireshvm")
|
||||
// private Boolean requiresHvm;
|
||||
//
|
||||
// @Param(name="bits")
|
||||
// private Integer bits;
|
||||
|
||||
@Param(name="created")
|
||||
private Date created;
|
||||
|
||||
@Param(name="isready", propName="ready")
|
||||
private boolean isReady;
|
||||
|
||||
@Param(name="isfeatured", propName="featured")
|
||||
private boolean isFeatured;
|
||||
|
||||
@Param(name="passwordenabled")
|
||||
private boolean passwordEnabled;
|
||||
|
||||
@Param(name="format")
|
||||
private ImageFormat format;
|
||||
|
||||
@Param(name="ostypeid")
|
||||
private long guestOsId;
|
||||
|
||||
@Param(name="zoneid")
|
||||
private long zoneId;
|
||||
|
||||
@Param(name="zonename")
|
||||
private String zoneName;
|
||||
|
||||
@Param(name="ostypename")
|
||||
private String osTypeName;
|
||||
|
||||
@Param(name="account")
|
||||
private String accountName;
|
||||
|
||||
@Param(name="domain")
|
||||
private String domainName;
|
||||
|
||||
@Param(name="domainid")
|
||||
private long domainId;
|
||||
|
||||
@Param(name="templatestatus")
|
||||
private String templateStatus;
|
||||
|
||||
public String getTemplateStatus() {
|
||||
return templateStatus;
|
||||
}
|
||||
|
||||
public void setTemplateStatus(String templateStatus) {
|
||||
this.templateStatus = templateStatus;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
}
|
||||
|
||||
public void setDisplayText(String displayText) {
|
||||
this.displayText = displayText;
|
||||
}
|
||||
|
||||
public boolean isPublic() {
|
||||
return isPublic;
|
||||
}
|
||||
|
||||
public void setPublic(boolean isPublic) {
|
||||
this.isPublic = isPublic;
|
||||
}
|
||||
|
||||
// public boolean isRequiresHvm() {
|
||||
// return requiresHvm;
|
||||
// }
|
||||
//
|
||||
// public void setRequiresHvm(boolean requiresHvm) {
|
||||
// this.requiresHvm = requiresHvm;
|
||||
// }
|
||||
//
|
||||
// public int getBits() {
|
||||
// return bits;
|
||||
// }
|
||||
//
|
||||
// public void setBits(int bits) {
|
||||
// this.bits = bits;
|
||||
// }
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public String getOsTypeName() {
|
||||
return this.osTypeName;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public boolean isReady() {
|
||||
return isReady;
|
||||
}
|
||||
|
||||
public void setReady(boolean isReady) {
|
||||
this.isReady = isReady;
|
||||
}
|
||||
|
||||
public boolean isFeatured() {
|
||||
return isFeatured;
|
||||
}
|
||||
|
||||
public void setFeatured(boolean isFeatured) {
|
||||
this.isFeatured = isFeatured;
|
||||
}
|
||||
|
||||
public boolean isPasswordEnabled() {
|
||||
return passwordEnabled;
|
||||
}
|
||||
|
||||
public void setPasswordEnabled(boolean passwordEnabled) {
|
||||
this.passwordEnabled = passwordEnabled;
|
||||
}
|
||||
|
||||
public ImageFormat getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
public void setFormat(ImageFormat format) {
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
public long getGuestOsId() {
|
||||
return guestOsId;
|
||||
}
|
||||
|
||||
public void setGuestOsId(long guestOsId) {
|
||||
this.guestOsId = guestOsId;
|
||||
}
|
||||
|
||||
public void setOsTypeName(String osTypeName) {
|
||||
this.osTypeName = osTypeName;
|
||||
}
|
||||
|
||||
public void setAccountName(String accountName) {
|
||||
this.accountName = accountName;
|
||||
}
|
||||
|
||||
public void setDomainName(String domainName) {
|
||||
this.domainName = domainName;
|
||||
}
|
||||
|
||||
public void setDomainId(long domainId) {
|
||||
this.domainId = domainId;
|
||||
}
|
||||
|
||||
public long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public String getAccountName(){
|
||||
return accountName;
|
||||
}
|
||||
|
||||
public String getDomainName(){
|
||||
return domainName;
|
||||
}
|
||||
|
||||
public void setZoneId(long zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
|
||||
public String getZoneName() {
|
||||
return zoneName;
|
||||
}
|
||||
|
||||
public void setZoneName(String zoneName) {
|
||||
this.zoneName = zoneName;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,119 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobResult;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.async.BaseAsyncJobExecutor;
|
||||
import com.cloud.exception.InternalErrorException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.NetworkRuleConflictException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.network.NetworkRuleConfigVO;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class CreateOrUpdateRuleExecutor extends BaseAsyncJobExecutor {
|
||||
public static final Logger s_logger = Logger.getLogger(CreateOrUpdateRuleExecutor.class.getName());
|
||||
|
||||
public boolean execute() {
|
||||
Gson gson = GsonHelper.getBuilder().create();
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
AsyncJobVO job = getJob();
|
||||
ManagementServer managementServer = asyncMgr.getExecutorContext().getManagementServer();
|
||||
CreateOrUpdateRuleParam param = gson.fromJson(job.getCmdInfo(), CreateOrUpdateRuleParam.class);
|
||||
|
||||
/*
|
||||
try {
|
||||
if(s_logger.isDebugEnabled())
|
||||
s_logger.debug("Executing createOrUpdateRule, uid: " + job.getUserId() + ", pfservice id: " + param.getSecurityGroupId()
|
||||
+ ", addr: " + param.getAddress() + ", port: " + param.getPort() + ", private IP: " + param.getPrivateIpAddress()
|
||||
+ ", private port: " + param.getPrivatePort() + ", protocol: " + param.getProtocol() + ", algorithm: " + param.getAlgorithm());
|
||||
|
||||
NetworkRuleConfigVO rule = managementServer.createOrUpdateRule(job.getUserId(), param.getSecurityGroupId(),
|
||||
param.getAddress(), param.getPort(), param.getPrivateIpAddress(), param.getPrivatePort(),
|
||||
param.getProtocol(), param.getAlgorithm());
|
||||
|
||||
if(rule != null) {
|
||||
if(s_logger.isDebugEnabled())
|
||||
s_logger.debug("createOrUpdateRule executed successfully, complete async-execution");
|
||||
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0,
|
||||
composeResultObject(managementServer, param, rule));
|
||||
|
||||
} else {
|
||||
s_logger.warn("createOrUpdateRule execution failed: null rule object is returned, complete async-execution");
|
||||
|
||||
asyncMgr.completeAsyncJob(getJob().getId(),
|
||||
AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR, "operation failed");
|
||||
}
|
||||
} catch (InvalidParameterValueException e) {
|
||||
if(s_logger.isDebugEnabled())
|
||||
s_logger.debug("Unable to creat or update rule: " + e.getMessage());
|
||||
asyncMgr.completeAsyncJob(getJob().getId(),
|
||||
AsyncJobResult.STATUS_FAILED, BaseCmd.PARAM_ERROR, e.getMessage());
|
||||
} catch (PermissionDeniedException e) {
|
||||
if(s_logger.isDebugEnabled())
|
||||
s_logger.debug("Unable to creat or update rule: " + e.getMessage());
|
||||
asyncMgr.completeAsyncJob(getJob().getId(),
|
||||
AsyncJobResult.STATUS_FAILED, BaseCmd.PARAM_ERROR, e.getMessage());
|
||||
} catch (NetworkRuleConflictException e) {
|
||||
if(s_logger.isDebugEnabled())
|
||||
s_logger.debug("Unable to creat or update rule: " + e.getMessage());
|
||||
if(param.isForwarding())
|
||||
asyncMgr.completeAsyncJob(getJob().getId(),
|
||||
AsyncJobResult.STATUS_FAILED, BaseCmd.NET_CONFLICT_IPFW_RULE_ERROR, e.getMessage());
|
||||
else
|
||||
asyncMgr.completeAsyncJob(getJob().getId(),
|
||||
AsyncJobResult.STATUS_FAILED, BaseCmd.NET_CONFLICT_LB_RULE_ERROR, e.getMessage());
|
||||
} catch (InternalErrorException e) {
|
||||
if(s_logger.isDebugEnabled())
|
||||
s_logger.debug("Unable to creat or update rule: " + e.getMessage());
|
||||
asyncMgr.completeAsyncJob(getJob().getId(),
|
||||
AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR, e.getMessage());
|
||||
} catch(Exception e) {
|
||||
s_logger.warn("Unable to creat or update rule: " + e.getMessage(), e);
|
||||
asyncMgr.completeAsyncJob(getJob().getId(),
|
||||
AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR, e.getMessage());
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
private CreateOrUpdateRuleResultObject composeResultObject(ManagementServer managementServer,
|
||||
CreateOrUpdateRuleParam param, NetworkRuleConfigVO rule) {
|
||||
|
||||
CreateOrUpdateRuleResultObject resultObject = new CreateOrUpdateRuleResultObject();
|
||||
resultObject.setRuleId(rule.getId());
|
||||
resultObject.setPublicIp(param.getAddress());
|
||||
resultObject.setPublicPort(Integer.valueOf(param.getPort()));
|
||||
resultObject.setPrivateIp(param.getPrivateIpAddress());
|
||||
resultObject.setPrivatePort(Integer.valueOf(param.getPrivatePort()));
|
||||
resultObject.setEnabled(true);
|
||||
resultObject.setAlgorithm(param.getAlgorithm());
|
||||
resultObject.setProtocol(param.getProtocol());
|
||||
resultObject.setPortForwardingServiceId(param.getSecurityGroupId());
|
||||
return resultObject;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,140 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
public class CreateOrUpdateRuleParam {
|
||||
private boolean isForwarding;
|
||||
private long userId;
|
||||
private Long accountId;
|
||||
private String address;
|
||||
private String port;
|
||||
private String privateIpAddress;
|
||||
private String privatePort;
|
||||
private String protocol;
|
||||
private String algorithm;
|
||||
private Long domainId;
|
||||
private Long securityGroupId;
|
||||
|
||||
public CreateOrUpdateRuleParam() {
|
||||
}
|
||||
|
||||
public CreateOrUpdateRuleParam(boolean isForwarding, long userId, Long accountId, String address,
|
||||
String port, String privateIpAddress, String privatePort, String protocol, String algorithm, Long domainId, Long securityGroupId) {
|
||||
this.isForwarding = isForwarding;
|
||||
this.userId = userId;
|
||||
this.accountId = accountId;
|
||||
this.address = address;
|
||||
this.port = port;
|
||||
this.privateIpAddress = privateIpAddress;
|
||||
this.privatePort = privatePort;
|
||||
this.protocol = protocol;
|
||||
this.algorithm = algorithm;
|
||||
this.domainId = domainId;
|
||||
this.securityGroupId = securityGroupId;
|
||||
}
|
||||
|
||||
public boolean isForwarding() {
|
||||
return isForwarding;
|
||||
}
|
||||
|
||||
public void setForwarding(boolean isForwarding) {
|
||||
this.isForwarding = isForwarding;
|
||||
}
|
||||
|
||||
public long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Long getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public void setAccountId(Long accountId) {
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(String port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getPrivateIpAddress() {
|
||||
return privateIpAddress;
|
||||
}
|
||||
|
||||
public void setPrivateIpAddress(String privateIpAddress) {
|
||||
this.privateIpAddress = privateIpAddress;
|
||||
}
|
||||
|
||||
public String getPrivatePort() {
|
||||
return privatePort;
|
||||
}
|
||||
|
||||
public void setPrivatePort(String privatePort) {
|
||||
this.privatePort = privatePort;
|
||||
}
|
||||
|
||||
public String getProtocol() {
|
||||
return protocol;
|
||||
}
|
||||
|
||||
public void setProtocol(String protocol) {
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
public String getAlgorithm() {
|
||||
return algorithm;
|
||||
}
|
||||
|
||||
public void setAlgorithm(String algorithm) {
|
||||
this.algorithm = algorithm;
|
||||
}
|
||||
|
||||
public Long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public void setDomainId(Long domainId) {
|
||||
this.domainId = domainId;
|
||||
}
|
||||
|
||||
public Long getSecurityGroupId() {
|
||||
return securityGroupId;
|
||||
}
|
||||
|
||||
public void setSecurityGroupId(Long securityGroupId) {
|
||||
this.securityGroupId = securityGroupId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,123 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
|
||||
public class CreateOrUpdateRuleResultObject {
|
||||
|
||||
@Param(name="id")
|
||||
private long ruleId;
|
||||
|
||||
@Param(name="publicip")
|
||||
private String publicIp;
|
||||
|
||||
@Param(name="publicport")
|
||||
private int publicPort;
|
||||
|
||||
@Param(name="privateip")
|
||||
private String privateIp;
|
||||
|
||||
@Param(name="privateport")
|
||||
private int privatePort;
|
||||
|
||||
@Param(name="isenabled")
|
||||
private boolean isEnabled;
|
||||
|
||||
@Param(name="protocol")
|
||||
private String protocol;
|
||||
|
||||
@Param(name="algorithm")
|
||||
private String algorithm;
|
||||
|
||||
@Param(name="portforwardingserviceid")
|
||||
private Long portForwardingServiceId;
|
||||
|
||||
public Long getPortForwardingServiceId() {
|
||||
return portForwardingServiceId;
|
||||
}
|
||||
|
||||
public void setPortForwardingServiceId(Long portForwardingServiceId) {
|
||||
this.portForwardingServiceId = portForwardingServiceId;
|
||||
}
|
||||
|
||||
public String getAlgorithm() {
|
||||
return algorithm;
|
||||
}
|
||||
|
||||
public void setAlgorithm(String algorithm) {
|
||||
this.algorithm = algorithm;
|
||||
}
|
||||
|
||||
public long getRuleId() {
|
||||
return ruleId;
|
||||
}
|
||||
|
||||
public void setRuleId(long ruleId) {
|
||||
this.ruleId = ruleId;
|
||||
}
|
||||
|
||||
public String getPublicIp() {
|
||||
return publicIp;
|
||||
}
|
||||
|
||||
public void setPublicIp(String publicIp) {
|
||||
this.publicIp = publicIp;
|
||||
}
|
||||
|
||||
public int getPublicPort() {
|
||||
return publicPort;
|
||||
}
|
||||
|
||||
public void setPublicPort(int publicPort) {
|
||||
this.publicPort = publicPort;
|
||||
}
|
||||
|
||||
public String getPrivateIp() {
|
||||
return privateIp;
|
||||
}
|
||||
|
||||
public void setPrivateIp(String privateIp) {
|
||||
this.privateIp = privateIp;
|
||||
}
|
||||
|
||||
public int getPrivatePort() {
|
||||
return privatePort;
|
||||
}
|
||||
|
||||
public void setPrivatePort(int privatePort) {
|
||||
this.privatePort = privatePort;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return isEnabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean isEnabled) {
|
||||
this.isEnabled = isEnabled;
|
||||
}
|
||||
|
||||
public String getProtocol() {
|
||||
return protocol;
|
||||
}
|
||||
|
||||
public void setProtocol(String protocol) {
|
||||
this.protocol = protocol;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,194 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.async.AsyncJobExecutorContext;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobResult;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.configuration.ResourceCount.ResourceType;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventVO;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.cloud.storage.GuestOS;
|
||||
import com.cloud.storage.Snapshot;
|
||||
import com.cloud.storage.VMTemplateHostVO;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.vm.UserVmManager;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class CreatePrivateTemplateExecutor extends VolumeOperationExecutor {
|
||||
public static final Logger s_logger = Logger.getLogger(CreatePrivateTemplateExecutor.class.getName());
|
||||
|
||||
public boolean execute() {
|
||||
Gson gson = GsonHelper.getBuilder().create();
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
AsyncJobVO job = getJob();
|
||||
|
||||
/*
|
||||
if(getSyncSource() == null) {
|
||||
CreatePrivateTemplateParam param = gson.fromJson(job.getCmdInfo(), CreatePrivateTemplateParam.class);
|
||||
asyncMgr.syncAsyncJobExecution(job.getId(), "Volume", param.getVolumeId());
|
||||
|
||||
// always true if it does not have sync-source
|
||||
return true;
|
||||
} else {
|
||||
CreatePrivateTemplateParam param = gson.fromJson(job.getCmdInfo(), CreatePrivateTemplateParam.class);
|
||||
|
||||
AsyncJobExecutorContext asyncJobExecutorContext = asyncMgr.getExecutorContext();
|
||||
ManagementServer managerServer = asyncJobExecutorContext.getManagementServer();
|
||||
AccountManager accountManager = asyncJobExecutorContext.getAccountMgr();
|
||||
UserVmManager vmMgr = asyncJobExecutorContext.getVmMgr();
|
||||
|
||||
Long snapshotId = param.getSnapshotId();
|
||||
Long volumeId = param.getVolumeId();
|
||||
managerServer.saveStartedEvent(param.getUserId(), param.getAccountId(), EventTypes.EVENT_TEMPLATE_CREATE, "Creating Template: " +param.getName(), param.getEventId());
|
||||
// By default, assume failure
|
||||
String details = "Could not create private template from ";
|
||||
if (snapshotId != null) {
|
||||
details += "snapshot with id: " + snapshotId;
|
||||
}
|
||||
else {
|
||||
details += "volume with id: " + volumeId;
|
||||
}
|
||||
// Job details
|
||||
Long jobId = getJob().getId();
|
||||
int jobStatus = AsyncJobResult.STATUS_FAILED;
|
||||
int resultCode = BaseCmd.INTERNAL_ERROR;
|
||||
Object resultObject = null;
|
||||
try {
|
||||
// Check that the resource limit for templates won't be exceeded
|
||||
VolumeVO volume = managerServer.findAnyVolumeById(volumeId);
|
||||
|
||||
if (volume == null) {
|
||||
throw new InvalidParameterValueException("Could not find active volume with ID " + volumeId);
|
||||
}
|
||||
|
||||
AccountVO account = (AccountVO) managerServer.findAccountById(volume.getAccountId());
|
||||
if (accountManager.resourceLimitExceeded(account, ResourceType.template)) {
|
||||
details += ", reason: The maximum number of templates for the specified account has been exceeded.";
|
||||
}
|
||||
else {
|
||||
VMTemplateVO template = vmMgr.createPrivateTemplateRecord(param.getUserId(),
|
||||
param.getVolumeId(),
|
||||
param.getName(),
|
||||
param.getDescription(),
|
||||
param.getGuestOsId(),
|
||||
param.getRequiresHvm(),
|
||||
param.getBits(),
|
||||
param.isPasswordEnabled(),
|
||||
param.isPublic(),
|
||||
param.isFeatured());
|
||||
|
||||
if (template != null) {
|
||||
|
||||
if(s_logger.isInfoEnabled())
|
||||
s_logger.info("CreatePrivateTemplate created a new instance " + template.getId()
|
||||
+ ", update async job-" + job.getId() + " progress status");
|
||||
|
||||
asyncMgr.updateAsyncJobAttachment(job.getId(), "vm_template", template.getId());
|
||||
asyncMgr.updateAsyncJobStatus(job.getId(), BaseCmd.PROGRESS_INSTANCE_CREATED, template.getId());
|
||||
|
||||
template = managerServer.createPrivateTemplate(template, param.getUserId(), snapshotId, volumeId, param.getName(), param.getDescription());
|
||||
|
||||
if (template != null) {
|
||||
VMTemplateHostVO templateHostRef = managerServer.findTemplateHostRef(template.getId(),
|
||||
volume.getDataCenterId());
|
||||
jobStatus = AsyncJobResult.STATUS_SUCCEEDED;
|
||||
resultCode = 0;
|
||||
details = null;
|
||||
String eventParams = "id=" + template.getId() + "\nname=" + template.getName() + "\nsize="
|
||||
+ volume.getSize() + "\ndcId=" + volume.getDataCenterId();
|
||||
managerServer.saveEvent(param.getUserId(), param.getAccountId(), EventVO.LEVEL_INFO,
|
||||
EventTypes.EVENT_TEMPLATE_CREATE, "Successfully created Template "
|
||||
+ param.getName(), eventParams, param.getEventId());
|
||||
resultObject = composeResultObject(template, templateHostRef, volume.getDataCenterId());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch (InvalidParameterValueException e) {
|
||||
details += ", reason: " + e.getMessage();
|
||||
s_logger.error(details, e);
|
||||
resultCode = BaseCmd.PARAM_ERROR;
|
||||
} catch (Exception e) {
|
||||
details += ", reason: " + e.getMessage();
|
||||
s_logger.error(details, e);
|
||||
}
|
||||
|
||||
if (jobStatus == AsyncJobResult.STATUS_FAILED) {
|
||||
resultObject = details;
|
||||
managerServer.saveEvent(param.getUserId(), param.getAccountId(), EventVO.LEVEL_ERROR, EventTypes.EVENT_TEMPLATE_CREATE, details, "" ,param.getEventId());
|
||||
}
|
||||
asyncMgr.completeAsyncJob(jobId, jobStatus, resultCode, resultObject);
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
private CreatePrivateTemplateResultObject composeResultObject(VMTemplateVO template, VMTemplateHostVO templateHostRef, Long dataCenterId) {
|
||||
CreatePrivateTemplateResultObject resultObject = new CreatePrivateTemplateResultObject();
|
||||
|
||||
resultObject.setId(template.getId());
|
||||
resultObject.setName(template.getName());
|
||||
resultObject.setDisplayText(template.getDisplayText());
|
||||
resultObject.setPublic(template.isPublicTemplate());
|
||||
resultObject.setCreated(templateHostRef.getCreated());
|
||||
resultObject.setReady(templateHostRef != null && templateHostRef.getDownloadState() == Status.DOWNLOADED);
|
||||
resultObject.setPasswordEnabled(template.getEnablePassword());
|
||||
resultObject.setCrossZones(template.isCrossZones());
|
||||
ManagementServer managerServer = getAsyncJobMgr().getExecutorContext().getManagementServer();
|
||||
// GuestOS os = managerServer.findGuestOSById(template.getGuestOSId());
|
||||
// if (os != null) {
|
||||
// resultObject.setOsTypeId(os.getId());
|
||||
// resultObject.setOsTypeName(os.getDisplayName());
|
||||
// } else {
|
||||
// resultObject.setOsTypeId(-1L);
|
||||
// resultObject.setOsTypeName("");
|
||||
// }
|
||||
|
||||
Account owner = managerServer.findAccountById(template.getAccountId());
|
||||
if (owner != null) {
|
||||
resultObject.setAccount(owner.getAccountName());
|
||||
resultObject.setDomainId(owner.getDomainId());
|
||||
// resultObject.setDomainName(managerServer.findDomainIdById(owner.getDomainId()).getName());
|
||||
}
|
||||
|
||||
|
||||
DataCenterVO zone = managerServer.findDataCenterById(dataCenterId);
|
||||
if (zone != null) {
|
||||
resultObject.setZoneId(zone.getId());
|
||||
resultObject.setZoneName(zone.getName());
|
||||
}
|
||||
|
||||
return resultObject;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,154 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
public class CreatePrivateTemplateParam {
|
||||
private long userId;
|
||||
private long accountId;
|
||||
private Long volumeId;
|
||||
private Long snapshotId;
|
||||
private long guestOsId;
|
||||
private long eventId;
|
||||
private String name;
|
||||
private String description;
|
||||
private Boolean requiresHvm;
|
||||
private Integer bits;
|
||||
private Boolean passwordEnabled;
|
||||
private Boolean isPublic;
|
||||
private Boolean isFeatured;
|
||||
|
||||
public CreatePrivateTemplateParam() {
|
||||
}
|
||||
|
||||
public CreatePrivateTemplateParam(long userId, long accountId, Long volumeId, long guestOsId, long eventId, String name, String description, Boolean requiresHvm, Integer bits, Boolean passwordEnabled, Boolean isPublic, Boolean featured, Long snapshotId) {
|
||||
this.userId = userId;
|
||||
this.accountId = accountId;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.volumeId = volumeId;
|
||||
this.guestOsId = guestOsId;
|
||||
this.eventId = eventId;
|
||||
this.requiresHvm = requiresHvm;
|
||||
this.bits = bits;
|
||||
this.passwordEnabled = passwordEnabled;
|
||||
this.isPublic = isPublic;
|
||||
this.isFeatured = featured;
|
||||
this.snapshotId = snapshotId;
|
||||
}
|
||||
|
||||
public long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public long getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public void setAccountId(long accountId) {
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
public long getVolumeId() {
|
||||
return volumeId;
|
||||
}
|
||||
|
||||
public void setVmId(long volumeId) {
|
||||
this.volumeId = volumeId;
|
||||
}
|
||||
|
||||
public Long getSnapshotId() {
|
||||
return snapshotId;
|
||||
}
|
||||
|
||||
public void setSnapshotId(Long snapshotId) {
|
||||
this.snapshotId = snapshotId;
|
||||
}
|
||||
|
||||
public long getGuestOsId() {
|
||||
return guestOsId;
|
||||
}
|
||||
|
||||
public void setGuestOsId(long guestOsId) {
|
||||
this.guestOsId = guestOsId;
|
||||
}
|
||||
|
||||
public long getEventId() {
|
||||
return eventId;
|
||||
}
|
||||
|
||||
public void setEventId(long eventId) {
|
||||
this.eventId = eventId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Boolean getRequiresHvm() {
|
||||
return requiresHvm;
|
||||
}
|
||||
|
||||
public void setRequiresHvm(Boolean requiresHvm) {
|
||||
this.requiresHvm = requiresHvm;
|
||||
}
|
||||
|
||||
public Integer getBits() {
|
||||
return bits;
|
||||
}
|
||||
|
||||
public void setBits(Integer bits) {
|
||||
this.bits = bits;
|
||||
}
|
||||
|
||||
public Boolean isPasswordEnabled() {
|
||||
return passwordEnabled;
|
||||
}
|
||||
|
||||
public void setPasswordEnabled(Boolean passwordEnabled) {
|
||||
this.passwordEnabled = passwordEnabled;
|
||||
}
|
||||
|
||||
public Boolean isPublic() {
|
||||
return isPublic;
|
||||
}
|
||||
|
||||
public boolean isFeatured() {
|
||||
return isFeatured;
|
||||
}
|
||||
|
||||
public void setIsPublic(Boolean isPublic) {
|
||||
this.isPublic = isPublic;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,225 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
|
||||
public class CreatePrivateTemplateResultObject {
|
||||
@Param(name="id")
|
||||
private long id;
|
||||
|
||||
@Param(name="name")
|
||||
private String name;
|
||||
|
||||
@Param(name="displaytext")
|
||||
private String displayText;
|
||||
|
||||
@Param(name="ispublic", propName="public")
|
||||
private boolean isPublic;
|
||||
|
||||
// @Param(name="requireshvm")
|
||||
// private boolean requiresHvm;
|
||||
//
|
||||
// @Param(name="bits")
|
||||
// private int bits;
|
||||
|
||||
@Param(name="created")
|
||||
private Date created;
|
||||
|
||||
@Param(name="isready", propName="ready")
|
||||
private boolean isReady;
|
||||
|
||||
@Param(name="passwordenabled")
|
||||
private boolean passwordEnabled;
|
||||
|
||||
@Param(name="crossZones")
|
||||
private boolean crossZones;
|
||||
|
||||
@Param(name="ostypeid")
|
||||
private Long osTypeId;
|
||||
|
||||
@Param(name="ostypename")
|
||||
private String osTypeName;
|
||||
|
||||
@Param(name="accountid")
|
||||
private Long accountId;
|
||||
|
||||
@Param(name="account")
|
||||
private String account;
|
||||
|
||||
@Param(name="zoneid")
|
||||
private Long zoneId;
|
||||
|
||||
@Param(name="zonename")
|
||||
private String zoneName;
|
||||
|
||||
@Param(name="domain")
|
||||
private String domainName;
|
||||
|
||||
@Param(name="domainid")
|
||||
private long domainId;
|
||||
|
||||
|
||||
public Long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public void setZoneId(Long zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
|
||||
public String getZoneName() {
|
||||
return zoneName;
|
||||
}
|
||||
|
||||
public void setZoneName(String zoneName) {
|
||||
this.zoneName = zoneName;
|
||||
}
|
||||
|
||||
public Long getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public void setAccountId(Long accountId) {
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setAccount(String account) {
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public Long getOsTypeId() {
|
||||
return osTypeId;
|
||||
}
|
||||
|
||||
public void setOsTypeId(Long osTypeId) {
|
||||
this.osTypeId = osTypeId;
|
||||
}
|
||||
|
||||
public String getOsTypeName() {
|
||||
return osTypeName;
|
||||
}
|
||||
|
||||
public void setOsTypeName(String osTypeName) {
|
||||
this.osTypeName = osTypeName;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
}
|
||||
|
||||
public void setDisplayText(String displayText) {
|
||||
this.displayText = displayText;
|
||||
}
|
||||
|
||||
public boolean isPublic() {
|
||||
return isPublic;
|
||||
}
|
||||
|
||||
public void setPublic(boolean isPublic) {
|
||||
this.isPublic = isPublic;
|
||||
}
|
||||
|
||||
// public boolean isRequiresHvm() {
|
||||
// return requiresHvm;
|
||||
// }
|
||||
//
|
||||
// public void setRequiresHvm(boolean requiresHvm) {
|
||||
// this.requiresHvm = requiresHvm;
|
||||
// }
|
||||
//
|
||||
// public int getBits() {
|
||||
// return bits;
|
||||
// }
|
||||
//
|
||||
// public void setBits(int bits) {
|
||||
// this.bits = bits;
|
||||
// }
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public boolean isReady() {
|
||||
return isReady;
|
||||
}
|
||||
|
||||
public void setReady(boolean isReady) {
|
||||
this.isReady = isReady;
|
||||
}
|
||||
|
||||
public boolean isPasswordEnabled() {
|
||||
return passwordEnabled;
|
||||
}
|
||||
|
||||
public void setPasswordEnabled(boolean passwordEnabled) {
|
||||
this.passwordEnabled = passwordEnabled;
|
||||
}
|
||||
|
||||
public boolean isCrossZones() {
|
||||
return crossZones;
|
||||
}
|
||||
|
||||
public void setCrossZones(boolean crossZones) {
|
||||
this.crossZones = crossZones;
|
||||
}
|
||||
|
||||
public long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public String getDomainName(){
|
||||
return domainName;
|
||||
}
|
||||
|
||||
public void setDomainName(String domainName) {
|
||||
this.domainName = domainName;
|
||||
}
|
||||
|
||||
public void setDomainId(long domainId) {
|
||||
this.domainId = domainId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,144 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.async.BaseAsyncJobExecutor;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.cloud.storage.Snapshot;
|
||||
import com.cloud.storage.Snapshot.Type;
|
||||
import com.cloud.user.Account;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class CreateSnapshotExecutor extends BaseAsyncJobExecutor {
|
||||
public static final Logger s_logger = Logger.getLogger(CreateSnapshotExecutor.class.getName());
|
||||
|
||||
public boolean execute() {
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
AsyncJobVO job = getJob();
|
||||
Gson gson = GsonHelper.getBuilder().create();
|
||||
|
||||
/*
|
||||
if (getSyncSource() == null) {
|
||||
SnapshotOperationParam param = gson.fromJson(job.getCmdInfo(), SnapshotOperationParam.class);
|
||||
asyncMgr.syncAsyncJobExecution(job.getId(), "Volume", param.getVolumeId());
|
||||
|
||||
// always true if it does not have sync-source
|
||||
return true;
|
||||
} else {
|
||||
SnapshotOperationParam param = gson.fromJson(job.getCmdInfo(), SnapshotOperationParam.class);
|
||||
SnapshotManager snapshotManager = asyncMgr.getExecutorContext().getSnapshotMgr();
|
||||
ManagementServer managementServer = getAsyncJobMgr().getExecutorContext().getManagementServer();
|
||||
VolumeDao volumeDao = asyncMgr.getExecutorContext().getVolumeDao();
|
||||
long volumeId = param.getVolumeId();
|
||||
long policyId = param.getPolicyId();
|
||||
long startEventId = param.getEventId();
|
||||
|
||||
long snapshotId = 0;
|
||||
long userId = param.getUserId();
|
||||
|
||||
// By default assume that everything has failed.
|
||||
boolean backedUp = false;
|
||||
Long jobId = getJob().getId();
|
||||
int result = AsyncJobResult.STATUS_FAILED;
|
||||
int errorCode = BaseCmd.INTERNAL_ERROR;
|
||||
Object resultObject = "Failed to create snapshot.";
|
||||
VolumeVO vol = null;
|
||||
|
||||
try {
|
||||
vol = volumeDao.acquire(volumeId, 10);
|
||||
if( vol != null) {
|
||||
managementServer.saveStartedEvent(userId, vol.getAccountId(), EventTypes.EVENT_SNAPSHOT_CREATE, "Start creating snapshot for volume:"+volumeId, startEventId);
|
||||
SnapshotVO snapshot = snapshotManager.createSnapshot(userId, volumeId, policyId);
|
||||
|
||||
if (snapshot != null && snapshot.getStatus() == Snapshot.Status.CreatedOnPrimary) {
|
||||
snapshotId = snapshot.getId();
|
||||
asyncMgr.updateAsyncJobStatus(jobId, BaseCmd.PROGRESS_INSTANCE_CREATED, snapshotId);
|
||||
backedUp = snapshotManager.backupSnapshotToSecondaryStorage(userId, snapshot, startEventId);
|
||||
if (backedUp) {
|
||||
result = AsyncJobResult.STATUS_SUCCEEDED;
|
||||
errorCode = 0; // Success
|
||||
resultObject = composeResultObject(snapshot);
|
||||
}
|
||||
else {
|
||||
// More specific error
|
||||
resultObject = "Created snapshot: " + snapshotId + " on primary but failed to backup on secondary";
|
||||
}
|
||||
} else if (snapshot != null && snapshot.getStatus() == Snapshot.Status.EmptySnapshot) {
|
||||
resultObject ="There is no change since last snapshot, please use last snapshot";
|
||||
s_logger.warn(resultObject);
|
||||
}
|
||||
} else {
|
||||
resultObject = "Another snapshot is being created for " + volumeId + " try another time ";
|
||||
s_logger.warn(resultObject);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
resultObject = "Unable to create snapshot: " + e.getMessage();
|
||||
s_logger.warn(resultObject, e);
|
||||
} finally {
|
||||
if( vol != null ){
|
||||
volumeDao.release(volumeId);
|
||||
}
|
||||
}
|
||||
|
||||
// In all cases, ensure that we call completeAsyncJob to the asyncMgr.
|
||||
asyncMgr.completeAsyncJob(jobId, result, errorCode, resultObject);
|
||||
|
||||
// Cleanup jobs to do after the snapshot has been created.
|
||||
snapshotManager.postCreateSnapshot(userId, volumeId, snapshotId, policyId, backedUp);
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
private CreateSnapshotResultObject composeResultObject(Snapshot snapshot) {
|
||||
CreateSnapshotResultObject resultObject = new CreateSnapshotResultObject();
|
||||
ManagementServer managementServer = getAsyncJobMgr().getExecutorContext().getManagementServer();
|
||||
// VolumeVO volume = managementServer.findVolumeById(snapshot.getVolumeId());
|
||||
|
||||
resultObject.setId(snapshot.getId());
|
||||
long domainId = -1;
|
||||
Account account = getAsyncJobMgr().getExecutorContext().getAccountDao().findById(snapshot.getAccountId());
|
||||
if(account != null)
|
||||
{
|
||||
resultObject.setAccountName(account.getAccountName());
|
||||
domainId = account.getDomainId();
|
||||
|
||||
if(domainId != -1)
|
||||
{
|
||||
resultObject.setDomainId(domainId);
|
||||
// resultObject.setDomainName(getAsyncJobMgr().getExecutorContext().getManagementServer().findDomainIdById(domainId).getName());
|
||||
}
|
||||
|
||||
}
|
||||
String snapshotTypeStr = Type.values()[snapshot.getSnapshotType()].name();
|
||||
resultObject.setSnapshotType(snapshotTypeStr);
|
||||
resultObject.setVolumeId(snapshot.getVolumeId());
|
||||
// resultObject.setVolumeName(volume.getName());
|
||||
// resultObject.setVolumeType(volume.getVolumeType());
|
||||
resultObject.setCreated(snapshot.getCreated());
|
||||
resultObject.setName(snapshot.getName());
|
||||
return resultObject;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,149 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
import com.cloud.storage.Volume.VolumeType;
|
||||
|
||||
public class CreateSnapshotResultObject {
|
||||
|
||||
@Param(name="id")
|
||||
private long id;
|
||||
|
||||
@Param(name="account")
|
||||
private String accountName;
|
||||
|
||||
@Param(name="volumeid")
|
||||
private long volumeId;
|
||||
|
||||
@Param(name="domainid")
|
||||
private long domainId;
|
||||
|
||||
@Param(name="domainname")
|
||||
private String domainName;
|
||||
|
||||
@Param(name="created")
|
||||
private Date created;
|
||||
|
||||
@Param(name="name")
|
||||
private String name;
|
||||
|
||||
@Param(name="path")
|
||||
private String path;
|
||||
|
||||
@Param(name="snapshottype")
|
||||
private String snapshotType;
|
||||
|
||||
@Param(name="volumename")
|
||||
private String volumeName;
|
||||
|
||||
@Param(name="volumetype")
|
||||
private VolumeType volumeType;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getAccountName() {
|
||||
return accountName;
|
||||
}
|
||||
|
||||
public void setAccountName(String accountName) {
|
||||
this.accountName = accountName;
|
||||
}
|
||||
|
||||
public long getVolumeId() {
|
||||
return volumeId;
|
||||
}
|
||||
|
||||
public void setVolumeId(long volumeId) {
|
||||
this.volumeId = volumeId;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
|
||||
public void setDomainId(long domainId) {
|
||||
this.domainId = domainId;
|
||||
}
|
||||
|
||||
public long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public void setDomainName(String domainName) {
|
||||
this.domainName = domainName;
|
||||
}
|
||||
|
||||
public String getDomainName() {
|
||||
return domainName;
|
||||
}
|
||||
|
||||
public void setSnapshotType(String snapshotType){
|
||||
this.snapshotType = snapshotType;
|
||||
}
|
||||
|
||||
public String getSnapshotType(){
|
||||
return this.snapshotType;
|
||||
}
|
||||
|
||||
public String getVolumeName() {
|
||||
return volumeName;
|
||||
}
|
||||
|
||||
public void setVolumeName(String volumeName) {
|
||||
this.volumeName = volumeName;
|
||||
}
|
||||
|
||||
public VolumeType getVolumeType() {
|
||||
return volumeType;
|
||||
}
|
||||
|
||||
public void setVolumeType(VolumeType volumeType) {
|
||||
this.volumeType = volumeType;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,134 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.async.AsyncInstanceCreateStatus;
|
||||
import com.cloud.async.AsyncJobExecutorContext;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobResult;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.async.BaseAsyncJobExecutor;
|
||||
import com.cloud.configuration.ResourceCount.ResourceType;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.cloud.storage.Snapshot;
|
||||
import com.cloud.storage.StorageManager;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class CreateVolumeFromSnapshotExecutor extends BaseAsyncJobExecutor {
|
||||
public static final Logger s_logger = Logger.getLogger(CreateVolumeFromSnapshotExecutor.class.getName());
|
||||
|
||||
public boolean execute() {
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
AsyncJobVO job = getJob();
|
||||
Gson gson = GsonHelper.getBuilder().create();
|
||||
AsyncJobExecutorContext context = asyncMgr.getExecutorContext();
|
||||
ManagementServer managerServer = context.getManagementServer();
|
||||
//SnapshotManager snapshotManager = context.getSnapshotMgr();
|
||||
StorageManager storageManager = context.getStorageMgr();
|
||||
AccountManager accountManager = context.getAccountMgr();
|
||||
/*
|
||||
if (getSyncSource() == null) {
|
||||
SnapshotOperationParam param = gson.fromJson(job.getCmdInfo(), SnapshotOperationParam.class);
|
||||
asyncMgr.syncAsyncJobExecution(job.getId(), "Volume", param.getVolumeId());
|
||||
|
||||
// always true if it does not have sync-source
|
||||
return true;
|
||||
} else {
|
||||
SnapshotOperationParam param = gson.fromJson(job.getCmdInfo(), SnapshotOperationParam.class);
|
||||
VolumeVO volume = null;
|
||||
|
||||
// By default assume that everything has failed.
|
||||
Long jobId = getJob().getId();
|
||||
int result = AsyncJobResult.STATUS_FAILED;
|
||||
int errorCode = BaseCmd.INTERNAL_ERROR;
|
||||
Object resultObject = "Failed to create volume from snapshot: " + param.getSnapshotId();
|
||||
|
||||
try {
|
||||
long accountId = param.getAccountId();
|
||||
long userId = param.getUserId();
|
||||
long snapshotId = param.getSnapshotId();
|
||||
String volumeName = param.getName();
|
||||
Snapshot snapshot = managerServer.findSnapshotById(snapshotId);
|
||||
if (snapshot == null) {
|
||||
throw new InvalidParameterValueException("The snapshot was deleted after createVolumeFromSnapshot command was issued.");
|
||||
}
|
||||
AccountVO account = (AccountVO) managerServer.findAccountById(snapshot.getAccountId());
|
||||
|
||||
// Check that the resource limit for volumes won't be exceeded
|
||||
if (accountManager.resourceLimitExceeded(account, ResourceType.volume)) {
|
||||
ResourceAllocationException rae = new ResourceAllocationException("Maximum number of volumes for account: " + account.getAccountName() + " has been exceeded.");
|
||||
rae.setResourceType("volume");
|
||||
throw rae;
|
||||
}
|
||||
|
||||
volume = storageManager.createVolumeFromSnapshot(userId, accountId, snapshotId, volumeName, param.getEventId());
|
||||
|
||||
if (volume != null && volume.getStatus() == AsyncInstanceCreateStatus.Created) {
|
||||
result = AsyncJobResult.STATUS_SUCCEEDED;
|
||||
errorCode = 0; // Success
|
||||
resultObject = composeResultObject(volume);
|
||||
// Increment the number of volumes
|
||||
accountManager.incrementResourceCount(accountId, ResourceType.volume);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
resultObject = (String)resultObject + ", reason: " + e.getMessage();
|
||||
s_logger.warn(resultObject, e);
|
||||
}
|
||||
// In all cases, ensure that we call completeAsyncJob to the asyncMgr.
|
||||
asyncMgr.completeAsyncJob(jobId, result, errorCode, resultObject);
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
private VolumeOperationResultObject composeResultObject(VolumeVO volume)
|
||||
{
|
||||
VolumeOperationResultObject resultObject = new VolumeOperationResultObject();
|
||||
ManagementServer managementServer = getAsyncJobMgr().getExecutorContext().getManagementServer();
|
||||
resultObject.setId(volume.getId());
|
||||
resultObject.setName(volume.getName());
|
||||
resultObject.setVolumeType(volume.getVolumeType());
|
||||
resultObject.setVolumeSize(volume.getSize());
|
||||
resultObject.setDiskOfferingId(volume.getDiskOfferingId());
|
||||
resultObject.setCreatedDate(volume.getCreated());
|
||||
resultObject.setState(volume.getStatus());
|
||||
Long accountId = volume.getAccountId();
|
||||
Account account = managementServer.findAccountById(accountId);
|
||||
resultObject.setAccountName(account.getAccountName());
|
||||
resultObject.setDomainId(volume.getDomainId());
|
||||
// resultObject.setDomain(managementServer.findDomainIdById(volume.getDomainId()).getName());
|
||||
resultObject.setZoneId(volume.getDataCenterId());
|
||||
// resultObject.setZoneName(getAsyncJobMgr().getExecutorContext().getManagementServer().getDataCenterBy(volume.getDataCenterId()).getName());
|
||||
resultObject.setStorageType("shared"); // NOTE: You can never create a local disk volume but if that changes, we need to change this
|
||||
if (volume.getPoolId() != null)
|
||||
resultObject.setStorage(managementServer.findPoolById(volume.getPoolId()).getName());
|
||||
return resultObject;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobResult;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.async.BaseAsyncJobExecutor;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class DeleteDomainExecutor extends BaseAsyncJobExecutor {
|
||||
public static final Logger s_logger = Logger.getLogger(DeleteDomainExecutor.class.getName());
|
||||
|
||||
public boolean execute() {
|
||||
Gson gson = GsonHelper.getBuilder().create();
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
AsyncJobVO job = getJob();
|
||||
ManagementServer managementServer = asyncMgr.getExecutorContext().getManagementServer();
|
||||
DeleteDomainParam param = gson.fromJson(job.getCmdInfo(), DeleteDomainParam.class);
|
||||
|
||||
/*
|
||||
try {
|
||||
String result = managementServer.deleteDomain(param.getDomainId(), param.getOwnerId(), param.getCleanup());
|
||||
if (result == null) {
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0, "success");
|
||||
} else {
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR, result);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
s_logger.warn("Unable to delete domain : " + e.getMessage(), e);
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR, e.getMessage());
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.async.executor;
|
||||
|
||||
public class DeleteDomainParam {
|
||||
private Long domainId;
|
||||
private Long ownerId;
|
||||
private Boolean cleanup;
|
||||
|
||||
public DeleteDomainParam() {}
|
||||
|
||||
public DeleteDomainParam(Long domainId, Long ownerId, Boolean cleanup) {
|
||||
this.domainId = domainId;
|
||||
this.ownerId = ownerId;
|
||||
this.cleanup = cleanup;
|
||||
}
|
||||
|
||||
public Long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public Long getOwnerId() {
|
||||
return ownerId;
|
||||
}
|
||||
|
||||
public Boolean getCleanup() {
|
||||
return cleanup;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobResult;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.async.BaseAsyncJobExecutor;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class DeleteLoadBalancerExecutor extends BaseAsyncJobExecutor {
|
||||
public static final Logger s_logger = Logger.getLogger(DeleteLoadBalancerExecutor.class.getName());
|
||||
|
||||
@Override
|
||||
public boolean execute() {
|
||||
Gson gson = GsonHelper.getBuilder().create();
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
AsyncJobVO job = getJob();
|
||||
LoadBalancerParam param = gson.fromJson(job.getCmdInfo(), LoadBalancerParam.class);
|
||||
|
||||
/*
|
||||
if (getSyncSource() == null) {
|
||||
asyncMgr.syncAsyncJobExecution(job.getId(), "Router", param.getDomainRouterId());
|
||||
|
||||
// always true if it does not have sync-source
|
||||
return true;
|
||||
} else {
|
||||
ManagementServer managementServer = asyncMgr.getExecutorContext().getManagementServer();
|
||||
try {
|
||||
boolean result = managementServer.deleteLoadBalancer(param.getUserId(), param.getLoadBalancerId().longValue());
|
||||
if (result)
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0, Boolean.valueOf(result).toString());
|
||||
else
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
Boolean.valueOf(result).toString());
|
||||
} catch(Exception e) {
|
||||
s_logger.warn("Unable to delete load balancer : " + e.getMessage(), e);
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
e.getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobResult;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.async.BaseAsyncJobExecutor;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class DeleteNetworkRuleConfigExecutor extends BaseAsyncJobExecutor {
|
||||
|
||||
@Override
|
||||
public boolean execute() {
|
||||
Gson gson = GsonHelper.getBuilder().create();
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
AsyncJobVO job = getJob();
|
||||
ManagementServer managementServer = asyncMgr.getExecutorContext().getManagementServer();
|
||||
Long param = gson.fromJson(job.getCmdInfo(), Long.class);
|
||||
|
||||
/*
|
||||
boolean success = managementServer.deleteNetworkRuleConfig(job.getUserId(), param.longValue());
|
||||
if (success) {
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0, "success");
|
||||
} else {
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, 0, "failed");
|
||||
}
|
||||
*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobResult;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.async.BaseAsyncJobExecutor;
|
||||
import com.cloud.exception.InternalErrorException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class DeleteRuleExecutor extends BaseAsyncJobExecutor {
|
||||
public static final Logger s_logger = Logger.getLogger(DeleteRuleExecutor.class.getName());
|
||||
|
||||
public boolean execute() {
|
||||
Gson gson = GsonHelper.getBuilder().create();
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
AsyncJobVO job = getJob();
|
||||
ManagementServer managementServer = asyncMgr.getExecutorContext().getManagementServer();
|
||||
DeleteRuleParam param = gson.fromJson(job.getCmdInfo(), DeleteRuleParam.class);
|
||||
/*
|
||||
try {
|
||||
managementServer.deleteRule(param.getRuleId(), param.getUserId(), param.getAccountId());
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0,
|
||||
"success");
|
||||
} catch (InvalidParameterValueException e) {
|
||||
if(s_logger.isDebugEnabled())
|
||||
s_logger.debug("Unable to delete rule: " + e.getMessage());
|
||||
asyncMgr.completeAsyncJob(getJob().getId(),
|
||||
AsyncJobResult.STATUS_FAILED, BaseCmd.PARAM_ERROR, e.getMessage());
|
||||
} catch (PermissionDeniedException e) {
|
||||
if(s_logger.isDebugEnabled())
|
||||
s_logger.debug("Unable to delete rule: " + e.getMessage());
|
||||
asyncMgr.completeAsyncJob(getJob().getId(),
|
||||
AsyncJobResult.STATUS_FAILED, BaseCmd.PARAM_ERROR, e.getMessage());
|
||||
} catch (InternalErrorException e) {
|
||||
if(s_logger.isDebugEnabled())
|
||||
s_logger.debug("Unable to delete rule: " + e.getMessage());
|
||||
asyncMgr.completeAsyncJob(getJob().getId(),
|
||||
AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR, e.getMessage());
|
||||
} catch(Exception e) {
|
||||
s_logger.warn("Unable to delete rule: " + e.getMessage(), e);
|
||||
asyncMgr.completeAsyncJob(getJob().getId(),
|
||||
AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR, e.getMessage());
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
public class DeleteRuleParam {
|
||||
private long ruleId;
|
||||
private long userId;
|
||||
private long accountId;
|
||||
|
||||
public DeleteRuleParam() {
|
||||
}
|
||||
|
||||
public DeleteRuleParam(long id, long userId, long accountId) {
|
||||
this.ruleId = id;
|
||||
this.userId = userId;
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
public long getRuleId() {
|
||||
return ruleId;
|
||||
}
|
||||
|
||||
public void setRuleId(long ruleId) {
|
||||
this.ruleId = ruleId;
|
||||
}
|
||||
|
||||
public long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public long getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public void setAccountId(long accountId) {
|
||||
this.accountId = accountId;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,83 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobResult;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.async.BaseAsyncJobExecutor;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.cloud.storage.Snapshot;
|
||||
import com.cloud.storage.snapshot.SnapshotManager;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class DeleteSnapshotExecutor extends BaseAsyncJobExecutor {
|
||||
public static final Logger s_logger = Logger.getLogger(DeleteSnapshotExecutor.class.getName());
|
||||
|
||||
public boolean execute() {
|
||||
|
||||
Gson gson = GsonHelper.getBuilder().create();
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
AsyncJobVO job = getJob();
|
||||
SnapshotManager snapshotManager = asyncMgr.getExecutorContext().getSnapshotMgr();
|
||||
ManagementServer managementServer = asyncMgr.getExecutorContext().getManagementServer();
|
||||
|
||||
/*
|
||||
if(getSyncSource() == null) {
|
||||
SnapshotOperationParam param = gson.fromJson(job.getCmdInfo(), SnapshotOperationParam.class);
|
||||
Snapshot snapshot = managementServer.findSnapshotById(param.getSnapshotId());
|
||||
if(snapshot != null) {
|
||||
asyncMgr.syncAsyncJobExecution(job.getId(), "Volume", snapshot.getVolumeId());
|
||||
} else {
|
||||
asyncMgr.completeAsyncJob(getJob().getId(),
|
||||
AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR, "snapshot no long exists");
|
||||
}
|
||||
|
||||
// always true if it does not have sync-source
|
||||
return true;
|
||||
} else {
|
||||
SnapshotOperationParam param = gson.fromJson(job.getCmdInfo(), SnapshotOperationParam.class);
|
||||
Long jobId = getJob().getId();
|
||||
int result = AsyncJobResult.STATUS_FAILED;
|
||||
int errorCode = BaseCmd.INTERNAL_ERROR;
|
||||
Object resultObject = "Failed to delete snapshot.";
|
||||
|
||||
try {
|
||||
if(snapshotManager.deleteSnapshot(param.getUserId(), param.getSnapshotId(), param.getPolicyId())) {
|
||||
result = AsyncJobResult.STATUS_SUCCEEDED;
|
||||
errorCode = 0;
|
||||
resultObject = "success"; // Might want to put something more substantial later.
|
||||
}
|
||||
} catch(Exception e) {
|
||||
resultObject = "Unable to destroy snapshot: " + e.getMessage();
|
||||
s_logger.warn(resultObject, e);
|
||||
}
|
||||
// In all cases, ensure that we call completeAsyncJob to the asyncMgr.
|
||||
asyncMgr.completeAsyncJob(jobId, result, errorCode, resultObject);
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobResult;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.async.BaseAsyncJobExecutor;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.google.gson.Gson;
|
||||
import com.cloud.user.User;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class DeleteUserExecutor extends BaseAsyncJobExecutor {
|
||||
public static final Logger s_logger = Logger.getLogger(DeleteUserExecutor.class.getName());
|
||||
|
||||
public boolean execute() {
|
||||
Gson gson = GsonHelper.getBuilder().create();
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
AsyncJobVO job = getJob();
|
||||
ManagementServer managementServer = asyncMgr.getExecutorContext().getManagementServer();
|
||||
Long param = gson.fromJson(job.getCmdInfo(), Long.class);
|
||||
/*
|
||||
try {
|
||||
if(managementServer.deleteUser(param.longValue())) {
|
||||
DeleteUserParam param = gson.fromJson(job.getCmdInfo(), DeleteUserParam.class);
|
||||
|
||||
try {
|
||||
User user = managementServer.getUser(param.getUserId(), true);
|
||||
String description = "Starting deleting User " + user.getUsername() + " (id: " + param.getUserId()
|
||||
+ ") for accountId = " + user.getAccountId();
|
||||
managementServer.saveStartedEvent(1L, 1L, EventTypes.EVENT_USER_DELETE, description, param.getEventId());
|
||||
|
||||
if(managementServer.deleteUser(param.getUserId())) {
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0,
|
||||
"success");
|
||||
} else {
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
"operation failed");
|
||||
}
|
||||
} catch(Exception e) {
|
||||
s_logger.warn("Unable to delete User " + param.getUserId() + ": " + e.getMessage(), e);
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
e.getMessage());
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
package com.cloud.async.executor;
|
||||
|
||||
public class DeleteUserParam {
|
||||
|
||||
private Long userId;
|
||||
private Long eventId;
|
||||
|
||||
public DeleteUserParam() {}
|
||||
|
||||
public DeleteUserParam(Long userId, Long eventId) {
|
||||
this.userId = userId;
|
||||
this.eventId = eventId;
|
||||
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public Long getEventId() {
|
||||
return eventId;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobResult;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class DestroyConsoleProxyExecutor extends VMOperationExecutor {
|
||||
public static final Logger s_logger = Logger.getLogger(DestroyConsoleProxyExecutor.class.getName());
|
||||
|
||||
public boolean execute() {
|
||||
Gson gson = GsonHelper.getBuilder().create();
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
AsyncJobVO job = getJob();
|
||||
ManagementServer managementServer = asyncMgr.getExecutorContext().getManagementServer();
|
||||
VMOperationParam param = gson.fromJson(job.getCmdInfo(), VMOperationParam.class);
|
||||
/*
|
||||
if(getSyncSource() == null) {
|
||||
asyncMgr.syncAsyncJobExecution(job.getId(), "ConsoleProxy", param.getVmId());
|
||||
return true;
|
||||
} else {
|
||||
try {
|
||||
boolean result = managementServer.destroyConsoleProxy(param.getVmId(), param.getEventId());
|
||||
if(result)
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0,
|
||||
"success");
|
||||
else
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
"operation failed");
|
||||
} catch(Exception e) {
|
||||
s_logger.warn("Unable to destroy console proxy " + param.getVmId() + ":" + e.getMessage(), e);
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
e.getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
public void processAnswer(VMOperationListener listener, long agentId, long seq, Answer answer) {
|
||||
}
|
||||
|
||||
public void processDisconnect(VMOperationListener listener, long agentId) {
|
||||
}
|
||||
|
||||
public void processTimeout(VMOperationListener listener, long agentId, long seq) {
|
||||
}
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
package com.cloud.async.executor;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobResult;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.async.BaseAsyncJobExecutor;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class ExtractTemplateExecutor extends BaseAsyncJobExecutor {
|
||||
|
||||
public static final Logger s_logger = Logger.getLogger(ExtractTemplateExecutor.class.getName());
|
||||
@Override
|
||||
public boolean execute() {
|
||||
Gson gson = GsonHelper.getBuilder().create();
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
AsyncJobVO job = getJob();
|
||||
|
||||
ExtractTemplateParam param = gson.fromJson(job.getCmdInfo(), ExtractTemplateParam.class);
|
||||
ManagementServer managementServer = asyncMgr.getExecutorContext().getManagementServer();
|
||||
|
||||
/*
|
||||
try {
|
||||
managementServer.extractTemplate(param.getUrl(), param.getTemplateId(), param.getZoneId(), param.getEventId(), getJob().getId(), param.getExtractMode());
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Unable to extract template: " + e.getMessage(), e);
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR, e.getMessage());
|
||||
}
|
||||
*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
package com.cloud.async.executor;
|
||||
|
||||
import com.cloud.storage.Upload;
|
||||
|
||||
public class ExtractTemplateParam {
|
||||
|
||||
private long userId;
|
||||
private long templateId;
|
||||
private Long zoneId;
|
||||
private long eventId;
|
||||
private String url;
|
||||
private Upload.Mode extractMode;
|
||||
|
||||
public ExtractTemplateParam() {
|
||||
}
|
||||
|
||||
public ExtractTemplateParam(long userId, long templateId, Long zoneId, long eventId, String url) {
|
||||
this.userId = userId;
|
||||
this.templateId = templateId;
|
||||
this.zoneId = zoneId;
|
||||
this.eventId = eventId;
|
||||
this.url = url;
|
||||
this.extractMode = Upload.Mode.FTP_UPLOAD;
|
||||
}
|
||||
|
||||
public ExtractTemplateParam(long userId, long templateId, Long zoneId, long eventId, String url, Upload.Mode mode) {
|
||||
this.userId = userId;
|
||||
this.templateId = templateId;
|
||||
this.zoneId = zoneId;
|
||||
this.eventId = eventId;
|
||||
this.url = url;
|
||||
this.extractMode = mode;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public long getTemplateId() {
|
||||
return templateId;
|
||||
}
|
||||
|
||||
public Long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public void setEventId(long eventId) {
|
||||
this.eventId = eventId;
|
||||
}
|
||||
|
||||
public long getEventId() {
|
||||
return eventId;
|
||||
}
|
||||
|
||||
public Upload.Mode getExtractMode() {
|
||||
return extractMode;
|
||||
}
|
||||
|
||||
public void setExtractMode(Upload.Mode extractMode) {
|
||||
this.extractMode = extractMode;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
package com.cloud.async.executor;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobResult;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.async.BaseAsyncJobExecutor;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class ExtractVolumeExecutor extends BaseAsyncJobExecutor {
|
||||
|
||||
public static final Logger s_logger = Logger.getLogger(ExtractVolumeExecutor.class.getName());
|
||||
|
||||
@Override
|
||||
public boolean execute() {
|
||||
Gson gson = GsonHelper.getBuilder().create();
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
AsyncJobVO job = getJob();
|
||||
|
||||
ExtractTemplateParam param = gson.fromJson(job.getCmdInfo(), ExtractTemplateParam.class);
|
||||
ManagementServer managementServer = asyncMgr.getExecutorContext().getManagementServer();
|
||||
|
||||
/*
|
||||
try {
|
||||
managementServer.extractVolume(param.getUrl(), param.getTemplateId(), param.getZoneId(), param.getEventId(), getJob().getId());
|
||||
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Unable to extract volume: " + e.getMessage(), e);
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR, e.getMessage());
|
||||
}
|
||||
*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobResult;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.cloud.vm.ConsoleProxyVO;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class RebootConsoleProxyExecutor extends VMOperationExecutor {
|
||||
public static final Logger s_logger = Logger.getLogger(RebootConsoleProxyExecutor.class.getName());
|
||||
|
||||
public boolean execute() {
|
||||
Gson gson = GsonHelper.getBuilder().create();
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
AsyncJobVO job = getJob();
|
||||
ManagementServer managementServer = asyncMgr.getExecutorContext().getManagementServer();
|
||||
VMOperationParam param = gson.fromJson(job.getCmdInfo(), VMOperationParam.class);
|
||||
/*
|
||||
if(getSyncSource() == null) {
|
||||
asyncMgr.syncAsyncJobExecution(job, "ConsoleProxy", param.getVmId());
|
||||
return true;
|
||||
} else {
|
||||
try {
|
||||
boolean result = managementServer.rebootConsoleProxy(param.getVmId(), param.getEventId());
|
||||
if(result)
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0,
|
||||
composeResultObject(managementServer, param.getVmId()));
|
||||
else
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
"operation failed");
|
||||
} catch(Exception e) {
|
||||
s_logger.warn("Unable to reboot console proxy " + param.getVmId() + ":" + e.getMessage(), e);
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
e.getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
public void processAnswer(VMOperationListener listener, long agentId, long seq, Answer answer) {
|
||||
}
|
||||
|
||||
public void processDisconnect(VMOperationListener listener, long agentId) {
|
||||
}
|
||||
|
||||
public void processTimeout(VMOperationListener listener, long agentId, long seq) {
|
||||
}
|
||||
|
||||
private ConsoleProxyOperationResultObject composeResultObject(ManagementServer managementServer, long proxyVmId) {
|
||||
ConsoleProxyVO proxy = managementServer.findConsoleProxyById(proxyVmId);
|
||||
return ConsoleProxyExecutorHelper.composeResultObject(managementServer, proxy);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,83 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobResult;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.exception.InternalErrorException;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class RebootRouterExecutor extends VMOperationExecutor {
|
||||
public static final Logger s_logger = Logger.getLogger(RebootRouterExecutor.class.getName());
|
||||
|
||||
public boolean execute() {
|
||||
Gson gson = GsonHelper.getBuilder().create();
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
AsyncJobVO job = getJob();
|
||||
ManagementServer managementServer = asyncMgr.getExecutorContext().getManagementServer();
|
||||
VMOperationParam param = gson.fromJson(job.getCmdInfo(), VMOperationParam.class);
|
||||
|
||||
/*
|
||||
if(getSyncSource() == null) {
|
||||
asyncMgr.syncAsyncJobExecution(job, "Router", param.getVmId());
|
||||
return true;
|
||||
} else {
|
||||
try {
|
||||
if(managementServer.rebootRouter(param.getVmId(), param.getEventId())) {
|
||||
DomainRouter router = managementServer.findDomainRouterById(param.getVmId());
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0,
|
||||
RouterExecutorHelper.composeResultObject(managementServer, router));
|
||||
} else {
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
"operation failed");
|
||||
}
|
||||
} catch (InternalErrorException e) {
|
||||
if(s_logger.isDebugEnabled())
|
||||
s_logger.debug("Unable to reboot router " + param.getVmId() + ":" + e.getMessage());
|
||||
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
e.getMessage());
|
||||
} catch(Exception e) {
|
||||
s_logger.warn("Unable to reboot router " + param.getVmId() + ":" + e.getMessage(), e);
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
e.getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
public void processAnswer(VMOperationListener listener, long agentId, long seq, Answer answer) {
|
||||
}
|
||||
|
||||
public void processDisconnect(VMOperationListener listener, long agentId) {
|
||||
}
|
||||
|
||||
public void processTimeout(VMOperationListener listener, long agentId, long seq) {
|
||||
}
|
||||
}
|
||||
|
|
@ -1,142 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobResult;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.cloud.vm.UserVmVO;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class RebootVMExecutor extends VMOperationExecutor {
|
||||
public static final Logger s_logger = Logger.getLogger(RebootVMExecutor.class.getName());
|
||||
|
||||
public boolean execute() {
|
||||
Gson gson = GsonHelper.getBuilder().create();
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
AsyncJobVO job = getJob();
|
||||
VMOperationParam param = gson.fromJson(job.getCmdInfo(), VMOperationParam.class);
|
||||
ManagementServer managementServer = asyncMgr.getExecutorContext().getManagementServer();
|
||||
UserVmVO vm = managementServer.findUserVMInstanceById(param.getVmId());
|
||||
OperationResponse response;
|
||||
|
||||
/*
|
||||
if(getSyncSource() == null) {
|
||||
asyncMgr.syncAsyncJobExecution(job.getId(), "UserVM", param.getVmId());
|
||||
|
||||
// always true if it does not have sync-source
|
||||
return true;
|
||||
} else {
|
||||
|
||||
managementServer.saveStartedEvent(param.getUserId(), param.getAccountId(), EventTypes.EVENT_VM_REBOOT, "Rebooting Vm with Id: "+param.getVmId(), param.getEventId());
|
||||
asyncMgr.updateAsyncJobAttachment(job.getId(), "vm_instance", param.getVmId());
|
||||
response = asyncMgr.getExecutorContext().getVmMgr().executeRebootVM(this, param);
|
||||
String params = "id="+vm.getId() + "\nvmName=" + vm.getName() + "\nsoId=" + vm.getServiceOfferingId() + "\ntId=" + vm.getTemplateId() + "\ndcId=" + vm.getDataCenterId();
|
||||
|
||||
if (OperationResponse.STATUS_SUCCEEDED == response.getResultCode() ){
|
||||
managementServer.saveEvent(param.getUserId(), param.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_VM_REBOOT,
|
||||
"Rebooting Vm with Id: " + param.getVmId(), params, param.getEventId());
|
||||
return true;
|
||||
}else if (OperationResponse.STATUS_FAILED == response.getResultCode()){
|
||||
managementServer.saveEvent(param.getUserId(), param.getAccountId(), EventVO.LEVEL_ERROR, EventTypes.EVENT_VM_REBOOT,
|
||||
"Failed to reboot VM instance : " + response.getResultDescription(), params, param.getEventId());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
public void processAnswer(VMOperationListener listener, long agentId, long seq, Answer answer) {
|
||||
UserVmVO vm = listener.getVm();
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
|
||||
boolean jobStatusUpdated = false;
|
||||
try {
|
||||
if(s_logger.isDebugEnabled())
|
||||
s_logger.debug("Execute asynchronize Reboot VM command: received answer, " + vm.getHostId() + "-" + seq);
|
||||
|
||||
if(answer != null) {
|
||||
asyncMgr.completeAsyncJob(getJob().getId(),
|
||||
AsyncJobResult.STATUS_SUCCEEDED, 0, VMExecutorHelper.composeResultObject(asyncMgr.getExecutorContext().getManagementServer(), vm, null));
|
||||
jobStatusUpdated = true;
|
||||
} else {
|
||||
asyncMgr.completeAsyncJob(getJob().getId(),
|
||||
AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR, "Agent is unable to execute the command");
|
||||
|
||||
jobStatusUpdated = true;
|
||||
}
|
||||
|
||||
} catch(Exception e) {
|
||||
s_logger.error("Unexpected exception " + e.getMessage(), e);
|
||||
|
||||
if(!jobStatusUpdated) {
|
||||
if(answer != null) {
|
||||
asyncMgr.completeAsyncJob(getJob().getId(),
|
||||
AsyncJobResult.STATUS_SUCCEEDED, 0, VMExecutorHelper.composeResultObject(asyncMgr.getExecutorContext().getManagementServer(), vm, null));
|
||||
} else {
|
||||
asyncMgr.completeAsyncJob(getJob().getId(),
|
||||
AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR, "Agent is unable to execute the command");
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
asyncMgr.releaseSyncSource(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void processDisconnect(VMOperationListener listener, long agentId) {
|
||||
if(s_logger.isDebugEnabled())
|
||||
s_logger.debug("Execute asynchronize Reboot VM command: agent " + agentId + " disconnected");
|
||||
|
||||
processDisconnectAndTimeout(listener, "agent is disconnected");
|
||||
}
|
||||
|
||||
public void processTimeout(VMOperationListener listener, long agentId, long seq) {
|
||||
if(s_logger.isDebugEnabled())
|
||||
s_logger.debug("Execute asynchronize Reboot VM command: timed out, " + agentId + "-" + seq);
|
||||
|
||||
processDisconnectAndTimeout(listener, "operation timed out");
|
||||
}
|
||||
|
||||
private void processDisconnectAndTimeout(VMOperationListener listener, String resultMessage) {
|
||||
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
|
||||
boolean jobStatusUpdated = false;
|
||||
try {
|
||||
asyncMgr.completeAsyncJob(getJob().getId(),
|
||||
AsyncJobResult.STATUS_FAILED, 0, resultMessage);
|
||||
jobStatusUpdated = true;
|
||||
} catch (Exception e) {
|
||||
s_logger.error("Unexpected exception " + e.getMessage(), e);
|
||||
if(!jobStatusUpdated)
|
||||
asyncMgr.completeAsyncJob(getJob().getId(),
|
||||
AsyncJobResult.STATUS_FAILED, 0, resultMessage);
|
||||
} finally {
|
||||
asyncMgr.releaseSyncSource(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,199 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobResult;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.async.BaseAsyncJobExecutor;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostStats;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.host.Status.Event;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.cloud.storage.GuestOSCategoryVO;
|
||||
import com.cloud.utils.fsm.StateMachine;
|
||||
import com.cloud.vm.UserVmVO;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class ReconnectExecutor extends BaseAsyncJobExecutor {
|
||||
public static final Logger s_logger = Logger.getLogger(ReconnectExecutor.class.getName());
|
||||
|
||||
@Override
|
||||
public boolean execute() {
|
||||
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
Gson gson = GsonHelper.getBuilder().create();
|
||||
AsyncJobVO job = getJob();
|
||||
|
||||
/*
|
||||
if(getSyncSource() == null) {
|
||||
Long param = gson.fromJson(job.getCmdInfo(), Long.class);
|
||||
asyncMgr.syncAsyncJobExecution(job.getId(), "host", param.longValue());
|
||||
|
||||
// always true if it does not have sync-source
|
||||
return true;
|
||||
} else {
|
||||
ManagementServer managementServer = asyncMgr.getExecutorContext().getManagementServer();
|
||||
Long param = gson.fromJson(job.getCmdInfo(), Long.class);
|
||||
|
||||
try {
|
||||
boolean success = managementServer.reconnect(param.longValue());
|
||||
if(success)
|
||||
{
|
||||
HostVO host = managementServer.getHostBy(param);
|
||||
final StateMachine<Status, Event> sm = new StateMachine<Status, Event>();
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0, composeResultObject(host,sm,managementServer));
|
||||
}
|
||||
else
|
||||
{
|
||||
HostVO host = managementServer.getHostBy(param);
|
||||
final StateMachine<Status, Event> sm = new StateMachine<Status, Event>();
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
composeResultObject(host,sm, managementServer));
|
||||
}
|
||||
} catch(Exception e) {
|
||||
s_logger.warn("Unable to reconnect host " + param + ": " + e.getMessage(), e);
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
e.getMessage());
|
||||
}
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
private HostResultObject composeResultObject(HostVO hostVO, StateMachine<Status, Event> sm, ManagementServer managementServer)
|
||||
{
|
||||
HostResultObject hostRO = new HostResultObject();
|
||||
|
||||
hostRO.setId(hostVO.getId());
|
||||
|
||||
hostRO.setName(hostVO.getName());
|
||||
hostRO.setState(hostVO.getStatus().toString());
|
||||
|
||||
if(hostVO.getDisconnectedOn() != null)
|
||||
hostRO.setDisconnected(hostVO.getDisconnectedOn());
|
||||
|
||||
|
||||
if (hostVO.getType() != null) {
|
||||
hostRO.setType(hostVO.getType().toString());
|
||||
}
|
||||
|
||||
// GuestOSCategoryVO guestOSCategory = managementServer.getHostGuestOSCategory(hostVO.getId());
|
||||
// if (guestOSCategory != null) {
|
||||
// hostRO.setOsCategoryId(guestOSCategory.getId());
|
||||
// hostRO.setOsCategoryName(guestOSCategory.getName());
|
||||
// }
|
||||
|
||||
|
||||
hostRO.setIpAddress(hostVO.getPrivateIpAddress());
|
||||
hostRO.setZoneId(hostVO.getDataCenterId());
|
||||
// hostRO.setZoneName(managementServer.getDataCenterBy(hostVO.getDataCenterId()).getName());
|
||||
|
||||
if (hostVO.getPodId() != null && managementServer.findHostPodById(hostVO.getPodId()) != null) {
|
||||
hostRO.setPodId(hostVO.getPodId());
|
||||
hostRO.setPodName((managementServer.findHostPodById(hostVO.getPodId())).getName());
|
||||
}
|
||||
|
||||
hostRO.setVersion(hostVO.getVersion().toString());
|
||||
|
||||
if (hostVO.getHypervisorType() != null) {
|
||||
hostRO.setHypervisorType(hostVO.getHypervisorType().toString());
|
||||
}
|
||||
|
||||
if ((hostVO.getCpus() != null) && (hostVO.getSpeed() != null) && !(hostVO.getType().toString().equals("Storage")))
|
||||
{
|
||||
|
||||
hostRO.setCpuNumber(hostVO.getCpus());
|
||||
hostRO.setCpuSpeed(hostVO.getSpeed());
|
||||
// calculate cpu allocated by vm
|
||||
int cpu = 0;
|
||||
String cpuAlloc = null;
|
||||
DecimalFormat decimalFormat = new DecimalFormat("#.##");
|
||||
// List<UserVmVO> instances = managementServer.listUserVMsByHostId(hostVO.getId());
|
||||
// for (UserVmVO vm : instances) {
|
||||
// ServiceOffering so = managementServer.findServiceOfferingById(vm.getServiceOfferingId());
|
||||
// cpu += so.getCpu() * so.getSpeed();
|
||||
// }
|
||||
cpuAlloc = decimalFormat.format(((float) cpu / (float) (hostVO.getCpus() * hostVO.getSpeed())) * 100f) + "%";
|
||||
hostRO.setCpuAllocated(cpuAlloc);
|
||||
|
||||
// calculate cpu utilized
|
||||
String cpuUsed = null;
|
||||
// HostStats hostStats = managementServer.getHostStatistics(hostVO.getId());
|
||||
// if (hostStats != null) {
|
||||
// float cpuUtil = (float) hostStats.getCpuUtilization();
|
||||
// cpuUsed = decimalFormat.format(cpuUtil) + "%";
|
||||
// hostRO.setCpuUsed(cpuUsed);
|
||||
//
|
||||
// long avgLoad = (long)hostStats.getAverageLoad();
|
||||
// hostRO.setAverageLoad(avgLoad);
|
||||
//
|
||||
// long networkKbsRead = (long)hostStats.getNetworkReadKBs();
|
||||
// hostRO.setNetworkKbsRead(networkKbsRead);
|
||||
//
|
||||
// long networkKbsWrite = (long)hostStats.getNetworkWriteKBs();
|
||||
// hostRO.setNetworkKbsWrite(networkKbsWrite);
|
||||
// }
|
||||
}
|
||||
|
||||
if ( hostVO.getType() == Host.Type.Routing ) {
|
||||
Long memory = hostVO.getTotalMemory();
|
||||
hostRO.setTotalMemory(memory);
|
||||
// calculate memory allocated by systemVM and userVm
|
||||
long mem = managementServer.getMemoryUsagebyHost(hostVO.getId());
|
||||
hostRO.setMemoryAllocated(mem);
|
||||
// calculate memory utilized, we don't provide memory over commit
|
||||
hostRO.setMemoryUsed(mem);
|
||||
|
||||
}
|
||||
if (hostVO.getType().toString().equals("Storage")) {
|
||||
hostRO.setDiskSizeTotal(hostVO.getTotalSize());
|
||||
hostRO.setDiskSizeAllocated(0);
|
||||
}
|
||||
hostRO.setCaps(hostVO.getCapabilities());
|
||||
hostRO.setLastPinged(hostVO.getLastPinged());
|
||||
if (hostVO.getManagementServerId() != null) {
|
||||
hostRO.setManagementServerId(hostVO.getManagementServerId());
|
||||
}
|
||||
|
||||
if (hostVO.getCreated() != null) {
|
||||
hostRO.setCreated(hostVO.getCreated());
|
||||
}
|
||||
if (hostVO.getRemoved() != null) {
|
||||
hostRO.setRemoved(hostVO.getRemoved());
|
||||
}
|
||||
|
||||
Set<Event> possibleEvents = hostVO.getStatus().getPossibleEvents();
|
||||
hostRO.setEvents(possibleEvents);
|
||||
|
||||
return hostRO;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
package com.cloud.async.executor;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobResult;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.async.BaseAsyncJobExecutor;
|
||||
import com.cloud.network.security.SecurityGroupVO;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class RevokeNetworkGroupIngressExecutor extends BaseAsyncJobExecutor {
|
||||
public static final Logger s_logger = Logger.getLogger(RevokeNetworkGroupIngressExecutor.class.getName());
|
||||
|
||||
@Override
|
||||
public boolean execute() {
|
||||
Gson gson = GsonHelper.getBuilder().create();
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
AsyncJobVO job = getJob();
|
||||
ManagementServer managementServer = asyncMgr.getExecutorContext().getManagementServer();
|
||||
SecurityGroupIngressParam param = gson.fromJson(job.getCmdInfo(), SecurityGroupIngressParam.class);
|
||||
AccountVO account = param.getAccount();
|
||||
|
||||
/*
|
||||
if (getSyncSource() == null) {
|
||||
SecurityGroupVO networkGroup = managementServer.findNetworkGroupByName(param.getAccount().getId(), param.getGroupName());
|
||||
if(networkGroup == null) {
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED,
|
||||
BaseCmd.PARAM_ERROR, "Unable to find network group " + param.getGroupName() + " for account " + account.getAccountName() + " (id: " + account.getId() + ")");
|
||||
} else {
|
||||
asyncMgr.syncAsyncJobExecution(job.getId(), "SecurityGroup", networkGroup.getId());
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
try {
|
||||
boolean success = managementServer.revokeNetworkGroupIngress(account, param.getGroupName(), param.getProtocol(), param.getStartPort(), param.getEndPort(), param.getCidrList(), param.getAuthorizedGroups());
|
||||
if (success) {
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0, "success");
|
||||
} else {
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
"Failed to revoke network group ingress from group: " + param.getGroupName() + " for account: " + account.getAccountName() + " (id: " + account.getId() + ")");
|
||||
}
|
||||
} catch(Exception e) {
|
||||
s_logger.warn("Failed to revoke network group ingress from group: " + param.getGroupName() + " for account: " + account.getAccountName() + " (id: " + account.getId() + ")", e);
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
"Failed to revoke network group ingress from group: " + param.getGroupName() + " for account: " + account.getAccountName() + " (id: " + account.getId() + ")");
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
package com.cloud.async.executor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.network.security.SecurityGroupVO;
|
||||
import com.cloud.user.AccountVO;
|
||||
|
||||
public class SecurityGroupIngressParam {
|
||||
private AccountVO account;
|
||||
private String groupName;
|
||||
private String protocol;
|
||||
private int startPort;
|
||||
private int endPort;
|
||||
private String[] cidrList;
|
||||
private List<SecurityGroupVO> authorizedGroups;
|
||||
|
||||
protected SecurityGroupIngressParam() { }
|
||||
|
||||
public SecurityGroupIngressParam(AccountVO account, String groupName, String protocol, int startPort, int endPort, String[] cidrList, List<SecurityGroupVO> authorizedGroups) {
|
||||
this.account = account;
|
||||
this.groupName = groupName;
|
||||
this.protocol = protocol;
|
||||
this.startPort = startPort;
|
||||
this.endPort = endPort;
|
||||
this.cidrList = cidrList;
|
||||
this.authorizedGroups = authorizedGroups;
|
||||
}
|
||||
|
||||
public AccountVO getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public String getGroupName() {
|
||||
return groupName;
|
||||
}
|
||||
|
||||
public String getProtocol() {
|
||||
return protocol;
|
||||
}
|
||||
|
||||
public int getStartPort() {
|
||||
return startPort;
|
||||
}
|
||||
|
||||
public int getEndPort() {
|
||||
return endPort;
|
||||
}
|
||||
|
||||
public String[] getCidrList() {
|
||||
return cidrList;
|
||||
}
|
||||
|
||||
public List<SecurityGroupVO> getAuthorizedGroups() {
|
||||
return authorizedGroups;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobResult;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.cloud.vm.ConsoleProxyVO;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class StartConsoleProxyExecutor extends VMOperationExecutor {
|
||||
public static final Logger s_logger = Logger.getLogger(StartConsoleProxyExecutor.class.getName());
|
||||
|
||||
@Override
|
||||
public boolean execute() {
|
||||
Gson gson = GsonHelper.getBuilder().create();
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
AsyncJobVO job = getJob();
|
||||
ManagementServer managementServer = asyncMgr.getExecutorContext().getManagementServer();
|
||||
VMOperationParam param = gson.fromJson(job.getCmdInfo(), VMOperationParam.class);
|
||||
if(getSyncSource() == null) {
|
||||
asyncMgr.syncAsyncJobExecution(job, "ConsoleProxy", param.getVmId());
|
||||
return true;
|
||||
} else {
|
||||
try {
|
||||
ConsoleProxyVO proxy = managementServer.startConsoleProxy(param.getVmId());
|
||||
if(proxy != null)
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0,
|
||||
ConsoleProxyExecutorHelper.composeResultObject(managementServer, proxy));
|
||||
else
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
"operation failed");
|
||||
} catch(Exception e) {
|
||||
s_logger.warn("Unable to start console proxy " + param.getVmId() + ":" + e.getMessage(), e);
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
e.getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processAnswer(VMOperationListener listener, long agentId, long seq, Answer answer) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processDisconnect(VMOperationListener listener, long agentId) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processTimeout(VMOperationListener listener, long agentId, long seq) {
|
||||
}
|
||||
}
|
||||
|
|
@ -1,260 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
|
||||
public class StartConsoleProxyResult {
|
||||
|
||||
@Param(name="id")
|
||||
private long id;
|
||||
|
||||
@Param(name="name")
|
||||
private String name;
|
||||
|
||||
@Param(name="zoneid")
|
||||
private long zoneId;
|
||||
|
||||
@Param(name="zonename")
|
||||
private String zoneName;
|
||||
|
||||
@Param(name="dns1")
|
||||
private String dns1;
|
||||
|
||||
@Param(name="dns2")
|
||||
private String dns2;
|
||||
|
||||
@Param(name="networkdomain")
|
||||
private String networkDomain;
|
||||
|
||||
@Param(name="gateway")
|
||||
private String gateway;
|
||||
|
||||
@Param(name="podid")
|
||||
private long podId;
|
||||
|
||||
@Param(name="hostid")
|
||||
private Long hostId;
|
||||
|
||||
@Param(name="hostname")
|
||||
private String hostName;
|
||||
|
||||
@Param(name="privateip")
|
||||
private String privateIp;
|
||||
|
||||
@Param(name="privatemacaddress")
|
||||
private String privateMac;
|
||||
|
||||
@Param(name="privatenetmask")
|
||||
private String privateNetmask;
|
||||
|
||||
@Param(name="publicip")
|
||||
private String publicIp;
|
||||
|
||||
@Param(name="publicmacaddress")
|
||||
private String publicMac;
|
||||
|
||||
@Param(name="publicnetmask")
|
||||
private String publicNetmask;
|
||||
|
||||
@Param(name="templateid")
|
||||
private long templateId;
|
||||
|
||||
@Param(name="created")
|
||||
private Date created;
|
||||
|
||||
@Param(name="activeviewersessions")
|
||||
private int actionSessions;
|
||||
|
||||
@Param(name="state")
|
||||
private String state;
|
||||
|
||||
public StartConsoleProxyResult() {
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public void setZoneId(long zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
|
||||
public String getZoneName() {
|
||||
return zoneName;
|
||||
}
|
||||
|
||||
public void setZoneName(String zoneName) {
|
||||
this.zoneName = zoneName;
|
||||
}
|
||||
|
||||
public String getDns1() {
|
||||
return dns1;
|
||||
}
|
||||
|
||||
public void setDns1(String dns1) {
|
||||
this.dns1 = dns1;
|
||||
}
|
||||
|
||||
public String getDns2() {
|
||||
return dns2;
|
||||
}
|
||||
|
||||
public void setDns2(String dns2) {
|
||||
this.dns2 = dns2;
|
||||
}
|
||||
|
||||
public String getNetworkDomain() {
|
||||
return networkDomain;
|
||||
}
|
||||
|
||||
public void setNetworkDomain(String networkDomain) {
|
||||
this.networkDomain = networkDomain;
|
||||
}
|
||||
|
||||
public String getGateway() {
|
||||
return gateway;
|
||||
}
|
||||
|
||||
public void setGateway(String gateway) {
|
||||
this.gateway = gateway;
|
||||
}
|
||||
|
||||
public long getPodId() {
|
||||
return podId;
|
||||
}
|
||||
|
||||
public void setPodId(long podId) {
|
||||
this.podId = podId;
|
||||
}
|
||||
|
||||
public Long getHostId() {
|
||||
return hostId;
|
||||
}
|
||||
|
||||
public void setHostId(Long hostId) {
|
||||
this.hostId = hostId;
|
||||
}
|
||||
|
||||
public String getHostName() {
|
||||
return hostName;
|
||||
}
|
||||
|
||||
public void setHostName(String hostName) {
|
||||
this.hostName = hostName;
|
||||
}
|
||||
|
||||
public String getPrivateIp() {
|
||||
return privateIp;
|
||||
}
|
||||
|
||||
public void setPrivateIp(String privateIp) {
|
||||
this.privateIp = privateIp;
|
||||
}
|
||||
|
||||
public String getPrivateMac() {
|
||||
return privateMac;
|
||||
}
|
||||
|
||||
public void setPrivateMac(String privateMac) {
|
||||
this.privateMac = privateMac;
|
||||
}
|
||||
|
||||
public String getPrivateNetmask() {
|
||||
return privateNetmask;
|
||||
}
|
||||
|
||||
public void setPrivateNetmask(String privateNetmask) {
|
||||
this.privateNetmask = privateNetmask;
|
||||
}
|
||||
|
||||
public String getPublicIp() {
|
||||
return publicIp;
|
||||
}
|
||||
|
||||
public void setPublicIp(String publicIp) {
|
||||
this.publicIp = publicIp;
|
||||
}
|
||||
|
||||
public String getPublicMac() {
|
||||
return publicMac;
|
||||
}
|
||||
|
||||
public void setPublicMac(String publicMac) {
|
||||
this.publicMac = publicMac;
|
||||
}
|
||||
|
||||
public String getPublicNetmask() {
|
||||
return publicNetmask;
|
||||
}
|
||||
|
||||
public void setPublicNetmask(String publicNetmask) {
|
||||
this.publicNetmask = publicNetmask;
|
||||
}
|
||||
|
||||
public long getTemplateId() {
|
||||
return templateId;
|
||||
}
|
||||
|
||||
public void setTemplateId(long templateId) {
|
||||
this.templateId = templateId;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public int getActionSessions() {
|
||||
return actionSessions;
|
||||
}
|
||||
|
||||
public void setActionSessions(int actionSessions) {
|
||||
this.actionSessions = actionSessions;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,91 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobResult;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventVO;
|
||||
import com.cloud.exception.InternalErrorException;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.User;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class StartRouterExecutor extends VMOperationExecutor {
|
||||
public static final Logger s_logger = Logger.getLogger(StartRouterExecutor.class.getName());
|
||||
|
||||
public boolean execute() {
|
||||
Gson gson = GsonHelper.getBuilder().create();
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
AsyncJobVO job = getJob();
|
||||
ManagementServer managementServer = asyncMgr.getExecutorContext().getManagementServer();
|
||||
VMOperationParam param = gson.fromJson(job.getCmdInfo(), VMOperationParam.class);
|
||||
|
||||
/*
|
||||
if(getSyncSource() == null) {
|
||||
asyncMgr.syncAsyncJobExecution(job, "Router", param.getVmId());
|
||||
return true;
|
||||
} else {
|
||||
boolean success = false;
|
||||
try {
|
||||
DomainRouter router = managementServer.startRouter(param.getVmId(), param.getEventId());
|
||||
if(router != null){
|
||||
success = true;
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0,
|
||||
RouterExecutorHelper.composeResultObject(managementServer, router));
|
||||
}
|
||||
else
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
"operation failed");
|
||||
} catch (InternalErrorException e) {
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
e.getMessage());
|
||||
} catch(Exception e) {
|
||||
s_logger.warn("Unable to start router " + param.getVmId() + ":" + e.getMessage(), e);
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
e.getMessage());
|
||||
} finally {
|
||||
if(!success){
|
||||
// Save completed event when operation fails
|
||||
// asyncMgr.getExecutorContext().getManagementServer().saveEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventVO.LEVEL_ERROR, EventTypes.EVENT_ROUTER_START, "Failed to start router", null, param.getEventId());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
public void processAnswer(VMOperationListener listener, long agentId, long seq, Answer answer) {
|
||||
}
|
||||
|
||||
public void processDisconnect(VMOperationListener listener, long agentId) {
|
||||
}
|
||||
|
||||
public void processTimeout(VMOperationListener listener, long agentId, long seq) {
|
||||
}
|
||||
}
|
||||
|
|
@ -1,300 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
|
||||
public class StartRouterResultObject {
|
||||
@Param(name="id")
|
||||
private long id;
|
||||
|
||||
@Param(name="zoneid")
|
||||
private long zoneId;
|
||||
|
||||
@Param(name="zonename")
|
||||
private String zoneName;
|
||||
|
||||
@Param(name="dns1")
|
||||
private String dns1;
|
||||
|
||||
@Param(name="dns2")
|
||||
private String dns2;
|
||||
|
||||
@Param(name="networkdomain")
|
||||
private String networkDomain;
|
||||
|
||||
@Param(name="gateway")
|
||||
private String gateway;
|
||||
|
||||
@Param(name="name")
|
||||
private String name;
|
||||
|
||||
@Param(name="podid")
|
||||
private long podId;
|
||||
|
||||
@Param(name="privateip")
|
||||
private String privateIp;
|
||||
|
||||
@Param(name="privatemacaddress")
|
||||
private String privateMacAddress;
|
||||
|
||||
@Param(name="privatenetmask")
|
||||
private String privateNetMask;
|
||||
|
||||
@Param(name="publicip")
|
||||
private String publicIp;
|
||||
|
||||
@Param(name="publicmacaddress")
|
||||
private String publicMacAddress;
|
||||
|
||||
@Param(name="publicnetmask")
|
||||
private String publicNetMask;
|
||||
|
||||
@Param(name="ipaddress")
|
||||
private String guestIp;
|
||||
|
||||
@Param(name="macaddress")
|
||||
private String guestMacAddress;
|
||||
|
||||
@Param(name="templateid")
|
||||
private long templateId;
|
||||
|
||||
@Param(name="created")
|
||||
private Date created;
|
||||
|
||||
@Param(name="account")
|
||||
private String account;
|
||||
|
||||
@Param(name="domainid")
|
||||
private long domainId;
|
||||
|
||||
@Param(name="domain")
|
||||
private String domain;
|
||||
|
||||
@Param(name="hostid")
|
||||
private Long hostId;
|
||||
|
||||
@Param(name="state")
|
||||
private String state;
|
||||
|
||||
@Param(name="hostname")
|
||||
private String hostname;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public void setZoneId(long zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
|
||||
public String getZoneName() {
|
||||
return zoneName;
|
||||
}
|
||||
|
||||
public void setZoneName(String zoneName) {
|
||||
this.zoneName = zoneName;
|
||||
}
|
||||
|
||||
public String getDns1() {
|
||||
return dns1;
|
||||
}
|
||||
|
||||
public void setDns1(String dns1) {
|
||||
this.dns1 = dns1;
|
||||
}
|
||||
|
||||
public String getDns2() {
|
||||
return dns2;
|
||||
}
|
||||
|
||||
public void setDns2(String dns2) {
|
||||
this.dns2 = dns2;
|
||||
}
|
||||
|
||||
public String getNetworkDomain() {
|
||||
return networkDomain;
|
||||
}
|
||||
|
||||
public void setNetworkDomain(String networkDomain) {
|
||||
this.networkDomain = networkDomain;
|
||||
}
|
||||
|
||||
public String getGateway() {
|
||||
return gateway;
|
||||
}
|
||||
|
||||
public void setGateway(String gateway) {
|
||||
this.gateway = gateway;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public long getPodId() {
|
||||
return podId;
|
||||
}
|
||||
|
||||
public void setPodId(long podId) {
|
||||
this.podId = podId;
|
||||
}
|
||||
|
||||
public String getPrivateIp() {
|
||||
return privateIp;
|
||||
}
|
||||
|
||||
public void setPrivateIp(String privateIp) {
|
||||
this.privateIp = privateIp;
|
||||
}
|
||||
|
||||
public String getPrivateMacAddress() {
|
||||
return privateMacAddress;
|
||||
}
|
||||
|
||||
public void setPrivateMacAddress(String privateMacAddress) {
|
||||
this.privateMacAddress = privateMacAddress;
|
||||
}
|
||||
|
||||
public String getPrivateNetMask() {
|
||||
return privateNetMask;
|
||||
}
|
||||
|
||||
public void setPrivateNetMask(String privateNetMask) {
|
||||
this.privateNetMask = privateNetMask;
|
||||
}
|
||||
|
||||
public String getPublicIp() {
|
||||
return publicIp;
|
||||
}
|
||||
|
||||
public void setPublicIp(String publicIp) {
|
||||
this.publicIp = publicIp;
|
||||
}
|
||||
|
||||
public String getPublicMacAddress() {
|
||||
return publicMacAddress;
|
||||
}
|
||||
|
||||
public void setPublicMacAddress(String publicMacAddress) {
|
||||
this.publicMacAddress = publicMacAddress;
|
||||
}
|
||||
|
||||
public String getPublicNetMask() {
|
||||
return publicNetMask;
|
||||
}
|
||||
|
||||
public void setPublicNetMask(String publicNetMask) {
|
||||
this.publicNetMask = publicNetMask;
|
||||
}
|
||||
|
||||
public String getGuestIp() {
|
||||
return guestIp;
|
||||
}
|
||||
|
||||
public void setGuestIp(String guestIp) {
|
||||
this.guestIp = guestIp;
|
||||
}
|
||||
|
||||
public String getGuestMacAddress() {
|
||||
return guestMacAddress;
|
||||
}
|
||||
|
||||
public void setGuestMacAddress(String guestMacAddress) {
|
||||
this.guestMacAddress = guestMacAddress;
|
||||
}
|
||||
|
||||
public long getTemplateId() {
|
||||
return templateId;
|
||||
}
|
||||
|
||||
public void setTemplateId(long templateId) {
|
||||
this.templateId = templateId;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setAccount(String account) {
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public Long getHostId() {
|
||||
return hostId;
|
||||
}
|
||||
|
||||
public void setHostId(Long hostId) {
|
||||
this.hostId = hostId;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
public void setDomain(String domain) {
|
||||
this.domain = domain;
|
||||
}
|
||||
|
||||
public long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public void setDomainId(long domainId) {
|
||||
this.domainId = domainId;
|
||||
}
|
||||
|
||||
public String getHostname() {
|
||||
return hostname;
|
||||
}
|
||||
|
||||
public void setHostname(String hostname) {
|
||||
this.hostname = hostname;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobResult;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.cloud.vm.ConsoleProxyVO;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class StopConsoleProxyExecutor extends VMOperationExecutor {
|
||||
public static final Logger s_logger = Logger.getLogger(StopConsoleProxyExecutor.class.getName());
|
||||
|
||||
public boolean execute() {
|
||||
Gson gson = GsonHelper.getBuilder().create();
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
AsyncJobVO job = getJob();
|
||||
ManagementServer managementServer = asyncMgr.getExecutorContext().getManagementServer();
|
||||
VMOperationParam param = gson.fromJson(job.getCmdInfo(), VMOperationParam.class);
|
||||
/*
|
||||
if(getSyncSource() == null) {
|
||||
asyncMgr.syncAsyncJobExecution(job, "ConsoleProxy", param.getVmId());
|
||||
return true;
|
||||
} else {
|
||||
try {
|
||||
boolean result = managementServer.stopConsoleProxy(param.getVmId(), param.getEventId());
|
||||
if(result)
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0,
|
||||
composeResultObject(managementServer, param.getVmId()));
|
||||
else
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
"Operation failed");
|
||||
} catch(Exception e) {
|
||||
s_logger.warn("Unable to stop console proxy " + param.getVmId() + ":" + e.getMessage(), e);
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
e.getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
public void processAnswer(VMOperationListener listener, long agentId, long seq, Answer answer) {
|
||||
}
|
||||
|
||||
public void processDisconnect(VMOperationListener listener, long agentId) {
|
||||
}
|
||||
|
||||
public void processTimeout(VMOperationListener listener, long agentId, long seq) {
|
||||
}
|
||||
|
||||
private ConsoleProxyOperationResultObject composeResultObject(ManagementServer managementServer, long proxyVmId) {
|
||||
ConsoleProxyVO proxy = managementServer.findConsoleProxyById(proxyVmId);
|
||||
return ConsoleProxyExecutorHelper.composeResultObject(managementServer, proxy);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobResult;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class StopRouterExecutor extends VMOperationExecutor {
|
||||
public static final Logger s_logger = Logger.getLogger(StopRouterExecutor.class.getName());
|
||||
|
||||
public boolean execute() {
|
||||
Gson gson = GsonHelper.getBuilder().create();
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
AsyncJobVO job = getJob();
|
||||
ManagementServer managementServer = asyncMgr.getExecutorContext().getManagementServer();
|
||||
VMOperationParam param = gson.fromJson(job.getCmdInfo(), VMOperationParam.class);
|
||||
|
||||
/*
|
||||
if(getSyncSource() == null) {
|
||||
asyncMgr.syncAsyncJobExecution(job, "Router", param.getVmId());
|
||||
return true;
|
||||
} else {
|
||||
try {
|
||||
if(managementServer.stopRouter(param.getVmId(), param.getEventId())) {
|
||||
DomainRouter router = managementServer.findDomainRouterById(param.getVmId());
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0,
|
||||
RouterExecutorHelper.composeResultObject(managementServer, router));
|
||||
} else {
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
"failed");
|
||||
}
|
||||
} catch(Exception e) {
|
||||
s_logger.warn("Unable to stop router " + param.getVmId() + ":" + e.getMessage(), e);
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
e.getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
public void processAnswer(VMOperationListener listener, long agentId, long seq, Answer answer) {
|
||||
}
|
||||
|
||||
public void processDisconnect(VMOperationListener listener, long agentId) {
|
||||
}
|
||||
|
||||
public void processTimeout(VMOperationListener listener, long agentId, long seq) {
|
||||
}
|
||||
}
|
||||
|
|
@ -1,147 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobResult;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.async.executor.VMOperationParam.VmOp;
|
||||
import com.cloud.exception.InternalErrorException;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.cloud.vm.SecondaryStorageVmVO;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class SystemVmCmdExecutor extends VMOperationExecutor {
|
||||
public static final Logger s_logger = Logger.getLogger(SystemVmCmdExecutor.class.getName());
|
||||
|
||||
public boolean execute() {
|
||||
Gson gson = GsonHelper.getBuilder().create();
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
AsyncJobVO job = getJob();
|
||||
ManagementServer managementServer = asyncMgr.getExecutorContext().getManagementServer();
|
||||
VMOperationParam param = gson.fromJson(job.getCmdInfo(), VMOperationParam.class);
|
||||
VmOp oper = param.getOperation();
|
||||
VMInstanceVO vm;
|
||||
/*
|
||||
if(getSyncSource() == null) {
|
||||
asyncMgr.syncAsyncJobExecution(job.getId(), "SystemVm", param.getVmId());
|
||||
return true;
|
||||
} else {
|
||||
try {
|
||||
switch (oper){
|
||||
case Destroy:
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.UNSUPPORTED_ACTION_ERROR,
|
||||
"operation not allowed");
|
||||
break;
|
||||
case Noop:
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0, "noop operation");
|
||||
break;
|
||||
case Start:
|
||||
vm = managementServer.startSystemVM(param.getVmId(), param.getEventId());
|
||||
if(vm != null)
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0,
|
||||
composeResultObject(managementServer, vm));
|
||||
else
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
"operation failed");
|
||||
break;
|
||||
case Stop:
|
||||
boolean result = managementServer.stopSystemVM(param.getVmId(), param.getEventId());
|
||||
if(result) {
|
||||
vm = managementServer.findSystemVMById(param.getVmId());
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0, composeResultObject(managementServer, vm));
|
||||
} else {
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
"operation failed");
|
||||
}
|
||||
break;
|
||||
case Reboot:
|
||||
result = managementServer.rebootSystemVM(param.getVmId(), param.getEventId());
|
||||
if(result) {
|
||||
vm = managementServer.findSystemVMById(param.getVmId());
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0, composeResultObject(managementServer, vm));
|
||||
} else {
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
"operation failed");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert false :"Unknown vm operation";
|
||||
}
|
||||
|
||||
} catch (InternalErrorException e) {
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
e.getMessage());
|
||||
} catch(Exception e) {
|
||||
s_logger.warn("Unable to start console vm " + param.getVmId() + ":" + e.getMessage(), e);
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
|
||||
e.getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
private Object composeResultObject(ManagementServer managementServer, VMInstanceVO vm) {
|
||||
SystemVmOperationResultObject result = new SystemVmOperationResultObject();
|
||||
if (vm instanceof SecondaryStorageVmVO) {
|
||||
SecondaryStorageVmVO ssVm = (SecondaryStorageVmVO)vm;
|
||||
result.setId(ssVm.getId());
|
||||
result.setName(vm.getName());
|
||||
result.setZoneId(ssVm.getDataCenterId());
|
||||
result.setZoneName(managementServer.findDataCenterById(ssVm.getDataCenterId()).getName());
|
||||
result.setDns1(ssVm.getDns1());
|
||||
result.setDns2(ssVm.getDns2());
|
||||
result.setNetworkDomain(ssVm.getDomain());
|
||||
result.setGateway(ssVm.getGateway());
|
||||
result.setPodId(ssVm.getPodId());
|
||||
result.setHostId(ssVm.getHostId());
|
||||
if(ssVm.getHostId() != null)
|
||||
result.setHostName(managementServer.getHostBy(ssVm.getHostId()).getName());
|
||||
|
||||
result.setPrivateIp(ssVm.getPrivateIpAddress());
|
||||
result.setPrivateMac(ssVm.getPrivateMacAddress());
|
||||
result.setPrivateNetmask(ssVm.getPrivateNetmask());
|
||||
result.setPublicIp(ssVm.getPublicIpAddress());
|
||||
result.setPublicMac(ssVm.getPublicMacAddress());
|
||||
result.setPublicNetmask(ssVm.getPublicNetmask());
|
||||
result.setTemplateId(ssVm.getTemplateId());
|
||||
result.setCreated(ssVm.getCreated());
|
||||
result.setState(ssVm.getState().toString());
|
||||
//result.setNfsShare(ssVm.getNfsShare());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void processAnswer(VMOperationListener listener, long agentId, long seq, Answer answer) {
|
||||
}
|
||||
|
||||
public void processDisconnect(VMOperationListener listener, long agentId) {
|
||||
}
|
||||
|
||||
public void processTimeout(VMOperationListener listener, long agentId, long seq) {
|
||||
}
|
||||
}
|
||||
|
|
@ -1,260 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
|
||||
public class SystemVmOperationResultObject {
|
||||
|
||||
@Param(name="id")
|
||||
private long id;
|
||||
|
||||
@Param(name="name")
|
||||
private String name;
|
||||
|
||||
@Param(name="zoneid")
|
||||
private long zoneId;
|
||||
|
||||
@Param(name="zonename")
|
||||
private String zoneName;
|
||||
|
||||
@Param(name="dns1")
|
||||
private String dns1;
|
||||
|
||||
@Param(name="dns2")
|
||||
private String dns2;
|
||||
|
||||
@Param(name="networkdomain")
|
||||
private String networkDomain;
|
||||
|
||||
@Param(name="gateway")
|
||||
private String gateway;
|
||||
|
||||
@Param(name="podid")
|
||||
private long podId;
|
||||
|
||||
@Param(name="hostid")
|
||||
private Long hostId;
|
||||
|
||||
@Param(name="hostname")
|
||||
private String hostName;
|
||||
|
||||
@Param(name="privateip")
|
||||
private String privateIp;
|
||||
|
||||
@Param(name="privatemacaddress")
|
||||
private String privateMac;
|
||||
|
||||
@Param(name="privatenetmask")
|
||||
private String privateNetmask;
|
||||
|
||||
@Param(name="publicip")
|
||||
private String publicIp;
|
||||
|
||||
@Param(name="publicmacaddress")
|
||||
private String publicMac;
|
||||
|
||||
@Param(name="publicnetmask")
|
||||
private String publicNetmask;
|
||||
|
||||
@Param(name="templateid")
|
||||
private long templateId;
|
||||
|
||||
@Param(name="created")
|
||||
private Date created;
|
||||
|
||||
@Param(name="activeviewersessions")
|
||||
private int actionSessions;
|
||||
|
||||
@Param(name="state")
|
||||
private String state;
|
||||
|
||||
public SystemVmOperationResultObject() {
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public void setZoneId(long zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
|
||||
public String getZoneName() {
|
||||
return zoneName;
|
||||
}
|
||||
|
||||
public void setZoneName(String zoneName) {
|
||||
this.zoneName = zoneName;
|
||||
}
|
||||
|
||||
public String getDns1() {
|
||||
return dns1;
|
||||
}
|
||||
|
||||
public void setDns1(String dns1) {
|
||||
this.dns1 = dns1;
|
||||
}
|
||||
|
||||
public String getDns2() {
|
||||
return dns2;
|
||||
}
|
||||
|
||||
public void setDns2(String dns2) {
|
||||
this.dns2 = dns2;
|
||||
}
|
||||
|
||||
public String getNetworkDomain() {
|
||||
return networkDomain;
|
||||
}
|
||||
|
||||
public void setNetworkDomain(String networkDomain) {
|
||||
this.networkDomain = networkDomain;
|
||||
}
|
||||
|
||||
public String getGateway() {
|
||||
return gateway;
|
||||
}
|
||||
|
||||
public void setGateway(String gateway) {
|
||||
this.gateway = gateway;
|
||||
}
|
||||
|
||||
public long getPodId() {
|
||||
return podId;
|
||||
}
|
||||
|
||||
public void setPodId(long podId) {
|
||||
this.podId = podId;
|
||||
}
|
||||
|
||||
public Long getHostId() {
|
||||
return hostId;
|
||||
}
|
||||
|
||||
public void setHostId(Long hostId) {
|
||||
this.hostId = hostId;
|
||||
}
|
||||
|
||||
public String getHostName() {
|
||||
return hostName;
|
||||
}
|
||||
|
||||
public void setHostName(String hostName) {
|
||||
this.hostName = hostName;
|
||||
}
|
||||
|
||||
public String getPrivateIp() {
|
||||
return privateIp;
|
||||
}
|
||||
|
||||
public void setPrivateIp(String privateIp) {
|
||||
this.privateIp = privateIp;
|
||||
}
|
||||
|
||||
public String getPrivateMac() {
|
||||
return privateMac;
|
||||
}
|
||||
|
||||
public void setPrivateMac(String privateMac) {
|
||||
this.privateMac = privateMac;
|
||||
}
|
||||
|
||||
public String getPrivateNetmask() {
|
||||
return privateNetmask;
|
||||
}
|
||||
|
||||
public void setPrivateNetmask(String privateNetmask) {
|
||||
this.privateNetmask = privateNetmask;
|
||||
}
|
||||
|
||||
public String getPublicIp() {
|
||||
return publicIp;
|
||||
}
|
||||
|
||||
public void setPublicIp(String publicIp) {
|
||||
this.publicIp = publicIp;
|
||||
}
|
||||
|
||||
public String getPublicMac() {
|
||||
return publicMac;
|
||||
}
|
||||
|
||||
public void setPublicMac(String publicMac) {
|
||||
this.publicMac = publicMac;
|
||||
}
|
||||
|
||||
public String getPublicNetmask() {
|
||||
return publicNetmask;
|
||||
}
|
||||
|
||||
public void setPublicNetmask(String publicNetmask) {
|
||||
this.publicNetmask = publicNetmask;
|
||||
}
|
||||
|
||||
public long getTemplateId() {
|
||||
return templateId;
|
||||
}
|
||||
|
||||
public void setTemplateId(long templateId) {
|
||||
this.templateId = templateId;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public int getActionSessions() {
|
||||
return actionSessions;
|
||||
}
|
||||
|
||||
public void setActionSessions(int actionSessions) {
|
||||
this.actionSessions = actionSessions;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
package com.cloud.async.executor;
|
||||
|
||||
public class UpdateLoadBalancerParam {
|
||||
private long userId;
|
||||
private long loadBalancerId;
|
||||
private String name;
|
||||
private String description;
|
||||
private String privatePort;
|
||||
private String algorithm;
|
||||
|
||||
public UpdateLoadBalancerParam() { }
|
||||
|
||||
public UpdateLoadBalancerParam(long userId, long loadBalancerId, String name, String description, String privatePort, String algorithm) {
|
||||
this.userId = userId;
|
||||
this.loadBalancerId = loadBalancerId;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.privatePort = privatePort;
|
||||
this.algorithm = algorithm;
|
||||
}
|
||||
|
||||
public long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public long getLoadBalancerId() {
|
||||
return loadBalancerId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getPrivatePort() {
|
||||
return privatePort;
|
||||
}
|
||||
|
||||
public String getAlgorithm() {
|
||||
return algorithm;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,105 +0,0 @@
|
|||
package com.cloud.async.executor;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
|
||||
public class UpdateLoadBalancerRuleResultObject {
|
||||
@Param(name="id")
|
||||
private long id;
|
||||
|
||||
@Param(name="name")
|
||||
private String name;
|
||||
|
||||
@Param(name="description")
|
||||
private String description;
|
||||
|
||||
@Param(name="publicip")
|
||||
private String publicIp;
|
||||
|
||||
@Param(name="publicport")
|
||||
private String publicPort;
|
||||
|
||||
@Param(name="privateport")
|
||||
private String privatePort;
|
||||
|
||||
@Param(name="algorithm")
|
||||
private String algorithm;
|
||||
|
||||
@Param(name="account")
|
||||
private String accountName;
|
||||
|
||||
@Param(name="domainid")
|
||||
private long domainId;
|
||||
|
||||
@Param(name="domain")
|
||||
private String domainName;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getPublicIp() {
|
||||
return publicIp;
|
||||
}
|
||||
public void setPublicIp(String publicIp) {
|
||||
this.publicIp = publicIp;
|
||||
}
|
||||
|
||||
public String getPublicPort() {
|
||||
return publicPort;
|
||||
}
|
||||
public void setPublicPort(String publicPort) {
|
||||
this.publicPort = publicPort;
|
||||
}
|
||||
|
||||
public String getPrivatePort() {
|
||||
return privatePort;
|
||||
}
|
||||
public void setPrivatePort(String privatePort) {
|
||||
this.privatePort = privatePort;
|
||||
}
|
||||
|
||||
public String getAlgorithm() {
|
||||
return algorithm;
|
||||
}
|
||||
public void setAlgorithm(String algorithm) {
|
||||
this.algorithm = algorithm;
|
||||
}
|
||||
|
||||
public String getAccountName() {
|
||||
return accountName;
|
||||
}
|
||||
public void setAccountName(String accountName) {
|
||||
this.accountName = accountName;
|
||||
}
|
||||
|
||||
public long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
public void setDomainId(long domainId) {
|
||||
this.domainId = domainId;
|
||||
}
|
||||
|
||||
public String getDomainName() {
|
||||
return domainName;
|
||||
}
|
||||
public void setDomainName(String domainName) {
|
||||
this.domainName = domainName;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,104 +0,0 @@
|
|||
package com.cloud.async.executor;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
|
||||
public class UpdatePortForwardingRuleResultObject {
|
||||
@Param(name="id")
|
||||
private long id;
|
||||
|
||||
@Param(name="publicip")
|
||||
private String publicIp;
|
||||
|
||||
@Param(name="privateip")
|
||||
private String privateIp;
|
||||
|
||||
@Param(name="publicport")
|
||||
private String publicPort;
|
||||
|
||||
@Param(name="privateport")
|
||||
private String privatePort;
|
||||
|
||||
@Param(name="protocol")
|
||||
private String protocol;
|
||||
|
||||
@Param(name="virtualmachineid")
|
||||
private long virtualMachineId;
|
||||
|
||||
@Param(name="vmname")
|
||||
private String virtualMachineName;
|
||||
|
||||
@Param(name="vmdisplayname")
|
||||
private String virtualMachineDisplayName;
|
||||
|
||||
public String getVirtualMachineDisplayName(){
|
||||
return this.virtualMachineDisplayName;
|
||||
}
|
||||
|
||||
public void setVirtualMachineDisplayName(String name){
|
||||
this.virtualMachineDisplayName = name;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPublicIp() {
|
||||
return publicIp;
|
||||
}
|
||||
|
||||
public void setPublicIp(String publicIp) {
|
||||
this.publicIp = publicIp;
|
||||
}
|
||||
|
||||
public String getPrivateIp() {
|
||||
return privateIp;
|
||||
}
|
||||
|
||||
public void setPrivateIp(String privateIp) {
|
||||
this.privateIp = privateIp;
|
||||
}
|
||||
|
||||
public String getPublicPort() {
|
||||
return publicPort;
|
||||
}
|
||||
|
||||
public void setPublicPort(String publicPort) {
|
||||
this.publicPort = publicPort;
|
||||
}
|
||||
|
||||
public String getPrivatePort() {
|
||||
return privatePort;
|
||||
}
|
||||
|
||||
public void setPrivatePort(String privatePort) {
|
||||
this.privatePort = privatePort;
|
||||
}
|
||||
|
||||
public String getProtocol() {
|
||||
return protocol;
|
||||
}
|
||||
|
||||
public void setProtocol(String protocol) {
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
public long getVirtualMachineId() {
|
||||
return virtualMachineId;
|
||||
}
|
||||
|
||||
public void setVirtualMachineId(long virtualMachineId) {
|
||||
this.virtualMachineId = virtualMachineId;
|
||||
}
|
||||
|
||||
public String getVirtualMachineName() {
|
||||
return virtualMachineName;
|
||||
}
|
||||
|
||||
public void setVirtualMachineName(String virtualMachineName) {
|
||||
this.virtualMachineName = virtualMachineName;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,134 +0,0 @@
|
|||
//TODO -- This will be removed
|
||||
///**
|
||||
// * Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
// *
|
||||
// * This software is licensed under the GNU General Public License v3 or later.
|
||||
// *
|
||||
// * It is free software: you can redistribute it and/or modify
|
||||
// * it under the terms of the GNU General Public License as published by
|
||||
// * the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
// * This program is distributed in the hope that it will be useful,
|
||||
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// * GNU General Public License for more details.
|
||||
// *
|
||||
// * You should have received a copy of the GNU General Public License
|
||||
// * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// *
|
||||
// */
|
||||
//
|
||||
//package com.cloud.async.executor;
|
||||
//
|
||||
//import org.apache.log4j.Logger;
|
||||
//
|
||||
//import com.cloud.api.BaseCmd;
|
||||
//import com.cloud.async.AsyncJobManager;
|
||||
//import com.cloud.async.AsyncJobResult;
|
||||
//import com.cloud.async.AsyncJobVO;
|
||||
//import com.cloud.async.BaseAsyncJobExecutor;
|
||||
//import com.cloud.serializer.GsonHelper;
|
||||
//import com.cloud.server.ManagementServer;
|
||||
//import com.cloud.service.ServiceOfferingVO;
|
||||
//import com.cloud.storage.VMTemplateVO;
|
||||
//import com.cloud.user.Account;
|
||||
//import com.cloud.uservm.UserVm;
|
||||
//import com.cloud.vm.UserVmVO;
|
||||
//import com.cloud.vm.VMInstanceVO;
|
||||
//import com.cloud.vm.VmStats;
|
||||
//import com.google.gson.Gson;
|
||||
//
|
||||
//public class UpgradeVMExecutor extends BaseAsyncJobExecutor {
|
||||
// public static final Logger s_logger = Logger.getLogger(UpgradeVMExecutor.class.getName());
|
||||
//
|
||||
// public boolean execute() {
|
||||
// AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
// AsyncJobVO job = getJob();
|
||||
// Gson gson = GsonHelper.getBuilder().create();
|
||||
//
|
||||
// if(getSyncSource() == null) {
|
||||
// VMOperationParam param = gson.fromJson(job.getCmdInfo(), VMOperationParam.class);
|
||||
// asyncMgr.syncAsyncJobExecution(job.getId(), "UserVM", param.getVmId());
|
||||
//
|
||||
// // always true if it does not have sync-source
|
||||
// return true;
|
||||
// } else {
|
||||
// ManagementServer managementServer = asyncMgr.getExecutorContext().getManagementServer();
|
||||
// UpgradeVMParam param = gson.fromJson(job.getCmdInfo(), UpgradeVMParam.class);
|
||||
//
|
||||
// try {
|
||||
// asyncMgr.updateAsyncJobAttachment(job.getId(), "vm_instance", param.getVmId());
|
||||
// boolean success = managementServer.upgradeVirtualMachine(param.getUserId(),
|
||||
// param.getVmId(), param.getServiceOfferingId(), param.getEventId());
|
||||
//
|
||||
// if (success) {
|
||||
// //get the upgraded vm to compose the result object
|
||||
// UserVmVO userVm = managementServer.findUserVMInstanceById(param.getVmId());
|
||||
// asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0,
|
||||
// composeResultObject(userVm, managementServer));
|
||||
//
|
||||
// } else {
|
||||
// asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED,
|
||||
// BaseCmd.VM_CHANGE_SERVICE_ERROR,
|
||||
// composeResultObject(null, managementServer));
|
||||
// }
|
||||
// } catch(Exception e) {
|
||||
// s_logger.warn("Unable to upgrade VM " + param.getVmId() + ":" + e.getMessage(), e);
|
||||
// asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED,
|
||||
// BaseCmd.INTERNAL_ERROR,
|
||||
// e.getMessage());
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private VmResultObject composeResultObject(UserVmVO vm, ManagementServer ms)
|
||||
// {
|
||||
// if(vm == null)
|
||||
// return null;
|
||||
//
|
||||
// VmResultObject resultObj = new VmResultObject();
|
||||
// Account acct = ms.findAccountById(Long.valueOf(vm.getAccountId()));
|
||||
// resultObj.setAccount(acct.getAccountName());
|
||||
//
|
||||
// ServiceOfferingVO offering = ms.findServiceOfferingById(vm.getServiceOfferingId());
|
||||
// resultObj.setCpuSpeed(offering.getSpeed());
|
||||
// resultObj.setMemory(offering.getRamSize());
|
||||
// if(offering.getDisplayText()!=null)
|
||||
// resultObj.setServiceOfferingName(offering.getDisplayText());
|
||||
// else
|
||||
// resultObj.setServiceOfferingName(offering.getName());
|
||||
// resultObj.setServiceOfferingId(vm.getServiceOfferingId());
|
||||
//
|
||||
// VmStats vmStats = ms.getVmStatistics(vm.getId());
|
||||
// if(vmStats != null)
|
||||
// {
|
||||
// resultObj.setCpuUsed((long) vmStats.getCPUUtilization());
|
||||
// resultObj.setNetworkKbsRead((long) vmStats.getNetworkReadKBs());
|
||||
// resultObj.setNetworkKbsWrite((long) vmStats.getNetworkWriteKBs());
|
||||
// }
|
||||
//
|
||||
// resultObj.setCreated(vm.getCreated());
|
||||
// resultObj.setDisplayName(vm.getDisplayName());
|
||||
// resultObj.setDomain(ms.findDomainIdById(acct.getDomainId()).getName());
|
||||
// resultObj.setDomainId(acct.getDomainId());
|
||||
// resultObj.setHaEnable(vm.isHaEnabled());
|
||||
// if(vm.getHostId() != null)
|
||||
// {
|
||||
// resultObj.setHostId(vm.getHostId());
|
||||
// resultObj.setHostName(ms.getHostBy(vm.getHostId()).getName());
|
||||
// }
|
||||
// resultObj.setIpAddress(vm.getPrivateIpAddress());
|
||||
// resultObj.setName(vm.getName());
|
||||
// resultObj.setState(vm.getState().toString());
|
||||
// resultObj.setZoneId(vm.getDataCenterId());
|
||||
// resultObj.setZoneName(ms.findDataCenterById(vm.getDataCenterId()).getName());
|
||||
//
|
||||
// VMTemplateVO template = ms.findTemplateById(vm.getTemplateId());
|
||||
// resultObj.setPasswordEnabled(template.getEnablePassword());
|
||||
// resultObj.setTemplateDisplayText(template.getDisplayText());
|
||||
// resultObj.setTemplateId(template.getId());
|
||||
// resultObj.setTemplateName(template.getName());
|
||||
//
|
||||
// return resultObj;
|
||||
// }
|
||||
//}
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
public class UpgradeVMParam {
|
||||
private long userId;
|
||||
private long vmId;
|
||||
private long serviceOfferingId;
|
||||
private long eventId;
|
||||
|
||||
public UpgradeVMParam() {
|
||||
}
|
||||
|
||||
public UpgradeVMParam(long userId, long vmId, long serviceOfferingId) {
|
||||
this.userId = userId;
|
||||
this.vmId = vmId;
|
||||
this.serviceOfferingId = serviceOfferingId;
|
||||
}
|
||||
|
||||
public long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public long getVmId() {
|
||||
return vmId;
|
||||
}
|
||||
|
||||
public void setVmId(long vmId) {
|
||||
this.vmId = vmId;
|
||||
}
|
||||
|
||||
public long getServiceOfferingId() {
|
||||
return serviceOfferingId;
|
||||
}
|
||||
|
||||
public void setServiceOfferingId(long serviceOfferingId) {
|
||||
this.serviceOfferingId = serviceOfferingId;
|
||||
}
|
||||
|
||||
public void setEventId(long eventId) {
|
||||
this.eventId = eventId;
|
||||
}
|
||||
|
||||
public long getEventId() {
|
||||
return eventId;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,164 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.async.AsyncInstanceCreateStatus;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobResult;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.async.BaseAsyncJobExecutor;
|
||||
import com.cloud.async.executor.VolumeOperationParam.VolumeOp;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventVO;
|
||||
import com.cloud.exception.InternalErrorException;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
|
||||
public class VolumeOperationExecutor extends BaseAsyncJobExecutor {
|
||||
public static final Logger s_logger = Logger.getLogger(VolumeOperationExecutor.class.getName());
|
||||
|
||||
public boolean execute() {
|
||||
Gson gson = GsonHelper.getBuilder().create();
|
||||
AsyncJobManager asyncMgr = getAsyncJobMgr();
|
||||
AsyncJobVO job = getJob();
|
||||
/*
|
||||
if (getSyncSource() == null) {
|
||||
VolumeOperationParam param = gson.fromJson(job.getCmdInfo(), VolumeOperationParam.class);
|
||||
asyncMgr.syncAsyncJobExecution(job.getId(), "Volume", param.getVolumeId());
|
||||
|
||||
// always true if it does not have sync-source
|
||||
return true;
|
||||
} else {
|
||||
VolumeOperationParam param = gson.fromJson(job.getCmdInfo(), VolumeOperationParam.class);
|
||||
boolean success = false;
|
||||
String eventType = null;
|
||||
String failureDescription = "";
|
||||
try {
|
||||
VolumeVO volume = null;
|
||||
VolumeOp op = param.getOp();
|
||||
if (op == VolumeOp.Create) {
|
||||
eventType = EventTypes.EVENT_VOLUME_CREATE;
|
||||
failureDescription = "Failed to create volume";
|
||||
volume = asyncMgr.getExecutorContext().getManagementServer().createVolume(param.getUserId(), param.getAccountId(), param.getName(), param.getZoneId(), param.getDiskOfferingId(), param.getEventId(), param.getSize());
|
||||
if (volume.getStatus() == AsyncInstanceCreateStatus.Corrupted) {
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR, "Failed to create volume.");
|
||||
} else {
|
||||
success = true;
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0, composeResultObject(volume, param));
|
||||
}
|
||||
}
|
||||
else if (op == VolumeOp.Attach) {
|
||||
eventType = EventTypes.EVENT_VOLUME_ATTACH;
|
||||
failureDescription = "Failed to attach volume";
|
||||
|
||||
asyncMgr.getExecutorContext().getManagementServer().attachVolumeToVM(param.getVmId(), param.getVolumeId(), param.getDeviceId(), param.getEventId());
|
||||
|
||||
// get the VM instance and Volume for the result object
|
||||
UserVm vmInstance = asyncMgr.getExecutorContext().getManagementServer().findUserVMInstanceById(param.getVmId());
|
||||
VolumeVO vol = asyncMgr.getExecutorContext().getManagementServer().findVolumeById(param.getVolumeId());
|
||||
success = true;
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0, composeAttachResultObject(vmInstance, vol));
|
||||
}
|
||||
else if (op == VolumeOp.Detach) {
|
||||
eventType = EventTypes.EVENT_VOLUME_DETACH;
|
||||
failureDescription = "Failed to detach volume";
|
||||
|
||||
asyncMgr.getExecutorContext().getManagementServer().detachVolumeFromVM(param.getVolumeId(), param.getEventId(),param.getDeviceId(),param.getVmId());
|
||||
success = true;
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0, null);
|
||||
} else {
|
||||
throw new Exception("Invalid Volume Operation. Valid Operations are: CreateVolume, AttachVolume, and DetachVolume.");
|
||||
}
|
||||
|
||||
} catch (InternalErrorException e) {
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR, e.getMessage());
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Unhandled Exception executing volume operation " + param.getOp(), e);
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR, e.getMessage());
|
||||
} finally {
|
||||
if(!success){
|
||||
// Save completed event when operation fails
|
||||
asyncMgr.getExecutorContext().getManagementServer().saveEvent(param.getUserId(), param.getAccountId(), EventVO.LEVEL_ERROR, eventType, failureDescription, null, param.getEventId());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
public void processAnswer(VolumeOperationListener listener, long agentId, long seq, Answer answer) {
|
||||
}
|
||||
|
||||
public void processDisconnect(VolumeOperationListener listener, long agentId) {
|
||||
}
|
||||
|
||||
public void processTimeout(VolumeOperationListener listener, long agentId, long seq) {
|
||||
}
|
||||
|
||||
protected VolumeOperationResultObject composeResultObject(VolumeVO volume, VolumeOperationParam param) {
|
||||
VolumeOperationResultObject resultObject = new VolumeOperationResultObject();
|
||||
Long diskOfferingId = null;
|
||||
|
||||
diskOfferingId = volume.getDiskOfferingId();
|
||||
|
||||
resultObject.setId(volume.getId());
|
||||
resultObject.setName(param.getName());
|
||||
resultObject.setVolumeType(volume.getVolumeType());
|
||||
resultObject.setVolumeSize(volume.getSize());
|
||||
resultObject.setCreatedDate(volume.getCreated());
|
||||
resultObject.setState(volume.getStatus());
|
||||
resultObject.setAccountName(getAsyncJobMgr().getExecutorContext().getManagementServer().findAccountById(param.getAccountId()).getAccountName());
|
||||
resultObject.setDomainId(volume.getDomainId());
|
||||
resultObject.setDiskOfferingId(volume.getDiskOfferingId());
|
||||
|
||||
if (diskOfferingId != null) {
|
||||
resultObject.setDiskOfferingName(getAsyncJobMgr().getExecutorContext().getManagementServer().findDiskOfferingById(diskOfferingId).getName());
|
||||
resultObject.setDiskOfferingDisplayText(getAsyncJobMgr().getExecutorContext().getManagementServer().findDiskOfferingById(diskOfferingId).getDisplayText());
|
||||
}
|
||||
// resultObject.setDomain(getAsyncJobMgr().getExecutorContext().getManagementServer().findDomainIdById(volume.getDomainId()).getName());
|
||||
resultObject.setStorageType("shared"); // NOTE: You can never create a local disk volume but if that changes, we need to change this
|
||||
if (volume.getPoolId() != null)
|
||||
resultObject.setStorage(getAsyncJobMgr().getExecutorContext().getManagementServer().findPoolById(volume.getPoolId()).getName());
|
||||
resultObject.setZoneId(volume.getDataCenterId());
|
||||
// resultObject.setZoneName(getAsyncJobMgr().getExecutorContext().getManagementServer().getDataCenterBy(volume.getDataCenterId()).getName());
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
private AttachVolumeOperationResultObject composeAttachResultObject(UserVm instance, VolumeVO vol) {
|
||||
AttachVolumeOperationResultObject resultObject = new AttachVolumeOperationResultObject();
|
||||
|
||||
resultObject.setVmName(instance.getName());
|
||||
resultObject.setVmDisplayName(instance.getDisplayName());
|
||||
resultObject.setVirtualMachineId(instance.getId());
|
||||
resultObject.setVmState(instance.getState().toString());
|
||||
resultObject.setStorageType("shared"); // NOTE: You can never attach a local disk volume but if that changes, we need to change this
|
||||
resultObject.setVolumeId(vol.getId());
|
||||
resultObject.setVolumeName(vol.getName());
|
||||
|
||||
return resultObject;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,128 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.Listener;
|
||||
import com.cloud.agent.api.AgentControlAnswer;
|
||||
import com.cloud.agent.api.AgentControlCommand;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.StartupCommand;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.vm.UserVmVO;
|
||||
|
||||
public class VolumeOperationListener implements Listener {
|
||||
private static final Logger s_logger = Logger.getLogger(VolumeOperationListener.class);
|
||||
|
||||
private final VolumeOperationExecutor _executor;
|
||||
private final VolumeOperationParam _param;
|
||||
private final UserVmVO _vm;
|
||||
private final VolumeVO _volume;
|
||||
private int _cookie;
|
||||
|
||||
public VolumeOperationListener(VolumeOperationExecutor executor, VolumeOperationParam param, UserVmVO vm, VolumeVO volume, int cookie) {
|
||||
|
||||
if(s_logger.isDebugEnabled())
|
||||
s_logger.debug("VM operation listener is created");
|
||||
|
||||
_executor = executor;
|
||||
_param = param;
|
||||
_vm = vm;
|
||||
_volume = volume;
|
||||
_cookie = cookie;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processAnswers(long agentId, long seq, Answer[] answers) {
|
||||
Answer answer = null;
|
||||
if(answers != null)
|
||||
answer = answers[0];
|
||||
|
||||
if(s_logger.isDebugEnabled())
|
||||
s_logger.debug("Process command answer for " + agentId + "-" + seq + " " + answer);
|
||||
|
||||
_executor.processAnswer(this, agentId, seq, answer);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processCommands(long agentId, long seq, Command[] commands) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AgentControlAnswer processControlCommand(long agentId, AgentControlCommand cmd) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processConnect(HostVO agent, StartupCommand cmd) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processDisconnect(long agentId, Status state) {
|
||||
if(_vm.getHostId() == agentId)
|
||||
_executor.processDisconnect(this, agentId);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecurring() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTimeout() {
|
||||
// TODO : no time out support for now as underlying support does not work as expected
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processTimeout(long agentId, long seq) {
|
||||
if(s_logger.isDebugEnabled())
|
||||
s_logger.debug("Process time out for " + agentId + "-" + seq);
|
||||
|
||||
_executor.processTimeout(this, agentId, seq);
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getCookie() {
|
||||
return _cookie;
|
||||
}
|
||||
|
||||
public void setCookie(int cookie) {
|
||||
_cookie = cookie;
|
||||
}
|
||||
|
||||
public VolumeOperationExecutor getExecutor() {
|
||||
return _executor;
|
||||
}
|
||||
|
||||
public VolumeOperationParam getParam() {
|
||||
return _param;
|
||||
}
|
||||
|
||||
public UserVmVO getVm() {
|
||||
return _vm;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,135 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
public class VolumeOperationParam {
|
||||
|
||||
public enum VolumeOp { Create, Attach, Detach;}
|
||||
|
||||
// Used for all VolumeOps
|
||||
private VolumeOp op;
|
||||
private long accountId;
|
||||
private long userId;
|
||||
|
||||
// Used for Create
|
||||
private long zoneId;
|
||||
private String name;
|
||||
private long diskOfferingId;
|
||||
private long size;
|
||||
|
||||
// Used for Attach and Detach
|
||||
private long vmId;
|
||||
|
||||
|
||||
// Used for Attach, Detach, and Delete
|
||||
private long volumeId;
|
||||
private long eventId;
|
||||
private Long deviceId;
|
||||
|
||||
public VolumeOperationParam() {
|
||||
}
|
||||
|
||||
public VolumeOp getOp() {
|
||||
return op;
|
||||
}
|
||||
|
||||
public void setOp(VolumeOp op) {
|
||||
this.op = op;
|
||||
}
|
||||
|
||||
public long getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public void setAccountId(long accountId) {
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
public long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public void setZoneId(long zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public long getDiskOfferingId() {
|
||||
return diskOfferingId;
|
||||
}
|
||||
|
||||
public void setDiskOfferingId(long diskOfferingId) {
|
||||
this.diskOfferingId = diskOfferingId;
|
||||
}
|
||||
|
||||
public long getVolumeId() {
|
||||
return volumeId;
|
||||
}
|
||||
|
||||
public void setVolumeId(long volumeId) {
|
||||
this.volumeId = volumeId;
|
||||
}
|
||||
|
||||
public long getVmId() {
|
||||
return vmId;
|
||||
}
|
||||
|
||||
public void setVmId(long vmId) {
|
||||
this.vmId = vmId;
|
||||
}
|
||||
|
||||
public void setEventId(long eventId) {
|
||||
this.eventId = eventId;
|
||||
}
|
||||
|
||||
public long getEventId() {
|
||||
return eventId;
|
||||
}
|
||||
|
||||
public void setDeviceId(Long deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public Long getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public long getSize(){
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(long size){
|
||||
this.size = size;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,344 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.async.executor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.cloud.async.AsyncInstanceCreateStatus;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.cloud.storage.Volume.VolumeType;
|
||||
|
||||
public class VolumeOperationResultObject {
|
||||
@Param(name="id")
|
||||
private long id;
|
||||
|
||||
@Param(name="name")
|
||||
private String name;
|
||||
|
||||
@Param(name="hostname")
|
||||
private String hostName;
|
||||
|
||||
// @Param(name="host_id")
|
||||
// private Long hostId;
|
||||
|
||||
// @Param(name="pool_id")
|
||||
// private Long poolId;
|
||||
|
||||
//@Param(name="accountid")
|
||||
//long accountId;
|
||||
|
||||
@Param(name="account")
|
||||
private String accountName;
|
||||
|
||||
@Param(name="domainid")
|
||||
long domainId;
|
||||
|
||||
@Param(name="domain")
|
||||
String domain;
|
||||
|
||||
@Param(name="iscsiname")
|
||||
String iscsiName;
|
||||
|
||||
// @Param(name="pod_id")
|
||||
// Long podId;
|
||||
|
||||
@Param(name="destroyed")
|
||||
boolean destroyed;
|
||||
|
||||
// @Param(name="created")
|
||||
// Date created;
|
||||
|
||||
// @Param(name="host_ip")
|
||||
// String hostip;
|
||||
|
||||
@Param(name="diskofferingid")
|
||||
Long diskOfferingId;
|
||||
|
||||
@Param(name="diskofferingname")
|
||||
String diskOfferingName;
|
||||
|
||||
@Param(name="diskofferingdisplaytext")
|
||||
String diskOfferingDisplayText;
|
||||
|
||||
// @Param(name="mirror_vol")
|
||||
// Long mirrorVolume;
|
||||
|
||||
// @Param(name="template_name")
|
||||
// String templateName;
|
||||
|
||||
// @Param(name="device_name")
|
||||
// String deviceName;
|
||||
|
||||
@Param(name="type")
|
||||
VolumeType volumeType;
|
||||
|
||||
@Param(name="size")
|
||||
private long volumeSize;
|
||||
|
||||
// @Param(name="removed")
|
||||
// Date removed;
|
||||
|
||||
@Param(name="vmstate")
|
||||
private String instanceState;
|
||||
|
||||
@Param(name="created")
|
||||
private Date createdDate;
|
||||
|
||||
@Param(name="state")
|
||||
private AsyncInstanceCreateStatus state;
|
||||
|
||||
@Param(name="storagetype")
|
||||
String storageType;
|
||||
|
||||
@Param(name="storage")
|
||||
private String storage;
|
||||
|
||||
@Param(name="zoneid")
|
||||
private Long zoneId;
|
||||
|
||||
public Long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public void setZoneId(Long zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
|
||||
public String getZoneName() {
|
||||
return zoneName;
|
||||
}
|
||||
|
||||
public void setZoneName(String zoneName) {
|
||||
this.zoneName = zoneName;
|
||||
}
|
||||
|
||||
@Param(name="zonename")
|
||||
private String zoneName;
|
||||
|
||||
public String getStorage() {
|
||||
return storage;
|
||||
}
|
||||
|
||||
public void setStorage(String storage) {
|
||||
this.storage = storage;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setHostName(String hostName) {
|
||||
this.hostName = hostName;
|
||||
}
|
||||
|
||||
public String getHostName() {
|
||||
return hostName;
|
||||
}
|
||||
|
||||
public void setAccountName(String accountName) {
|
||||
this.accountName = accountName;
|
||||
}
|
||||
|
||||
public String getAccountName() {
|
||||
return accountName;
|
||||
}
|
||||
|
||||
public void setDomainId(long domainId) {
|
||||
this.domainId = domainId;
|
||||
}
|
||||
|
||||
public long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public void setDomain(String domain) {
|
||||
this.domain = domain;
|
||||
}
|
||||
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
/*
|
||||
public void setSize(long size) {
|
||||
this.size = size;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
public void setFolder(String folder) {
|
||||
this.folder = folder;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
*/
|
||||
|
||||
public void setIscsiName(String iscsiName) {
|
||||
this.iscsiName = iscsiName;
|
||||
}
|
||||
|
||||
public String getIscsiName() {
|
||||
return iscsiName;
|
||||
}
|
||||
|
||||
/*
|
||||
public void setPodId(Long podId) {
|
||||
this.podId = podId;
|
||||
}
|
||||
*/
|
||||
|
||||
public void setDestroyed(boolean destroyed) {
|
||||
this.destroyed = destroyed;
|
||||
}
|
||||
|
||||
public boolean getDestroyed() {
|
||||
return destroyed;
|
||||
}
|
||||
|
||||
/*
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
public void setHostIp(String hostIp) {
|
||||
this.hostip = hostIp;
|
||||
}
|
||||
*/
|
||||
|
||||
public void setDiskOfferingId(Long diskOfferingId) {
|
||||
this.diskOfferingId = diskOfferingId;
|
||||
}
|
||||
|
||||
public Long getDiskOfferingId() {
|
||||
return diskOfferingId;
|
||||
}
|
||||
|
||||
public void setDiskOfferingName(String diskOfferingName) {
|
||||
this.diskOfferingName = diskOfferingName;
|
||||
}
|
||||
|
||||
public String getDiskOfferingDisplayText() {
|
||||
return diskOfferingDisplayText;
|
||||
}
|
||||
|
||||
public void setDiskOfferingDisplayText(String diskOfferingDisplayText) {
|
||||
this.diskOfferingDisplayText = diskOfferingDisplayText;
|
||||
}
|
||||
|
||||
public String getDiskOfferingName() {
|
||||
return diskOfferingName;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public void setMirrorVolume(long mirrorVolume) {
|
||||
this.mirrorVolume = mirrorVolume;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
public long getMirrorVolume() {
|
||||
return mirrorVolume;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
public void setTemplateName(String templateName) {
|
||||
this.templateName = templateName;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
public void setDeviceName(String deviceName) {
|
||||
this.deviceName = deviceName;
|
||||
}
|
||||
*/
|
||||
|
||||
public void setVolumeType(VolumeType volumeType) {
|
||||
this.volumeType = volumeType;
|
||||
}
|
||||
|
||||
public VolumeType getVolumeType() {
|
||||
return volumeType;
|
||||
}
|
||||
|
||||
public void setVolumeSize(long volumeSize) {
|
||||
this.volumeSize = volumeSize;
|
||||
}
|
||||
|
||||
public long getVolumeSize() {
|
||||
return volumeSize;
|
||||
}
|
||||
|
||||
/*
|
||||
public void setRemoved(Date removed) {
|
||||
this.removed = removed;
|
||||
}
|
||||
*/
|
||||
|
||||
public void setCreatedDate(Date createdDate) {
|
||||
this.createdDate = createdDate;
|
||||
}
|
||||
|
||||
public Date getCreatedDate() {
|
||||
return createdDate;
|
||||
}
|
||||
|
||||
public void setState(AsyncInstanceCreateStatus status) {
|
||||
this.state = status;
|
||||
}
|
||||
|
||||
public AsyncInstanceCreateStatus getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setStorageType (String storageType) {
|
||||
this.storageType = storageType;
|
||||
}
|
||||
|
||||
public String getStorageType() {
|
||||
return storageType;
|
||||
}
|
||||
|
||||
public void setInstanceState(String state) {
|
||||
this.instanceState = state;
|
||||
}
|
||||
|
||||
public String getInstanceState() {
|
||||
return instanceState;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue