mirror of https://github.com/apache/cloudstack.git
1) add destroySystemVm command to allow destroying of system VMs
2) add consoleproxy.launch.max to allow specifying a configured max number of console proxy VM that can be launched within a zone(if not specified, default is 10), this is to prevent possible DoS attacks or uncontrolled usage of system resources 3) Remove some unused code.
This commit is contained in:
parent
46e1f6279a
commit
34178bec61
|
|
@ -0,0 +1,81 @@
|
|||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.SystemVmResponse;
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
@Implementation(responseObject=SystemVmResponse.class, description="Destroyes a system virtual machine.")
|
||||
public class DestroySystemVmCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(DestroySystemVmCmd.class.getName());
|
||||
|
||||
private static final String s_name = "destroysystemvmresponse";
|
||||
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="The ID of the system virtual machine")
|
||||
private Long id;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
public static String getResultObjectName() {
|
||||
return "systemvm";
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
Account account = UserContext.current().getCaller();
|
||||
if (account != null) {
|
||||
return account.getId();
|
||||
}
|
||||
|
||||
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_SSVM_START;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "destroying system vm: " + getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncJob.Type getInstanceType() {
|
||||
return AsyncJob.Type.SystemVm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getInstanceId() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
VirtualMachine instance = _mgr.destroySystemVM(this);
|
||||
if (instance != null) {
|
||||
SystemVmResponse response = _responseGenerator.createSystemVmResponse(instance);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Fail to destroy system vm");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -30,6 +30,7 @@ import com.cloud.api.commands.CreateSSHKeyPairCmd;
|
|||
import com.cloud.api.commands.DeleteDomainCmd;
|
||||
import com.cloud.api.commands.DeletePreallocatedLunCmd;
|
||||
import com.cloud.api.commands.DeleteSSHKeyPairCmd;
|
||||
import com.cloud.api.commands.DestroySystemVmCmd;
|
||||
import com.cloud.api.commands.ExtractVolumeCmd;
|
||||
import com.cloud.api.commands.GetCloudIdentifierCmd;
|
||||
import com.cloud.api.commands.GetVMPasswordCmd;
|
||||
|
|
@ -61,7 +62,6 @@ import com.cloud.api.commands.ListTemplateOrIsoPermissionsCmd;
|
|||
import com.cloud.api.commands.ListTemplatesCmd;
|
||||
import com.cloud.api.commands.ListUsersCmd;
|
||||
import com.cloud.api.commands.ListVMGroupsCmd;
|
||||
import com.cloud.api.commands.ListVMsCmd;
|
||||
import com.cloud.api.commands.ListVlanIpRangesCmd;
|
||||
import com.cloud.api.commands.ListVolumesCmd;
|
||||
import com.cloud.api.commands.ListZonesByCmd;
|
||||
|
|
@ -103,7 +103,6 @@ import com.cloud.template.VirtualMachineTemplate;
|
|||
import com.cloud.user.Account;
|
||||
import com.cloud.user.SSHKeyPair;
|
||||
import com.cloud.user.UserAccount;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.vm.InstanceGroup;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
|
@ -239,6 +238,8 @@ public interface ManagementService {
|
|||
VirtualMachine stopSystemVM(StopSystemVmCmd cmd);
|
||||
VirtualMachine startSystemVM(StartSystemVMCmd cmd);
|
||||
VirtualMachine rebootSystemVM(RebootSystemVmCmd cmd);
|
||||
VirtualMachine destroySystemVM(DestroySystemVmCmd cmd);
|
||||
|
||||
/**
|
||||
* Search for domains owned by the given domainId/domainName (those parameters are wrapped
|
||||
* in a command object.
|
||||
|
|
|
|||
|
|
@ -137,6 +137,7 @@ listRouters=com.cloud.api.commands.ListRoutersCmd;7
|
|||
startSystemVm=com.cloud.api.commands.StartSystemVMCmd;1
|
||||
rebootSystemVm=com.cloud.api.commands.RebootSystemVmCmd;1
|
||||
stopSystemVm=com.cloud.api.commands.StopSystemVmCmd;1
|
||||
destroySystemVm=com.cloud.api.commands.DestroySystemVmCmd;1
|
||||
listSystemVms=com.cloud.api.commands.ListSystemVMsCmd;1
|
||||
|
||||
#### configuration commands
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@ public enum Config {
|
|||
ConsoleProxySessionMax("Console Proxy", AgentManager.class, Integer.class, "consoleproxy.session.max", "50", "The max number of viewer sessions console proxy is configured to serve for", null),
|
||||
ConsoleProxySessionTimeout("Console Proxy", AgentManager.class, Integer.class, "consoleproxy.session.timeout", "300000", "Timeout(in milliseconds) that console proxy tries to maintain a viewer session before it times out the session for no activity", null),
|
||||
ConsoleProxyDisableRpFilter("Console Proxy", AgentManager.class, Integer.class, "consoleproxy.disable.rpfilter", "true", "disable rp_filter on console proxy VM public interface", null),
|
||||
ConsoleProxyLaunchMax("Console Proxy", AgentManager.class, Integer.class, "consoleproxy.launch.max", "10", "maximum number of console proxy instances per zone can be launched", null),
|
||||
|
||||
// Snapshots
|
||||
SnapshotHourlyMax("Snapshots", SnapshotManager.class, Integer.class, "snapshot.max.hourly", "8", "Maximum hourly snapshots for a volume", null),
|
||||
|
|
|
|||
|
|
@ -65,14 +65,13 @@ import com.cloud.cluster.ClusterManager;
|
|||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.dc.dao.HostPodDao;
|
||||
import com.cloud.deploy.DataCenterDeployment;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.event.dao.EventDao;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
|
|
@ -80,8 +79,8 @@ import com.cloud.exception.OperationTimedoutException;
|
|||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.ha.HighAvailabilityManager;
|
||||
import com.cloud.host.Host.Type;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Host.Type;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.info.ConsoleProxyConnectionInfo;
|
||||
import com.cloud.info.ConsoleProxyInfo;
|
||||
|
|
@ -104,16 +103,14 @@ import com.cloud.service.dao.ServiceOfferingDao;
|
|||
import com.cloud.servlet.ConsoleProxyServlet;
|
||||
import com.cloud.storage.StorageManager;
|
||||
import com.cloud.storage.VMTemplateHostVO;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||
import com.cloud.storage.dao.GuestOSDao;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.storage.dao.VMTemplateHostDao;
|
||||
import com.cloud.storage.dao.VolumeDao;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.utils.DateUtil;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.Pair;
|
||||
|
|
@ -132,11 +129,11 @@ import com.cloud.vm.NicVO;
|
|||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.VirtualMachineGuru;
|
||||
import com.cloud.vm.VirtualMachineManager;
|
||||
import com.cloud.vm.VirtualMachineName;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.dao.ConsoleProxyDao;
|
||||
import com.cloud.vm.dao.NicDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
|
@ -145,41 +142,30 @@ import com.google.gson.GsonBuilder;
|
|||
|
||||
//
|
||||
// Possible console proxy state transition cases
|
||||
// Creating -> Destroyed
|
||||
// Creating -> Stopped --> Starting -> Running
|
||||
// Stopped --> Starting -> Running
|
||||
// HA -> Stopped -> Starting -> Running
|
||||
// Migrating -> Running (if previous state is Running before it enters into Migrating state
|
||||
// Migrating -> Stopped (if previous state is not Running before it enters into Migrating state)
|
||||
// Running -> HA (if agent lost connection)
|
||||
// Stopped -> Destroyed
|
||||
//
|
||||
// Creating state indicates of record creating and IP address allocation are ready, it is a transient
|
||||
// state which will soon be switching towards Running if everything goes well.
|
||||
// Stopped state indicates the readiness of being able to start (has storage and IP resources allocated)
|
||||
// Starting state can only be entered from Stopped states
|
||||
//
|
||||
// Starting, HA, Migrating, Creating and Running state are all counted as "Open" for available capacity calculation
|
||||
// Starting, HA, Migrating, Running state are all counted as "Open" for available capacity calculation
|
||||
// because sooner or later, it will be driven into Running state
|
||||
//
|
||||
@Local(value = { ConsoleProxyManager.class, ConsoleProxyService.class })
|
||||
public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProxyService, Manager, AgentHook, VirtualMachineGuru<ConsoleProxyVO> {
|
||||
private static final Logger s_logger = Logger.getLogger(ConsoleProxyManagerImpl.class);
|
||||
|
||||
private static final int DEFAULT_CAPACITY_SCAN_INTERVAL = 30000; // 30
|
||||
// seconds
|
||||
private static final int EXECUTOR_SHUTDOWN_TIMEOUT = 1000; // 1 second
|
||||
private static final int DEFAULT_CAPACITY_SCAN_INTERVAL = 30000; // 30 seconds
|
||||
private static final int EXECUTOR_SHUTDOWN_TIMEOUT = 1000; // 1 second
|
||||
|
||||
private static final int ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION = 3; // 3
|
||||
// seconds
|
||||
private static final int ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC = 180; // 3
|
||||
// minutes
|
||||
private static final int ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION = 3; // 3 seconds
|
||||
private static final int ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC = 180; // 3 minutes
|
||||
|
||||
private static final int API_WAIT_TIMEOUT = 5000; // 5 seconds (in
|
||||
// milliseconds)
|
||||
private static final int STARTUP_DELAY = 60000; // 60 seconds
|
||||
private static final int API_WAIT_TIMEOUT = 5000; // 5 seconds (in milliseconds)
|
||||
private static final int STARTUP_DELAY = 60000; // 60 seconds
|
||||
|
||||
private int _consoleProxyPort = ConsoleProxyManager.DEFAULT_PROXY_VNC_PORT;
|
||||
private int _consoleProxyUrlPort = ConsoleProxyManager.DEFAULT_PROXY_URL_PORT;
|
||||
|
||||
private String _mgmt_host;
|
||||
private int _mgmt_port = 8250;
|
||||
|
|
@ -187,37 +173,25 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
private String _name;
|
||||
private Adapters<ConsoleProxyAllocator> _consoleProxyAllocators;
|
||||
|
||||
@Inject
|
||||
private ConsoleProxyDao _consoleProxyDao;
|
||||
@Inject
|
||||
private DataCenterDao _dcDao;
|
||||
@Inject
|
||||
private VMTemplateDao _templateDao;
|
||||
@Inject
|
||||
private VolumeDao _volsDao;
|
||||
@Inject
|
||||
private HostPodDao _podDao;
|
||||
@Inject
|
||||
private HostDao _hostDao;
|
||||
@Inject
|
||||
private ConfigurationDao _configDao;
|
||||
@Inject
|
||||
private CertificateDao _certDao;
|
||||
@Inject
|
||||
private VMInstanceDao _instanceDao;
|
||||
@Inject
|
||||
private AccountDao _accountDao;
|
||||
@Inject private ConsoleProxyDao _consoleProxyDao;
|
||||
@Inject private DataCenterDao _dcDao;
|
||||
@Inject private VMTemplateDao _templateDao;
|
||||
@Inject private HostPodDao _podDao;
|
||||
@Inject private HostDao _hostDao;
|
||||
@Inject private ConfigurationDao _configDao;
|
||||
@Inject private CertificateDao _certDao;
|
||||
@Inject private VMInstanceDao _instanceDao;
|
||||
@Inject private VMTemplateHostDao _vmTemplateHostDao;
|
||||
@Inject private AgentManager _agentMgr;
|
||||
@Inject private StorageManager _storageMgr;
|
||||
@Inject NetworkManager _networkMgr;
|
||||
@Inject AccountManager _accountMgr;
|
||||
@Inject private EventDao _eventDao;
|
||||
@Inject GuestOSDao _guestOSDao = null;
|
||||
@Inject ServiceOfferingDao _offeringDao;
|
||||
@Inject NetworkOfferingDao _networkOfferingDao;
|
||||
@Inject NicDao _nicDao;
|
||||
@Inject NetworkDao _networkDao;
|
||||
|
||||
private IpAddrAllocator _IpAllocator;
|
||||
|
||||
private ConsoleProxyListener _listener;
|
||||
|
|
@ -229,11 +203,8 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
NetworkOfferingVO _managementNetworkOffering;
|
||||
NetworkOfferingVO _linkLocalNetworkOffering;
|
||||
|
||||
@Inject
|
||||
private AsyncJobManager _asyncMgr;
|
||||
|
||||
@Inject
|
||||
private VirtualMachineManager _itMgr;
|
||||
@Inject private AsyncJobManager _asyncMgr;
|
||||
@Inject private VirtualMachineManager _itMgr;
|
||||
|
||||
private final ScheduledExecutorService _capacityScanScheduler = Executors.newScheduledThreadPool(1, new NamedThreadFactory("CP-Scan"));
|
||||
private final ExecutorService _requestHandlerScheduler = Executors.newCachedThreadPool(new NamedThreadFactory("Request-handler"));
|
||||
|
|
@ -243,16 +214,12 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
private int _standbyCapacity = ConsoleProxyManager.DEFAULT_STANDBY_CAPACITY;
|
||||
|
||||
private int _proxyRamSize;
|
||||
private int _ssh_retry;
|
||||
private int _ssh_sleep;
|
||||
private boolean _use_lvm;
|
||||
private boolean _use_storage_vm;
|
||||
private boolean _disable_rp_filter = false;
|
||||
private String _domain;
|
||||
private String _instance;
|
||||
|
||||
// private String _privateNetmask;
|
||||
private int _proxyCmdPort = DEFAULT_PROXY_CMD_PORT;
|
||||
private int _proxySessionTimeoutValue = DEFAULT_PROXY_SESSION_TIMEOUT;
|
||||
private boolean _sslEnabled = false;
|
||||
|
||||
|
|
@ -352,7 +319,6 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
proxy.setPort(80);
|
||||
}
|
||||
|
||||
|
||||
return proxy;
|
||||
}
|
||||
}
|
||||
|
|
@ -573,6 +539,11 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Assign console proxy from a newly started instance for request from data center : " + dataCenterId);
|
||||
}
|
||||
|
||||
if(!allowToLaunchNew(dataCenterId)) {
|
||||
s_logger.warn("The number of launched console proxy on zone " + dataCenterId + " has reached to limit");
|
||||
return null;
|
||||
}
|
||||
|
||||
Map<String, Object> context = createProxyInstance(dataCenterId);
|
||||
|
||||
|
|
@ -895,6 +866,16 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean allowToLaunchNew(long dcId) {
|
||||
List<ConsoleProxyVO> l = _consoleProxyDao.getProxyListInStates(dcId, VirtualMachine.State.Starting,
|
||||
VirtualMachine.State.Running, VirtualMachine.State.Stopping, VirtualMachine.State.Stopped,
|
||||
VirtualMachine.State.Migrating, VirtualMachine.State.Shutdowned, VirtualMachine.State.Unknown);
|
||||
|
||||
String value = _configDao.getValue(Config.ConsoleProxyLaunchMax.key());
|
||||
int launchLimit = NumbersUtil.parseInt(value, 10);
|
||||
return l.size() < launchLimit;
|
||||
}
|
||||
|
||||
private Runnable getCapacityScanTask() {
|
||||
return new Runnable() {
|
||||
|
|
@ -1256,12 +1237,11 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
s_logger.debug("Successfully reboot console proxy " + proxy.getName());
|
||||
}
|
||||
|
||||
SubscriptionMgr.getInstance()
|
||||
.notifySubscribers(
|
||||
ConsoleProxyManager.ALERT_SUBJECT,
|
||||
this,
|
||||
new ConsoleProxyAlertEventArgs(ConsoleProxyAlertEventArgs.PROXY_REBOOTED, proxy.getDataCenterId(), proxy.getId(),
|
||||
proxy, null));
|
||||
SubscriptionMgr.getInstance().notifySubscribers(
|
||||
ConsoleProxyManager.ALERT_SUBJECT,
|
||||
this,
|
||||
new ConsoleProxyAlertEventArgs(ConsoleProxyAlertEventArgs.PROXY_REBOOTED, proxy.getDataCenterId(), proxy.getId(),
|
||||
proxy, null));
|
||||
|
||||
return true;
|
||||
} else {
|
||||
|
|
@ -1319,8 +1299,6 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
_proxyRamSize = NumbersUtil.parseInt(configs.get("consoleproxy.ram.size"), DEFAULT_PROXY_VM_RAMSIZE);
|
||||
|
||||
String value = configs.get("consoleproxy.cmd.port");
|
||||
_proxyCmdPort = NumbersUtil.parseInt(value, DEFAULT_PROXY_CMD_PORT);
|
||||
|
||||
value = configs.get("consoleproxy.sslEnabled");
|
||||
if (value != null && value.equalsIgnoreCase("true")) {
|
||||
_sslEnabled = true;
|
||||
|
|
@ -1337,11 +1315,6 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
if (value != null) {
|
||||
_consoleProxyPort = NumbersUtil.parseInt(value, ConsoleProxyManager.DEFAULT_PROXY_VNC_PORT);
|
||||
}
|
||||
|
||||
value = configs.get("consoleproxy.url.port");
|
||||
if (value != null) {
|
||||
_consoleProxyUrlPort = NumbersUtil.parseInt(value, ConsoleProxyManager.DEFAULT_PROXY_URL_PORT);
|
||||
}
|
||||
|
||||
value = configs.get(Config.ConsoleProxyDisableRpFilter.key());
|
||||
if(value != null && value.equalsIgnoreCase("true")) {
|
||||
|
|
@ -1373,12 +1346,6 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
_instance = "DEFAULT";
|
||||
}
|
||||
|
||||
value = (String) params.get("ssh.sleep");
|
||||
_ssh_sleep = NumbersUtil.parseInt(value, 5) * 1000;
|
||||
|
||||
value = (String) params.get("ssh.retry");
|
||||
_ssh_retry = NumbersUtil.parseInt(value, 3);
|
||||
|
||||
Map<String, String> agentMgrConfigs = configDao.getConfiguration("AgentManager", params);
|
||||
_mgmt_host = agentMgrConfigs.get("host");
|
||||
if (_mgmt_host == null) {
|
||||
|
|
@ -1581,7 +1548,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
return false;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
return false;//no cert entry in the db record
|
||||
}
|
||||
return false;//cert already applied in previous cycles
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ import com.cloud.api.commands.CreateSSHKeyPairCmd;
|
|||
import com.cloud.api.commands.DeleteDomainCmd;
|
||||
import com.cloud.api.commands.DeletePreallocatedLunCmd;
|
||||
import com.cloud.api.commands.DeleteSSHKeyPairCmd;
|
||||
import com.cloud.api.commands.DestroySystemVmCmd;
|
||||
import com.cloud.api.commands.ExtractVolumeCmd;
|
||||
import com.cloud.api.commands.GetCloudIdentifierCmd;
|
||||
import com.cloud.api.commands.GetVMPasswordCmd;
|
||||
|
|
@ -152,8 +153,8 @@ import com.cloud.dc.DataCenterIpAddressVO;
|
|||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
import com.cloud.dc.PodVlanMapVO;
|
||||
import com.cloud.dc.Vlan.VlanType;
|
||||
import com.cloud.dc.VlanVO;
|
||||
import com.cloud.dc.Vlan.VlanType;
|
||||
import com.cloud.dc.dao.AccountVlanMapDao;
|
||||
import com.cloud.dc.dao.ClusterDao;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
|
|
@ -196,19 +197,19 @@ import com.cloud.storage.GuestOSCategoryVO;
|
|||
import com.cloud.storage.GuestOSVO;
|
||||
import com.cloud.storage.LaunchPermissionVO;
|
||||
import com.cloud.storage.Storage;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.Storage.TemplateType;
|
||||
import com.cloud.storage.StorageManager;
|
||||
import com.cloud.storage.StoragePoolHostVO;
|
||||
import com.cloud.storage.StoragePoolVO;
|
||||
import com.cloud.storage.StorageStats;
|
||||
import com.cloud.storage.Upload;
|
||||
import com.cloud.storage.Upload.Mode;
|
||||
import com.cloud.storage.UploadVO;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.storage.VolumeStats;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.Storage.TemplateType;
|
||||
import com.cloud.storage.Upload.Mode;
|
||||
import com.cloud.storage.dao.DiskOfferingDao;
|
||||
import com.cloud.storage.dao.GuestOSCategoryDao;
|
||||
import com.cloud.storage.dao.GuestOSDao;
|
||||
|
|
@ -249,10 +250,10 @@ import com.cloud.utils.db.DB;
|
|||
import com.cloud.utils.db.Filter;
|
||||
import com.cloud.utils.db.GlobalLock;
|
||||
import com.cloud.utils.db.JoinBuilder;
|
||||
import com.cloud.utils.db.JoinBuilder.JoinType;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.JoinBuilder.JoinType;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.exception.ExecutionException;
|
||||
import com.cloud.utils.net.MacAddress;
|
||||
|
|
@ -346,7 +347,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
|
||||
private final Map<String, Boolean> _availableIdsMap;
|
||||
|
||||
private boolean _isHypervisorSnapshotCapable = false;
|
||||
private final boolean _isHypervisorSnapshotCapable = false;
|
||||
private String _hashKey = null;
|
||||
|
||||
protected ManagementServerImpl() {
|
||||
|
|
@ -2760,6 +2761,11 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
_consoleProxyMgr.rebootProxy(instanceId);
|
||||
return _consoleProxyDao.findById(instanceId);
|
||||
}
|
||||
|
||||
public ConsoleProxyVO destroyConsoleProxy(long instanceId) {
|
||||
_consoleProxyMgr.destroyProxy(instanceId);
|
||||
return _consoleProxyDao.findById(instanceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConsoleAccessUrlRoot(long vmId) {
|
||||
|
|
@ -3881,8 +3887,9 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
return _secStorageVmDao.findById(instanceId);
|
||||
}
|
||||
|
||||
public boolean destroySecondaryStorageVm(long instanceId) {
|
||||
return _secStorageVmMgr.destroySecStorageVm(instanceId);
|
||||
public SecondaryStorageVmVO destroySecondaryStorageVm(long instanceId) {
|
||||
_secStorageVmMgr.destroySecStorageVm(instanceId);
|
||||
return _secStorageVmDao.findById(instanceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -4024,6 +4031,20 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
}
|
||||
}
|
||||
|
||||
public VMInstanceVO destroySystemVM(DestroySystemVmCmd cmd) {
|
||||
VMInstanceVO systemVm = _vmInstanceDao.findByIdTypes(cmd.getId(), VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm);
|
||||
|
||||
if (systemVm == null) {
|
||||
throw new ServerApiException (BaseCmd.PARAM_ERROR, "unable to find a system vm with id " + cmd.getId());
|
||||
}
|
||||
|
||||
if (systemVm.getType().equals(VirtualMachine.Type.ConsoleProxy)){
|
||||
return destroyConsoleProxy(cmd.getId());
|
||||
} else {
|
||||
return destroySecondaryStorageVm(cmd.getId());
|
||||
}
|
||||
}
|
||||
|
||||
private String signRequest(String request, String key) {
|
||||
try
|
||||
{
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ import com.cloud.agent.api.CheckVirtualMachineCommand;
|
|||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.MigrateAnswer;
|
||||
import com.cloud.agent.api.MigrateCommand;
|
||||
import com.cloud.agent.api.NetworkRulesSystemVmCommand;
|
||||
import com.cloud.agent.api.PrepareForMigrationAnswer;
|
||||
import com.cloud.agent.api.PrepareForMigrationCommand;
|
||||
import com.cloud.agent.api.RebootAnswer;
|
||||
|
|
@ -76,18 +75,18 @@ import com.cloud.exception.OperationTimedoutException;
|
|||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.hypervisor.HypervisorGuru;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.org.Cluster;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.StorageManager;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.Volume.VolumeType;
|
||||
import com.cloud.storage.dao.GuestOSCategoryDao;
|
||||
import com.cloud.storage.dao.GuestOSDao;
|
||||
|
|
@ -376,6 +375,14 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, StateLi
|
|||
//Clean up volumes based on the vm's instance id
|
||||
_storageMgr.cleanupVolumes(vm.getId());
|
||||
|
||||
ConsoleProxyVO proxy = _consoleDao.findById(vm.getId());
|
||||
proxy.setPublicIpAddress(null);
|
||||
proxy.setPublicMacAddress(null);
|
||||
proxy.setPublicNetmask(null);
|
||||
proxy.setPrivateMacAddress(null);
|
||||
proxy.setPrivateIpAddress(null);
|
||||
_consoleDao.update(vm.getId(), proxy);
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Expunged " + vm);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue