removed useless code

This commit is contained in:
Alex Huang 2011-01-21 12:10:35 -08:00
parent 48ec23ce95
commit 73e5a789d1
27 changed files with 167 additions and 4333 deletions

View File

@ -1,253 +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.EventUtils;
import com.cloud.event.EventVO;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientStorageCapacityException;
import com.cloud.exception.InternalErrorException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.serializer.GsonHelper;
import com.cloud.server.ManagementServer;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.storage.StoragePoolVO;
import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.VolumeVO;
import com.cloud.user.Account;
import com.cloud.user.User;
import com.cloud.uservm.UserVm;
import com.cloud.utils.Pair;
import com.cloud.utils.exception.ExecutionException;
import com.cloud.vm.InstanceGroupVO;
import com.google.gson.Gson;
public class DeployVMExecutor extends VMOperationExecutor {
public static final Logger s_logger = Logger.getLogger(DeployVMExecutor.class.getName());
@Override
public boolean execute() {
// currently deploy VM operation will not be sync-ed with any queue, execute it directly
Gson gson = GsonHelper.getBuilder().create();
AsyncJobManager asyncMgr = getAsyncJobMgr();
AsyncJobVO job = getJob();
DeployVMParam param = gson.fromJson(job.getCmdInfo(), DeployVMParam.class);
/*
try {
UserVm vm = asyncMgr.getExecutorContext().getManagementServer().deployVirtualMachine(
param.getUserId(), param.getAccountId(), param.getDataCenterId(),
param.getServiceOfferingId(),
param.getTemplateId(), param.getDiskOfferingId(), param.getDomain(),
param.getPassword(), param.getDisplayName(), param.getGroup(), param.getUserData(), param.getNetworkGroup(), param.getEventId(), param.getSize());
asyncMgr.completeAsyncJob(getJob().getId(),
AsyncJobResult.STATUS_SUCCEEDED, 0, composeResultObject(param.getUserId(), vm, param));
} catch (ResourceAllocationException e) {
if(s_logger.isDebugEnabled())
s_logger.debug("Unable to deploy VM: " + e.getMessage());
saveEvent(param, EventVO.LEVEL_ERROR, EventTypes.EVENT_VM_CREATE, "Unable to deploy VM: VM_INSUFFICIENT_CAPACITY");
asyncMgr.completeAsyncJob(getJob().getId(),
AsyncJobResult.STATUS_FAILED, BaseCmd.VM_INSUFFICIENT_CAPACITY, e.getMessage());
} catch (ExecutionException e) {
if(s_logger.isDebugEnabled())
s_logger.debug("Unable to deploy VM: " + e.getMessage());
saveEvent(param, EventVO.LEVEL_ERROR, EventTypes.EVENT_VM_CREATE, "Unable to deploy VM: VM_HOST_LICENSE_EXPIRED");
asyncMgr.completeAsyncJob(getJob().getId(),AsyncJobResult.STATUS_FAILED, BaseCmd.VM_HOST_LICENSE_EXPIRED, e.getMessage());
} catch (InvalidParameterValueException e) {
if(s_logger.isDebugEnabled())
s_logger.debug("Unable to deploy VM: " + e.getMessage());
saveEvent(param, EventVO.LEVEL_ERROR, EventTypes.EVENT_VM_CREATE, "Unable to deploy VM: VM_INVALID_PARAM_ERROR");
asyncMgr.completeAsyncJob(getJob().getId(),
AsyncJobResult.STATUS_FAILED, BaseCmd.VM_INVALID_PARAM_ERROR, e.getMessage());
} catch (InternalErrorException e) {
if(s_logger.isDebugEnabled())
s_logger.debug("Unable to deploy VM: " + e.getMessage());
saveEvent(param, EventVO.LEVEL_ERROR, EventTypes.EVENT_VM_CREATE, "Unable to deploy VM: INTERNAL_ERROR");
asyncMgr.completeAsyncJob(getJob().getId(),
AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR, e.getMessage());
} catch (InsufficientStorageCapacityException e) {
if(s_logger.isDebugEnabled())
s_logger.debug("Unable to deploy VM: " + e.getMessage());
saveEvent(param, EventVO.LEVEL_ERROR, EventTypes.EVENT_VM_CREATE, "Unable to deploy VM: VM_INSUFFICIENT_CAPACITY");
asyncMgr.completeAsyncJob(getJob().getId(),
AsyncJobResult.STATUS_FAILED, BaseCmd.VM_INSUFFICIENT_CAPACITY, e.getMessage());
} catch (PermissionDeniedException e) {
if(s_logger.isDebugEnabled())
s_logger.debug("Unable to deploy VM: " + e.getMessage());
saveEvent(param, EventVO.LEVEL_ERROR, EventTypes.EVENT_VM_CREATE, "Unable to deploy VM: ACCOUNT_ERROR");
asyncMgr.completeAsyncJob(getJob().getId(),
AsyncJobResult.STATUS_FAILED, BaseCmd.ACCOUNT_ERROR, e.getMessage());
} catch (ConcurrentOperationException e) {
if(s_logger.isDebugEnabled())
s_logger.debug("Unable to deploy VM: " + e.getMessage());
saveEvent(param, EventVO.LEVEL_ERROR, EventTypes.EVENT_VM_CREATE, "Unable to deploy VM: INTERNAL_ERROR");
asyncMgr.completeAsyncJob(getJob().getId(),
AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR, e.getMessage());
} catch(Exception e) {
s_logger.warn("Unable to deploy VM : " + e.getMessage(), e);
saveEvent(param, EventVO.LEVEL_ERROR, EventTypes.EVENT_VM_CREATE, "Unable to deploy VM: INTERNAL_ERROR");
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) {
}
private long saveEvent(DeployVMParam param, String level, String type, String description){
return EventUtils.saveEvent(param.getUserId(), param.getAccountId(), level, type, description, null, param.getEventId());
}
private DeployVMResultObject composeResultObject(long userId, UserVm vm, DeployVMParam param) {
DeployVMResultObject resultObject = new DeployVMResultObject();
if(vm == null)
return resultObject;
resultObject.setId(vm.getId());
resultObject.setName(vm.getName());
resultObject.setCreated(vm.getCreated());
resultObject.setZoneId(vm.getDataCenterId());
resultObject.setZoneName(getAsyncJobMgr().getExecutorContext().getManagementServer().findDataCenterById(vm.getDataCenterId()).getName());
resultObject.setIpAddress(vm.getPrivateIpAddress());
resultObject.setServiceOfferingId(vm.getServiceOfferingId());
resultObject.setHaEnabled(vm.isHaEnabled());
if (vm.getDisplayName() == null || vm.getDisplayName().length() == 0) {
resultObject.setDisplayName(vm.getName());
}
else {
resultObject.setDisplayName(vm.getDisplayName());
}
if(vm.getState() != null)
resultObject.setState(vm.getState().toString());
ManagementServer managementServer = getAsyncJobMgr().getExecutorContext().getManagementServer();
InstanceGroupVO group = managementServer.getGroupForVm(vm.getId());
if (group != null) {
resultObject.setGroupId(group.getId());
resultObject.setGroup(group.getName());
}
VMTemplateVO template = managementServer.findTemplateById(vm.getTemplateId());
Account acct = managementServer.findAccountById(Long.valueOf(vm.getAccountId()));
if (acct != null) {
resultObject.setAccount(acct.getAccountName());
resultObject.setDomainId(acct.getDomainId());
// resultObject.setDomain(managementServer.findDomainIdById(acct.getDomainId()).getName());
}
User userExecutingCmd = managementServer.getUser(userId);
//this is for the case where the admin deploys a vm for a normal user
Account acctForUserExecutingCmd = managementServer.findAccountById(Long.valueOf(userExecutingCmd.getAccountId()));
if ((BaseCmd.isAdmin(acctForUserExecutingCmd.getType()) && (vm.getHostId() != null)) || (BaseCmd.isAdmin(acct.getType()) && (vm.getHostId() != null)))
{
resultObject.setHostname(managementServer.getHostBy(vm.getHostId()).getName());
resultObject.setHostid(vm.getHostId());
}
String templateName = "none";
boolean templatePasswordEnabled = false;
String templateDisplayText = null;
if (template != null) {
templateName = template.getName();
templatePasswordEnabled = template.getEnablePassword();
templateDisplayText = template.getDisplayText();
if (templateDisplayText == null) {
templateDisplayText = templateName;
}
}
if (templatePasswordEnabled) {
resultObject.setPassword(param.getPassword());
}
// ISO Info
Long isoId = vm.getIsoId();
if (isoId != null) {
VMTemplateVO iso = getAsyncJobMgr().getExecutorContext().getManagementServer().findTemplateById(isoId.longValue());
if (iso != null) {
resultObject.setIsoId(isoId.longValue());
resultObject.setIsoName(iso.getName());
resultObject.setTemplateId(isoId.longValue());
resultObject.setTemplateName(iso.getName());
templateDisplayText = iso.getDisplayText();
if(templateDisplayText == null)
templateDisplayText = iso.getName();
resultObject.setIsoDisplayText(templateDisplayText);
resultObject.setTemplateDisplayText(templateDisplayText);
}
}
else
{
resultObject.setTemplateId(vm.getTemplateId());
resultObject.setTemplateName(templateName);
resultObject.setTemplateDisplayText(templateDisplayText);
resultObject.setPasswordEnabled(templatePasswordEnabled);
}
ServiceOfferingVO offering = managementServer.findServiceOfferingById(vm.getServiceOfferingId());
resultObject.setServiceOfferingId(vm.getServiceOfferingId());
resultObject.setServiceOfferingName(offering.getName());
resultObject.setCpuNumber(String.valueOf(offering.getCpu()));
resultObject.setCpuSpeed(String.valueOf(offering.getSpeed()));
resultObject.setMemory(String.valueOf(offering.getRamSize()));
//root device related
// VolumeVO rootVolume = managementServer.findRootVolume(vm.getId());
// if(rootVolume!=null)
// {
// resultObject.setRootDeviceId(rootVolume.getDeviceId());
// StoragePoolVO storagePool = managementServer.findPoolById(rootVolume.getPoolId());
// resultObject.setRootDeviceType(storagePool.getPoolType().toString());
// }
// resultObject.setNetworkGroupList(managementServer.getNetworkGroupsNamesForVm(vm.getId()));
return resultObject;
}
}

View File

@ -1,169 +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 DeployVMParam extends VMOperationParam {
private long dataCenterId;
private long serviceOfferingId;
private long templateId;
private Long diskOfferingId;
private String domain;
private String password;
private String displayName;
private String group;
private String userData;
private long domainId;
private String [] networkGroups;
private long size;
public DeployVMParam() {
}
public DeployVMParam(long userId, long accountId, long dataCenterId,
long serviceOfferingId, long templateId,
Long diskOfferingId, String domain, String password,
String displayName, String group, String userData, String [] networkGroups) {
setUserId(userId);
setAccountId(accountId);
this.dataCenterId = dataCenterId;
this.serviceOfferingId = serviceOfferingId;
this.templateId = templateId;
this.diskOfferingId = diskOfferingId;
this.domain = domain;
this.password = password;
this.displayName = displayName;
this.group = group;
this.userData = userData;
this.setNetworkGroups(networkGroups);
}
public DeployVMParam(long userId, long accountId, long dataCenterId,
long serviceOfferingId, long templateId,
Long diskOfferingId, String domain, String password,
String displayName, String group, String userData,
String [] networkGroups, long eventId, long size) {
setUserId(userId);
setAccountId(accountId);
this.dataCenterId = dataCenterId;
this.serviceOfferingId = serviceOfferingId;
this.templateId = templateId;
this.diskOfferingId = diskOfferingId;
this.domain = domain;
this.password = password;
this.displayName = displayName;
this.group = group;
this.userData = userData;
this.setNetworkGroups(networkGroups);
this.eventId = eventId;
this.size = size;
}
public long getSize(){
return size;
}
public long getDataCenterId() {
return dataCenterId;
}
public void setDataCenterId(long dataCenterId) {
this.dataCenterId = dataCenterId;
}
public long getServiceOfferingId() {
return serviceOfferingId;
}
public void setServiceOfferingId(long serviceOfferingId) {
this.serviceOfferingId = serviceOfferingId;
}
public Long getDiskOfferingId() {
return diskOfferingId;
}
public void setDiskOfferingId(Long diskOfferingId) {
this.diskOfferingId = diskOfferingId;
}
public long getTemplateId() {
return templateId;
}
public void setTemplateId(long templateId) {
this.templateId = templateId;
}
public String getDomain() {
return domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public String getGroup() {
return group;
}
public void setGroup(String group) {
this.group = group;
}
public long getDomainId() {
return domainId;
}
public void setDomainId(long domainId) {
this.domainId = domainId;
}
public void setUserData(String userData) {
this.userData = userData;
}
public String getUserData() {
return userData;
}
public void setNetworkGroups(String [] networkGroups) {
this.networkGroups = networkGroups;
}
public String [] getNetworkGroup() {
return networkGroups;
}
}

View File

@ -1,413 +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 DeployVMResultObject {
@Param(name="id")
private long id;
@Param(name="name")
private String name;
@Param(name="created")
private Date created;
@Param(name="zoneid")
private Long zoneId;
@Param(name="zonename")
private String zoneName;
@Param(name="ipaddress")
private String ipAddress;
@Param(name="serviceofferingid")
private Long serviceOfferingId;
@Param(name="haenable")
private boolean haEnabled;
@Param(name="state")
private String state;
@Param(name="templateid")
private Long templateId;
@Param(name="isoid")
private Long isoId;
@Param(name="password")
private String password;
@Param(name="templatename")
private String templateName;
@Param(name="isoname")
private String isoName;
@Param(name="templatedisplaytext")
private String templateDisplayText;
@Param(name="isodisplaytext")
private String isoDisplayText;
@Param(name="passwordenabled")
private boolean passwordEnabled;
@Param(name="serviceofferingname")
private String serviceOfferingName;
@Param(name="diskofferingid")
private Long diskOfferingId;
@Param(name="diskofferingname")
private String diskOfferingName;
@Param(name="cpunumber")
private String cpuNumber;
@Param(name="cpuspeed")
private String cpuSpeed;
@Param(name="memory")
private String memory;
@Param(name="storage")
private String storage;
@Param(name="displayname")
private String displayName;
@Param(name="group")
private String group;
@Param(name="groupid")
private Long groupId;
@Param(name="domainid")
private Long domainId;
@Param(name="domain")
private String domain;
@Param(name="account")
private String account;
@Param(name="hostname")
private String hostname;
@Param(name="hostid")
private Long hostid;
@Param(name="securitygrouplist")
private String securityGroupList;
@Param(name="rootdeviceid")
private Long rootDeviceId;
@Param(name="rootdevicetype")
private String rootDeviceType;
public Long getRootDeviceId(){
return this.rootDeviceId;
}
public void setRootDeviceId(Long rootDeviceId){
this.rootDeviceId = rootDeviceId;
}
public String getRootDeviceType(){
return this.rootDeviceType;
}
public void setRootDeviceType(String deviceType){
this.rootDeviceType = deviceType;
}
public String getSecurityGroupList(){
return this.securityGroupList;
}
public void setSecurityGroupList(String nGroups){
this.securityGroupList = nGroups;
}
public String getIsoDisplayText() {
return isoDisplayText;
}
public void setIsoDisplayText(String text) {
this.isoDisplayText = text;
}
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 Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
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 getIpAddress() {
return ipAddress;
}
public void setIpAddress(String ipAddress) {
this.ipAddress = ipAddress;
}
public Long getServiceOfferingId() {
return serviceOfferingId;
}
public void setServiceOfferingId(Long serviceOfferingId) {
this.serviceOfferingId = serviceOfferingId;
}
public boolean isHaEnabled() {
return haEnabled;
}
public void setHaEnabled(boolean haEnabled) {
this.haEnabled = haEnabled;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public Long getTemplateId() {
return templateId;
}
public void setTemplateId(Long templateId) {
this.templateId = templateId;
}
public Long getIsoId() {
return isoId;
}
public void setIsoId(Long isoId) {
this.isoId = isoId;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getTemplateName() {
return templateName;
}
public void setTemplateName(String templateName) {
this.templateName = templateName;
}
public String getIsoName() {
return isoName;
}
public void setIsoName(String isoName) {
this.isoName = isoName;
}
public String getTemplateDisplayText() {
return templateDisplayText;
}
public void setTemplateDisplayText(String templateDisplayText) {
this.templateDisplayText = templateDisplayText;
}
public boolean isPasswordEnabled() {
return passwordEnabled;
}
public void setPasswordEnabled(boolean passwordEnabled) {
this.passwordEnabled = passwordEnabled;
}
public String getServiceOfferingName() {
return serviceOfferingName;
}
public void setServiceOfferingName(String serviceOfferingName) {
this.serviceOfferingName = serviceOfferingName;
}
public Long getDiskOfferingId() {
return diskOfferingId;
}
public void setDiskOfferingId(Long diskOfferingId) {
this.diskOfferingId = diskOfferingId;
}
public String getDiskOfferingName() {
return diskOfferingName;
}
public void setDiskOfferingName(String diskOfferingName) {
this.diskOfferingName = diskOfferingName;
}
public String getCpuNumber() {
return cpuNumber;
}
public void setCpuNumber(String cpuNumber) {
this.cpuNumber = cpuNumber;
}
public String getCpuSpeed() {
return cpuSpeed;
}
public void setCpuSpeed(String cpuSpeed) {
this.cpuSpeed = cpuSpeed;
}
public String getMemory() {
return memory;
}
public void setMemory(String memory) {
this.memory = memory;
}
public String getStorage() {
return storage;
}
public void setStorage(String stroage) {
this.storage = stroage;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public String getGroup() {
return group;
}
public void setGroup(String group) {
this.group = group;
}
public Long getGroupId() {
return groupId;
}
public void setGroupId(Long groupId) {
this.groupId = groupId;
}
public Long getDomainId() {
return domainId;
}
public void setDomainId(Long domainId) {
this.domainId = domainId;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getHostname() {
return hostname;
}
public void setHostname(String hostname) {
this.hostname = hostname;
}
public Long getHostid() {
return hostid;
}
public void setHostid(Long hostid) {
this.hostid = hostid;
}
public String getDomain() {
return domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
}

View File

@ -1,162 +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.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.async.SyncQueueItemVO;
import com.cloud.serializer.GsonHelper;
import com.cloud.server.ManagementServer;
import com.cloud.user.AccountVO;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.Transaction;
import com.cloud.vm.DomainRouterVO;
import com.google.gson.Gson;
public class DisableAccountExecutor extends BaseAsyncJobExecutor {
public static final Logger s_logger = Logger.getLogger(DisableAccountExecutor.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);
// SyncQueueItemVO syncItem = getSyncSource();
// if(syncItem == null) {
// initialSchedule(managementServer, param.longValue());
// } else {
// if(allRouterOperationCeased(job)) {
// if(s_logger.isInfoEnabled())
// s_logger.info("All previous router operations have ceased, we can now disable account " + param);
//
// if(managementServer.disableAccount(param.longValue())) {
// asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0,
// "success");
// } else {
// asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
// "failed");
// }
// } else {
// if(s_logger.isInfoEnabled())
// s_logger.info("Previous operation on router " + syncItem.getContentId()
// + " has ceased, still more to go to disable account " + param);
// }
// }
return true;
}
public void initialSchedule(ManagementServer managementServer, long accountId) {
AsyncJobManager asyncMgr = getAsyncJobMgr();
AccountVO account = asyncMgr.getExecutorContext().getAccountDao().acquireInLockTable(accountId);
if(account == null) {
s_logger.warn("Unable to acquire account." + accountId + " to execute disable account command");
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
"unabled to acquire account." + accountId + " lock");
return;
}
// try {
// List<DomainRouterVO> routers = asyncMgr.getExecutorContext().getRouterDao().listBy(accountId);
// if(routers.size() > 0) {
// scheduleOperationAfterAllRouterOperations(managementServer, accountId, routers);
// } else {
// if(s_logger.isInfoEnabled())
// s_logger.info("Account " + accountId + " does not have running router, disable the account directly");
//
// if(managementServer.disableAccount(accountId)) {
// asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0,
// "success");
// } else {
// asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
// "failed");
// }
// }
// } catch (Exception e) {
// s_logger.warn("Unable to disable account: " + e.getMessage(), e);
// asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
// e.getMessage());
// } finally {
// asyncMgr.getExecutorContext().getAccountDao().releaseFromLockTable(accountId);
// }
}
@DB
protected void scheduleOperationAfterAllRouterOperations(ManagementServer managementServer, long accountId,
List<DomainRouterVO> routers) {
AsyncJobManager asyncMgr = getAsyncJobMgr();
AsyncJobVO job = getJob();
Transaction txn = Transaction.currentTxn();
try {
txn.start();
asyncMgr.updateAsyncJobStatus(job.getId(), routers.size(), "");
for(DomainRouterVO router : routers) {
if(s_logger.isInfoEnabled())
s_logger.info("Serialize DisableAccount operation on account " + accountId
+ " with previous activities on router " + router.getId());
asyncMgr.syncAsyncJobExecution(job, "Router", router.getId());
}
txn.commit();
} catch (Exception e) {
txn.rollback();
s_logger.warn("Unexpected exception " + e.getMessage(), e);
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
e.getMessage());
}
}
@DB
protected boolean allRouterOperationCeased(AsyncJobVO job) {
AsyncJobManager asyncMgr = getAsyncJobMgr();
Transaction txn = Transaction.currentTxn();
try {
txn.start();
AsyncJobVO jobUpdate = asyncMgr.getExecutorContext().getJobDao().lockRow(job.getId(), true);
int progress = jobUpdate.getProcessStatus();
jobUpdate.setProcessStatus(progress -1);
asyncMgr.getExecutorContext().getJobDao().update(job.getId(), jobUpdate);
txn.commit();
return progress == 1;
} catch(Exception e) {
s_logger.warn("Unexpected exception " + e.getMessage(), e);
txn.rollback();
}
return false;
}
}

View File

@ -1,191 +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.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.serializer.GsonHelper;
import com.cloud.server.ManagementServer;
import com.cloud.user.Account;
import com.cloud.user.UserVO;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.Transaction;
import com.cloud.vm.DomainRouterVO;
import com.google.gson.Gson;
public class DisableUserExecutor extends BaseAsyncJobExecutor {
public static final Logger s_logger = Logger.getLogger(DisableUserExecutor.class.getName());
@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);
/*
SyncQueueItemVO syncItem = getSyncSource();
if(syncItem == null) {
initialSchedule(managementServer, param.longValue());
} else {
if(allRouterOperationCeased(job)) {
if(s_logger.isInfoEnabled())
s_logger.info("All previous router operations have ceased, we can now disable account of the user " + param);
UserVO user = asyncMgr.getExecutorContext().getUserDao().findById(param.longValue());
if(user != null) {
if(managementServer.disableAccount(user.getAccountId())) {
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0,
"success");
} else {
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
"failed");
}
} else {
if(s_logger.isInfoEnabled())
s_logger.info("User " + param + " no longer exists, assuming it is already disbled");
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0,
"success");
}
} else {
if(s_logger.isInfoEnabled())
s_logger.info("Previous operation on router " + syncItem.getContentId()
+ " has ceased, still more to go to disable account for user " + param);
}
}
*/
return true;
}
public void initialSchedule(ManagementServer managementServer, long userId) {
AsyncJobManager asyncMgr = getAsyncJobMgr();
UserVO user = asyncMgr.getExecutorContext().getUserDao().findById(userId);
if(user == null) {
if(s_logger.isInfoEnabled()) {
s_logger.info("User " + userId + " does not exist");
}
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
"User " + userId + " does not exist");
return;
}
/*
if(managementServer.disableUser(userId)) {
if(needToDisableAccount(user)) {
if(s_logger.isInfoEnabled())
s_logger.info("This is the only user " + userId + " left for the account " + user.getAccountId() + ", we will disable account as well");
List<DomainRouterVO> routers = asyncMgr.getExecutorContext().getRouterDao().listBy(user.getAccountId());
if(routers.size() > 0) {
scheduleOperationAfterAllRouterOperations(managementServer, user.getAccountId(), routers);
} else {
if(s_logger.isInfoEnabled())
s_logger.info("Account " + user.getAccountId() + " does not have DomR to serialize with, disable it directly");
// no router being created under the account, disable the account directly
if(managementServer.disableAccount(user.getAccountId())) {
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0,
"success");
} else {
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
"failed");
}
}
}
} else {
if(s_logger.isInfoEnabled())
s_logger.info("Unable to disable user " + userId);
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
"Unable to disable user " + userId);
}
*/
}
private boolean needToDisableAccount(UserVO user) {
AsyncJobManager asyncMgr = getAsyncJobMgr();
List<UserVO> allUsersByAccount = asyncMgr.getExecutorContext().getUserDao().listByAccount(user.getAccountId());
for (UserVO oneUser : allUsersByAccount) {
if (oneUser.getState().equals(Account.State.enabled)) {
return false;
}
}
return true;
}
@DB
protected void scheduleOperationAfterAllRouterOperations(ManagementServer managementServer, long accountId,
List<DomainRouterVO> routers) {
AsyncJobManager asyncMgr = getAsyncJobMgr();
AsyncJobVO job = getJob();
Transaction txn = Transaction.currentTxn();
try {
txn.start();
asyncMgr.updateAsyncJobStatus(job.getId(), routers.size(), "");
for(DomainRouterVO router : routers) {
if(s_logger.isInfoEnabled()) {
s_logger.info("Serialize DisableUser operation with previous activities on router " + router.getId());
}
asyncMgr.syncAsyncJobExecution(job, "Router", router.getId());
}
txn.commit();
} catch (Exception e) {
txn.rollback();
s_logger.warn("Unexpected exception " + e.getMessage(), e);
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
e.getMessage());
}
}
@DB
protected boolean allRouterOperationCeased(AsyncJobVO job) {
AsyncJobManager asyncMgr = getAsyncJobMgr();
Transaction txn = Transaction.currentTxn();
try {
txn.start();
AsyncJobVO jobUpdate = asyncMgr.getExecutorContext().getJobDao().lockRow(job.getId(), true);
int progress = jobUpdate.getProcessStatus();
jobUpdate.setProcessStatus(progress -1);
asyncMgr.getExecutorContext().getJobDao().update(job.getId(), jobUpdate);
txn.commit();
return progress == 1;
} catch(Exception e) {
s_logger.warn("Unexpected exception " + e.getMessage(), e);
txn.rollback();
}
return false;
}
}

View File

@ -1,59 +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 DisassociateIpAddressParam {
private long userId;
private long accountId;
private String ipAddress;
public DisassociateIpAddressParam() {
}
public DisassociateIpAddressParam(long userId, long accountId, String ipAddress) {
this.userId = userId;
this.accountId = accountId;
this.ipAddress = ipAddress;
}
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 getIpAddress() {
return ipAddress;
}
public void setIpAddress(String ipAddress) {
this.ipAddress = ipAddress;
}
}

View File

@ -1,167 +1,167 @@
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;
import com.cloud.storage.upload.UploadState;
public class ExtractJobResultObject {
public ExtractJobResultObject(Long accountId, String typeName, String currState, int uploadPercent, Long uploadId){
this.accountId = accountId;
this.name = typeName;
this.state = currState;
this.id = uploadId;
this.uploadPercent = uploadPercent;
}
public ExtractJobResultObject(Long accountId, String typeName, String currState, Long uploadId, String url){
this.accountId = accountId;
this.name = typeName;
this.state = currState;
this.id = uploadId;
this.url = url;
}
public ExtractJobResultObject(){
}
@Param(name="id")
private long id;
@Param(name="name")
private String name;
@Param(name="uploadPercentage")
private int uploadPercent;
@Param(name="uploadStatus")
private String uploadStatus;
@Param(name="accountid")
long accountId;
@Param(name="result_string")
String result_string;
@Param(name="created")
private Date createdDate;
@Param(name="state")
private String state;
@Param(name="storagetype")
String storageType;
@Param(name="storage")
private String storage;
@Param(name="zoneid")
private Long zoneId;
@Param(name="zonename")
private String zoneName;
@Param(name="url")
private String url;
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public int getUploadPercent() {
return uploadPercent;
}
public void setUploadPercent(int i) {
this.uploadPercent = i;
}
public String getUploadStatus() {
return uploadStatus;
}
public void setUploadStatus(String uploadStatus) {
this.uploadStatus = uploadStatus;
}
public String getResult_string() {
return result_string;
}
public void setResult_string(String resultString) {
result_string = resultString;
}
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 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 setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
public Date getCreatedDate() {
return createdDate;
}
public void setState(String status) {
this.state = status;
}
public String getState() {
return state;
}
public void setStorageType (String storageType) {
this.storageType = storageType;
}
public String getStorageType() {
return storageType;
}
}
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;
import com.cloud.storage.upload.UploadState;
public class ExtractJobResultObject {
public ExtractJobResultObject(Long accountId, String typeName, String currState, int uploadPercent, Long uploadId){
this.accountId = accountId;
this.name = typeName;
this.state = currState;
this.id = uploadId;
this.uploadPercent = uploadPercent;
}
public ExtractJobResultObject(Long accountId, String typeName, String currState, Long uploadId, String url){
this.accountId = accountId;
this.name = typeName;
this.state = currState;
this.id = uploadId;
this.url = url;
}
public ExtractJobResultObject(){
}
@Param(name="id")
private long id;
@Param(name="name")
private String name;
@Param(name="uploadPercentage")
private int uploadPercent;
@Param(name="uploadStatus")
private String uploadStatus;
@Param(name="accountid")
long accountId;
@Param(name="result_string")
String result_string;
@Param(name="created")
private Date createdDate;
@Param(name="state")
private String state;
@Param(name="storagetype")
String storageType;
@Param(name="storage")
private String storage;
@Param(name="zoneid")
private Long zoneId;
@Param(name="zonename")
private String zoneName;
@Param(name="url")
private String url;
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public int getUploadPercent() {
return uploadPercent;
}
public void setUploadPercent(int i) {
this.uploadPercent = i;
}
public String getUploadStatus() {
return uploadStatus;
}
public void setUploadStatus(String uploadStatus) {
this.uploadStatus = uploadStatus;
}
public String getResult_string() {
return result_string;
}
public void setResult_string(String resultString) {
result_string = resultString;
}
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 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 setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
public Date getCreatedDate() {
return createdDate;
}
public void setState(String status) {
this.state = status;
}
public String getState() {
return state;
}
public void setStorageType (String storageType) {
this.storageType = storageType;
}
public String getStorageType() {
return storageType;
}
}

View File

@ -1,442 +0,0 @@
package com.cloud.async.executor;
/**
* 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/>.
*
*/
import java.util.Date;
import java.util.Set;
import com.cloud.host.Status.Event;
import com.cloud.serializer.Param;
public class HostResultObject {
@Param(name="id")
private long id;
@Param(name="averageload")
private long averageLoad;
@Param(name="name")
private String name;
@Param(name="state")
private String state;
@Param(name="type")
private String type;
@Param(name="ipaddress")
private String ipAddress;
@Param(name="hypervisor")
private String hypervisorType;
@Param(name="fstype")
private String fsType;
// @Param(name="available")
// private boolean available;
//
// @Param(name="setup")
// private boolean setup;
@Param(name="zoneid")
private long zoneId;
@Param(name="zonename")
private String zoneName;
@Param(name="podid")
private Long podId;
@Param(name="podname")
private String podName;
@Param(name="cpuallocated")
private String cpuAllocated;
@Param(name="cpuused")
private String cpuUsed;
@Param(name="cpunumber")
private long cpuNumber;
@Param(name="url")
private String storageUrl;
@Param(name="cpuspeed")
private Long cpuSpeed;
@Param(name="memorytotal")
private long totalMemory;
@Param(name="memoryallocated")
private long memoryAllocated;
@Param(name="memoryused")
private long memoryUsed;
@Param(name="disksizetotal")
private long diskSizeTotal;
@Param(name="disksizeallocated")
private long diskSizeAllocated;
@Param(name="capabilities")
private String caps;
@Param(name="totalsize")
private Long totalSize;
@Param(name="managementserverid")
private Long managementServerId;
@Param(name="version")
private String version;
@Param(name="created")
private Date created;
@Param(name="removed")
private Date removed;
@Param(name="disconnected")
private Date disconnected;
@Param(name="events")
private Set<Event> events;
@Param(name="oscategoryid")
private Long osCategoryId;
@Param(name="oscategoryname")
private String osCategoryName;
@Param(name="lastpinged")
private long lastPinged;
@Param(name="networkkbsread")
private Long networkKbsRead;
@Param(name="networkkbswrite")
private Long networkKbsWrite;
public long getId(){
return this.id;
}
public void setId(long id){
this.id = id;
}
public void setOsCategoryId(long osCategoryId){
this.osCategoryId = osCategoryId;
}
public void setOsCategoryName(String osCategoryName){
this.osCategoryName = osCategoryName;
}
public Long getOsCategoryId(){
return this.osCategoryId;
}
public String getOsCategoryName(){
return this.osCategoryName;
}
public HostResultObject() {
}
public Set<Event>getEvents()
{
return this.events;
}
public void setEvents(Set<Event> eventSet)
{
this.events = eventSet;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getIpAddress() {
return ipAddress;
}
public void setIpAddress(String ipAddress) {
this.ipAddress = ipAddress;
}
public String getHypervisorType() {
return hypervisorType;
}
public void setHypervisorType(String hypervisorType) {
this.hypervisorType = hypervisorType;
}
public String getFsType() {
return fsType;
}
public void setFsType(String fsType) {
this.fsType = fsType;
}
// public boolean isAvailable() {
// return available;
// }
//
// public void setAvailable(boolean available) {
// this.available = available;
// }
//
// public boolean isSetup() {
// return setup;
// }
//
// public void setSetup(boolean setup) {
// this.setup = setup;
// }
public long getZoneId() {
return zoneId;
}
public void setZoneId(long zoneId) {
this.zoneId = zoneId;
}
public String getZoneName() {
return zoneName;
}
public String getPodName() {
return podName;
}
public void setZoneName(String zoneName) {
this.zoneName = zoneName;
}
public void setPodName(String podName) {
this.podName = podName;
}
public Long getPodId() {
return podId;
}
public void setPodId(Long podId) {
this.podId = podId;
}
public String getCpuAllocated() {
return cpuAllocated;
}
public void setCpuAllocated(String cpuAllocated) {
this.cpuAllocated = cpuAllocated;
}
public String getCpuUsed() {
return cpuUsed;
}
public void setCpuUsed(String cpuUsed) {
this.cpuUsed = cpuUsed;
}
public long getCpuNumber() {
return cpuNumber;
}
public void setCpuNumber(long cpuNumber) {
this.cpuNumber = cpuNumber;
}
public String getStorageUrl() {
return storageUrl;
}
public void setStorageUrl(String storageUrl) {
this.storageUrl = storageUrl;
}
public Long getCpuSpeed() {
return cpuSpeed;
}
public void setCpuSpeed(Long cpuSpeed) {
this.cpuSpeed = cpuSpeed;
}
public long getTotalMemory() {
return totalMemory;
}
public void setTotalMemory(long totalMemory) {
this.totalMemory = totalMemory;
}
public long getMemoryAllocated() {
return memoryAllocated;
}
public void setMemoryAllocated(long memoryAllocated) {
this.memoryAllocated = memoryAllocated;
}
public long getMemoryUsed() {
return memoryUsed;
}
public void setMemoryUsed(long memoryUsed) {
this.memoryUsed = memoryUsed;
}
// public long getDiskSize() {
// return diskSizeTotal;
// }
public long isDiskSizeTotal() {
return diskSizeTotal;
}
public void setDiskSizeTotal(long diskSizeTotal) {
this.diskSizeTotal = diskSizeTotal;
}
public long getDiskSizeAllocated() {
return diskSizeAllocated;
}
public void setDiskSizeAllocated(long diskSizeAllocated) {
this.diskSizeAllocated = diskSizeAllocated;
}
public String getCaps() {
return caps;
}
public void setCaps(String caps) {
this.caps = caps;
}
public Long getTotalSize() {
return totalSize;
}
public void setTotalSize(Long totalSize) {
this.totalSize = totalSize;
}
public long getLastPinged() {
return lastPinged;
}
public void setLastPinged(long l) {
this.lastPinged = l;
}
public Long getManagementServerId() {
return managementServerId;
}
public void setManagementServerId(Long managementServerId) {
this.managementServerId = managementServerId;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public Date getRemoved() {
return removed;
}
public void setRemoved(Date removed) {
this.removed = removed;
}
public Date getDisconnected() {
return disconnected;
}
public void setDisconnected(Date disconnected) {
this.disconnected = disconnected;
}
public long getAverageLoad(){
return this.averageLoad;
}
public void setAverageLoad(long averageLoad){
this.averageLoad = averageLoad;
}
public Long getNetworkKbsRead(){
return this.networkKbsRead;
}
public void setNetworkKbsRead(long networkKbsRead){
this.networkKbsRead = networkKbsRead;
}
public Long getNetworkKbsWrite(){
return this.networkKbsWrite;
}
public void setNetworkKbsWrite(long networkKbsWrite){
this.networkKbsWrite = networkKbsWrite;
}
}

View File

@ -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 java.util.List;
public class LoadBalancerParam {
private Long userId;
private Long domainRouterId;
private Long loadBalancerId;
private List<Long> instanceIdList;
public LoadBalancerParam() {
}
public LoadBalancerParam(Long userId, Long domainRouterId, Long loadBalancerId, List<Long> instanceIdList) {
this.userId = userId;
this.domainRouterId = domainRouterId;
this.loadBalancerId = loadBalancerId;
this.instanceIdList = instanceIdList;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Long getDomainRouterId() {
return domainRouterId;
}
public void setDomainRouterId(Long domainRouterId) {
this.domainRouterId = domainRouterId;
}
public Long getLoadBalancerId() {
return loadBalancerId;
}
public void setLoadBalancerId(Long securityGroupId) {
this.loadBalancerId = securityGroupId;
}
public List<Long> getInstanceIdList() {
return instanceIdList;
}
public void setInstanceId(List<Long> instanceIdList) {
this.instanceIdList = instanceIdList;
}
}

View File

@ -1,33 +0,0 @@
package com.cloud.async.executor;
public class OperationResponse {
public static final int STATUS_IN_PROGRESS = 0;
public static final int STATUS_SUCCEEDED = 1;
public static final int STATUS_FAILED = 2;
private int resultCode;
private String resultDescription;
public OperationResponse(int resultCode, String resultDescription) {
this.resultCode = resultCode;
this.resultDescription = resultDescription;
}
public int getResultCode() {
return resultCode;
}
public void setResultCode(int resultCode) {
this.resultCode = resultCode;
}
public String getResultDescription() {
return resultDescription;
}
public void setResultDescription(String resultDescription) {
this.resultDescription = resultDescription;
}
}

View File

@ -1,189 +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 PrepareMaintenanceExecutor extends BaseAsyncJobExecutor {
public static final Logger s_logger = Logger.getLogger(PrepareMaintenanceExecutor.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 {
boolean result = managementServer.prepareForMaintenance(param.longValue());
if(result)
{
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 prepare maintenance: " + 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);
// calculate memory utilized
}
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;
}
}

View File

@ -1,117 +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.dc.ClusterVO;
import com.cloud.serializer.GsonHelper;
import com.cloud.server.ManagementServer;
import com.cloud.storage.StoragePoolVO;
import com.cloud.storage.StorageStats;
import com.google.gson.Gson;
public class PreparePrimaryStorageMaintenanceExecutor extends BaseAsyncJobExecutor {
public static final Logger s_logger = Logger.getLogger(PreparePrimaryStorageMaintenanceExecutor.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);
Long userId = job.getUserId();
/*
try {
boolean result = managementServer.preparePrimaryStorageForMaintenance(param.longValue(), userId.longValue());
if(result)
{
StoragePoolVO primaryStorage = managementServer.findPoolById(param);
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0,
composeResultObject(primaryStorage,managementServer));
}
else
{
StoragePoolVO primaryStorage = managementServer.findPoolById(param);
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
composeResultObject(primaryStorage,managementServer));
}
} catch(Exception e) {
s_logger.warn("Unable to prepare maintenance: " + e.getMessage(), e);
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
e.getMessage());
}
*/
return true;
}
private PrimaryStorageResultObject composeResultObject(StoragePoolVO storagePoolVO, ManagementServer managementServer)
{
PrimaryStorageResultObject primaryStorageRO = new PrimaryStorageResultObject();
primaryStorageRO.setId(storagePoolVO.getId());
primaryStorageRO.setName(storagePoolVO.getName());
primaryStorageRO.setType(storagePoolVO.getPoolType().toString());
primaryStorageRO.setState(storagePoolVO.getStatus().toString());
primaryStorageRO.setIpAddress(storagePoolVO.getHostAddress());
primaryStorageRO.setZoneId(storagePoolVO.getDataCenterId());
// primaryStorageRO.setZoneName(managementServer.getDataCenterBy(storagePoolVO.getDataCenterId()).getName());
if (storagePoolVO.getPodId() != null && managementServer.findHostPodById(storagePoolVO.getPodId()) != null) {
primaryStorageRO.setPodId(storagePoolVO.getPodId());
primaryStorageRO.setPodName((managementServer.findHostPodById(storagePoolVO.getPodId())).getName());
}
if (storagePoolVO.getCreated() != null) {
primaryStorageRO.setCreated(storagePoolVO.getCreated());
}
primaryStorageRO.setDiskSizeTotal(storagePoolVO.getCapacityBytes());
// StorageStats stats = managementServer.getStoragePoolStatistics(storagePoolVO.getId());
long capacity = storagePoolVO.getCapacityBytes();
long available = storagePoolVO.getAvailableBytes() ;
long used = capacity - available;
// if (stats != null) {
// used = stats.getByteUsed();
// available = capacity - used;
// }
primaryStorageRO.setDiskSizeAllocated(used);
if (storagePoolVO.getClusterId() != null)
{
// ClusterVO cluster = managementServer.findClusterById(storagePoolVO.getClusterId());
primaryStorageRO.setClusterId(storagePoolVO.getClusterId());
// primaryStorageRO.setClusterName(cluster.getName());
}
// primaryStorageRO.setTags(managementServer.getStoragePoolTags(storagePoolVO.getId()));
return primaryStorageRO;
}
}

View File

@ -1,185 +0,0 @@
package com.cloud.async.executor;
import java.util.Date;
import com.cloud.serializer.Param;
public class PrimaryStorageResultObject
{
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 getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getIpAddress() {
return ipAddress;
}
public void setIpAddress(String ipAddress) {
this.ipAddress = ipAddress;
}
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 getPodId() {
return podId;
}
public void setPodId(Long podId) {
this.podId = podId;
}
public String getPodName() {
return podName;
}
public void setPodName(String podName) {
this.podName = podName;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public Long getDiskSizeTotal() {
return diskSizeTotal;
}
public void setDiskSizeTotal(Long diskSizeTotal) {
this.diskSizeTotal = diskSizeTotal;
}
public Long getDiskSizeAllocated() {
return diskSizeAllocated;
}
public void setDiskSizeAllocated(Long diskSizeAllocated) {
this.diskSizeAllocated = diskSizeAllocated;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public Long getClusterId() {
return clusterId;
}
public void setClusterId(Long clusterId) {
this.clusterId = clusterId;
}
public String getClusterName() {
return clusterName;
}
public void setClusterName(String clusterName) {
this.clusterName = clusterName;
}
public String getTags() {
return tags;
}
public void setTags(String tags) {
this.tags = tags;
}
@Param(name="id")
private long id;
@Param(name="name")
private String name;
@Param(name="type")
private String type;
@Param(name="state")
private String state;
@Param(name="ipaddress")
private String ipAddress;
@Param(name="zoneid")
private long zoneId;
@Param(name="zonename")
private String zoneName;
@Param(name="podid")
private Long podId;
@Param(name="podname")
private String podName;
@Param(name="path")
private String path;
@Param(name="disksizetotal")
private Long diskSizeTotal;
@Param(name="disksizeallocated")
private Long diskSizeAllocated;
@Param(name="created")
private Date created;
@Param(name="clusterid")
private Long clusterId;
@Param(name="clustername")
private String clusterName;
@Param(name="tags")
private String tags;
}

View File

@ -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;
public class RecurringSnapshotParam extends VMOperationParam {
private int hourlyMax;
private int dailyMax;
private int weeklyMax;
private int monthlyMax;
public RecurringSnapshotParam() {
}
public RecurringSnapshotParam(long userId, long vmId, int hourlyMax, int dailyMax, int weeklyMax, int monthlyMax) {
setUserId(userId);
setVmId(vmId);
this.hourlyMax = hourlyMax;
this.dailyMax = dailyMax;
this.weeklyMax = weeklyMax;
this.monthlyMax = monthlyMax;
}
public int getHourlyMax() {
return hourlyMax;
}
public void setHourlyMax(int hourlyMax) {
this.hourlyMax = hourlyMax;
}
public int getDailyMax() {
return dailyMax;
}
public void setDailyMax(int dailyMax) {
this.dailyMax = dailyMax;
}
public int getWeeklyMax() {
return weeklyMax;
}
public void setWeeklyMax(int weeklyMax) {
this.weeklyMax = weeklyMax;
}
public int getMonthlyMax() {
return monthlyMax;
}
public void setMonthlyMax(int monthlyMax) {
this.monthlyMax = monthlyMax;
}
}

View File

@ -1,68 +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.google.gson.Gson;
public class RemoveFromLoadBalancerExecutor extends BaseAsyncJobExecutor {
public static final Logger s_logger = Logger.getLogger(RemoveFromLoadBalancerExecutor.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.removeFromLoadBalancer(param.getUserId().longValue(), param.getLoadBalancerId().longValue(), param.getInstanceIdList());
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(InvalidParameterValueException ex) {
if (s_logger.isInfoEnabled()) {
s_logger.info("Unable to remove from load balancer : " + ex.getMessage());
}
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.PARAM_ERROR, ex.getMessage());
} catch(Exception e) {
s_logger.warn("Unable to remove from load balancer : " + e.getMessage(), e);
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR, e.getMessage());
}
return true;
}
*/
return true;
}
}

View File

@ -1,68 +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 RemoveSecurityGroupParam {
private Long userId;
private Long securityGroupId;
private String publicIp;
private Long vmId;
public RemoveSecurityGroupParam() {
}
public RemoveSecurityGroupParam(Long userId, Long securityGroupId, String publicIp, Long vmId) {
this.userId = userId;
this.securityGroupId = securityGroupId;
this.publicIp = publicIp;
this.vmId = vmId;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Long getSecurityGroupId() {
return securityGroupId;
}
public void setSecurityGroupId(Long securityGroupId) {
this.securityGroupId = securityGroupId;
}
public String getPublicIp() {
return publicIp;
}
public void setPublicIp(String publicIp) {
this.publicIp = publicIp;
}
public Long getVmId() {
return vmId;
}
public void setVmId(Long vmId) {
this.vmId = vmId;
}
}

View File

@ -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.serializer.GsonHelper;
import com.cloud.server.ManagementServer;
import com.cloud.vm.UserVmVO;
import com.google.gson.Gson;
public class ResetVMPasswordExecutor extends BaseAsyncJobExecutor {
public static final Logger s_logger = Logger.getLogger(ResetVMPasswordExecutor.class.getName());
public boolean execute() {
AsyncJobManager asyncMgr = getAsyncJobMgr();
Gson gson = GsonHelper.getBuilder().create();
AsyncJobVO job = getJob();
/*
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();
ResetVMPasswordParam param = gson.fromJson(job.getCmdInfo(), ResetVMPasswordParam.class);
asyncMgr.updateAsyncJobAttachment(job.getId(), "vm_instance", param.getVmId());
try {
boolean success = managementServer.resetVMPassword(param.getUserId(), param.getVmId(), param.getPassword());
if(success) {
UserVmVO userVm = managementServer.findUserVMInstanceById(param.getVmId());
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0,
VMExecutorHelper.composeResultObject(managementServer, userVm, param.getPassword()));
}
else
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
"Operation failed");
} catch(Exception e) {
s_logger.warn("Unable to reset password for VM " + param.getVmId() + ": " + e.getMessage(), e);
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
e.getMessage());
}
}
*/
return true;
}
}

View File

@ -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 ResetVMPasswordParam {
private long userId;
private long vmId;
private String password;
public ResetVMPasswordParam() {
}
public ResetVMPasswordParam(long userId, long vmId, String password) {
this.userId = userId;
this.vmId = vmId;
this.password = password;
}
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 String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}

View File

@ -1,65 +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.network.router.VirtualRouter;
import com.cloud.server.ManagementServer;
import com.cloud.user.Account;
public class RouterExecutorHelper {
public static RouterOperationResultObject composeResultObject(ManagementServer managementServer, VirtualRouter router) {
RouterOperationResultObject resultObject = new RouterOperationResultObject();
resultObject.setId(router.getId());
resultObject.setZoneId(router.getDataCenterId());
resultObject.setZoneName(managementServer.findDataCenterById(router.getDataCenterId()).getName());
resultObject.setDns1(router.getDns1());
resultObject.setDns2(router.getDns2());
resultObject.setNetworkDomain(router.getDomain());
resultObject.setGateway(router.getGateway());
resultObject.setName(router.getName());
resultObject.setPodId(router.getPodId());
resultObject.setPrivateIp(router.getPrivateIpAddress());
resultObject.setPrivateMacAddress(router.getPrivateMacAddress());
resultObject.setPrivateNetMask(router.getPrivateNetmask());
resultObject.setPublicIp(router.getPublicIpAddress());
resultObject.setPublicMacAddress(router.getPublicMacAddress());
resultObject.setPublicNetMask(router.getPrivateNetmask());
resultObject.setGuestIp(router.getGuestIpAddress());
resultObject.setGuestMacAddress(router.getGuestMacAddress());
resultObject.setTemplateId(router.getTemplateId());
resultObject.setCreated(router.getCreated());
resultObject.setGuestNetmask(router.getGuestNetmask());
if (router.getHostId() != null) {
resultObject.setHostname(managementServer.getHostBy(router.getHostId()).getName());
resultObject.setHostId(router.getHostId());
}
Account acct = managementServer.findAccountById(Long.valueOf(router.getAccountId()));
if (acct != null) {
resultObject.setAccount(acct.getAccountName());
resultObject.setDomainId(acct.getDomainId());
// resultObject.setDomain(managementServer.findDomainIdById(acct.getDomainId()).getName());
}
if (router.getState() != null)
resultObject.setState(router.getState().toString());
return resultObject;
}
}

View File

@ -1,311 +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 RouterOperationResultObject {
@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="guestipaddress")
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;
@Param(name="guestnetmask")
private String guestNetmask;
public String getGuestNetmask(){
return this.guestNetmask;
}
public void setGuestNetmask(String guestNetmask){
this.guestNetmask = guestNetmask;
}
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;
}
}

View File

@ -1,113 +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.List;
public class SnapshotOperationParam {
public enum SnapshotOp {Create, Delete, CreateVolume};
private long accountId;
private long userId;
private long snapshotId = 0;
private long policyId = 0;
private long volumeId;
private String name = null;
private long eventId;
public SnapshotOperationParam() {
}
// Used for delete snapshot
public SnapshotOperationParam(long userId, long accountId, long volumeId, long snapshotId, long policyId) {
setUserId(userId);
setAccountId(accountId);
setVolumeId(volumeId);
this.snapshotId = snapshotId;
this.policyId = policyId;
}
// Used to create a snapshot
public SnapshotOperationParam(long userId, long accountId, long volumeId, long policyId) {
setUserId(userId);
setAccountId(accountId);
setVolumeId(volumeId);
this.policyId = policyId;
}
// Used for CreateVolumeFromSnapshot
public SnapshotOperationParam(long userId, long accountId, long volumeId, long snapshotId, String volumeName) {
setUserId(userId);
setAccountId(accountId);
setVolumeId(volumeId);
this.snapshotId = snapshotId;
setName(volumeName);
}
public long getUserId() {
return userId;
}
public long getAccountId() {
return accountId;
}
public long getVolumeId() {
return volumeId;
}
public String getName() {
return name;
}
public long getSnapshotId() {
return snapshotId;
}
public void setSnapshotId(long snapshotId) {
this.snapshotId = snapshotId;
}
public long getPolicyId() {
return policyId;
}
private void setUserId(long userId) {
this.userId = userId;
}
private void setAccountId(long accountId) {
this.accountId = accountId;
}
private void setVolumeId(long volumeId) {
this.volumeId = volumeId;
}
private void setName(String name) {
this.name = name;
}
public void setEventId(long eventId) {
this.eventId = eventId;
}
public long getEventId() {
return eventId;
}
}

View File

@ -1,117 +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.api.BaseCmd;
import com.cloud.server.ManagementServer;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.storage.VMTemplateVO;
import com.cloud.user.Account;
import com.cloud.vm.UserVmVO;
public class VMExecutorHelper {
public static VMOperationResultObject composeResultObject(ManagementServer managementServer, UserVmVO vm, String vmPassword) {
VMOperationResultObject resultObject = new VMOperationResultObject();
resultObject.setId(vm.getId());
resultObject.setName(vm.getName());
resultObject.setCreated(vm.getCreated());
resultObject.setZoneId(vm.getDataCenterId());
resultObject.setZoneName(managementServer.findDataCenterById(vm.getDataCenterId()).getName());
resultObject.setIpAddress(vm.getPrivateIpAddress());
resultObject.setServiceOfferingId(vm.getServiceOfferingId());
resultObject.setHaEnabled(vm.isHaEnabled());
if (vm.getDisplayName() == null || vm.getDisplayName().length() == 0) {
resultObject.setDisplayName(vm.getName());
}
else {
resultObject.setDisplayName(vm.getDisplayName());
}
if(vm.getState() != null)
resultObject.setState(vm.getState().toString());
// InstanceGroupVO group = managementServer.getGroupForVm(vm.getId());
// if (group != null) {
// resultObject.setGroupId(group.getId());
// resultObject.setGroup(group.getName());
// }
VMTemplateVO template = managementServer.findTemplateById(vm.getTemplateId());
Account acct = managementServer.findAccountById(Long.valueOf(vm.getAccountId()));
if (acct != null) {
resultObject.setAccount(acct.getAccountName());
resultObject.setDomainId(acct.getDomainId());
// resultObject.setDomain(managementServer.findDomainIdById(acct.getDomainId()).getName());
}
if ( BaseCmd.isAdmin(acct.getType()) && (vm.getHostId() != null)) {
resultObject.setHostname(managementServer.getHostBy(vm.getHostId()).getName());
resultObject.setHostid(vm.getHostId());
}
String templateName = "ISO Boot";
boolean templatePasswordEnabled = false;
String templateDisplayText = "ISO Boot";
if (template != null) {
templateName = template.getName();
templatePasswordEnabled = template.getEnablePassword();
templateDisplayText = template.getDisplayText();
if (templateDisplayText == null) {
templateDisplayText = templateName;
}
}
resultObject.setTemplateId(vm.getTemplateId());
resultObject.setTemplateName(templateName);
resultObject.setTemplateDisplayText(templateDisplayText);
resultObject.setPasswordEnabled(templatePasswordEnabled);
if(templatePasswordEnabled)
resultObject.setPassword(vmPassword);
// else
// resultObject.setPassword("");
String isoName = null;
if (vm.getIsoId() != null) {
VMTemplateVO iso = managementServer.findTemplateById(vm.getIsoId().longValue());
if (iso != null) {
isoName = iso.getName();
}
}
resultObject.setIsoId(vm.getIsoId());
resultObject.setIsoName(isoName);
ServiceOfferingVO offering = managementServer.findServiceOfferingById(vm.getServiceOfferingId());
resultObject.setServiceOfferingId(vm.getServiceOfferingId());
resultObject.setServiceOfferingName(offering.getName());
resultObject.setCpuNumber(String.valueOf(offering.getCpu()));
resultObject.setCpuSpeed(String.valueOf(offering.getSpeed()));
resultObject.setMemory(String.valueOf(offering.getRamSize()));
//Network groups
// resultObject.setNetworkGroupList(managementServer.getNetworkGroupsNamesForVm(vm.getId()));
return resultObject;
}
}

View File

@ -1,28 +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.agent.api.Answer;
import com.cloud.async.BaseAsyncJobExecutor;
public abstract class VMOperationExecutor extends BaseAsyncJobExecutor {
public abstract void processAnswer(VMOperationListener listener, long agentId, long seq, Answer answer);
public abstract void processDisconnect(VMOperationListener listener, long agentId);
public abstract void processTimeout(VMOperationListener listener, long agentId, long seq);
}

View File

@ -1,126 +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.vm.UserVmVO;
public class VMOperationListener implements Listener {
private static final Logger s_logger = Logger.getLogger(VMOperationListener.class);
private final VMOperationExecutor _executor;
private final VMOperationParam _param;
private final UserVmVO _vm;
private int _cookie;
public VMOperationListener(VMOperationExecutor executor, VMOperationParam param,
UserVmVO vm, int cookie) {
if(s_logger.isDebugEnabled())
s_logger.debug("VM operation listener is created");
_executor = executor;
_param = param;
_vm = vm;
_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) {
// return true;
}
@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 VMOperationExecutor getExecutor() {
return _executor;
}
public VMOperationParam getParam() {
return _param;
}
public UserVmVO getVm() {
return _vm;
}
}

View File

@ -1,101 +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 VMOperationParam {
public static enum VmOp { Noop, Start, Stop, Reboot, Destroy}; //WARN: Noop may not actually be noop
private long userId;
private long accountId;
private long vmId;
private String isoPath;
private VmOp operation;
protected long eventId;
protected long childEventId;// This would be used for child events we log during the parent event. In future it can as well be a Map.
public VMOperationParam() {
}
// This constructor is kept for backward compatibility. REMOVE when no longer needed.
public VMOperationParam(long userId, long vmId, String isoPath, long eventId) {
this.userId = userId;
this.vmId = vmId;
this.isoPath = isoPath;
this.operation = VmOp.Noop;
this.eventId = eventId;
}
public VMOperationParam(long userId, long accountId, long vmId, String isoPath, long eventId) {
this.userId = userId;
this.accountId = accountId;
this.vmId = vmId;
this.isoPath = isoPath;
this.operation = VmOp.Noop;
this.eventId = eventId;
}
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 getVmId() {
return vmId;
}
public void setVmId(long vmId) {
this.vmId = vmId;
}
public String getIsoPath() {
return isoPath;
}
public void setIsoPath(String isoPath) {
this.isoPath = isoPath;
}
public void setOperation(VmOp operation) {
this.operation = operation;
}
public VmOp getOperation() {
return operation;
}
public long getEventId() {
return eventId;
}
public long getChildEventId() {
return childEventId;
}
public void setChildEventId(long childEventId) {
this.childEventId = childEventId;
}
}

View File

@ -1,400 +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 VMOperationResultObject {
@Param(name="id")
private long id;
@Param(name="name")
private String name;
@Param(name="created")
private Date created;
@Param(name="zoneid")
private Long zoneId;
@Param(name="zonename")
private String zoneName;
@Param(name="ipaddress")
private String ipAddress;
@Param(name="serviceofferingid")
private Long serviceOfferingId;
@Param(name="haenable")
private boolean haEnabled;
@Param(name="state")
private String state;
@Param(name="templateid")
private Long templateId;
@Param(name="password")
private String password;
@Param(name="templatename")
private String templateName;
@Param(name="templatedisplaytext")
private String templateDisplayText;
@Param(name="isoid")
private Long isoId;
@Param(name="isoname")
private String isoName;
@Param(name="passwordenabled")
private boolean passwordEnabled;
@Param(name="serviceofferingname")
private String serviceOfferingName;
@Param(name="diskofferingid")
private Long diskOfferingId;
@Param(name="datadiskofferingname")
private String diskOfferingName;
@Param(name="cpunumber")
private String cpuNumber;
@Param(name="cpuspeed")
private String cpuSpeed;
@Param(name="memory")
private String memory;
@Param(name="storage")
private String storage;
@Param(name="displayname")
private String displayName;
@Param(name="group")
private String group;
@Param(name="groupid")
private Long groupId;
@Param(name="domainid")
private Long domainId;
@Param(name="domain")
private String domain;
@Param(name="account")
private String account;
@Param(name="hostname")
private String hostname;
@Param(name="hostid")
private Long hostid;
@Param(name="securitygrouplist")
private String securityGroupList;
@Param(name="rootdeviceid")
private Long rootDeviceId;
@Param(name="rootdevicetype")
private String rootDeviceType;
public Long getRootDeviceId(){
return this.rootDeviceId;
}
public void setRootDeviceId(Long rootDeviceId){
this.rootDeviceId = rootDeviceId;
}
public String getRootDeviceType(){
return this.rootDeviceType;
}
public void setRootDeviceType(String deviceType){
this.rootDeviceType = deviceType;
}
public String getSecurityGroupList(){
return this.securityGroupList;
}
public void setSecurityGroupList(String nGroups){
this.securityGroupList = nGroups;
}
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 Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
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 getIpAddress() {
return ipAddress;
}
public void setIpAddress(String ipAddress) {
this.ipAddress = ipAddress;
}
public Long getServiceOfferingId() {
return serviceOfferingId;
}
public void setServiceOfferingId(Long serviceOfferingId) {
this.serviceOfferingId = serviceOfferingId;
}
public boolean isHaEnabled() {
return haEnabled;
}
public void setHaEnabled(boolean haEnabled) {
this.haEnabled = haEnabled;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public Long getTemplateId() {
return templateId;
}
public void setTemplateId(Long templateId) {
this.templateId = templateId;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getTemplateName() {
return templateName;
}
public void setTemplateName(String templateName) {
this.templateName = templateName;
}
public String getTemplateDisplayText() {
return templateDisplayText;
}
public void setTemplateDisplayText(String templateDisplayText) {
this.templateDisplayText = templateDisplayText;
}
public Long getIsoId() {
return isoId;
}
public void setIsoId(Long isoId) {
this.isoId = isoId;
}
public String getIsoName() {
return isoName;
}
public void setIsoName(String isoName) {
this.isoName = isoName;
}
public boolean isPasswordEnabled() {
return passwordEnabled;
}
public void setPasswordEnabled(boolean passwordEnabled) {
this.passwordEnabled = passwordEnabled;
}
public String getServiceOfferingName() {
return serviceOfferingName;
}
public void setServiceOfferingName(String serviceOfferingName) {
this.serviceOfferingName = serviceOfferingName;
}
public Long getDiskOfferingId() {
return diskOfferingId;
}
public void setDiskOfferingId(Long diskOfferingId) {
this.diskOfferingId = diskOfferingId;
}
public String getDiskOfferingName() {
return diskOfferingName;
}
public void setDiskOfferingName(String diskOfferingName) {
this.diskOfferingName = diskOfferingName;
}
public String getCpuNumber() {
return cpuNumber;
}
public void setCpuNumber(String cpuNumber) {
this.cpuNumber = cpuNumber;
}
public String getCpuSpeed() {
return cpuSpeed;
}
public void setCpuSpeed(String cpuSpeed) {
this.cpuSpeed = cpuSpeed;
}
public String getMemory() {
return memory;
}
public void setMemory(String memory) {
this.memory = memory;
}
public String getStorage() {
return storage;
}
public void setStorage(String stroage) {
this.storage = stroage;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public String getGroup() {
return group;
}
public void setGroup(String group) {
this.group = group;
}
public Long getGroupId() {
return groupId;
}
public void setGroupId(Long groupId) {
this.groupId = groupId;
}
public Long getDomainId() {
return domainId;
}
public void setDomainId(Long domainId) {
this.domainId = domainId;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getHostname() {
return hostname;
}
public void setHostname(String hostname) {
this.hostname = hostname;
}
public Long getHostid() {
return hostid;
}
public void setHostid(Long hostid) {
this.hostid = hostid;
}
public String getDomain() {
return domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
}

View File

@ -1,286 +0,0 @@
package com.cloud.async.executor;
import java.util.Date;
import com.cloud.serializer.Param;
public class VmResultObject
{
@Param(name="id")
private Long id;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public String getIpAddress() {
return ipAddress;
}
public void setIpAddress(String ipAddress) {
this.ipAddress = ipAddress;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public long getDomainId() {
return domainId;
}
public void setDomainId(long domainId) {
this.domainId = domainId;
}
public String getDomain() {
return domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
public boolean isHaEnable() {
return haEnable;
}
public void setHaEnable(boolean haEnable) {
this.haEnable = haEnable;
}
public long getZoneId() {
return zoneId;
}
public void setZoneId(long zoneId) {
this.zoneId = zoneId;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public String getZoneName() {
return zoneName;
}
public void setZoneName(String zoneName) {
this.zoneName = zoneName;
}
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 long getTemplateId() {
return templateId;
}
public void setTemplateId(long templateId) {
this.templateId = templateId;
}
public String getTemplateName() {
return templateName;
}
public void setTemplateName(String templateName) {
this.templateName = templateName;
}
public String getTemplateDisplayText() {
return templateDisplayText;
}
public void setTemplateDisplayText(String templateDisplayText) {
this.templateDisplayText = templateDisplayText;
}
public boolean isPasswordEnabled() {
return passwordEnabled;
}
public void setPasswordEnabled(boolean passwordEnabled) {
this.passwordEnabled = passwordEnabled;
}
public long getServiceOfferingId() {
return serviceOfferingId;
}
public void setServiceOfferingId(long serviceOfferingId) {
this.serviceOfferingId = serviceOfferingId;
}
public String getServiceOfferingName() {
return serviceOfferingName;
}
public void setServiceOfferingName(String serviceOfferingName) {
this.serviceOfferingName = serviceOfferingName;
}
public long getCpuSpeed() {
return cpuSpeed;
}
public void setCpuSpeed(long cpuSpeed) {
this.cpuSpeed = cpuSpeed;
}
public long getMemory() {
return memory;
}
public void setMemory(long memory) {
this.memory = memory;
}
public long getCpuUsed() {
return cpuUsed;
}
public void setCpuUsed(long cpuUsed) {
this.cpuUsed = cpuUsed;
}
public long getNetworkKbsRead() {
return networkKbsRead;
}
public void setNetworkKbsRead(long networkKbsRead) {
this.networkKbsRead = networkKbsRead;
}
public long getNetworkKbsWrite() {
return networkKbsWrite;
}
public void setNetworkKbsWrite(long networkKbsWrite) {
this.networkKbsWrite = networkKbsWrite;
}
public Long getId()
{
return id;
}
public void setId(Long id){
this.id = id;
}
@Param(name="name")
private String name;
@Param(name="created")
private Date created;
@Param(name="ipaddress")
private String ipAddress;
@Param(name="state")
private String state;
@Param(name="account")
private String account;
@Param(name="domainid")
private long domainId;
@Param(name="domain")
private String domain;
@Param(name="haenable")
private boolean haEnable;
@Param(name="zoneid")
private long zoneId;
@Param(name="displayname")
private String displayName;
@Param(name="zonename")
private String zoneName;
@Param(name="hostid")
private Long hostId;
@Param(name="hostname")
private String hostName;
@Param(name="templateid")
private long templateId;
@Param(name="templatename")
private String templateName;
@Param(name="templatedisplaytext")
private String templateDisplayText;
@Param(name="passwordenabled")
private boolean passwordEnabled;
@Param(name="serviceofferingid")
private long serviceOfferingId;
@Param(name="serviceofferingname")
private String serviceOfferingName;
@Param(name="cpunumber")
private long cpuSpeed;
@Param(name="memory")
private long memory;
@Param(name="cpuused")
private long cpuUsed;
@Param(name="networkkbsread")
private long networkKbsRead;
@Param(name="networkkbswrite")
private long networkKbsWrite;
}