mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Checking in to do git pull...stupid git
This commit is contained in:
parent
1fe446002b
commit
5f90a8adb0
@ -11,6 +11,7 @@ import com.cloud.acl.ControlledEntity;
|
||||
import com.cloud.network.Network.BroadcastDomainType;
|
||||
import com.cloud.network.Network.Mode;
|
||||
import com.cloud.network.Network.TrafficType;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.utils.fsm.FiniteState;
|
||||
import com.cloud.utils.fsm.StateMachine;
|
||||
|
||||
@ -98,4 +99,6 @@ public interface NetworkConfiguration extends ControlledEntity {
|
||||
String getDns1();
|
||||
|
||||
String getDns2();
|
||||
|
||||
GuestIpType getGuestType();
|
||||
}
|
||||
|
||||
@ -30,6 +30,10 @@ public interface NetworkOffering {
|
||||
DirectSingle,
|
||||
DirectDual
|
||||
}
|
||||
|
||||
public final String DefaultVirtualizedNetworkOffering = "DefaultVirtualizedNetworkOffering";
|
||||
public final String DefaultDirectNetworkOffering = "DefaultDirectNetworkOffering";
|
||||
public final String DefaultDirectChooseVlanNetworkOffering = "DefaultDirectChooseVlanNetworkOffering";
|
||||
|
||||
long getId();
|
||||
|
||||
@ -64,4 +68,6 @@ public interface NetworkOffering {
|
||||
Integer getConcurrentConnections();
|
||||
|
||||
TrafficType getTrafficType();
|
||||
|
||||
boolean getSpecifyVlan();
|
||||
}
|
||||
|
||||
@ -17,24 +17,24 @@
|
||||
*/
|
||||
package com.cloud.uservm;
|
||||
|
||||
import com.cloud.domain.PartOf;
|
||||
import com.cloud.user.OwnedBy;
|
||||
import com.cloud.acl.ControlledEntity;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
/**
|
||||
* This represents one running virtual machine instance.
|
||||
*/
|
||||
public interface UserVm extends VirtualMachine, OwnedBy, PartOf {
|
||||
public interface UserVm extends VirtualMachine, ControlledEntity {
|
||||
|
||||
/**
|
||||
* @return service offering id
|
||||
*/
|
||||
@Override
|
||||
long getServiceOfferingId();
|
||||
|
||||
/**
|
||||
* @return the domain router associated with this vm.
|
||||
*/
|
||||
Long getDomainRouterId();
|
||||
*/
|
||||
|
||||
/**
|
||||
* @return the vnet associated with this vm.
|
||||
@ -44,6 +44,7 @@ public interface UserVm extends VirtualMachine, OwnedBy, PartOf {
|
||||
/**
|
||||
* @return the domain this vm instance belongs to.
|
||||
*/
|
||||
@Override
|
||||
long getDomainId();
|
||||
|
||||
/**
|
||||
@ -62,5 +63,9 @@ public interface UserVm extends VirtualMachine, OwnedBy, PartOf {
|
||||
|
||||
String getUserData();
|
||||
|
||||
String getPassword();
|
||||
|
||||
Long getDomainRouterId();
|
||||
|
||||
void setUserData(String userData);
|
||||
}
|
||||
|
||||
@ -33,11 +33,11 @@ updateResourceLimit=com.cloud.api.commands.UpdateResourceLimitCmd;3
|
||||
listResourceLimits=com.cloud.api.commands.ListResourceLimitsCmd;15
|
||||
|
||||
#### VM commands
|
||||
deployVirtualMachine=com.cloud.api.commands.DeployVMCmd;11
|
||||
deployVirtualMachine=com.cloud.api.commands.DeployVm2Cmd;11
|
||||
destroyVirtualMachine=com.cloud.api.commands.DestroyVMCmd;15
|
||||
rebootVirtualMachine=com.cloud.api.commands.RebootVMCmd;15
|
||||
startVirtualMachine=com.cloud.api.commands.StartVMCmd;15
|
||||
stopVirtualMachine=com.cloud.api.commands.StopVMCmd;15
|
||||
startVirtualMachine=com.cloud.api.commands.StartVm2Cmd;15
|
||||
stopVirtualMachine=com.cloud.api.commands.StopVm2Cmd;15
|
||||
resetPasswordForVirtualMachine=com.cloud.api.commands.ResetVMPasswordCmd;15
|
||||
changeServiceForVirtualMachine=com.cloud.api.commands.UpgradeVMCmd;15
|
||||
updateVirtualMachine=com.cloud.api.commands.UpdateVMCmd;15
|
||||
|
||||
31
core/src/com/cloud/dc/dao/DataCenterIpAddressDao.java
Normal file
31
core/src/com/cloud/dc/dao/DataCenterIpAddressDao.java
Normal file
@ -0,0 +1,31 @@
|
||||
/**
|
||||
* 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.dc.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.dc.DataCenterIpAddressVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface DataCenterIpAddressDao extends GenericDao<DataCenterIpAddressVO, Long> {
|
||||
boolean mark(long dcId, long podId, String ip);
|
||||
List<DataCenterIpAddressVO> listByPodIdDcIdIpAddress(long podId, long dcId, String ipAddress);
|
||||
int countIPs(long podId, long dcId, boolean onlyCountAllocated);
|
||||
boolean deleteIpAddressByPod(long podId);
|
||||
|
||||
}
|
||||
@ -27,7 +27,6 @@ import javax.ejb.Local;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.dc.DataCenterIpAddressVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
@ -35,8 +34,8 @@ import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
|
||||
@Local(value={DataCenterIpAddressDaoImpl.class})
|
||||
public class DataCenterIpAddressDaoImpl extends GenericDaoBase<DataCenterIpAddressVO, Long> implements GenericDao<DataCenterIpAddressVO, Long> {
|
||||
@Local(value={DataCenterIpAddressDao.class})
|
||||
public class DataCenterIpAddressDaoImpl extends GenericDaoBase<DataCenterIpAddressVO, Long> implements DataCenterIpAddressDao {
|
||||
private static final Logger s_logger = Logger.getLogger(DataCenterIpAddressDaoImpl.class);
|
||||
|
||||
private static final String COUNT_ALL_PRIVATE_IPS = "SELECT count(*) from `cloud`.`op_dc_ip_address_alloc` where pod_id = ? AND data_center_id = ?";
|
||||
|
||||
@ -36,11 +36,10 @@ import com.cloud.utils.db.GenericDao;
|
||||
@Entity
|
||||
@Table(name="network_offerings")
|
||||
public class NetworkOfferingVO implements NetworkOffering {
|
||||
public final static String SystemVmPublicNetwork = "System-Vm-Public-Network";
|
||||
public final static String SystemVmGuestNetwork = "System-Vm-Guest-Network";
|
||||
public final static String SystemVmControlNetwork = "System-Vm-Control-Network";
|
||||
public final static String SystemVmManagementNetwork = "System-Vm-Management-Network";
|
||||
public final static String SystemVmStorageNetwork = "System-Vm-Storage-Network";
|
||||
public final static String SystemVmPublicNetwork = "System-Public-Network";
|
||||
public final static String SystemVmControlNetwork = "System-Control-Network";
|
||||
public final static String SystemVmManagementNetwork = "System-Management-Network";
|
||||
public final static String SystemVmStorageNetwork = "System-Storage-Network";
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@ -70,6 +69,9 @@ public class NetworkOfferingVO implements NetworkOffering {
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
TrafficType trafficType;
|
||||
|
||||
@Column(name="specify_vlan")
|
||||
boolean specifyVlan;
|
||||
|
||||
@Column(name="system_only")
|
||||
boolean systemOnly;
|
||||
|
||||
@ -195,12 +197,17 @@ public class NetworkOfferingVO implements NetworkOffering {
|
||||
public void setRemoved(Date removed) {
|
||||
this.removed = removed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getSpecifyVlan() {
|
||||
return specifyVlan;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public NetworkOfferingVO(String name, String displayText, TrafficType trafficType, GuestIpType type, boolean systemOnly, Integer rateMbps, Integer multicastRateMbps, Integer concurrentConnections) {
|
||||
public NetworkOfferingVO(String name, String displayText, TrafficType trafficType, GuestIpType type, boolean systemOnly, boolean specifyVlan, Integer rateMbps, Integer multicastRateMbps, Integer concurrentConnections) {
|
||||
this.name = name;
|
||||
this.displayText = displayText;
|
||||
this.guestIpType = type;
|
||||
@ -209,10 +216,11 @@ public class NetworkOfferingVO implements NetworkOffering {
|
||||
this.concurrentConnections = concurrentConnections;
|
||||
this.trafficType = trafficType;
|
||||
this.systemOnly = systemOnly;
|
||||
this.specifyVlan = specifyVlan;
|
||||
}
|
||||
|
||||
public NetworkOfferingVO(ServiceOfferingVO offering) {
|
||||
this("Network Offering for " + offering.getName(), "Network Offering for " + offering.getDisplayText(), TrafficType.Guest, offering.getGuestIpType(), false, offering.getRateMbps(), offering.getMulticastRateMbps(), null);
|
||||
this("Network Offering for " + offering.getName(), "Network Offering for " + offering.getDisplayText(), TrafficType.Guest, offering.getGuestIpType(), false, false, offering.getRateMbps(), offering.getMulticastRateMbps(), null);
|
||||
this.serviceOfferingId = offering.getId();
|
||||
}
|
||||
|
||||
@ -223,7 +231,7 @@ public class NetworkOfferingVO implements NetworkOffering {
|
||||
* @param type
|
||||
*/
|
||||
public NetworkOfferingVO(String name, TrafficType trafficType, GuestIpType type) {
|
||||
this(name, "System Offering for " + name, trafficType, type, true, null, null, null);
|
||||
this(name, "System Offering for " + name, trafficType, type, true, false, null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -63,7 +63,17 @@ public class UserVmVO extends VMInstanceVO implements UserVm {
|
||||
|
||||
@Column(name="display_name", updatable=true, nullable=true)
|
||||
private String displayName;
|
||||
|
||||
transient String password;
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuestIpAddress() {
|
||||
return guestIpAddress;
|
||||
|
||||
@ -32,7 +32,7 @@ import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.utils.component.Inject;
|
||||
|
||||
@Local(value=DomainChecker.class)
|
||||
@Local(value=SecurityChecker.class)
|
||||
public class DomainChecker extends AdapterBase implements SecurityChecker {
|
||||
|
||||
@Inject DomainDao _domainDao;
|
||||
|
||||
@ -91,7 +91,7 @@ import com.cloud.dc.Pod;
|
||||
import com.cloud.dc.PodCluster;
|
||||
import com.cloud.dc.dao.ClusterDao;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.dc.dao.DataCenterIpAddressDaoImpl;
|
||||
import com.cloud.dc.dao.DataCenterIpAddressDao;
|
||||
import com.cloud.dc.dao.HostPodDao;
|
||||
import com.cloud.dc.dao.VlanDao;
|
||||
import com.cloud.event.dao.EventDao;
|
||||
@ -188,9 +188,9 @@ import com.cloud.vm.dao.VMInstanceDao;
|
||||
public class AgentManagerImpl implements AgentManager, HandlerFactory {
|
||||
private static final Logger s_logger = Logger.getLogger(AgentManagerImpl.class);
|
||||
|
||||
protected ConcurrentHashMap<Long, AgentAttache> _agents = new ConcurrentHashMap<Long, AgentAttache>(2047);
|
||||
protected List<Pair<Integer, Listener>> _hostMonitors = new ArrayList<Pair<Integer, Listener>>(11);
|
||||
protected List<Pair<Integer, Listener>> _cmdMonitors = new ArrayList<Pair<Integer, Listener>>(11);
|
||||
protected ConcurrentHashMap<Long, AgentAttache> _agents = new ConcurrentHashMap<Long, AgentAttache>(10007);
|
||||
protected List<Pair<Integer, Listener>> _hostMonitors = new ArrayList<Pair<Integer, Listener>>(17);
|
||||
protected List<Pair<Integer, Listener>> _cmdMonitors = new ArrayList<Pair<Integer, Listener>>(17);
|
||||
protected int _monitorId = 0;
|
||||
|
||||
protected NioServer _connection;
|
||||
@ -198,7 +198,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory {
|
||||
@Inject protected UserStatisticsDao _userStatsDao = null;
|
||||
@Inject protected DataCenterDao _dcDao = null;
|
||||
@Inject protected VlanDao _vlanDao = null;
|
||||
@Inject protected DataCenterIpAddressDaoImpl _privateIPAddressDao = null;
|
||||
@Inject protected DataCenterIpAddressDao _privateIPAddressDao = null;
|
||||
@Inject protected IPAddressDao _publicIPAddressDao = null;
|
||||
@Inject protected HostPodDao _podDao = null;
|
||||
protected Adapters<HostAllocator> _hostAllocators = null;
|
||||
|
||||
@ -48,7 +48,7 @@ import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.dc.dao.DataCenterIpAddressDaoImpl;
|
||||
import com.cloud.dc.dao.DataCenterIpAddressDao;
|
||||
import com.cloud.dc.dao.HostPodDao;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
@ -105,7 +105,7 @@ public class AlertManagerImpl implements AlertManager {
|
||||
@Inject private HostPodDao _podDao;
|
||||
@Inject private VolumeDao _volumeDao;
|
||||
@Inject private IPAddressDao _publicIPAddressDao;
|
||||
@Inject private DataCenterIpAddressDaoImpl _privateIPAddressDao;
|
||||
@Inject private DataCenterIpAddressDao _privateIPAddressDao;
|
||||
@Inject private StoragePoolDao _storagePoolDao;
|
||||
|
||||
private Timer _timer = null;
|
||||
|
||||
95
server/src/com/cloud/api/commands/StopVm2Cmd.java
Normal file
95
server/src/com/cloud/api/commands/StopVm2Cmd.java
Normal file
@ -0,0 +1,95 @@
|
||||
/**
|
||||
* 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.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.api.ApiResponseHelper;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.response.UserVmResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.vm.UserVmService;
|
||||
|
||||
@Implementation(method="stopVirtualMachine", manager=UserVmService.class, description="Stops a virtual machine.")
|
||||
public class StopVm2Cmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(StopVMCmd.class.getName());
|
||||
|
||||
private static final String s_name = "stopvirtualmachineresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="The ID of the virtual machine")
|
||||
private Long id;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
public static String getResultObjectName() {
|
||||
return "virtualmachine";
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
UserVm vm = ApiDBUtils.findUserVmById(getId());
|
||||
if (vm != null) {
|
||||
return vm.getAccountId();
|
||||
}
|
||||
|
||||
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_VM_STOP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "stopping user vm: " + getId();
|
||||
}
|
||||
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
public UserVmResponse getResponse() {
|
||||
UserVm userVm = (UserVm)getResponseObject();
|
||||
UserVmResponse recoverVmResponse = ApiResponseHelper.createUserVmResponse(userVm);
|
||||
recoverVmResponse.setResponseName(getName());
|
||||
return recoverVmResponse;
|
||||
}
|
||||
}
|
||||
@ -59,7 +59,7 @@ import com.cloud.dc.Vlan.VlanType;
|
||||
import com.cloud.dc.VlanVO;
|
||||
import com.cloud.dc.dao.AccountVlanMapDao;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.dc.dao.DataCenterIpAddressDaoImpl;
|
||||
import com.cloud.dc.dao.DataCenterIpAddressDao;
|
||||
import com.cloud.dc.dao.HostPodDao;
|
||||
import com.cloud.dc.dao.PodVlanMapDao;
|
||||
import com.cloud.dc.dao.VlanDao;
|
||||
@ -124,7 +124,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
||||
@Inject DiskOfferingDao _diskOfferingDao;
|
||||
@Inject VlanDao _vlanDao;
|
||||
@Inject IPAddressDao _publicIpAddressDao;
|
||||
@Inject DataCenterIpAddressDaoImpl _privateIpAddressDao;
|
||||
@Inject DataCenterIpAddressDao _privateIpAddressDao;
|
||||
@Inject VMInstanceDao _vmInstanceDao;
|
||||
@Inject AccountDao _accountDao;
|
||||
@Inject EventDao _eventDao;
|
||||
|
||||
@ -531,7 +531,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
||||
@Override
|
||||
public ConsoleProxyVO startProxy(long proxyVmId, long startEventId) {
|
||||
try {
|
||||
return start(proxyVmId, startEventId);
|
||||
return start2(proxyVmId, startEventId);
|
||||
} catch (StorageUnavailableException e) {
|
||||
s_logger.warn("Exception while trying to start console proxy", e);
|
||||
return null;
|
||||
@ -887,7 +887,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
||||
if (s_logger.isDebugEnabled())
|
||||
s_logger.debug("Assign console proxy from a newly started instance for request from data center : " + dataCenterId);
|
||||
|
||||
Map<String, Object> context = createProxyInstance(dataCenterId);
|
||||
Map<String, Object> context = createProxyInstance2(dataCenterId);
|
||||
|
||||
long proxyVmId = (Long) context.get("proxyVmId");
|
||||
if (proxyVmId == 0) {
|
||||
@ -927,7 +927,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
||||
if (s_logger.isDebugEnabled())
|
||||
s_logger.debug("Assign console proxy from a newly started instance for request from data center : " + dataCenterId);
|
||||
|
||||
Map<String, Object> context = createProxyInstance(dataCenterId);
|
||||
Map<String, Object> context = createProxyInstance2(dataCenterId);
|
||||
|
||||
long proxyVmId = (Long) context.get("proxyVmId");
|
||||
if (proxyVmId == 0) {
|
||||
@ -1468,7 +1468,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
||||
try {
|
||||
if (proxyLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
|
||||
try {
|
||||
readyProxy = start(readyProxy.getId(), 0);
|
||||
readyProxy = start2(readyProxy.getId(), 0);
|
||||
} finally {
|
||||
proxyLock.unlock();
|
||||
}
|
||||
|
||||
@ -31,6 +31,7 @@ import javax.persistence.Transient;
|
||||
import com.cloud.network.Network.BroadcastDomainType;
|
||||
import com.cloud.network.Network.Mode;
|
||||
import com.cloud.network.Network.TrafficType;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
|
||||
@ -58,6 +59,9 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
TrafficType trafficType;
|
||||
|
||||
@Column(name="guest_type")
|
||||
GuestIpType guestType;
|
||||
|
||||
@Column(name="broadcast_uri")
|
||||
URI broadcastUri;
|
||||
|
||||
@ -116,7 +120,7 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
|
||||
* @param networkOfferingId
|
||||
* @param dataCenterId
|
||||
*/
|
||||
public NetworkConfigurationVO(TrafficType trafficType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, long dataCenterId) {
|
||||
public NetworkConfigurationVO(TrafficType trafficType, GuestIpType guestType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, long dataCenterId) {
|
||||
this.trafficType = trafficType;
|
||||
this.mode = mode;
|
||||
this.broadcastDomainType = broadcastDomainType;
|
||||
@ -124,10 +128,11 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
|
||||
this.dataCenterId = dataCenterId;
|
||||
this.state = State.Allocated;
|
||||
this.id = -1;
|
||||
this.guestType = guestType;
|
||||
}
|
||||
|
||||
public NetworkConfigurationVO(long id, NetworkConfiguration that, long offeringId, long dataCenterId, String guruName, long domainId, long accountId, long related) {
|
||||
this(id, that.getTrafficType(), that.getMode(), that.getBroadcastDomainType(), offeringId, dataCenterId, domainId, accountId, related);
|
||||
this(id, that.getTrafficType(), that.getGuestType(), that.getMode(), that.getBroadcastDomainType(), offeringId, dataCenterId, domainId, accountId, related);
|
||||
this.gateway = that.getGateway();
|
||||
this.dns1 = that.getDns1();
|
||||
this.dns2 = that.getDns2();
|
||||
@ -149,8 +154,8 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
|
||||
* @param domainId
|
||||
* @param accountId
|
||||
*/
|
||||
public NetworkConfigurationVO(long id, TrafficType trafficType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, long dataCenterId, long domainId, long accountId, long related) {
|
||||
this(trafficType, mode, broadcastDomainType, networkOfferingId, dataCenterId);
|
||||
public NetworkConfigurationVO(long id, TrafficType trafficType, GuestIpType guestType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, long dataCenterId, long domainId, long accountId, long related) {
|
||||
this(trafficType, guestType, mode, broadcastDomainType, networkOfferingId, dataCenterId);
|
||||
this.domainId = domainId;
|
||||
this.accountId = accountId;
|
||||
this.related = related;
|
||||
@ -175,6 +180,11 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuestIpType getGuestType() {
|
||||
return guestType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mode getMode() {
|
||||
|
||||
@ -59,7 +59,6 @@ import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.Manager;
|
||||
import com.cloud.vm.DomainRouter;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
import com.cloud.vm.NicProfile;
|
||||
@ -73,7 +72,7 @@ import com.cloud.vm.VirtualMachineProfile;
|
||||
* NetworkManager manages the network for the different end users.
|
||||
*
|
||||
*/
|
||||
public interface NetworkManager extends Manager {
|
||||
public interface NetworkManager {
|
||||
public static final int DEFAULT_ROUTER_VM_RAMSIZE = 128; // 128M
|
||||
public static final boolean USE_POD_VLAN = false;
|
||||
/**
|
||||
|
||||
@ -66,6 +66,7 @@ import com.cloud.api.commands.UpdateLoadBalancerRuleCmd;
|
||||
import com.cloud.api.commands.UpgradeRouterCmd;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.capacity.dao.CapacityDao;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.configuration.ResourceCount.ResourceType;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
@ -144,6 +145,7 @@ import com.cloud.utils.StringUtils;
|
||||
import com.cloud.utils.Ternary;
|
||||
import com.cloud.utils.component.Adapters;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.component.Manager;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.JoinBuilder;
|
||||
import com.cloud.utils.db.JoinBuilder.JoinType;
|
||||
@ -167,8 +169,8 @@ import com.cloud.vm.dao.UserVmDao;
|
||||
/**
|
||||
* NetworkManagerImpl implements NetworkManager.
|
||||
*/
|
||||
@Local(value={NetworkManager.class, DomainRouterService.class})
|
||||
public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
||||
@Local(value={NetworkManager.class, NetworkService.class})
|
||||
public class NetworkManagerImpl implements NetworkManager, NetworkService, Manager {
|
||||
private static final Logger s_logger = Logger.getLogger(NetworkManagerImpl.class);
|
||||
|
||||
String _name;
|
||||
@ -1670,22 +1672,39 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
||||
_name = name;
|
||||
|
||||
final Map<String, String> configs = _configDao.getConfiguration("AgentManager", params);
|
||||
|
||||
|
||||
String value = configs.get(Config.NetworkThrottlingRate.key());
|
||||
Integer rateMbps = null;
|
||||
if (value != null) {
|
||||
rateMbps = Integer.parseInt(value);
|
||||
}
|
||||
|
||||
Integer multicastRateMbps = null;
|
||||
value = configs.get(Config.MulticastThrottlingRate.key());
|
||||
if (value != null) {
|
||||
multicastRateMbps = Integer.parseInt(value);
|
||||
}
|
||||
|
||||
NetworkOfferingVO publicNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmPublicNetwork, TrafficType.Public, null);
|
||||
publicNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(publicNetworkOffering);
|
||||
publicNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(publicNetworkOffering);
|
||||
_systemNetworks.put(NetworkOfferingVO.SystemVmPublicNetwork, publicNetworkOffering);
|
||||
NetworkOfferingVO managementNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmManagementNetwork, TrafficType.Management, null);
|
||||
managementNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(managementNetworkOffering);
|
||||
managementNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(managementNetworkOffering);
|
||||
_systemNetworks.put(NetworkOfferingVO.SystemVmManagementNetwork, managementNetworkOffering);
|
||||
NetworkOfferingVO controlNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmControlNetwork, TrafficType.Control, null);
|
||||
controlNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(controlNetworkOffering);
|
||||
controlNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(controlNetworkOffering);
|
||||
_systemNetworks.put(NetworkOfferingVO.SystemVmControlNetwork, controlNetworkOffering);
|
||||
NetworkOfferingVO guestNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmGuestNetwork, TrafficType.Guest, GuestIpType.Virtualized);
|
||||
guestNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(guestNetworkOffering);
|
||||
_systemNetworks.put(NetworkOfferingVO.SystemVmGuestNetwork, guestNetworkOffering);
|
||||
// NetworkOfferingVO guestNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmGuestNetwork, TrafficType.Guest, GuestIpType.Virtualized);
|
||||
// guestNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(guestNetworkOffering);
|
||||
// _systemNetworks.put(NetworkOfferingVO.SystemVmGuestNetwork, guestNetworkOffering);
|
||||
NetworkOfferingVO storageNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmStorageNetwork, TrafficType.Storage, null);
|
||||
storageNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(storageNetworkOffering);
|
||||
_systemNetworks.put(NetworkOfferingVO.SystemVmGuestNetwork, storageNetworkOffering);
|
||||
storageNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(storageNetworkOffering);
|
||||
_systemNetworks.put(NetworkOfferingVO.SystemVmStorageNetwork, storageNetworkOffering);
|
||||
|
||||
NetworkOfferingVO defaultGuestNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultVirtualizedNetworkOffering, "Virtual Vlan", TrafficType.Guest, GuestIpType.Virtualized, false, false, rateMbps, multicastRateMbps, null);
|
||||
defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestNetworkOffering);
|
||||
NetworkOfferingVO defaultGuestDirectNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultDirectNetworkOffering, "Direct", TrafficType.Guest, GuestIpType.DirectSingle, false, false, rateMbps, multicastRateMbps, null);
|
||||
defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestDirectNetworkOffering);
|
||||
|
||||
AccountsUsingNetworkConfigurationSearch = _accountDao.createSearchBuilder();
|
||||
SearchBuilder<NetworkAccountVO> networkAccountSearch = _networkConfigDao.createSearchBuilderForAccount();
|
||||
@ -1909,6 +1928,14 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
||||
vo.setNetmask(profile.getNetmask());
|
||||
vo.setGateway(profile.getGateway());
|
||||
|
||||
if (profile.getBroadCastUri() != null) {
|
||||
vo.setBroadcastUri(profile.getBroadCastUri());
|
||||
}
|
||||
|
||||
if (profile.getIsolationUri() != null) {
|
||||
vo.setIsolationUri(profile.getIsolationUri());
|
||||
}
|
||||
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
@ -2898,6 +2925,9 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<NetworkOfferingVO> listNetworkOfferings() {
|
||||
return _networkOfferingDao.listNonSystemNetworkOfferings();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
27
server/src/com/cloud/network/NetworkService.java
Normal file
27
server/src/com/cloud/network/NetworkService.java
Normal file
@ -0,0 +1,27 @@
|
||||
/**
|
||||
* 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.network;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
|
||||
|
||||
public interface NetworkService {
|
||||
List<? extends NetworkOffering> listNetworkOfferings();
|
||||
}
|
||||
@ -49,7 +49,7 @@ public class ControlNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
return null;
|
||||
}
|
||||
|
||||
NetworkConfigurationVO config = new NetworkConfigurationVO(offering.getTrafficType(), Mode.Static, BroadcastDomainType.LinkLocal, offering.getId(), plan.getDataCenterId());
|
||||
NetworkConfigurationVO config = new NetworkConfigurationVO(offering.getTrafficType(), offering.getGuestIpType(), Mode.Static, BroadcastDomainType.LinkLocal, offering.getId(), plan.getDataCenterId());
|
||||
config.setCidr(_cidr);
|
||||
config.setGateway(_gateway);
|
||||
|
||||
|
||||
@ -72,7 +72,7 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
}
|
||||
DataCenterVO dc = _dcDao.findById(plan.getDataCenterId());
|
||||
|
||||
NetworkConfigurationVO config = new NetworkConfigurationVO(offering.getTrafficType(), mode, broadcastType, offering.getId(), plan.getDataCenterId());
|
||||
NetworkConfigurationVO config = new NetworkConfigurationVO(offering.getTrafficType(), offering.getGuestIpType(), mode, broadcastType, offering.getId(), plan.getDataCenterId());
|
||||
if (userSpecified != null) {
|
||||
if ((userSpecified.getCidr() == null && userSpecified.getGateway() != null) ||
|
||||
(userSpecified.getCidr() != null && userSpecified.getGateway() == null)) {
|
||||
@ -116,7 +116,7 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
assert (config.getState() == State.Allocated) : "Why implement are we implementing " + config;
|
||||
|
||||
long dcId = dest.getDataCenter().getId();
|
||||
NetworkConfigurationVO implemented = new NetworkConfigurationVO(config.getTrafficType(), config.getMode(), config.getBroadcastDomainType(), config.getNetworkOfferingId(), config.getDataCenterId());
|
||||
NetworkConfigurationVO implemented = new NetworkConfigurationVO(config.getTrafficType(), config.getGuestType(), config.getMode(), config.getBroadcastDomainType(), config.getNetworkOfferingId(), config.getDataCenterId());
|
||||
|
||||
if (config.getBroadcastUri() == null) {
|
||||
String vnet = _dcDao.allocateVnet(dcId, config.getAccountId());
|
||||
|
||||
@ -44,7 +44,7 @@ public class PodBasedNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
return null;
|
||||
}
|
||||
|
||||
NetworkConfigurationVO config = new NetworkConfigurationVO(type, Mode.Static, BroadcastDomainType.Native, offering.getId(), plan.getDataCenterId());
|
||||
NetworkConfigurationVO config = new NetworkConfigurationVO(type, offering.getGuestIpType(), Mode.Static, BroadcastDomainType.Native, offering.getId(), plan.getDataCenterId());
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new NetworkConfigurationVO(offering.getTrafficType(), Mode.Static, BroadcastDomainType.Vlan, offering.getId(), plan.getDataCenterId());
|
||||
return new NetworkConfigurationVO(offering.getTrafficType(), offering.getGuestIpType(), Mode.Static, BroadcastDomainType.Vlan, offering.getId(), plan.getDataCenterId());
|
||||
}
|
||||
|
||||
protected PublicNetworkGuru() {
|
||||
@ -95,7 +95,7 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
}
|
||||
nic.setMacAddress(mac);
|
||||
|
||||
DataCenter dc = _dcDao.findById(config.getId());
|
||||
DataCenter dc = _dcDao.findById(config.getDataCenterId());
|
||||
getIp(nic, dc, vm);
|
||||
|
||||
return nic;
|
||||
|
||||
@ -75,7 +75,7 @@ public class NetworkConfigurationDaoImpl extends GenericDaoBase<NetworkConfigura
|
||||
AccountSearch.done();
|
||||
|
||||
OfferingSearch = createSearchBuilder();
|
||||
OfferingSearch.and("offering", OfferingSearch.entity().getNetworkOfferingId(), SearchCriteria.Op.EQ);
|
||||
OfferingSearch.and("guesttype", OfferingSearch.entity().getGuestType(), SearchCriteria.Op.EQ);
|
||||
OfferingSearch.and("datacenter", OfferingSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
|
||||
RelatedConfigSearch = createSearchBuilder();
|
||||
|
||||
@ -65,7 +65,7 @@ public class DomainRouterElement extends AdapterBase implements NetworkElement {
|
||||
return false;
|
||||
}
|
||||
|
||||
DomainRouterVO router = _routerMgr.deploy(guestConfig, offering, dest, context.getAccount());
|
||||
DomainRouterVO router = _routerMgr.deploy(guestConfig, dest, context.getAccount());
|
||||
if (router == null) {
|
||||
throw new ResourceUnavailableException("Unable to deploy the router for " + guestConfig);
|
||||
}
|
||||
@ -87,7 +87,7 @@ public class DomainRouterElement extends AdapterBase implements NetworkElement {
|
||||
@SuppressWarnings("unchecked")
|
||||
VirtualMachineProfile<UserVm> uservm = (VirtualMachineProfile<UserVm>)vm;
|
||||
|
||||
return _routerMgr.addVirtualMachineIntoNetwork(config, nic, uservm, context) != null;
|
||||
return _routerMgr.addVirtualMachineIntoNetwork(config, nic, uservm, dest, context) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -37,7 +37,6 @@ import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.NetworkConfiguration;
|
||||
import com.cloud.network.RemoteAccessVpnVO;
|
||||
import com.cloud.network.VpnUserVO;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.uservm.UserVm;
|
||||
@ -175,7 +174,7 @@ public interface DomainRouterManager extends Manager {
|
||||
DomainRouterVO getRouter(long accountId, long zoneId);
|
||||
DomainRouterVO getRouter(String publicIpAddress);
|
||||
|
||||
DomainRouterVO deploy(NetworkConfiguration guestConfig, NetworkOffering offering, DeployDestination dest, Account owner) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException;
|
||||
DomainRouterVO deploy(NetworkConfiguration guestConfig, DeployDestination dest, Account owner) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException;
|
||||
|
||||
RemoteAccessVpnVO startRemoteAccessVpn(RemoteAccessVpnVO vpnVO) throws ResourceUnavailableException;
|
||||
|
||||
@ -183,5 +182,5 @@ public interface DomainRouterManager extends Manager {
|
||||
|
||||
boolean deleteRemoteAccessVpn(RemoteAccessVpnVO vpnVO);
|
||||
|
||||
DomainRouterVO addVirtualMachineIntoNetwork(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile<UserVm> vm, ReservationContext context) throws ConcurrentOperationException, InsufficientNetworkCapacityException, ResourceUnavailableException;
|
||||
DomainRouterVO addVirtualMachineIntoNetwork(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile<UserVm> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientNetworkCapacityException, ResourceUnavailableException;
|
||||
}
|
||||
|
||||
@ -104,6 +104,7 @@ import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.DomainRouterService;
|
||||
import com.cloud.network.FirewallRuleVO;
|
||||
import com.cloud.network.IPAddressVO;
|
||||
import com.cloud.network.Network.TrafficType;
|
||||
@ -122,7 +123,6 @@ import com.cloud.network.dao.NetworkRuleConfigDao;
|
||||
import com.cloud.network.dao.RemoteAccessVpnDao;
|
||||
import com.cloud.network.dao.VpnUserDao;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
@ -180,8 +180,8 @@ import com.cloud.vm.dao.UserVmDao;
|
||||
/**
|
||||
* NetworkManagerImpl implements NetworkManager.
|
||||
*/
|
||||
@Local(value={DomainRouterManager.class})
|
||||
public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMachineManager<DomainRouterVO>, VirtualMachineGuru<DomainRouterVO> {
|
||||
@Local(value={DomainRouterManager.class, DomainRouterService.class})
|
||||
public class DomainRouterManagerImpl implements DomainRouterManager, DomainRouterService, VirtualMachineManager<DomainRouterVO>, VirtualMachineGuru<DomainRouterVO> {
|
||||
private static final Logger s_logger = Logger.getLogger(DomainRouterManagerImpl.class);
|
||||
|
||||
String _name;
|
||||
@ -2033,14 +2033,14 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainRouterVO deploy(NetworkConfiguration guestConfig, NetworkOffering offering, DeployDestination dest, Account owner) throws InsufficientCapacityException, StorageUnavailableException, ConcurrentOperationException, ResourceUnavailableException {
|
||||
public DomainRouterVO deploy(NetworkConfiguration guestConfig, DeployDestination dest, Account owner) throws InsufficientCapacityException, StorageUnavailableException, ConcurrentOperationException, ResourceUnavailableException {
|
||||
long dcId = dest.getDataCenter().getId();
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Starting a router for network configurations: virtual=" + guestConfig + " in " + dest);
|
||||
}
|
||||
assert guestConfig.getState() == NetworkConfiguration.State.Implemented : "Network is not yet fully implemented: " + guestConfig;
|
||||
assert offering.getGuestIpType() == GuestIpType.Virtualized;
|
||||
assert guestConfig.getTrafficType() == TrafficType.Guest;
|
||||
|
||||
DataCenterDeployment plan = new DataCenterDeployment(dcId);
|
||||
|
||||
@ -2221,10 +2221,10 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainRouterVO addVirtualMachineIntoNetwork(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile<UserVm> profile, ReservationContext context) throws ConcurrentOperationException, InsufficientNetworkCapacityException, ResourceUnavailableException {
|
||||
public DomainRouterVO addVirtualMachineIntoNetwork(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile<UserVm> profile, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientNetworkCapacityException, ResourceUnavailableException {
|
||||
DomainRouterVO router = _routerDao.findByNetworkConfiguration(config.getId());
|
||||
try {
|
||||
router = start(router, context.getCaller(), context.getAccount());
|
||||
router = this.deploy(config, dest, profile.getOwner());
|
||||
} catch (InsufficientNetworkCapacityException e) {
|
||||
throw e;
|
||||
} catch (InsufficientCapacityException e) {
|
||||
@ -2236,7 +2236,8 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
||||
throw new ResourceUnavailableException("Can't find a domain router to start " + profile + " in " + config);
|
||||
}
|
||||
|
||||
String password = null;
|
||||
|
||||
String password = profile.getVirtualMachine().getPassword();
|
||||
String userData = profile.getVirtualMachine().getUserData();
|
||||
Commands cmds = new Commands(OnError.Stop);
|
||||
String routerPublicIpAddress = nic.getIp4Address();
|
||||
|
||||
@ -3,6 +3,8 @@
|
||||
*/
|
||||
package com.cloud.offerings.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
@ -28,7 +30,9 @@ public interface NetworkOfferingDao extends GenericDao<NetworkOfferingVO, Long>
|
||||
* @param offering network offering to persist if not in the database.
|
||||
* @return NetworkOfferingVO backed by a row in the database
|
||||
*/
|
||||
NetworkOfferingVO persistSystemNetworkOffering(NetworkOfferingVO offering);
|
||||
NetworkOfferingVO persistDefaultNetworkOffering(NetworkOfferingVO offering);
|
||||
|
||||
NetworkOfferingVO findByServiceOffering(ServiceOfferingVO offering);
|
||||
|
||||
List<NetworkOfferingVO> listNonSystemNetworkOfferings();
|
||||
}
|
||||
|
||||
@ -4,6 +4,8 @@
|
||||
package com.cloud.offerings.dao;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.persistence.EntityExistsException;
|
||||
|
||||
@ -22,8 +24,9 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase<NetworkOfferingVO, Lo
|
||||
|
||||
private final static Logger s_logger = Logger.getLogger(NetworkOfferingDaoImpl.class);
|
||||
|
||||
SearchBuilder<NetworkOfferingVO> NameSearch;
|
||||
SearchBuilder<NetworkOfferingVO> ServiceOfferingSearch;
|
||||
final SearchBuilder<NetworkOfferingVO> NameSearch;
|
||||
final SearchBuilder<NetworkOfferingVO> ServiceOfferingSearch;
|
||||
final SearchBuilder<NetworkOfferingVO> SystemOfferingSearch;
|
||||
|
||||
protected NetworkOfferingDaoImpl() {
|
||||
super();
|
||||
@ -33,8 +36,12 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase<NetworkOfferingVO, Lo
|
||||
NameSearch.done();
|
||||
|
||||
ServiceOfferingSearch = createSearchBuilder();
|
||||
ServiceOfferingSearch.and("serviceoffering", ServiceOfferingSearch.entity().getServiceOfferingId(), SearchCriteria.Op.EQ);
|
||||
ServiceOfferingSearch.and("serviceoffering", ServiceOfferingSearch.entity().getGuestIpType(), SearchCriteria.Op.EQ);
|
||||
ServiceOfferingSearch.done();
|
||||
|
||||
SystemOfferingSearch = createSearchBuilder();
|
||||
SystemOfferingSearch.and("system", SystemOfferingSearch.entity().isSystemOnly(), SearchCriteria.Op.EQ);
|
||||
SystemOfferingSearch.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -48,7 +55,7 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase<NetworkOfferingVO, Lo
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkOfferingVO persistSystemNetworkOffering(NetworkOfferingVO offering) {
|
||||
public NetworkOfferingVO persistDefaultNetworkOffering(NetworkOfferingVO offering) {
|
||||
assert offering.getName() != null : "how are you going to find this later if you don't set it?";
|
||||
NetworkOfferingVO vo = findByName(offering.getName());
|
||||
if (vo != null) {
|
||||
@ -66,7 +73,7 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase<NetworkOfferingVO, Lo
|
||||
@Override
|
||||
public NetworkOfferingVO findByServiceOffering(ServiceOfferingVO offering) {
|
||||
SearchCriteria<NetworkOfferingVO> sc = ServiceOfferingSearch.create();
|
||||
sc.setParameters("serviceoffering", offering.getId());
|
||||
sc.setParameters("serviceoffering", offering.getGuestIpType());
|
||||
|
||||
NetworkOfferingVO vo = findOneBy(sc);
|
||||
if (vo != null) {
|
||||
@ -86,4 +93,11 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase<NetworkOfferingVO, Lo
|
||||
throw new CloudRuntimeException("Unable to persist network offering", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NetworkOfferingVO> listNonSystemNetworkOfferings() {
|
||||
SearchCriteria<NetworkOfferingVO> sc = SystemOfferingSearch.create();
|
||||
sc.setParameters("system", false);
|
||||
return this.listIncludingRemovedBy(sc, null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,6 +19,6 @@ package com.cloud.vm;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface ItWorkDao extends GenericDao<ItWorkVO, Long> {
|
||||
public interface ItWorkDao extends GenericDao<ItWorkVO, String> {
|
||||
|
||||
}
|
||||
|
||||
@ -76,6 +76,7 @@ import com.cloud.api.commands.RebootVMCmd;
|
||||
import com.cloud.api.commands.RecoverVMCmd;
|
||||
import com.cloud.api.commands.ResetVMPasswordCmd;
|
||||
import com.cloud.api.commands.StartVMCmd;
|
||||
import com.cloud.api.commands.StartVm2Cmd;
|
||||
import com.cloud.api.commands.StopVMCmd;
|
||||
import com.cloud.api.commands.StopVm2Cmd;
|
||||
import com.cloud.api.commands.UpdateVMCmd;
|
||||
@ -3726,13 +3727,27 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
||||
long vmId = cmd.getId();
|
||||
UserVmVO vm = _vmDao.findById(vmId);
|
||||
|
||||
long dcId = cmd.getZoneId();
|
||||
// Check that the password was passed in and is valid
|
||||
VMTemplateVO template = _templateDao.findById(vm.getTemplateId());
|
||||
|
||||
String password = "saved_password";
|
||||
if (template.getEnablePassword()) {
|
||||
password = generateRandomPassword();
|
||||
}
|
||||
|
||||
if (password == null || password.equals("") || (!validPassword(password))) {
|
||||
throw new InvalidParameterValueException("A valid password for this virtual machine was not provided.");
|
||||
}
|
||||
vm.setPassword(password);
|
||||
|
||||
long userId = UserContext.current().getUserId();
|
||||
UserVO caller = _userDao.findById(userId);
|
||||
|
||||
AccountVO owner = _accountDao.findById(vm.getAccountId());
|
||||
|
||||
return _itMgr.start(vm, null, caller, owner);
|
||||
vm = _itMgr.start(vm, null, caller, owner);
|
||||
vm.setPassword(password);
|
||||
return vm;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -3804,4 +3819,33 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
||||
public void finalizeStop(VirtualMachineProfile<UserVmVO> profile, long hostId, String reservationId) {
|
||||
}
|
||||
|
||||
public String generateRandomPassword() {
|
||||
return PasswordGenerator.generateRandomPassword(6);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public UserVm startVirtualMachine(StartVm2Cmd cmd) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
|
||||
//Input validation
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
Long id = cmd.getId();
|
||||
|
||||
//if account is removed, return error
|
||||
if(account!=null && account.getRemoved() != null)
|
||||
throw new PermissionDeniedException("The account " + account.getId()+" is removed");
|
||||
|
||||
UserVmVO vm = _vmDao.findById(id.longValue());
|
||||
if (vm == null) {
|
||||
throw new ServerApiException(BaseCmd.VM_INVALID_PARAM_ERROR, "unable to find a virtual machine with id " + id);
|
||||
}
|
||||
|
||||
long eventId = EventUtils.saveScheduledEvent(userId, vm.getAccountId(), EventTypes.EVENT_VM_START, "Starting Vm with Id: "+id);
|
||||
|
||||
userId = accountAndUserValidation(id, account, userId, vm);
|
||||
UserVO user = _userDao.findById(userId);
|
||||
|
||||
return _itMgr.start(vm, null, user, account);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -28,6 +28,7 @@ import com.cloud.api.commands.RebootVMCmd;
|
||||
import com.cloud.api.commands.RecoverVMCmd;
|
||||
import com.cloud.api.commands.ResetVMPasswordCmd;
|
||||
import com.cloud.api.commands.StartVMCmd;
|
||||
import com.cloud.api.commands.StartVm2Cmd;
|
||||
import com.cloud.api.commands.StopVMCmd;
|
||||
import com.cloud.api.commands.StopVm2Cmd;
|
||||
import com.cloud.api.commands.UpdateVMCmd;
|
||||
@ -148,4 +149,6 @@ public interface UserVmService extends Manager {
|
||||
UserVm upgradeVirtualMachine(UpgradeVMCmd cmd);
|
||||
|
||||
UserVm stopVirtualMachine(StopVm2Cmd cmd) throws ConcurrentOperationException;
|
||||
|
||||
UserVm startVirtualMachine(StartVm2Cmd cmd) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
}
|
||||
|
||||
@ -129,6 +129,7 @@ CREATE TABLE `cloud`.`network_configurations` (
|
||||
`dns2` varchar(255) COMMENT 'comma separated DNS list',
|
||||
`guru_data` varchar(1024) COMMENT 'data stored by the network guru that setup this network',
|
||||
`set_fields` bigint unsigned NOT NULL DEFAULT 0 COMMENT 'which fields are set already',
|
||||
`guest_type` char(32) COMMENT 'type of guest network',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
@ -184,6 +185,7 @@ CREATE TABLE `cloud`.`network_offerings` (
|
||||
`traffic_type` varchar(32) NOT NULL COMMENT 'traffic type carried on this network',
|
||||
`tags` varchar(4096) COMMENT 'tags supported by this offering',
|
||||
`system_only` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'Is this network offering for system use only',
|
||||
`specify_vlan` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'Should the user specify vlan',
|
||||
`service_offering_id` bigint unsigned UNIQUE COMMENT 'service offering id that this network offering is tied to',
|
||||
`created` datetime NOT NULL COMMENT 'time the entry was created',
|
||||
`removed` datetime DEFAULT NULL COMMENT 'time the entry was removed',
|
||||
|
||||
@ -379,6 +379,8 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
instance = locator.getDao(fc);
|
||||
} else if (Adapters.class.isAssignableFrom(fc)) {
|
||||
instance = locator.getAdapters(inject.adapter());
|
||||
} else {
|
||||
instance = locator.getManager(fc);
|
||||
}
|
||||
|
||||
if (instance == null) {
|
||||
@ -690,16 +692,25 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
throw new CloudRuntimeException("Caught throwable: ", e);
|
||||
}
|
||||
|
||||
if (!interphace.isAssignableFrom(info.clazz)) {
|
||||
throw new CloudRuntimeException("Class " + info.clazz.toString() + " does not implment " + interphace);
|
||||
}
|
||||
|
||||
Local local = info.clazz.getAnnotation(Local.class);
|
||||
if (local == null) {
|
||||
throw new CloudRuntimeException("Unable to find Local annotation for class " + clazzName);
|
||||
}
|
||||
|
||||
|
||||
Class<?>[] classes = local.value();
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
if (findInterfaceInHierarchy(classes[i].getInterfaces(), interphace)) {
|
||||
if (!classes[i].isInterface()) {
|
||||
throw new CloudRuntimeException(classes[i].getName() + " is not an interface");
|
||||
}
|
||||
if (classes[i].isAssignableFrom(info.clazz)) {
|
||||
info.keys.add(classes[i].getName());
|
||||
s_logger.info("Found component: " + interphace.getName() + " - " + clazzName + " - " + info.name);
|
||||
s_logger.info("Found component: " + classes[i].getName() + " in " + clazzName + " - " + info.name);
|
||||
} else {
|
||||
throw new CloudRuntimeException(classes[i].getName() + " is not implemented by " + info.clazz.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@ -752,6 +763,7 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
fillInfo(atts, Manager.class, info);
|
||||
s_logger.info("Adding Manager: " + info.name);
|
||||
for (String key : info.keys) {
|
||||
s_logger.info("Linking " + key + " to " + info.name);
|
||||
managers.put(key, info);
|
||||
}
|
||||
currentInfo = info;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user