mirror of https://github.com/apache/cloudstack.git
Made changes to the exceptions thrown by NetworkManagerImpl
This commit is contained in:
parent
0105c03a27
commit
86e51eb536
|
|
@ -28,31 +28,11 @@ public interface VirtualRouter extends VirtualMachine {
|
|||
DHCP_FIREWALL_LB_PASSWD_USERDATA,
|
||||
DHCP_USERDATA
|
||||
}
|
||||
/**
|
||||
* @return the mac address for the router.
|
||||
*/
|
||||
public String getGuestMacAddress();
|
||||
|
||||
public String getGuestIpAddress();
|
||||
|
||||
public String getPublicMacAddress();
|
||||
|
||||
public String getPublicNetmask();
|
||||
|
||||
/**
|
||||
* @return the ram size for this machine.
|
||||
*/
|
||||
public int getRamSize();
|
||||
|
||||
public String getGuestNetmask();
|
||||
|
||||
/**
|
||||
* @return the public ip address used for source nat.
|
||||
*/
|
||||
String getPublicIpAddress();
|
||||
|
||||
String getDomain();
|
||||
|
||||
Role getRole();
|
||||
|
||||
void setRamSize(int ramSize);
|
||||
|
|
|
|||
|
|
@ -49,9 +49,6 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
|
|||
@Column(name="public_netmask")
|
||||
private String publicNetmask;
|
||||
|
||||
@Column(name="guest_mac_address")
|
||||
private String guestMacAddress;
|
||||
|
||||
@Column(name="guest_ip_address")
|
||||
private String guestIpAddress;
|
||||
|
||||
|
|
@ -96,19 +93,10 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
|
|||
this.publicNetmask = publicNetmask;
|
||||
}
|
||||
|
||||
public void setGuestMacAddress(String routerMacAddress) {
|
||||
this.guestMacAddress = routerMacAddress;
|
||||
}
|
||||
|
||||
public long getNetworkId() {
|
||||
return networkId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuestNetmask() {
|
||||
return guestNetmask;
|
||||
}
|
||||
|
||||
public void setGuestIpAddress(String routerIpAddress) {
|
||||
this.guestIpAddress = routerIpAddress;
|
||||
}
|
||||
|
|
@ -122,17 +110,14 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
|
|||
return dataCenterId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPublicNetmask() {
|
||||
return publicNetmask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPublicMacAddress() {
|
||||
return publicMacAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuestIpAddress() {
|
||||
return guestIpAddress;
|
||||
}
|
||||
|
|
@ -141,7 +126,6 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
|
|||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
|
@ -156,16 +140,10 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
|
|||
this.ramSize = ramSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPublicIpAddress() {
|
||||
return publicIpAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuestMacAddress() {
|
||||
return guestMacAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Role getRole() {
|
||||
return role;
|
||||
|
|
|
|||
|
|
@ -1141,7 +1141,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
routerResponse.setTemplateId(router.getTemplateId());
|
||||
routerResponse.setCreated(router.getCreated());
|
||||
routerResponse.setState(router.getState());
|
||||
routerResponse.setNetworkDomain(router.getDomain());
|
||||
|
||||
if (router.getHostId() != null) {
|
||||
routerResponse.setHostId(router.getHostId());
|
||||
|
|
@ -1175,6 +1174,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
routerResponse.setGuestMacAddress(singleNicProfile.getMacAddress());
|
||||
routerResponse.setGuestNetmask(singleNicProfile.getNetmask());
|
||||
routerResponse.setGuestNetworkId(singleNicProfile.getNetworkId());
|
||||
routerResponse.setNetworkDomain(network.getNetworkDomain());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,7 +109,6 @@ import com.cloud.vm.dao.VMInstanceDao;
|
|||
* || stop.retry.wait | time to wait before retrying the stop | seconds | 120 ||
|
||||
* }
|
||||
**/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Local(value={HighAvailabilityManager.class})
|
||||
public class HighAvailabilityManagerImpl implements HighAvailabilityManager {
|
||||
protected static final Logger s_logger = Logger.getLogger(HighAvailabilityManagerImpl.class);
|
||||
|
|
@ -198,7 +197,7 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager {
|
|||
// collect list of vm names for the alert email
|
||||
VMInstanceVO vm = vms.get(0);
|
||||
if (vm.isHaEnabled()) {
|
||||
sb.append(" " + vm.getName());
|
||||
sb.append(" " + vm);
|
||||
}
|
||||
for (int i = 1; i < vms.size(); i++) {
|
||||
vm = vms.get(i);
|
||||
|
|
|
|||
|
|
@ -144,6 +144,7 @@ public interface NetworkManager extends NetworkService {
|
|||
Network createNetwork(long networkOfferingId, String name, String displayText, Boolean isShared, Boolean isDefault, Long zoneId, String gateway, String cidr, String vlanId, String networkDomain, Account owner) throws ConcurrentOperationException, InsufficientCapacityException;
|
||||
|
||||
/**
|
||||
* @throws InsufficientCapacityException
|
||||
* Associates an ip address list to an account. The list of ip addresses are all addresses associated with the given vlan id.
|
||||
* @param userId
|
||||
* @param accountId
|
||||
|
|
|
|||
|
|
@ -444,6 +444,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
return account;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyIpAssociations(Network network, boolean continueOnError) throws ResourceUnavailableException {
|
||||
List<IPAddressVO> userIps = _ipAddressDao.listByAssociatedNetwork(network.getId());
|
||||
List<PublicIp> publicIps = new ArrayList<PublicIp>();
|
||||
|
|
@ -1385,7 +1386,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
Long domainId = cmd.getDomainId();
|
||||
|
||||
Account owner = _accountMgr.finalizeOwner(ctxAccount, accountName, domainId);
|
||||
|
||||
// if end ip is not specified, default it to startIp
|
||||
if (endIP == null && startIP != null) {
|
||||
endIP = startIP;
|
||||
|
|
@ -1412,7 +1412,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
|
||||
// If networkDomain is not specified, take it from the global configuration
|
||||
if (networkDomain == null) {
|
||||
networkDomain = _networkDomain;
|
||||
networkDomain = "cs"+Long.toHexString(owner.getId())+_networkDomain;
|
||||
}
|
||||
|
||||
// Check if zone exists
|
||||
|
|
@ -1474,7 +1474,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
// Create network
|
||||
DataCenterDeployment plan = new DataCenterDeployment(zoneId, null, null, null);
|
||||
NetworkVO userNetwork = new NetworkVO();
|
||||
|
|
@ -2197,6 +2196,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
return elements;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean zoneIsConfiguredForExternalNetworking(long zoneId) {
|
||||
DataCenterVO zone = _dcDao.findById(zoneId);
|
||||
|
||||
|
|
|
|||
|
|
@ -670,7 +670,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
}
|
||||
}
|
||||
|
||||
private VmDataCommand generateVmDataCommand(VirtualRouter router, String vmPrivateIpAddress,
|
||||
private VmDataCommand generateVmDataCommand(DomainRouterVO router, String vmPrivateIpAddress,
|
||||
String userData, String serviceOffering, String zoneName, String guestIpAddress, String vmName, String vmInstanceName, long vmId, String publicKey) {
|
||||
VmDataCommand cmd = new VmDataCommand(vmPrivateIpAddress);
|
||||
|
||||
|
|
@ -755,7 +755,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
}
|
||||
|
||||
@Override
|
||||
public VirtualRouter deployVirtualRouter(Network guestNetwork, DeployDestination dest, Account owner, Map<Param, Object> params) throws InsufficientCapacityException,
|
||||
public DomainRouterVO deployVirtualRouter(Network guestNetwork, DeployDestination dest, Account owner, Map<Param, Object> params) throws InsufficientCapacityException,
|
||||
ConcurrentOperationException, ResourceUnavailableException {
|
||||
long dcId = dest.getDataCenter().getId();
|
||||
|
||||
|
|
@ -824,7 +824,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
}
|
||||
|
||||
@Override
|
||||
public VirtualRouter deployDhcp(Network guestNetwork, DeployDestination dest, Account owner, Map<Param, Object> params) throws InsufficientCapacityException,
|
||||
public DomainRouterVO deployDhcp(Network guestNetwork, DeployDestination dest, Account owner, Map<Param, Object> params) throws InsufficientCapacityException,
|
||||
StorageUnavailableException, ConcurrentOperationException, ResourceUnavailableException {
|
||||
long dcId = dest.getDataCenter().getId();
|
||||
|
||||
|
|
@ -994,7 +994,6 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
router.setPublicMacAddress(nic.getMacAddress());
|
||||
} else if (nic.getTrafficType() == TrafficType.Guest) {
|
||||
router.setGuestIpAddress(nic.getIp4Address());
|
||||
router.setGuestMacAddress(nic.getMacAddress());
|
||||
} else if (nic.getTrafficType() == TrafficType.Control) {
|
||||
router.setPrivateIpAddress(nic.getIp4Address());
|
||||
router.setPrivateMacAddress(nic.getMacAddress());
|
||||
|
|
@ -1197,7 +1196,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
public VirtualRouter addVirtualMachineIntoNetwork(Network network, NicProfile nic, VirtualMachineProfile<UserVm> profile, DeployDestination dest,
|
||||
ReservationContext context, Boolean startDhcp) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
|
||||
|
||||
VirtualRouter router = startDhcp ? deployDhcp(network, dest, profile.getOwner(), profile.getParameters()) : deployVirtualRouter(network, dest, profile.getOwner(), profile.getParameters());
|
||||
DomainRouterVO router = startDhcp ? deployDhcp(network, dest, profile.getOwner(), profile.getParameters()) : deployVirtualRouter(network, dest, profile.getOwner(), profile.getParameters());
|
||||
|
||||
_userVmDao.loadDetails((UserVmVO) profile.getVirtualMachine());
|
||||
|
||||
|
|
|
|||
|
|
@ -262,7 +262,6 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
String _name;
|
||||
String _instance;
|
||||
String _zone;
|
||||
String _defaultNetworkDomain;
|
||||
|
||||
private ConfigurationDao _configDao;
|
||||
|
||||
|
|
@ -1052,14 +1051,6 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
|
||||
Map<String, String> configs = _configDao.getConfiguration("AgentManager", params);
|
||||
|
||||
_defaultNetworkDomain = configs.get("domain");
|
||||
if (_defaultNetworkDomain == null) {
|
||||
_defaultNetworkDomain = ".myvm.com";
|
||||
}
|
||||
if (!_defaultNetworkDomain.startsWith(".")) {
|
||||
_defaultNetworkDomain = "." + _defaultNetworkDomain;
|
||||
}
|
||||
|
||||
_instance = configs.get("instance.name");
|
||||
if (_instance == null) {
|
||||
_instance = "DEFAULT";
|
||||
|
|
@ -1856,6 +1847,9 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
}
|
||||
|
||||
private boolean validPassword(String password) {
|
||||
if (password == null || password.length() == 0) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < password.length(); i++) {
|
||||
if (password.charAt(i) == ' ') {
|
||||
return false;
|
||||
|
|
@ -1970,20 +1964,6 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
}
|
||||
}
|
||||
|
||||
// Check that the password was passed in and is valid
|
||||
String password = PasswordGenerator.generateRandomPassword(6);
|
||||
if (!template.getEnablePassword()) {
|
||||
password = "saved_password";
|
||||
}
|
||||
if (password == null || password.equals("") || (!validPassword(password))) {
|
||||
throw new InvalidParameterValueException("A valid password for this virtual machine was not provided.");
|
||||
}
|
||||
|
||||
String networkDomain = null;
|
||||
if (networkDomain == null) {
|
||||
networkDomain = "v" + Long.toHexString(owner.getId()) + _defaultNetworkDomain;
|
||||
}
|
||||
|
||||
String userData = cmd.getUserData();
|
||||
byte [] decodedUserData = null;
|
||||
if (userData != null) {
|
||||
|
|
@ -2140,7 +2120,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
password = generateRandomPassword();
|
||||
}
|
||||
|
||||
if (password == null || password.equals("") || (!validPassword(password))) {
|
||||
if (!validPassword(password)) {
|
||||
throw new InvalidParameterValueException("A valid password for this virtual machine was not provided.");
|
||||
}
|
||||
|
||||
|
|
@ -2150,7 +2130,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
if (sshPublicKey != null && !sshPublicKey.equals("") && password != null && !password.equals("saved_password") ) {
|
||||
String encryptedPasswd = RSAHelper.encryptWithSSHPublicKey(sshPublicKey, password);
|
||||
if (encryptedPasswd == null) {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Error encrypting password");
|
||||
throw new CloudRuntimeException("Error encrypting password");
|
||||
}
|
||||
|
||||
vm.setDetail("Encrypted.Password", encryptedPasswd);
|
||||
|
|
@ -2183,14 +2163,22 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
|
||||
@Override
|
||||
public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<UserVmVO> profile, DeployDestination dest, ReservationContext context) {
|
||||
UserVmVO vo = profile.getVirtualMachine();
|
||||
UserVmVO vm = profile.getVirtualMachine();
|
||||
Account owner = _accountDao.findById(vm.getAccountId());
|
||||
|
||||
if (owner == null || owner.getState() == Account.State.disabled) {
|
||||
throw new PermissionDeniedException("The owner of " + vm + " either does not exist or is disabled: " + vm.getAccountId());
|
||||
}
|
||||
|
||||
|
||||
|
||||
VirtualMachineTemplate template = profile.getTemplate();
|
||||
if (vo.getIsoId() != null) {
|
||||
template = _templateDao.findById(vo.getIsoId());
|
||||
if (vm.getIsoId() != null) {
|
||||
template = _templateDao.findById(vm.getIsoId());
|
||||
}
|
||||
if (template != null && template.getFormat() == ImageFormat.ISO && vo.getIsoId() != null) {
|
||||
if (template != null && template.getFormat() == ImageFormat.ISO && vm.getIsoId() != null) {
|
||||
String isoPath = null;
|
||||
Pair<String, String> isoPathPair = _storageMgr.getAbsoluteIsoPath(template.getId(), vo.getDataCenterId());
|
||||
Pair<String, String> isoPathPair = _storageMgr.getAbsoluteIsoPath(template.getId(), vm.getDataCenterId());
|
||||
if (isoPathPair == null) {
|
||||
s_logger.warn("Couldn't get absolute iso path");
|
||||
return false;
|
||||
|
|
@ -2233,7 +2221,6 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
}
|
||||
}
|
||||
_vmDao.update(userVm.getId(), userVm);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -396,7 +396,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, StateLi
|
|||
//Clean up volumes based on the vm's instance id
|
||||
_storageMgr.cleanupVolumes(vm.getId());
|
||||
|
||||
VirtualMachineGuru<T> guru = (VirtualMachineGuru<T>)_vmGurus.get(vm.getType());
|
||||
VirtualMachineGuru<T> guru = getVmGuru(vm);
|
||||
guru.finalizeExpunge(vm);
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue