mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Added code to start domR
This commit is contained in:
parent
04c8c0f91c
commit
794ca16a65
@ -6,9 +6,11 @@ package com.cloud.network;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.cloud.domain.PartOf;
|
||||
import com.cloud.network.Network.BroadcastDomainType;
|
||||
import com.cloud.network.Network.Mode;
|
||||
import com.cloud.network.Network.TrafficType;
|
||||
import com.cloud.user.OwnedBy;
|
||||
import com.cloud.utils.fsm.FiniteState;
|
||||
import com.cloud.utils.fsm.StateMachine;
|
||||
|
||||
@ -16,7 +18,7 @@ import com.cloud.utils.fsm.StateMachine;
|
||||
* A NetworkProfile defines the specifics of a network
|
||||
* owned by an account.
|
||||
*/
|
||||
public interface NetworkConfiguration {
|
||||
public interface NetworkConfiguration extends OwnedBy, PartOf {
|
||||
enum Event {
|
||||
ImplementNetwork,
|
||||
DestroyNetwork;
|
||||
|
||||
@ -27,8 +27,6 @@ public interface NetworkGuru extends Adapter {
|
||||
|
||||
NicProfile allocate(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
|
||||
|
||||
// NicProfile create(NicProfile nic, NetworkConfiguration config, VirtualMachineProfile vm, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
|
||||
|
||||
String reserve(NicProfile nic, NetworkConfiguration config, VirtualMachineProfile vm, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
|
||||
|
||||
boolean release(String uniqueId);
|
||||
|
||||
@ -5,6 +5,7 @@ package com.cloud.network.element;
|
||||
|
||||
import com.cloud.network.NetworkConfiguration;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.component.Adapter;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
@ -17,9 +18,9 @@ public interface NetworkElement extends Adapter {
|
||||
* Implement the network configuration as specified.
|
||||
* @param config fully specified network configuration.
|
||||
* @param offering network offering that originated the network configuration.
|
||||
* @return true if network configuration is now usable; false if not.
|
||||
* @return true if network configuration is now usable; false if not; null if not handled by this element.
|
||||
*/
|
||||
boolean implement(NetworkConfiguration config, NetworkOffering offering);
|
||||
Boolean implement(NetworkConfiguration config, NetworkOffering offering, Account user);
|
||||
|
||||
/**
|
||||
* Prepare the nic profile to be used within the network.
|
||||
@ -28,9 +29,9 @@ public interface NetworkElement extends Adapter {
|
||||
* @param offering
|
||||
* @return
|
||||
*/
|
||||
boolean prepare(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm, NetworkOffering offering);
|
||||
Boolean prepare(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm, NetworkOffering offering, Account user);
|
||||
|
||||
boolean release(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm, NetworkOffering offering);
|
||||
Boolean release(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm, NetworkOffering offering, Account user);
|
||||
|
||||
boolean shutdown(NetworkConfiguration config, NetworkOffering offering);
|
||||
Boolean shutdown(NetworkConfiguration config, NetworkOffering offering, Account user);
|
||||
}
|
||||
|
||||
@ -66,4 +66,5 @@ public interface ServiceOffering {
|
||||
* @return whether or not the service offering requires local storage
|
||||
*/
|
||||
boolean getUseLocalStorage();
|
||||
|
||||
}
|
||||
|
||||
@ -87,55 +87,6 @@ public class DomainRouterVO extends VMInstanceVO implements DomainRouter {
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Role role = Role.DHCP_FIREWALL_LB_PASSWD_USERDATA;
|
||||
|
||||
public DomainRouterVO(long id,
|
||||
long serviceOfferingId,
|
||||
String name,
|
||||
String instanceName,
|
||||
String privateMacAddress,
|
||||
String privateIpAddress,
|
||||
String privateNetmask,
|
||||
long templateId,
|
||||
long guestOSId,
|
||||
String guestMacAddress,
|
||||
String guestIpAddress,
|
||||
String guestNetmask,
|
||||
String vnet,
|
||||
long accountId,
|
||||
long domainId,
|
||||
String publicMacAddress,
|
||||
String publicIpAddress,
|
||||
String publicNetMask,
|
||||
Long vlanDbId,
|
||||
String vlanId,
|
||||
long podId,
|
||||
long dataCenterId,
|
||||
int ramSize,
|
||||
String gateway,
|
||||
String domain,
|
||||
Long hostId,
|
||||
String dns1,
|
||||
String dns2) {
|
||||
super(id, serviceOfferingId, name, instanceName, Type.DomainRouter, templateId, guestOSId, privateMacAddress, privateIpAddress, privateNetmask, dataCenterId, podId, domainId, accountId, true, hostId);
|
||||
this.privateMacAddress = privateMacAddress;
|
||||
this.guestMacAddress = guestMacAddress;
|
||||
this.guestIpAddress = guestIpAddress;
|
||||
this.publicIpAddress = publicIpAddress;
|
||||
this.publicMacAddress = publicMacAddress;
|
||||
this.publicNetmask = publicNetMask;
|
||||
this.vlanDbId = vlanDbId;
|
||||
this.vlanId = vlanId;
|
||||
this.ramSize = ramSize;
|
||||
this.gateway = gateway;
|
||||
this.domain = domain;
|
||||
this.dns1 = dns1;
|
||||
this.dns2 = dns2;
|
||||
this.dataCenterId = dataCenterId;
|
||||
this.vnet = vnet;
|
||||
this.accountId = accountId;
|
||||
this.domainId = domainId;
|
||||
this.guestNetmask = guestNetmask;
|
||||
}
|
||||
|
||||
public DomainRouterVO(long id,
|
||||
long serviceOfferingId,
|
||||
String name,
|
||||
@ -160,7 +111,24 @@ public class DomainRouterVO extends VMInstanceVO implements DomainRouter {
|
||||
String domain,
|
||||
String dns1,
|
||||
String dns2) {
|
||||
this(id, serviceOfferingId, name, name, privateMacAddress, privateIpAddress, privateNetmask, templateId, guestOSId, guestMacAddress, guestIpAddress, guestNetmask, null, accountId, domainId, publicMacAddress, publicIpAddress, publicNetMask, vlanDbId, vlanId, podId, dataCenterId, ramSize, gateway, domain, null, dns1, dns2);
|
||||
super(id, serviceOfferingId, name, name, Type.DomainRouter, templateId, guestOSId, privateMacAddress, privateIpAddress, privateNetmask, dataCenterId, podId, domainId, accountId, true, null);
|
||||
this.privateMacAddress = privateMacAddress;
|
||||
this.guestMacAddress = guestMacAddress;
|
||||
this.guestIpAddress = guestIpAddress;
|
||||
this.publicIpAddress = publicIpAddress;
|
||||
this.publicMacAddress = publicMacAddress;
|
||||
this.publicNetmask = publicNetMask;
|
||||
this.vlanDbId = vlanDbId;
|
||||
this.vlanId = vlanId;
|
||||
this.ramSize = ramSize;
|
||||
this.gateway = gateway;
|
||||
this.domain = domain;
|
||||
this.dns1 = dns1;
|
||||
this.dns2 = dns2;
|
||||
this.dataCenterId = dataCenterId;
|
||||
this.accountId = accountId;
|
||||
this.domainId = domainId;
|
||||
this.guestNetmask = guestNetmask;
|
||||
}
|
||||
|
||||
public DomainRouterVO(long id,
|
||||
@ -170,7 +138,6 @@ public class DomainRouterVO extends VMInstanceVO implements DomainRouter {
|
||||
long guestOSId,
|
||||
long domainId,
|
||||
long accountId,
|
||||
long networkConfigurationId,
|
||||
boolean haEnabled) {
|
||||
super(id, serviceOfferingId, name, name, Type.DomainRouter, templateId, guestOSId, domainId, accountId, haEnabled);
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ import com.google.gson.GsonBuilder;
|
||||
// because sooner or later, it will be driven into Running state
|
||||
//
|
||||
@Local(value = { ConsoleProxyManager.class })
|
||||
public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMachineManager<ConsoleProxyVO>, AgentHook, VirtualMachineGuru {
|
||||
public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMachineManager<ConsoleProxyVO>, AgentHook, VirtualMachineGuru<ConsoleProxyVO> {
|
||||
private static final Logger s_logger = Logger.getLogger(ConsoleProxyManagerImpl.class);
|
||||
|
||||
private static final int DEFAULT_FIND_HOST_RETRY_COUNT = 2;
|
||||
@ -540,7 +540,8 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
||||
public ConsoleProxyVO start2(long proxyVmId, long startEventId) throws StorageUnavailableException, InsufficientCapacityException, ConcurrentOperationException {
|
||||
ConsoleProxyVO proxy = _consoleProxyDao.findById(proxyVmId);
|
||||
DeploymentPlan plan = new DataCenterDeployment(proxy.getDataCenterId(), 1);
|
||||
return _vmMgr.start(proxy, plan, this);
|
||||
AccountVO systemAcct = _accountMgr.getSystemAccount();
|
||||
return _vmMgr.start(proxy, plan, systemAcct, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -24,13 +24,17 @@ public class NetworkAccountVO implements OwnedBy {
|
||||
|
||||
@Column(name="network_configuration_id")
|
||||
long networkConfigurationId;
|
||||
|
||||
@Column(name="is_owner")
|
||||
boolean owner;
|
||||
|
||||
protected NetworkAccountVO() {
|
||||
}
|
||||
|
||||
public NetworkAccountVO(long networkConfigurationId, long accountId) {
|
||||
public NetworkAccountVO(long networkConfigurationId, long accountId, boolean owner) {
|
||||
this.networkConfigurationId = networkConfigurationId;
|
||||
this.accountId = accountId;
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -41,5 +45,9 @@ public class NetworkAccountVO implements OwnedBy {
|
||||
public long getNetworkConfigurationId() {
|
||||
return networkConfigurationId;
|
||||
}
|
||||
|
||||
public boolean isOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -34,15 +34,17 @@ import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
|
||||
/**
|
||||
* NetworkProfileVO contains information about a specific network.
|
||||
* NetworkConfigurationVO contains information about a specific network.
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="network_configurations")
|
||||
public class NetworkConfigurationVO implements NetworkConfiguration {
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
Long id;
|
||||
@TableGenerator(name="network_configuration_sq", table="sequence", pkColumnName="name", valueColumnName="value", pkColumnValue="network_configuration_seq", allocationSize=1)
|
||||
@GeneratedValue(strategy=GenerationType.SEQUENCE)
|
||||
@Column(name="id")
|
||||
long id;
|
||||
|
||||
@Column(name="mode")
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
@ -71,6 +73,9 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
|
||||
@Column(name="data_center_id")
|
||||
long dataCenterId;
|
||||
|
||||
@Column(name="related")
|
||||
long related;
|
||||
|
||||
@Column(name="guru_name")
|
||||
String guruName;
|
||||
|
||||
@ -81,6 +86,12 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
|
||||
@Column(name="dns")
|
||||
String dns;
|
||||
|
||||
@Column(name="domain_id")
|
||||
long domainId;
|
||||
|
||||
@Column(name="account_id")
|
||||
long accountId;
|
||||
|
||||
@Column(name="mac_address_seq", updatable=false, nullable=false)
|
||||
@TableGenerator(name="mac_address_seq", table="network_configuration", pkColumnName="id", valueColumnName="mac_address_seq", allocationSize=1)
|
||||
long macAddress = 1;
|
||||
@ -88,12 +99,14 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
|
||||
public NetworkConfigurationVO() {
|
||||
}
|
||||
|
||||
public NetworkConfigurationVO(NetworkConfiguration that, long offeringId, long dataCenterId, String guruName) {
|
||||
this(that.getTrafficType(), that.getMode(), that.getBroadcastDomainType(), offeringId, dataCenterId);
|
||||
this.guruName = guruName;
|
||||
this.state = that.getState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor to be used for the adapters because it only initializes what's needed.
|
||||
* @param trafficType
|
||||
* @param mode
|
||||
* @param broadcastDomainType
|
||||
* @param networkOfferingId
|
||||
* @param dataCenterId
|
||||
*/
|
||||
public NetworkConfigurationVO(TrafficType trafficType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, long dataCenterId) {
|
||||
this.trafficType = trafficType;
|
||||
this.mode = mode;
|
||||
@ -103,6 +116,29 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
|
||||
this.state = State.Allocated;
|
||||
}
|
||||
|
||||
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.guruName = guruName;
|
||||
this.state = that.getState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for the actual DAO object.
|
||||
* @param trafficType
|
||||
* @param mode
|
||||
* @param broadcastDomainType
|
||||
* @param networkOfferingId
|
||||
* @param dataCenterId
|
||||
* @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);
|
||||
this.domainId = domainId;
|
||||
this.accountId = accountId;
|
||||
this.related = related;
|
||||
}
|
||||
|
||||
@Override
|
||||
public State getState() {
|
||||
return state;
|
||||
@ -111,6 +147,10 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
|
||||
public void setState(State state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public long getRelated() {
|
||||
return related;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getId() {
|
||||
@ -122,6 +162,16 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
|
||||
return mode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getNetworkOfferingId() {
|
||||
return networkOfferingId;
|
||||
|
||||
@ -53,6 +53,7 @@ import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
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;
|
||||
@ -177,7 +178,7 @@ public interface NetworkManager extends Manager {
|
||||
* @param so service offering associated with this request
|
||||
* @return public ip address.
|
||||
*/
|
||||
public String assignSourceNatIpAddress(AccountVO account, DataCenterVO dc, String domain, ServiceOfferingVO so, long startEventId, HypervisorType hyperType) throws ResourceAllocationException;
|
||||
public String assignSourceNatIpAddress(Account account, DataCenterVO dc, String domain, ServiceOfferingVO so, long startEventId, HypervisorType hyperType) throws ResourceAllocationException;
|
||||
|
||||
/**
|
||||
* @param fwRules list of rules to be updated
|
||||
@ -297,19 +298,22 @@ public interface NetworkManager extends Manager {
|
||||
|
||||
public boolean deleteIpForwardingRule(DeleteIPForwardingRuleCmd cmd) throws PermissionDeniedException, InvalidParameterValueException;
|
||||
|
||||
NetworkConfigurationVO setupNetworkConfiguration(AccountVO owner, NetworkOfferingVO offering, DeploymentPlan plan);
|
||||
NetworkConfigurationVO setupNetworkConfiguration(AccountVO owner, NetworkOfferingVO offering, NetworkConfiguration predefined, DeploymentPlan plan);
|
||||
List<NetworkConfigurationVO> setupNetworkConfigurations(AccountVO owner, List<NetworkOfferingVO> offerings, DeploymentPlan plan);
|
||||
NetworkConfigurationVO setupNetworkConfiguration(Account owner, NetworkOfferingVO offering, DeploymentPlan plan);
|
||||
NetworkConfigurationVO setupNetworkConfiguration(Account owner, NetworkOfferingVO offering, NetworkConfiguration predefined, DeploymentPlan plan);
|
||||
List<NetworkConfigurationVO> setupNetworkConfigurations(Account owner, List<NetworkOfferingVO> offerings, DeploymentPlan plan);
|
||||
|
||||
List<NetworkOfferingVO> getSystemAccountNetworkOfferings(String... offeringNames);
|
||||
|
||||
List<NicProfile> allocate(VirtualMachineProfile vm, List<Pair<NetworkConfigurationVO, NicProfile>> networks) throws InsufficientCapacityException;
|
||||
|
||||
NicTO[] prepare(VirtualMachineProfile profile, DeployDestination dest) throws InsufficientAddressCapacityException, InsufficientVirtualNetworkCapcityException;
|
||||
NicTO[] prepare(VirtualMachineProfile profile, DeployDestination dest, Account user) throws InsufficientAddressCapacityException, InsufficientVirtualNetworkCapcityException;
|
||||
void release(VirtualMachineProfile vmProfile);
|
||||
|
||||
<K extends VMInstanceVO> void create(K vm);
|
||||
|
||||
<K extends VMInstanceVO> List<NicVO> getNics(K vm);
|
||||
boolean upgradeRouter(UpgradeRouterCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
|
||||
|
||||
List<AccountVO> getAccountsUsingNetworkConfiguration(long configurationId);
|
||||
AccountVO getNetworkConfigurationOwner(long configurationId);
|
||||
|
||||
List<NetworkConfigurationVO> getNetworkConfigurationsforOffering(long offeringId, long dataCenterId, long accountId);
|
||||
}
|
||||
|
||||
@ -136,6 +136,7 @@ import com.cloud.utils.component.Adapters;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.db.DB;
|
||||
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;
|
||||
@ -197,7 +198,7 @@ public class NetworkManagerImpl implements NetworkManager {
|
||||
@Inject AccountVlanMapDao _accountVlanMapDao;
|
||||
@Inject UserStatisticsDao _statsDao = null;
|
||||
@Inject NetworkOfferingDao _networkOfferingDao = null;
|
||||
@Inject NetworkConfigurationDao _networkProfileDao = null;
|
||||
@Inject NetworkConfigurationDao _networkConfigDao = null;
|
||||
@Inject NicDao _nicDao;
|
||||
@Inject GuestOSDao _guestOSDao = null;
|
||||
@Inject DomainRouterManager _routerMgr;
|
||||
@ -210,6 +211,8 @@ public class NetworkManagerImpl implements NetworkManager {
|
||||
private HashMap<String, NetworkOfferingVO> _systemNetworks = new HashMap<String, NetworkOfferingVO>(5);
|
||||
|
||||
ScheduledExecutorService _executor;
|
||||
|
||||
SearchBuilder<AccountVO> AccountsUsingNetworkConfigurationSearch;
|
||||
|
||||
@Override
|
||||
public boolean sendSshKeysToHost(Long hostId, String pubKey, String prvKey) {
|
||||
@ -217,7 +220,7 @@ public class NetworkManagerImpl implements NetworkManager {
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
public String assignSourceNatIpAddress(AccountVO account, final DataCenterVO dc, final String domain, final ServiceOfferingVO serviceOffering, long startEventId, HypervisorType hyperType) throws ResourceAllocationException {
|
||||
public String assignSourceNatIpAddress(Account account, final DataCenterVO dc, final String domain, final ServiceOfferingVO serviceOffering, long startEventId, HypervisorType hyperType) throws ResourceAllocationException {
|
||||
if (serviceOffering.getGuestIpType() == NetworkOffering.GuestIpType.DirectDual || serviceOffering.getGuestIpType() == NetworkOffering.GuestIpType.DirectSingle) {
|
||||
return null;
|
||||
}
|
||||
@ -525,7 +528,7 @@ public class NetworkManagerImpl implements NetworkManager {
|
||||
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
AccountVO accountToLock = null;
|
||||
Account accountToLock = null;
|
||||
try {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Associate IP address called for user " + userId + " account " + accountId);
|
||||
@ -1496,6 +1499,13 @@ public class NetworkManagerImpl implements NetworkManager {
|
||||
storageNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(storageNetworkOffering);
|
||||
_systemNetworks.put(NetworkOfferingVO.SystemVmGuestNetwork, storageNetworkOffering);
|
||||
|
||||
AccountsUsingNetworkConfigurationSearch = _accountDao.createSearchBuilder();
|
||||
SearchBuilder<NetworkAccountVO> networkAccountSearch = _networkConfigDao.createSearchBuilderForAccount();
|
||||
AccountsUsingNetworkConfigurationSearch.join("nc", networkAccountSearch, AccountsUsingNetworkConfigurationSearch.entity().getId(), networkAccountSearch.entity().getAccountId(), JoinType.INNER);
|
||||
networkAccountSearch.and("config", networkAccountSearch.entity().getNetworkConfigurationId(), SearchCriteria.Op.EQ);
|
||||
networkAccountSearch.and("owner", networkAccountSearch.entity().isOwner(), SearchCriteria.Op.EQ);
|
||||
AccountsUsingNetworkConfigurationSearch.done();
|
||||
|
||||
s_logger.info("Network Manager is configured.");
|
||||
|
||||
return true;
|
||||
@ -1566,13 +1576,13 @@ public class NetworkManagerImpl implements NetworkManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkConfigurationVO setupNetworkConfiguration(AccountVO owner, NetworkOfferingVO offering, DeploymentPlan plan) {
|
||||
public NetworkConfigurationVO setupNetworkConfiguration(Account owner, NetworkOfferingVO offering, DeploymentPlan plan) {
|
||||
return setupNetworkConfiguration(owner, offering, null, plan);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkConfigurationVO setupNetworkConfiguration(AccountVO owner, NetworkOfferingVO offering, NetworkConfiguration predefined, DeploymentPlan plan) {
|
||||
List<NetworkConfigurationVO> configs = _networkProfileDao.listBy(owner.getId(), offering.getId(), plan.getDataCenterId());
|
||||
public NetworkConfigurationVO setupNetworkConfiguration(Account owner, NetworkOfferingVO offering, NetworkConfiguration predefined, DeploymentPlan plan) {
|
||||
List<NetworkConfigurationVO> configs = _networkConfigDao.listBy(owner.getId(), offering.getId(), plan.getDataCenterId());
|
||||
if (configs.size() > 0) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Found existing network configuration for offering " + offering + ": " + configs.get(0));
|
||||
@ -1580,6 +1590,9 @@ public class NetworkManagerImpl implements NetworkManager {
|
||||
return configs.get(0);
|
||||
}
|
||||
|
||||
long id = _networkConfigDao.getNextInSequence(Long.class, "id");
|
||||
long related = id;
|
||||
|
||||
for (NetworkGuru guru : _networkGurus) {
|
||||
NetworkConfiguration config = guru.design(offering, plan, predefined, owner);
|
||||
if (config == null) {
|
||||
@ -1590,19 +1603,19 @@ public class NetworkManagerImpl implements NetworkManager {
|
||||
if (config instanceof NetworkConfigurationVO) {
|
||||
return (NetworkConfigurationVO)config;
|
||||
} else {
|
||||
return _networkProfileDao.findById(config.getId());
|
||||
return _networkConfigDao.findById(config.getId());
|
||||
}
|
||||
}
|
||||
|
||||
NetworkConfigurationVO vo = new NetworkConfigurationVO(config, offering.getId(), plan.getDataCenterId(), guru.getName());
|
||||
return _networkProfileDao.persist(vo, owner.getId());
|
||||
NetworkConfigurationVO vo = new NetworkConfigurationVO(id, config, offering.getId(), plan.getDataCenterId(), guru.getName(), owner.getDomainId(), owner.getId(), related);
|
||||
return _networkConfigDao.persist(vo);
|
||||
}
|
||||
|
||||
throw new CloudRuntimeException("Unable to convert network offering to network profile: " + offering.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NetworkConfigurationVO> setupNetworkConfigurations(AccountVO owner, List<NetworkOfferingVO> offerings, DeploymentPlan plan) {
|
||||
public List<NetworkConfigurationVO> setupNetworkConfigurations(Account owner, List<NetworkOfferingVO> offerings, DeploymentPlan plan) {
|
||||
List<NetworkConfigurationVO> profiles = new ArrayList<NetworkConfigurationVO>(offerings.size());
|
||||
for (NetworkOfferingVO offering : offerings) {
|
||||
profiles.add(setupNetworkConfiguration(owner, offering, plan));
|
||||
@ -1623,7 +1636,7 @@ public class NetworkManagerImpl implements NetworkManager {
|
||||
return offerings;
|
||||
}
|
||||
|
||||
public NetworkConfigurationVO createNetworkConfiguration(NetworkOfferingVO offering, DeploymentPlan plan, AccountVO owner) {
|
||||
public NetworkConfigurationVO createNetworkConfiguration(NetworkOfferingVO offering, DeploymentPlan plan, Account owner) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -1750,12 +1763,12 @@ public class NetworkManagerImpl implements NetworkManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NicTO[] prepare(VirtualMachineProfile vmProfile, DeployDestination dest) throws InsufficientAddressCapacityException, InsufficientVirtualNetworkCapcityException {
|
||||
public NicTO[] prepare(VirtualMachineProfile vmProfile, DeployDestination dest, Account user) throws InsufficientAddressCapacityException, InsufficientVirtualNetworkCapcityException {
|
||||
List<NicVO> nics = _nicDao.listBy(vmProfile.getId());
|
||||
NicTO[] nicTos = new NicTO[nics.size()];
|
||||
int i = 0;
|
||||
for (NicVO nic : nics) {
|
||||
NetworkConfigurationVO config = _networkProfileDao.findById(nic.getNetworkConfigurationId());
|
||||
NetworkConfigurationVO config = _networkConfigDao.findById(nic.getNetworkConfigurationId());
|
||||
NicProfile profile = null;
|
||||
if (nic.getReservationStrategy() == ReservationStrategy.Start) {
|
||||
NetworkGuru concierge = _networkGurus.get(config.getGuruName());
|
||||
@ -1776,7 +1789,7 @@ public class NetworkManagerImpl implements NetworkManager {
|
||||
nic.setAddressFormat(profile.getFormat());
|
||||
_nicDao.update(nic.getId(), nic);
|
||||
for (NetworkElement element : _networkElements) {
|
||||
if (!element.prepare(config, profile, vmProfile, null)) {
|
||||
if (!element.prepare(config, profile, vmProfile, null, user)) {
|
||||
s_logger.warn("Unable to prepare " + nic + " for element " + element.getName());
|
||||
return null;
|
||||
}
|
||||
@ -1793,7 +1806,7 @@ public class NetworkManagerImpl implements NetworkManager {
|
||||
public void release(VirtualMachineProfile vmProfile) {
|
||||
List<NicVO> nics = _nicDao.listBy(vmProfile.getId());
|
||||
for (NicVO nic : nics) {
|
||||
NetworkConfigurationVO config = _networkProfileDao.findById(nic.getNetworkConfigurationId());
|
||||
NetworkConfigurationVO config = _networkConfigDao.findById(nic.getNetworkConfigurationId());
|
||||
if (nic.getReservationStrategy() == ReservationStrategy.Start) {
|
||||
NetworkGuru concierge = _networkGurus.get(config.getGuruName());
|
||||
nic.setState(Resource.State.Releasing);
|
||||
@ -1804,7 +1817,7 @@ public class NetworkManagerImpl implements NetworkManager {
|
||||
}
|
||||
|
||||
NicProfile toNicProfile(NicVO nic) {
|
||||
NetworkConfiguration config = _networkProfileDao.findById(nic.getNetworkConfigurationId());
|
||||
NetworkConfiguration config = _networkConfigDao.findById(nic.getNetworkConfigurationId());
|
||||
NicProfile profile = new NicProfile(nic, config, nic.getBroadcastUri(), nic.getIsolationUri());
|
||||
return profile;
|
||||
}
|
||||
@ -1824,10 +1837,6 @@ public class NetworkManagerImpl implements NetworkManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <K extends VMInstanceVO> void create(K vm) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <K extends VMInstanceVO> List<NicVO> getNics(K vm) {
|
||||
return _nicDao.listBy(vm.getId());
|
||||
@ -2275,14 +2284,14 @@ public class NetworkManagerImpl implements NetworkManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
AccountVO accountVO = _accountDao.findById(accountId);
|
||||
if (accountVO == null) {
|
||||
Account Account = _accountDao.findById(accountId);
|
||||
if (Account == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((ipVO.getAccountId() == null) || (ipVO.getAccountId().longValue() != accountId)) {
|
||||
// FIXME: is the user visible in the admin account's domain????
|
||||
if (!BaseCmd.isAdmin(accountVO.getType())) {
|
||||
if (!BaseCmd.isAdmin(Account.getType())) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("permission denied disassociating IP address " + ipAddress + "; acct: " + accountId + "; ip (acct / dc / dom / alloc): "
|
||||
+ ipVO.getAccountId() + " / " + ipVO.getDataCenterId() + " / " + ipVO.getDomainId() + " / " + ipVO.getAllocated());
|
||||
@ -2433,5 +2442,25 @@ public class NetworkManagerImpl implements NetworkManager {
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<AccountVO> getAccountsUsingNetworkConfiguration(long configurationId) {
|
||||
SearchCriteria<AccountVO> sc = AccountsUsingNetworkConfigurationSearch.create();
|
||||
sc.setJoinParameters("nc", "config", configurationId);
|
||||
return _accountDao.search(sc, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccountVO getNetworkConfigurationOwner(long configurationId) {
|
||||
SearchCriteria<AccountVO> sc = AccountsUsingNetworkConfigurationSearch.create();
|
||||
sc.setJoinParameters("nc", "config", configurationId);
|
||||
sc.setJoinParameters("nc", "owner", true);
|
||||
List<AccountVO> accounts = _accountDao.search(sc, null);
|
||||
return accounts.size() != 0 ? accounts.get(0) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NetworkConfigurationVO> getNetworkConfigurationsforOffering(long offeringId, long dataCenterId, long accountId) {
|
||||
return _networkConfigDao.getNetworkConfigurationsForOffering(offeringId, dataCenterId, accountId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,12 +19,17 @@ package com.cloud.network.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.network.NetworkAccountVO;
|
||||
import com.cloud.network.NetworkConfigurationVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
|
||||
public interface NetworkConfigurationDao extends GenericDao<NetworkConfigurationVO, Long> {
|
||||
List<NetworkConfigurationVO> listBy(long accountId);
|
||||
List<NetworkConfigurationVO> listBy(long accountId, long offeringId, long dataCenterId);
|
||||
NetworkConfigurationVO persist(NetworkConfigurationVO config, long accountId);
|
||||
@Override
|
||||
NetworkConfigurationVO persist(NetworkConfigurationVO config);
|
||||
void addAccountToNetworkConfiguration(long configId, long accountId);
|
||||
SearchBuilder<NetworkAccountVO> createSearchBuilderForAccount();
|
||||
List<NetworkConfigurationVO> getNetworkConfigurationsForOffering(long offeringId, long dataCenterId, long accountId);
|
||||
}
|
||||
|
||||
@ -30,6 +30,7 @@ import com.cloud.network.NetworkConfigurationVO;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
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;
|
||||
@ -39,6 +40,7 @@ public class NetworkConfigurationDaoImpl extends GenericDaoBase<NetworkConfigura
|
||||
final SearchBuilder<NetworkConfigurationVO> ProfileSearch;
|
||||
final SearchBuilder<NetworkConfigurationVO> AccountSearch;
|
||||
final SearchBuilder<NetworkConfigurationVO> OfferingSearch;
|
||||
final SearchBuilder<NetworkConfigurationVO> RelatedConfigSearch;
|
||||
|
||||
NetworkAccountDaoImpl _accountsDao = new NetworkAccountDaoImpl();
|
||||
|
||||
@ -64,6 +66,14 @@ public class NetworkConfigurationDaoImpl extends GenericDaoBase<NetworkConfigura
|
||||
OfferingSearch = createSearchBuilder();
|
||||
OfferingSearch.and("offering", OfferingSearch.entity().getNetworkOfferingId(), SearchCriteria.Op.EQ);
|
||||
OfferingSearch.and("datacenter", OfferingSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
|
||||
RelatedConfigSearch = createSearchBuilder();
|
||||
RelatedConfigSearch.and("offering", RelatedConfigSearch.entity().getNetworkOfferingId(), SearchCriteria.Op.EQ);
|
||||
RelatedConfigSearch.and("datacenter", RelatedConfigSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
SearchBuilder<NetworkAccountVO> join2 = _accountsDao.createSearchBuilder();
|
||||
join2.and("account", join2.entity().getAccountId(), SearchCriteria.Op.EQ);
|
||||
RelatedConfigSearch.join("account", join2, join2.entity().getNetworkConfigurationId(), RelatedConfigSearch.entity().getId(), JoinType.INNER);
|
||||
RelatedConfigSearch.done();
|
||||
}
|
||||
|
||||
public List<NetworkConfigurationVO> findBy(TrafficType trafficType, Mode mode, BroadcastDomainType broadcastType, long networkOfferingId, long dataCenterId) {
|
||||
@ -95,24 +105,37 @@ public class NetworkConfigurationDaoImpl extends GenericDaoBase<NetworkConfigura
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkConfigurationVO persist(NetworkConfigurationVO config) {
|
||||
throw new UnsupportedOperationException("Use the persist for NetworkConfigurationDao");
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
public NetworkConfigurationVO persist(NetworkConfigurationVO config, long accountId) {
|
||||
public NetworkConfigurationVO persist(NetworkConfigurationVO config) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
config = super.persist(config);
|
||||
addAccountToNetworkConfiguration(config.getId(), accountId);
|
||||
addAccountToNetworkConfiguration(config.getId(), config.getAccountId(), true);
|
||||
txn.commit();
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAccountToNetworkConfiguration(long configurationId, long accountId) {
|
||||
NetworkAccountVO account = new NetworkAccountVO(configurationId, accountId);
|
||||
addAccountToNetworkConfiguration(configurationId, accountId, false);
|
||||
}
|
||||
|
||||
protected void addAccountToNetworkConfiguration(long configurationId, long accountId, boolean isOwner) {
|
||||
NetworkAccountVO account = new NetworkAccountVO(configurationId, accountId, isOwner);
|
||||
_accountsDao.persist(account);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearchBuilder<NetworkAccountVO> createSearchBuilderForAccount() {
|
||||
return _accountsDao.createSearchBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NetworkConfigurationVO> getNetworkConfigurationsForOffering(long offeringId, long dataCenterId, long accountId) {
|
||||
SearchCriteria<NetworkConfigurationVO> sc = RelatedConfigSearch.create();
|
||||
sc.setParameters("offering", offeringId);
|
||||
sc.setParameters("dc", dataCenterId);
|
||||
sc.setJoinParameters("account", "account", accountId);
|
||||
return search(sc, null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,38 +17,64 @@
|
||||
*/
|
||||
package com.cloud.network.element;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.network.NetworkConfiguration;
|
||||
import com.cloud.network.NetworkConfiguration.State;
|
||||
import com.cloud.network.NetworkConfigurationVO;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
|
||||
|
||||
@Local(value=NetworkElement.class)
|
||||
public class DomainRouterElement extends AdapterBase implements NetworkElement {
|
||||
private static final Logger s_logger = Logger.getLogger(DomainRouterElement.class);
|
||||
|
||||
@Inject NetworkManager _networkMgr;
|
||||
|
||||
@Override
|
||||
public boolean implement(NetworkConfiguration config, NetworkOffering offering) {
|
||||
public Boolean implement(NetworkConfiguration config, NetworkOffering offering, Account user) {
|
||||
if (offering.getGuestIpType() != GuestIpType.Virtualized) {
|
||||
s_logger.trace("Not handling guest ip type = " + offering.getGuestIpType());
|
||||
return null;
|
||||
}
|
||||
|
||||
List<NetworkConfigurationVO> configs = _networkMgr.getNetworkConfigurationsforOffering(offering.getId(), config.getDataCenterId(), user.getId());
|
||||
for (NetworkConfigurationVO c : configs) {
|
||||
if (c.getState() != State.Implemented && c.getState() != State.Setup) {
|
||||
s_logger.debug("Not all network is ready to be implemented yet.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean prepare(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm, NetworkOffering offering, Account user) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean prepare(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm, NetworkOffering offering) {
|
||||
public Boolean release(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm, NetworkOffering offering, Account user) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean release(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm, NetworkOffering offering) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shutdown(NetworkConfiguration config, NetworkOffering offering) {
|
||||
public Boolean shutdown(NetworkConfiguration config, NetworkOffering offering, Account user) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -46,12 +46,16 @@ import com.cloud.agent.api.NetworkUsageCommand;
|
||||
import com.cloud.agent.api.PrepareForMigrationCommand;
|
||||
import com.cloud.agent.api.RebootAnswer;
|
||||
import com.cloud.agent.api.RebootRouterCommand;
|
||||
import com.cloud.agent.api.Start2Command;
|
||||
import com.cloud.agent.api.StartRouterAnswer;
|
||||
import com.cloud.agent.api.StartRouterCommand;
|
||||
import com.cloud.agent.api.StopCommand;
|
||||
import com.cloud.agent.api.routing.DhcpEntryCommand;
|
||||
import com.cloud.agent.api.routing.SavePasswordCommand;
|
||||
import com.cloud.agent.api.routing.VmDataCommand;
|
||||
import com.cloud.agent.api.to.NicTO;
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
import com.cloud.agent.api.to.VirtualMachineTO.SshMonitor;
|
||||
import com.cloud.agent.manager.Commands;
|
||||
import com.cloud.alert.AlertManager;
|
||||
import com.cloud.api.commands.RebootRouterCmd;
|
||||
@ -76,6 +80,8 @@ import com.cloud.dc.dao.AccountVlanMapDao;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.dc.dao.HostPodDao;
|
||||
import com.cloud.dc.dao.VlanDao;
|
||||
import com.cloud.deploy.DataCenterDeployment;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.domain.DomainVO;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
import com.cloud.event.EventState;
|
||||
@ -85,6 +91,7 @@ import com.cloud.event.EventVO;
|
||||
import com.cloud.event.dao.EventDao;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
@ -96,6 +103,9 @@ import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.FirewallRuleVO;
|
||||
import com.cloud.network.IPAddressVO;
|
||||
import com.cloud.network.Network.TrafficType;
|
||||
import com.cloud.network.NetworkConfiguration;
|
||||
import com.cloud.network.NetworkConfigurationVO;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.SshKeysDistriMonitor;
|
||||
import com.cloud.network.dao.FirewallRulesDao;
|
||||
@ -107,6 +117,7 @@ import com.cloud.network.dao.NetworkRuleConfigDao;
|
||||
import com.cloud.network.dao.SecurityGroupDao;
|
||||
import com.cloud.network.dao.SecurityGroupVMMapDao;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
@ -143,12 +154,16 @@ import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.vm.DomainRouter;
|
||||
import com.cloud.vm.DomainRouter.Role;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.State;
|
||||
import com.cloud.vm.UserVmVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.Event;
|
||||
import com.cloud.vm.VirtualMachineGuru;
|
||||
import com.cloud.vm.VirtualMachineManager;
|
||||
import com.cloud.vm.VirtualMachineName;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
import com.cloud.vm.VmManager;
|
||||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
import com.cloud.vm.dao.NicDao;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
@ -157,7 +172,7 @@ import com.cloud.vm.dao.UserVmDao;
|
||||
* NetworkManagerImpl implements NetworkManager.
|
||||
*/
|
||||
@Local(value={DomainRouterManager.class})
|
||||
public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMachineManager<DomainRouterVO> {
|
||||
public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMachineManager<DomainRouterVO>, VirtualMachineGuru<DomainRouterVO> {
|
||||
private static final Logger s_logger = Logger.getLogger(DomainRouterManagerImpl.class);
|
||||
|
||||
String _name;
|
||||
@ -204,6 +219,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
||||
@Inject NicDao _nicDao;
|
||||
@Inject GuestOSDao _guestOSDao = null;
|
||||
@Inject NetworkManager _networkMgr;
|
||||
@Inject VmManager _vmMgr;
|
||||
|
||||
long _routerTemplateId = -1;
|
||||
int _routerRamSize;
|
||||
@ -220,6 +236,8 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
||||
private VMTemplateVO _template;
|
||||
|
||||
ScheduledExecutorService _executor;
|
||||
|
||||
AccountVO _systemAcct;
|
||||
|
||||
@Override
|
||||
public DomainRouterVO getRouter(long accountId, long dataCenterId) {
|
||||
@ -1414,6 +1432,8 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
||||
_routerTemplateId = _template.getId();
|
||||
}
|
||||
|
||||
_systemAcct = _accountMgr.getSystemAccount();
|
||||
|
||||
s_logger.info("DomainRouterManager is configured.");
|
||||
|
||||
return true;
|
||||
@ -1936,5 +1956,255 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
||||
(accountType == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) ||
|
||||
(accountType == Account.ACCOUNT_TYPE_READ_ONLY_ADMIN));
|
||||
}
|
||||
|
||||
public DomainRouterVO deploy(NetworkConfiguration publicConfig, NetworkConfiguration virtualConfig, NetworkOffering offering, Account owner) throws InsufficientCapacityException, StorageUnavailableException, ConcurrentOperationException {
|
||||
long dcId = publicConfig.getDataCenterId();
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Creating a router for network configurations: public=" + publicConfig + "; virtual=" + virtualConfig);
|
||||
}
|
||||
assert dcId == virtualConfig.getDataCenterId() : "Domain router cannot span networks in two data centers";
|
||||
assert publicConfig.getState() == NetworkConfiguration.State.Implemented : "Network is not yet fully implemented: " + publicConfig;
|
||||
assert virtualConfig.getState() == NetworkConfiguration.State.Implemented : "Network is not yet fully implemented: " + virtualConfig;
|
||||
|
||||
DataCenterDeployment plan = new DataCenterDeployment(dcId, 1);
|
||||
List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmControlNetwork);
|
||||
|
||||
NetworkOfferingVO controlOffering = offerings.get(0);
|
||||
NetworkConfigurationVO controlConfig = _networkMgr.setupNetworkConfiguration(_systemAcct, controlOffering, plan);
|
||||
|
||||
long id = _routerDao.getNextInSequence(Long.class, "id");
|
||||
DomainRouterVO router = new DomainRouterVO(id, _offering.getId(), VirtualMachineName.getRouterName(id, _instance), _template.getId(), _template.getGuestOSId(), owner.getDomainId(), owner.getId(), _offering.getOfferHA());
|
||||
_routerDao.persist(router);
|
||||
|
||||
List<Pair<NetworkConfigurationVO, NicProfile>> networks = new ArrayList<Pair<NetworkConfigurationVO, NicProfile>>(3);
|
||||
NicProfile defaultNic = new NicProfile();
|
||||
defaultNic.setDefaultNic(true);
|
||||
defaultNic.setDeviceId(2);
|
||||
networks.add(new Pair<NetworkConfigurationVO, NicProfile>((NetworkConfigurationVO)publicConfig, defaultNic));
|
||||
networks.add(new Pair<NetworkConfigurationVO, NicProfile>((NetworkConfigurationVO)virtualConfig, null));
|
||||
networks.add(new Pair<NetworkConfigurationVO, NicProfile>(controlConfig, null));
|
||||
|
||||
_vmMgr.allocate(router, _template, _offering, networks, plan, owner);
|
||||
router = _vmMgr.start(router, plan, owner, this);
|
||||
|
||||
return router;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean finalizeDeployment(Commands cmds, VirtualMachineProfile profile, DeployDestination dest) {
|
||||
Start2Command cmd = cmds.getCommand(Start2Command.class);
|
||||
VirtualMachineTO vm = cmd.getVirtualMachine();
|
||||
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(" template=domP type=router");
|
||||
buf.append(" name=").append(vm.getName());
|
||||
NicTO controlNic = null;
|
||||
for (NicTO nic : vm.getNics()) {
|
||||
int deviceId = nic.getDeviceId();
|
||||
buf.append(" eth").append(deviceId).append("ip=").append(nic.getIp());
|
||||
buf.append(" eth").append(deviceId).append("mask=").append(nic.getNetmask());
|
||||
if (nic.isDefaultNic()) {
|
||||
buf.append(" gateway=").append(nic.getGateway());
|
||||
buf.append(" dns1=").append(nic.getDns1());
|
||||
if (nic.getDns2() != null) {
|
||||
buf.append(" dns2=").append(nic.getDns2());
|
||||
}
|
||||
}
|
||||
if (nic.getType() == TrafficType.Management) {
|
||||
buf.append(" localgw=").append(dest.getPod().getGateway());
|
||||
} else if (nic.getType() == TrafficType.Control) {
|
||||
controlNic = nic;
|
||||
}
|
||||
}
|
||||
|
||||
String bootArgs = buf.toString();
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Boot Args for " + vm + ": " + bootArgs);
|
||||
}
|
||||
vm.setBootArgs(bootArgs);
|
||||
|
||||
if (controlNic == null) {
|
||||
throw new CloudRuntimeException("Didn't start a control port");
|
||||
}
|
||||
|
||||
SshMonitor monitor = new SshMonitor(controlNic.getIp(), 3922);
|
||||
vm.setMonitor(monitor);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkDeploymentResult(Commands cmds, VirtualMachineProfile profile, DeployDestination dest) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// if (s_logger.isDebugEnabled()) {
|
||||
// s_logger.debug("Creating a router for account=" + accountId + "; publicIpAddress=" + publicIpAddress + "; dc=" + dataCenterId + "domain=" + domain);
|
||||
// }
|
||||
//
|
||||
// final AccountVO account = _accountDao.acquire(accountId);
|
||||
// if (account == null) {
|
||||
// throw new ConcurrentOperationException("Unable to acquire account " + accountId);
|
||||
// }
|
||||
//
|
||||
// if(s_logger.isDebugEnabled())
|
||||
// s_logger.debug("lock on account " + accountId + " for createRouter is acquired");
|
||||
//
|
||||
// final Transaction txn = Transaction.currentTxn();
|
||||
// DomainRouterVO router = null;
|
||||
// boolean success = false;
|
||||
// try {
|
||||
// router = _routerDao.findBy(accountId, dataCenterId);
|
||||
// if (router != null && router.getState() != State.Creating) {
|
||||
// if (s_logger.isDebugEnabled()) {
|
||||
// s_logger.debug("Router " + router.toString() + " found for account " + accountId + " in data center " + dataCenterId);
|
||||
// }
|
||||
// success = true;
|
||||
// return router;
|
||||
// }
|
||||
// EventVO event = new EventVO();
|
||||
// event.setUserId(1L);
|
||||
// event.setAccountId(accountId);
|
||||
// event.setType(EventTypes.EVENT_ROUTER_CREATE);
|
||||
// event.setState(EventState.Started);
|
||||
// event.setStartId(startEventId);
|
||||
// event.setDescription("Creating Router for account with Id: "+accountId);
|
||||
// event = _eventDao.persist(event);
|
||||
//
|
||||
// final DataCenterVO dc = _dcDao.findById(dataCenterId);
|
||||
// final VMTemplateVO template = _templateDao.findRoutingTemplate();
|
||||
//
|
||||
// String[] macAddresses = getMacAddressPair(dataCenterId);
|
||||
// String privateMacAddress = macAddresses[0];
|
||||
// String publicMacAddress = macAddresses[1];
|
||||
//
|
||||
// final long id = _routerDao.getNextInSequence(Long.class, "id");
|
||||
//
|
||||
// if (domain == null) {
|
||||
// domain = "v" + Long.toHexString(accountId) + "." + _domain;
|
||||
// }
|
||||
//
|
||||
// final String name = VirtualMachineName.getRouterName(id, _instance).intern();
|
||||
// long routerMacAddress = NetUtils.mac2Long(dc.getRouterMacAddress()) | ((dc.getId() & 0xff) << 32);
|
||||
//
|
||||
// //set the guestNetworkCidr from the dc obj
|
||||
// String guestNetworkCidr = dc.getGuestNetworkCidr();
|
||||
// String[] cidrTuple = guestNetworkCidr.split("\\/");
|
||||
// String guestIpAddress = NetUtils.getIpRangeStartIpFromCidr(cidrTuple[0], Long.parseLong(cidrTuple[1]));
|
||||
// String guestNetmask = NetUtils.getCidrNetmask(Long.parseLong(cidrTuple[1]));
|
||||
//
|
||||
//// String path = null;
|
||||
//// final int numVolumes = offering.isMirroredVolumes()?2:1;
|
||||
//// long routerId = 0;
|
||||
//
|
||||
// // Find the VLAN ID, VLAN gateway, and VLAN netmask for publicIpAddress
|
||||
// IPAddressVO ipVO = _ipAddressDao.findById(publicIpAddress);
|
||||
// VlanVO vlan = _vlanDao.findById(ipVO.getVlanDbId());
|
||||
// String vlanId = vlan.getVlanId();
|
||||
// String vlanGateway = vlan.getVlanGateway();
|
||||
// String vlanNetmask = vlan.getVlanNetmask();
|
||||
//
|
||||
// Pair<HostPodVO, Long> pod = null;
|
||||
// Set<Long> avoids = new HashSet<Long>();
|
||||
// boolean found = false;
|
||||
// while ((pod = _agentMgr.findPod(template, offering, dc, accountId, avoids)) != null) {
|
||||
//
|
||||
// if (s_logger.isDebugEnabled()) {
|
||||
// s_logger.debug("Attempting to create in pod " + pod.first().getName());
|
||||
// }
|
||||
//
|
||||
// router = new DomainRouterVO(id,
|
||||
// _offering.getId(),
|
||||
// name,
|
||||
// privateMacAddress,
|
||||
// null,
|
||||
// null,
|
||||
// _routerTemplateId,
|
||||
// template.getGuestOSId(),
|
||||
// NetUtils.long2Mac(routerMacAddress),
|
||||
// guestIpAddress,
|
||||
// guestNetmask,
|
||||
// accountId,
|
||||
// account.getDomainId(),
|
||||
// publicMacAddress,
|
||||
// publicIpAddress,
|
||||
// vlanNetmask,
|
||||
// vlan.getId(),
|
||||
// vlanId,
|
||||
// pod.first().getId(),
|
||||
// dataCenterId,
|
||||
// _routerRamSize,
|
||||
// vlanGateway,
|
||||
// domain,
|
||||
// dc.getDns1(),
|
||||
// dc.getDns2());
|
||||
// router.setMirroredVols(offering.isMirrored());
|
||||
//
|
||||
// router.setLastHostId(pod.second());
|
||||
// router = _routerDao.persist(router);
|
||||
//
|
||||
// List<VolumeVO> vols = _storageMgr.create(account, router, template, dc, pod.first(), _offering, null,0);
|
||||
// if(vols != null) {
|
||||
// found = true;
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// _routerDao.expunge(router.getId());
|
||||
// if (s_logger.isDebugEnabled()) {
|
||||
// s_logger.debug("Unable to find storage host or pool in pod " + pod.first().getName() + " (id:" + pod.first().getId() + "), checking other pods");
|
||||
// }
|
||||
// avoids.add(pod.first().getId());
|
||||
// }
|
||||
//
|
||||
// if (!found) {
|
||||
// event.setDescription("failed to create Domain Router : " + name);
|
||||
// event.setLevel(EventVO.LEVEL_ERROR);
|
||||
// _eventDao.persist(event);
|
||||
// throw new ExecutionException("Unable to create DomainRouter");
|
||||
// }
|
||||
// _routerDao.updateIf(router, Event.OperationSucceeded, null);
|
||||
//
|
||||
// s_logger.debug("Router created: id=" + router.getId() + "; name=" + router.getName());
|
||||
//
|
||||
// event = new EventVO();
|
||||
// event.setUserId(1L); // system user performed the action
|
||||
// event.setAccountId(accountId);
|
||||
// event.setType(EventTypes.EVENT_ROUTER_CREATE);
|
||||
// event.setStartId(startEventId);
|
||||
// event.setDescription("successfully created Domain Router : " + router.getName() + " with ip : " + publicIpAddress);
|
||||
// _eventDao.persist(event);
|
||||
// success = true;
|
||||
// return router;
|
||||
// } catch (final Throwable th) {
|
||||
// if (th instanceof ExecutionException) {
|
||||
// s_logger.error("Error while starting router due to " + th.getMessage());
|
||||
// } else {
|
||||
// s_logger.error("Unable to create router", th);
|
||||
// }
|
||||
// txn.rollback();
|
||||
//
|
||||
// if (router != null && router.getState() == State.Creating) {
|
||||
// _routerDao.expunge(router.getId());
|
||||
// }
|
||||
// return null;
|
||||
// } finally {
|
||||
// if (account != null) {
|
||||
// if(s_logger.isDebugEnabled())
|
||||
// s_logger.debug("Releasing lock on account " + account.getId() + " for createRouter");
|
||||
// _accountDao.release(account.getId());
|
||||
// }
|
||||
// if(!success){
|
||||
// EventVO event = new EventVO();
|
||||
// event.setUserId(1L); // system user performed the action
|
||||
// event.setAccountId(accountId);
|
||||
// event.setType(EventTypes.EVENT_ROUTER_CREATE);
|
||||
// event.setStartId(startEventId);
|
||||
// event.setLevel(EventVO.LEVEL_ERROR);
|
||||
// event.setDescription("Failed to create router for account " + accountId + " in data center " + dataCenterId);
|
||||
// _eventDao.persist(event);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -48,7 +48,6 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.storage.Volume.VolumeType;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.Manager;
|
||||
import com.cloud.utils.exception.ExecutionException;
|
||||
@ -59,7 +58,7 @@ import com.cloud.vm.VirtualMachineProfile;
|
||||
public interface StorageManager extends Manager {
|
||||
|
||||
|
||||
VolumeVO allocateIsoInstalledVm(VMInstanceVO vm, VMTemplateVO template, DiskOfferingVO rootOffering, Long size, DataCenterVO dc, AccountVO account);
|
||||
VolumeVO allocateIsoInstalledVm(VMInstanceVO vm, VMTemplateVO template, DiskOfferingVO rootOffering, Long size, DataCenterVO dc, Account account);
|
||||
|
||||
/**
|
||||
* Calls the storage agent and makes the volumes sharable with this host.
|
||||
@ -339,8 +338,8 @@ public interface StorageManager extends Manager {
|
||||
* @param account
|
||||
* @return VolumeVO a persisted volume.
|
||||
*/
|
||||
<T extends VMInstanceVO> DiskProfile allocateRawVolume(VolumeType type, String name, DiskOfferingVO offering, Long size, T vm, AccountVO owner);
|
||||
<T extends VMInstanceVO> DiskProfile allocateTemplatedVolume(VolumeType type, String name, DiskOfferingVO offering, VMTemplateVO template, T vm, AccountVO owner);
|
||||
<T extends VMInstanceVO> DiskProfile allocateRawVolume(VolumeType type, String name, DiskOfferingVO offering, Long size, T vm, Account owner);
|
||||
<T extends VMInstanceVO> DiskProfile allocateTemplatedVolume(VolumeType type, String name, DiskOfferingVO offering, VMTemplateVO template, T vm, Account owner);
|
||||
|
||||
Long findHostIdForStoragePool(StoragePool pool);
|
||||
void createCapacityEntry(StoragePoolVO storagePool, long allocated);
|
||||
|
||||
@ -136,7 +136,6 @@ import com.cloud.storage.snapshot.SnapshotScheduler;
|
||||
import com.cloud.template.TemplateManager;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
@ -253,14 +252,14 @@ public class StorageManagerImpl implements StorageManager {
|
||||
}
|
||||
|
||||
@DB
|
||||
public List<VolumeVO> allocate(DiskProfile rootDisk, List<DiskProfile> dataDisks, VMInstanceVO vm, DataCenterVO dc, AccountVO account) {
|
||||
public List<VolumeVO> allocate(DiskProfile rootDisk, List<DiskProfile> dataDisks, VMInstanceVO vm, DataCenterVO dc, Account owner) {
|
||||
ArrayList<VolumeVO> vols = new ArrayList<VolumeVO>(dataDisks.size() + 1);
|
||||
VolumeVO dataVol = null;
|
||||
VolumeVO rootVol = null;
|
||||
long deviceId = 0;
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
rootVol = new VolumeVO(VolumeType.ROOT, rootDisk.getName(), dc.getId(), account.getDomainId(), account.getId(), rootDisk.getDiskOfferingId(), rootDisk.getSize());
|
||||
rootVol = new VolumeVO(VolumeType.ROOT, rootDisk.getName(), dc.getId(), owner.getDomainId(), owner.getId(), rootDisk.getDiskOfferingId(), rootDisk.getSize());
|
||||
if (rootDisk.getTemplateId() != null) {
|
||||
rootVol.setTemplateId(rootDisk.getTemplateId());
|
||||
}
|
||||
@ -269,7 +268,7 @@ public class StorageManagerImpl implements StorageManager {
|
||||
rootVol = _volsDao.persist(rootVol);
|
||||
vols.add(rootVol);
|
||||
for (DiskProfile dataDisk : dataDisks) {
|
||||
dataVol = new VolumeVO(VolumeType.DATADISK, dataDisk.getName(), dc.getId(), account.getDomainId(), account.getId(), dataDisk.getDiskOfferingId(), dataDisk.getSize());
|
||||
dataVol = new VolumeVO(VolumeType.DATADISK, dataDisk.getName(), dc.getId(), owner.getDomainId(), owner.getId(), dataDisk.getDiskOfferingId(), dataDisk.getSize());
|
||||
dataVol.setDeviceId(deviceId++);
|
||||
dataVol.setInstanceId(vm.getId());
|
||||
dataVol = _volsDao.persist(dataVol);
|
||||
@ -281,7 +280,7 @@ public class StorageManagerImpl implements StorageManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public VolumeVO allocateIsoInstalledVm(VMInstanceVO vm, VMTemplateVO template, DiskOfferingVO rootOffering, Long size, DataCenterVO dc, AccountVO account) {
|
||||
public VolumeVO allocateIsoInstalledVm(VMInstanceVO vm, VMTemplateVO template, DiskOfferingVO rootOffering, Long size, DataCenterVO dc, Account account) {
|
||||
assert (template.getFormat() == ImageFormat.ISO) : "The template has to be ISO";
|
||||
|
||||
long rootId = _volsDao.getNextInSequence(Long.class, "volume_seq");
|
||||
@ -1662,7 +1661,7 @@ public class StorageManagerImpl implements StorageManager {
|
||||
|
||||
// check if the volume can be created for the user
|
||||
// Check that the resource limit for volumes won't be exceeded
|
||||
if (_accountMgr.resourceLimitExceeded((AccountVO)targetAccount, ResourceType.volume)) {
|
||||
if (_accountMgr.resourceLimitExceeded((Account)targetAccount, ResourceType.volume)) {
|
||||
ResourceAllocationException rae = new ResourceAllocationException("Maximum number of volumes for account: " + targetAccount.getAccountName() + " has been exceeded.");
|
||||
rae.setResourceType("volume");
|
||||
throw rae;
|
||||
@ -2509,7 +2508,7 @@ public class StorageManagerImpl implements StorageManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> DiskProfile allocateRawVolume(VolumeType type, String name, DiskOfferingVO offering, Long size, T vm, AccountVO owner) {
|
||||
public <T extends VMInstanceVO> DiskProfile allocateRawVolume(VolumeType type, String name, DiskOfferingVO offering, Long size, T vm, Account owner) {
|
||||
if (size == null) {
|
||||
size = offering.getDiskSizeInBytes();
|
||||
}
|
||||
@ -2524,7 +2523,7 @@ public class StorageManagerImpl implements StorageManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> DiskProfile allocateTemplatedVolume(VolumeType type, String name, DiskOfferingVO offering, VMTemplateVO template, T vm, AccountVO owner) {
|
||||
public <T extends VMInstanceVO> DiskProfile allocateTemplatedVolume(VolumeType type, String name, DiskOfferingVO offering, VMTemplateVO template, T vm, Account owner) {
|
||||
assert (template.getFormat() != ImageFormat.ISO) : "ISO is not a template really....";
|
||||
|
||||
SearchCriteria<VMTemplateHostVO> sc = HostTemplateStatesSearch.create();
|
||||
|
||||
@ -85,7 +85,7 @@ public interface AccountManager extends Manager {
|
||||
* @param count the number of resources being allocated, count will be added to current allocation and compared against maximum allowed allocation
|
||||
* @return true if the limit has been exceeded
|
||||
*/
|
||||
public boolean resourceLimitExceeded(AccountVO account, ResourceCount.ResourceType type, long...count);
|
||||
public boolean resourceLimitExceeded(Account account, ResourceCount.ResourceType type, long...count);
|
||||
|
||||
/**
|
||||
* Gets the count of resources for a resource type and account
|
||||
|
||||
@ -185,7 +185,7 @@ public class AccountManagerImpl implements AccountManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean resourceLimitExceeded(AccountVO account, ResourceType type, long...count) {
|
||||
public boolean resourceLimitExceeded(Account account, ResourceType type, long...count) {
|
||||
long numResources = ((count.length == 0) ? 1 : count[0]);
|
||||
|
||||
// Don't place any limits on system or admin accounts
|
||||
|
||||
@ -61,7 +61,7 @@ import com.cloud.storage.Volume.VolumeType;
|
||||
import com.cloud.storage.dao.GuestOSDao;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.template.VirtualMachineTemplate.BootloaderType;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.Journal;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.Pair;
|
||||
@ -100,7 +100,7 @@ public class MauriceMoss implements VmManager {
|
||||
List<Pair<DiskOfferingVO, Long>> dataDiskOfferings,
|
||||
List<Pair<NetworkConfigurationVO, NicProfile>> networks,
|
||||
DeploymentPlan plan,
|
||||
AccountVO owner) throws InsufficientCapacityException {
|
||||
Account owner) throws InsufficientCapacityException {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Allocating entries for VM: " + vm);
|
||||
}
|
||||
@ -154,7 +154,7 @@ public class MauriceMoss implements VmManager {
|
||||
Pair<DiskOfferingVO, Long> dataDiskOffering,
|
||||
List<Pair<NetworkConfigurationVO, NicProfile>> networks,
|
||||
DeploymentPlan plan,
|
||||
AccountVO owner) throws InsufficientCapacityException {
|
||||
Account owner) throws InsufficientCapacityException {
|
||||
List<Pair<DiskOfferingVO, Long>> diskOfferings = new ArrayList<Pair<DiskOfferingVO, Long>>(1);
|
||||
if (dataDiskOffering != null) {
|
||||
diskOfferings.add(dataDiskOffering);
|
||||
@ -168,7 +168,7 @@ public class MauriceMoss implements VmManager {
|
||||
ServiceOfferingVO serviceOffering,
|
||||
List<Pair<NetworkConfigurationVO, NicProfile>> networks,
|
||||
DeploymentPlan plan,
|
||||
AccountVO owner) throws InsufficientCapacityException {
|
||||
Account owner) throws InsufficientCapacityException {
|
||||
return allocate(vm, template, serviceOffering, new Pair<DiskOfferingVO, Long>(serviceOffering, null), null, networks, plan, owner);
|
||||
}
|
||||
|
||||
@ -211,7 +211,7 @@ public class MauriceMoss implements VmManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> T start(T vm, DeploymentPlan plan, VirtualMachineGuru guru) throws InsufficientCapacityException, ConcurrentOperationException {
|
||||
public <T extends VMInstanceVO> T start(T vm, DeploymentPlan plan, Account acct, VirtualMachineGuru<T> guru) throws InsufficientCapacityException, ConcurrentOperationException {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Creating actual resources for VM " + vm);
|
||||
}
|
||||
@ -267,7 +267,7 @@ public class MauriceMoss implements VmManager {
|
||||
s_logger.warn("Unable to contact storage.", e);
|
||||
continue;
|
||||
}
|
||||
NicTO[] nics = _networkMgr.prepare(vmProfile, dest);
|
||||
NicTO[] nics = _networkMgr.prepare(vmProfile, dest, acct);
|
||||
|
||||
vmTO.setNics(nics);
|
||||
vmTO.setDisks(volumes);
|
||||
|
||||
@ -24,7 +24,7 @@ import com.cloud.deploy.DeployDestination;
|
||||
* A VirtualMachineGuru knows how to process a certain type of virtual machine.
|
||||
*
|
||||
*/
|
||||
public interface VirtualMachineGuru {
|
||||
public interface VirtualMachineGuru<T extends VMInstanceVO> {
|
||||
/**
|
||||
* finalize the virtual machine deployment.
|
||||
* @param cmds commands that were created.
|
||||
|
||||
@ -28,7 +28,7 @@ import com.cloud.network.NetworkConfigurationVO;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.Manager;
|
||||
|
||||
@ -44,7 +44,7 @@ public interface VmManager extends Manager {
|
||||
List<Pair<DiskOfferingVO, Long>> dataDiskOfferings,
|
||||
List<Pair<NetworkConfigurationVO, NicProfile>> networks,
|
||||
DeploymentPlan plan,
|
||||
AccountVO owner) throws InsufficientCapacityException, StorageUnavailableException;
|
||||
Account owner) throws InsufficientCapacityException, StorageUnavailableException;
|
||||
|
||||
<T extends VMInstanceVO> VirtualMachineProfile allocate(T vm,
|
||||
VMTemplateVO template,
|
||||
@ -53,16 +53,16 @@ public interface VmManager extends Manager {
|
||||
Pair<DiskOfferingVO, Long> dataDiskOffering,
|
||||
List<Pair<NetworkConfigurationVO, NicProfile>> networks,
|
||||
DeploymentPlan plan,
|
||||
AccountVO owner) throws InsufficientCapacityException, StorageUnavailableException;
|
||||
Account owner) throws InsufficientCapacityException, StorageUnavailableException;
|
||||
|
||||
<T extends VMInstanceVO> VirtualMachineProfile allocate(T vm,
|
||||
VMTemplateVO template,
|
||||
ServiceOfferingVO serviceOffering,
|
||||
List<Pair<NetworkConfigurationVO, NicProfile>> networkProfiles,
|
||||
DeploymentPlan plan,
|
||||
AccountVO owner) throws InsufficientCapacityException, StorageUnavailableException;
|
||||
Account owner) throws InsufficientCapacityException, StorageUnavailableException;
|
||||
|
||||
<T extends VMInstanceVO> T start(T vm, DeploymentPlan plan, VirtualMachineGuru checker) throws InsufficientCapacityException, StorageUnavailableException, ConcurrentOperationException;
|
||||
<T extends VMInstanceVO> T start(T vm, DeploymentPlan plan, Account user, VirtualMachineGuru<T> checker) throws InsufficientCapacityException, StorageUnavailableException, ConcurrentOperationException;
|
||||
|
||||
<T extends VMInstanceVO> T stop(T vm) throws AgentUnavailableException, ConcurrentOperationException;
|
||||
|
||||
|
||||
@ -244,6 +244,7 @@ INSERT INTO `cloud`.`sequence` (name, value) VALUES ('public_mac_address_seq', 1
|
||||
INSERT INTO `cloud`.`sequence` (name, value) VALUES ('private_mac_address_seq', 1);
|
||||
INSERT INTO `cloud`.`sequence` (name, value) VALUES ('storage_pool_seq', 200);
|
||||
INSERT INTO `cloud`.`sequence` (name, value) VALUES ('volume_seq', 1);
|
||||
INSERT INTO `cloud`.`sequence` (name, value) VALUES ('network_configuration_seq', 1);
|
||||
|
||||
CREATE TABLE `cloud`.`disk_template_ref` (
|
||||
`id` bigint unsigned NOT NULL auto_increment,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user