mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
more work from alex
This commit is contained in:
parent
e0d962a8e4
commit
bebe79ebc9
@ -12,6 +12,11 @@ import com.cloud.network.Network.TrafficType;
|
|||||||
* owned by an account.
|
* owned by an account.
|
||||||
*/
|
*/
|
||||||
public interface NetworkConfiguration {
|
public interface NetworkConfiguration {
|
||||||
|
enum State {
|
||||||
|
Allocated, // Indicates the network configuration is in allocated but not setup.
|
||||||
|
Setup, // Indicates the network configuration is setup.
|
||||||
|
InUse; // Indicates the network configuration is in use.
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return id of the network profile. Null means the network profile is not from the database.
|
* @return id of the network profile. Null means the network profile is not from the database.
|
||||||
@ -28,7 +33,9 @@ public interface NetworkConfiguration {
|
|||||||
|
|
||||||
String getCidr();
|
String getCidr();
|
||||||
|
|
||||||
public long getDataCenterId();
|
long getDataCenterId();
|
||||||
|
|
||||||
long getNetworkOfferingId();
|
long getNetworkOfferingId();
|
||||||
|
|
||||||
|
State getState();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,21 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package com.cloud.network;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.cloud.deploy.DeploymentPlan;
|
|
||||||
import com.cloud.offering.NetworkOffering;
|
|
||||||
import com.cloud.user.Account;
|
|
||||||
import com.cloud.utils.component.Adapter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* NetworkProfiler takes the list of network offerings requested and figures
|
|
||||||
* out what are the additional network profiles that are needed to add
|
|
||||||
* to the account in order to support this network.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public interface NetworkProfiler extends Adapter {
|
|
||||||
NetworkConfiguration convert(NetworkOffering offering, DeploymentPlan plan, Map<String, String> params, Account owner);
|
|
||||||
}
|
|
||||||
24
api/src/com/cloud/network/configuration/NetworkGuru.java
Normal file
24
api/src/com/cloud/network/configuration/NetworkGuru.java
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.cloud.network.configuration;
|
||||||
|
|
||||||
|
import com.cloud.deploy.DeployDestination;
|
||||||
|
import com.cloud.deploy.DeploymentPlan;
|
||||||
|
import com.cloud.network.NetworkConfiguration;
|
||||||
|
import com.cloud.offering.NetworkOffering;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.utils.component.Adapter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NetworkProfiler takes the list of network offerings requested and figures
|
||||||
|
* out what are the additional network profiles that are needed to add
|
||||||
|
* to the account in order to support this network.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface NetworkGuru extends Adapter {
|
||||||
|
NetworkConfiguration design(NetworkOffering offering, DeploymentPlan plan, NetworkConfiguration config, Account owner);
|
||||||
|
NetworkConfiguration implement(NetworkConfiguration config, NetworkOffering offering, DeployDestination destination);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
32
api/src/com/cloud/network/element/NetworkElement.java
Normal file
32
api/src/com/cloud/network/element/NetworkElement.java
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.cloud.network.element;
|
||||||
|
|
||||||
|
import com.cloud.network.NetworkConfiguration;
|
||||||
|
import com.cloud.offering.NetworkOffering;
|
||||||
|
import com.cloud.utils.component.Adapter;
|
||||||
|
import com.cloud.vm.NicProfile;
|
||||||
|
import com.cloud.vm.VirtualMachineProfile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents one network element that exists in a network.
|
||||||
|
*/
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
boolean implement(NetworkConfiguration config, NetworkOffering offering);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the nic profile to be used within the network.
|
||||||
|
* @param config
|
||||||
|
* @param nic
|
||||||
|
* @param offering
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean prepare(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm, NetworkOffering offering);
|
||||||
|
}
|
||||||
@ -19,6 +19,12 @@ public interface Resource {
|
|||||||
Releasing,
|
Releasing,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum ReservationStrategy {
|
||||||
|
UserSpecified,
|
||||||
|
Create,
|
||||||
|
Start
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return id in the CloudStack database
|
* @return id in the CloudStack database
|
||||||
*/
|
*/
|
||||||
@ -56,4 +62,6 @@ public interface Resource {
|
|||||||
* @return the reservation state of the resource.
|
* @return the reservation state of the resource.
|
||||||
*/
|
*/
|
||||||
State getState();
|
State getState();
|
||||||
|
|
||||||
|
ReservationStrategy getReservationStrategy();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import com.cloud.deploy.DeployDestination;
|
|||||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||||
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||||
import com.cloud.network.NetworkConfiguration;
|
import com.cloud.network.NetworkConfiguration;
|
||||||
import com.cloud.utils.component.Adapter;
|
import com.cloud.resource.Concierge;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NetworkConcierge reserves network settings for a VM based
|
* NetworkConcierge reserves network settings for a VM based
|
||||||
@ -16,7 +16,7 @@ import com.cloud.utils.component.Adapter;
|
|||||||
* the reservation.
|
* the reservation.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface NetworkConcierge extends Adapter {
|
public interface NetworkConcierge extends Concierge<Nic> {
|
||||||
String getUniqueName();
|
String getUniqueName();
|
||||||
|
|
||||||
NicProfile allocate(VirtualMachine vm, NetworkConfiguration config, NicProfile nic) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
|
NicProfile allocate(VirtualMachine vm, NetworkConfiguration config, NicProfile nic) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
|
||||||
|
|||||||
@ -19,10 +19,13 @@
|
|||||||
package com.cloud.vm;
|
package com.cloud.vm;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.cloud.utils.fsm.FiniteState;
|
||||||
import com.cloud.utils.fsm.StateMachine;
|
import com.cloud.utils.fsm.StateMachine;
|
||||||
|
import com.cloud.vm.VirtualMachine.Event;
|
||||||
|
|
||||||
public enum State {
|
public enum State implements FiniteState<State, Event> {
|
||||||
Creating(true),
|
Creating(true),
|
||||||
Starting(true),
|
Starting(true),
|
||||||
Running(false),
|
Running(false),
|
||||||
@ -44,22 +47,24 @@ public enum State {
|
|||||||
return _transitional;
|
return _transitional;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] toStrings(State... states) {
|
@Override
|
||||||
String[] strs = new String[states.length];
|
|
||||||
for (int i = 0; i < states.length; i++) {
|
|
||||||
strs[i] = states[i].toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
return strs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public State getNextState(VirtualMachine.Event e) {
|
public State getNextState(VirtualMachine.Event e) {
|
||||||
return s_fsm.getNextState(this, e);
|
return s_fsm.getNextState(this, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
public State[] getFromStates(VirtualMachine.Event e) {
|
@Override
|
||||||
List<State> from = s_fsm.getFromStates(this, e);
|
public List<State> getFromStates(VirtualMachine.Event e) {
|
||||||
return from.toArray(new State[from.size()]);
|
return s_fsm.getFromStates(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Event> getPossibleEvents() {
|
||||||
|
return s_fsm.getPossibleEvents(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StateMachine<State, Event> getStateMachine() {
|
||||||
|
return s_fsm;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static final StateMachine<State, VirtualMachine.Event> s_fsm = new StateMachine<State, VirtualMachine.Event>();
|
protected static final StateMachine<State, VirtualMachine.Event> s_fsm = new StateMachine<State, VirtualMachine.Event>();
|
||||||
|
|||||||
@ -67,10 +67,18 @@ public class VirtualMachineProfile {
|
|||||||
this._nics = profiles;
|
this._nics = profiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<NicProfile> getNics() {
|
||||||
|
return _nics;
|
||||||
|
}
|
||||||
|
|
||||||
public void setDisks(List<DiskProfile> profiles) {
|
public void setDisks(List<DiskProfile> profiles) {
|
||||||
this._disks = profiles;
|
this._disks = profiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<DiskProfile> getDisks() {
|
||||||
|
return _disks;
|
||||||
|
}
|
||||||
|
|
||||||
public Hypervisor.Type getHypervisorType() {
|
public Hypervisor.Type getHypervisorType() {
|
||||||
return _hypervisorType;
|
return _hypervisorType;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,12 +36,14 @@ import javax.persistence.Temporal;
|
|||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
|
|
||||||
import com.cloud.utils.db.GenericDao;
|
import com.cloud.utils.db.GenericDao;
|
||||||
|
import com.cloud.utils.db.StateMachine;
|
||||||
|
import com.cloud.utils.fsm.FiniteStateObject;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="vm_instance")
|
@Table(name="vm_instance")
|
||||||
@Inheritance(strategy=InheritanceType.JOINED)
|
@Inheritance(strategy=InheritanceType.JOINED)
|
||||||
@DiscriminatorColumn(name="type", discriminatorType=DiscriminatorType.STRING, length=32)
|
@DiscriminatorColumn(name="type", discriminatorType=DiscriminatorType.STRING, length=32)
|
||||||
public class VMInstanceVO implements VirtualMachine {
|
public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, VirtualMachine.Event> {
|
||||||
@Id
|
@Id
|
||||||
@TableGenerator(name="vm_instance_sq", table="sequence", pkColumnName="name", valueColumnName="value", pkColumnValue="vm_instance_seq", allocationSize=1)
|
@TableGenerator(name="vm_instance_sq", table="sequence", pkColumnName="name", valueColumnName="value", pkColumnValue="vm_instance_seq", allocationSize=1)
|
||||||
@Column(name="id", updatable=false, nullable = false)
|
@Column(name="id", updatable=false, nullable = false)
|
||||||
@ -65,7 +67,8 @@ public class VMInstanceVO implements VirtualMachine {
|
|||||||
* the state machine needs to go through the DAO object because someone
|
* the state machine needs to go through the DAO object because someone
|
||||||
* else could be updating it as well.
|
* else could be updating it as well.
|
||||||
*/
|
*/
|
||||||
@Enumerated(value=EnumType.STRING)
|
@Enumerated(value=EnumType.STRING)
|
||||||
|
@StateMachine(state=State.class, event=Event.class)
|
||||||
@Column(name="state", updatable=true, nullable=false, length=32)
|
@Column(name="state", updatable=true, nullable=false, length=32)
|
||||||
private State state = null;
|
private State state = null;
|
||||||
|
|
||||||
@ -249,7 +252,8 @@ public class VMInstanceVO implements VirtualMachine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// don't use this directly, use VM state machine instead, this method is added for migration tool only
|
// don't use this directly, use VM state machine instead, this method is added for migration tool only
|
||||||
public void setState(State state) {
|
@Override
|
||||||
|
public void setState(State state) {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1020,7 +1020,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||||||
List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmControlNetwork, NetworkOfferingVO.SystemVmManagementNetwork, NetworkOfferingVO.SystemVmPublicNetwork);
|
List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmControlNetwork, NetworkOfferingVO.SystemVmManagementNetwork, NetworkOfferingVO.SystemVmPublicNetwork);
|
||||||
List<NetworkConfigurationVO> profiles = new ArrayList<NetworkConfigurationVO>(offerings.size());
|
List<NetworkConfigurationVO> profiles = new ArrayList<NetworkConfigurationVO>(offerings.size());
|
||||||
for (NetworkOfferingVO offering : offerings) {
|
for (NetworkOfferingVO offering : offerings) {
|
||||||
profiles.add(_networkMgr.setupNetworkProfile(_accountMgr.getSystemAccount(), offering, plan));
|
profiles.add(_networkMgr.setupNetworkConfiguration(_accountMgr.getSystemAccount(), offering, plan));
|
||||||
}
|
}
|
||||||
ConsoleProxyVO proxy = new ConsoleProxyVO(id, name, _template.getId(), _template.getGuestOSId(), dataCenterId, 0);
|
ConsoleProxyVO proxy = new ConsoleProxyVO(id, name, _template.getId(), _template.getGuestOSId(), dataCenterId, 0);
|
||||||
proxy = _consoleProxyDao.persist(proxy);
|
proxy = _consoleProxyDao.persist(proxy);
|
||||||
|
|||||||
@ -70,11 +70,20 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
|
|||||||
@Column(name="data_center_id")
|
@Column(name="data_center_id")
|
||||||
long dataCenterId;
|
long dataCenterId;
|
||||||
|
|
||||||
|
@Column(name="handler_name")
|
||||||
|
String handlerName;
|
||||||
|
|
||||||
|
@Column(name="state")
|
||||||
|
@Enumerated(value=EnumType.STRING)
|
||||||
|
State state;
|
||||||
|
|
||||||
public NetworkConfigurationVO() {
|
public NetworkConfigurationVO() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public NetworkConfigurationVO(NetworkConfiguration that, long offeringId, long dataCenterId) {
|
public NetworkConfigurationVO(NetworkConfiguration that, long offeringId, long dataCenterId, String handlerName) {
|
||||||
this(that.getTrafficType(), that.getMode(), that.getBroadcastDomainType(), offeringId, dataCenterId);
|
this(that.getTrafficType(), that.getMode(), that.getBroadcastDomainType(), offeringId, dataCenterId);
|
||||||
|
this.handlerName = handlerName;
|
||||||
|
this.state = that.getState();
|
||||||
}
|
}
|
||||||
|
|
||||||
public NetworkConfigurationVO(TrafficType trafficType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, long dataCenterId) {
|
public NetworkConfigurationVO(TrafficType trafficType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, long dataCenterId) {
|
||||||
@ -83,6 +92,16 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
|
|||||||
this.broadcastDomainType = broadcastDomainType;
|
this.broadcastDomainType = broadcastDomainType;
|
||||||
this.networkOfferingId = networkOfferingId;
|
this.networkOfferingId = networkOfferingId;
|
||||||
this.dataCenterId = dataCenterId;
|
this.dataCenterId = dataCenterId;
|
||||||
|
this.state = State.Allocated;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public State getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(State state) {
|
||||||
|
this.state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -108,6 +127,14 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
|
|||||||
public BroadcastDomainType getBroadcastDomainType() {
|
public BroadcastDomainType getBroadcastDomainType() {
|
||||||
return broadcastDomainType;
|
return broadcastDomainType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getHandlerName() {
|
||||||
|
return handlerName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHandlerName(String handlerName) {
|
||||||
|
this.handlerName = handlerName;
|
||||||
|
}
|
||||||
|
|
||||||
public void setBroadcastDomainType(BroadcastDomainType broadcastDomainType) {
|
public void setBroadcastDomainType(BroadcastDomainType broadcastDomainType) {
|
||||||
this.broadcastDomainType = broadcastDomainType;
|
this.broadcastDomainType = broadcastDomainType;
|
||||||
|
|||||||
@ -26,9 +26,12 @@ import com.cloud.async.executor.LoadBalancerParam;
|
|||||||
import com.cloud.dc.DataCenterVO;
|
import com.cloud.dc.DataCenterVO;
|
||||||
import com.cloud.dc.HostPodVO;
|
import com.cloud.dc.HostPodVO;
|
||||||
import com.cloud.dc.VlanVO;
|
import com.cloud.dc.VlanVO;
|
||||||
|
import com.cloud.deploy.DeployDestination;
|
||||||
import com.cloud.deploy.DeploymentPlan;
|
import com.cloud.deploy.DeploymentPlan;
|
||||||
import com.cloud.exception.ConcurrentOperationException;
|
import com.cloud.exception.ConcurrentOperationException;
|
||||||
|
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||||
import com.cloud.exception.InsufficientCapacityException;
|
import com.cloud.exception.InsufficientCapacityException;
|
||||||
|
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||||
import com.cloud.exception.ResourceAllocationException;
|
import com.cloud.exception.ResourceAllocationException;
|
||||||
import com.cloud.offerings.NetworkOfferingVO;
|
import com.cloud.offerings.NetworkOfferingVO;
|
||||||
import com.cloud.service.ServiceOfferingVO;
|
import com.cloud.service.ServiceOfferingVO;
|
||||||
@ -41,6 +44,7 @@ import com.cloud.vm.NicProfile;
|
|||||||
import com.cloud.vm.NicVO;
|
import com.cloud.vm.NicVO;
|
||||||
import com.cloud.vm.UserVmVO;
|
import com.cloud.vm.UserVmVO;
|
||||||
import com.cloud.vm.VMInstanceVO;
|
import com.cloud.vm.VMInstanceVO;
|
||||||
|
import com.cloud.vm.VirtualMachineProfile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NetworkManager manages the network for the different end users.
|
* NetworkManager manages the network for the different end users.
|
||||||
@ -215,15 +219,15 @@ public interface NetworkManager extends Manager {
|
|||||||
*/
|
*/
|
||||||
List<IPAddressVO> listPublicIpAddressesInVirtualNetwork(long accountId, long dcId, Boolean sourceNat);
|
List<IPAddressVO> listPublicIpAddressesInVirtualNetwork(long accountId, long dcId, Boolean sourceNat);
|
||||||
|
|
||||||
NetworkConfigurationVO setupNetworkProfile(AccountVO account, NetworkOfferingVO offering, DeploymentPlan plan);
|
NetworkConfigurationVO setupNetworkConfiguration(AccountVO owner, NetworkOfferingVO offering, DeploymentPlan plan);
|
||||||
NetworkConfigurationVO setupNetworkProfile(AccountVO account, NetworkOfferingVO offering, Map<String, String> params, DeploymentPlan plan);
|
NetworkConfigurationVO setupNetworkConfiguration(AccountVO owner, NetworkOfferingVO offering, NetworkConfiguration predefined, DeploymentPlan plan);
|
||||||
List<NetworkConfigurationVO> setupNetworkProfiles(AccountVO account, List<NetworkOfferingVO> offerings, DeploymentPlan plan);
|
List<NetworkConfigurationVO> setupNetworkConfigurations(AccountVO owner, List<NetworkOfferingVO> offerings, DeploymentPlan plan);
|
||||||
|
|
||||||
List<NetworkOfferingVO> getSystemAccountNetworkOfferings(String... offeringNames);
|
List<NetworkOfferingVO> getSystemAccountNetworkOfferings(String... offeringNames);
|
||||||
|
|
||||||
<K extends VMInstanceVO> List<NicProfile> allocate(K vm, List<Pair<NetworkConfigurationVO, NicProfile>> networks) throws InsufficientCapacityException;
|
<K extends VMInstanceVO> List<NicProfile> allocate(K vm, List<Pair<NetworkConfigurationVO, NicProfile>> networks) throws InsufficientCapacityException;
|
||||||
|
|
||||||
<K extends VMInstanceVO> List<NicTO> prepare(K vm);
|
List<NicTO> prepare(VirtualMachineProfile profile, DeployDestination dest) throws InsufficientAddressCapacityException, InsufficientVirtualNetworkCapcityException;
|
||||||
|
|
||||||
<K extends VMInstanceVO> void create(K vm);
|
<K extends VMInstanceVO> void create(K vm);
|
||||||
|
|
||||||
|
|||||||
@ -79,6 +79,7 @@ import com.cloud.dc.VlanVO;
|
|||||||
import com.cloud.dc.dao.DataCenterDao;
|
import com.cloud.dc.dao.DataCenterDao;
|
||||||
import com.cloud.dc.dao.HostPodDao;
|
import com.cloud.dc.dao.HostPodDao;
|
||||||
import com.cloud.dc.dao.VlanDao;
|
import com.cloud.dc.dao.VlanDao;
|
||||||
|
import com.cloud.deploy.DeployDestination;
|
||||||
import com.cloud.deploy.DeploymentPlan;
|
import com.cloud.deploy.DeploymentPlan;
|
||||||
import com.cloud.domain.DomainVO;
|
import com.cloud.domain.DomainVO;
|
||||||
import com.cloud.domain.dao.DomainDao;
|
import com.cloud.domain.dao.DomainDao;
|
||||||
@ -88,7 +89,9 @@ import com.cloud.event.EventVO;
|
|||||||
import com.cloud.event.dao.EventDao;
|
import com.cloud.event.dao.EventDao;
|
||||||
import com.cloud.exception.AgentUnavailableException;
|
import com.cloud.exception.AgentUnavailableException;
|
||||||
import com.cloud.exception.ConcurrentOperationException;
|
import com.cloud.exception.ConcurrentOperationException;
|
||||||
|
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||||
import com.cloud.exception.InsufficientCapacityException;
|
import com.cloud.exception.InsufficientCapacityException;
|
||||||
|
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||||
import com.cloud.exception.InternalErrorException;
|
import com.cloud.exception.InternalErrorException;
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
import com.cloud.exception.InvalidParameterValueException;
|
||||||
import com.cloud.exception.NetworkRuleConflictException;
|
import com.cloud.exception.NetworkRuleConflictException;
|
||||||
@ -102,6 +105,7 @@ import com.cloud.host.HostVO;
|
|||||||
import com.cloud.host.dao.HostDao;
|
import com.cloud.host.dao.HostDao;
|
||||||
import com.cloud.hypervisor.Hypervisor;
|
import com.cloud.hypervisor.Hypervisor;
|
||||||
import com.cloud.network.Network.TrafficType;
|
import com.cloud.network.Network.TrafficType;
|
||||||
|
import com.cloud.network.configuration.NetworkGuru;
|
||||||
import com.cloud.network.dao.FirewallRulesDao;
|
import com.cloud.network.dao.FirewallRulesDao;
|
||||||
import com.cloud.network.dao.IPAddressDao;
|
import com.cloud.network.dao.IPAddressDao;
|
||||||
import com.cloud.network.dao.LoadBalancerDao;
|
import com.cloud.network.dao.LoadBalancerDao;
|
||||||
@ -111,6 +115,8 @@ import com.cloud.offering.NetworkOffering;
|
|||||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||||
import com.cloud.offerings.NetworkOfferingVO;
|
import com.cloud.offerings.NetworkOfferingVO;
|
||||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||||
|
import com.cloud.resource.Resource;
|
||||||
|
import com.cloud.resource.Resource.ReservationStrategy;
|
||||||
import com.cloud.service.ServiceOfferingVO;
|
import com.cloud.service.ServiceOfferingVO;
|
||||||
import com.cloud.service.dao.ServiceOfferingDao;
|
import com.cloud.service.dao.ServiceOfferingDao;
|
||||||
import com.cloud.storage.StorageManager;
|
import com.cloud.storage.StorageManager;
|
||||||
@ -157,6 +163,7 @@ import com.cloud.vm.VirtualMachine;
|
|||||||
import com.cloud.vm.VirtualMachine.Event;
|
import com.cloud.vm.VirtualMachine.Event;
|
||||||
import com.cloud.vm.VirtualMachineManager;
|
import com.cloud.vm.VirtualMachineManager;
|
||||||
import com.cloud.vm.VirtualMachineName;
|
import com.cloud.vm.VirtualMachineName;
|
||||||
|
import com.cloud.vm.VirtualMachineProfile;
|
||||||
import com.cloud.vm.dao.DomainRouterDao;
|
import com.cloud.vm.dao.DomainRouterDao;
|
||||||
import com.cloud.vm.dao.NicDao;
|
import com.cloud.vm.dao.NicDao;
|
||||||
import com.cloud.vm.dao.UserVmDao;
|
import com.cloud.vm.dao.UserVmDao;
|
||||||
@ -205,8 +212,8 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||||||
@Inject NetworkConfigurationDao _networkProfileDao = null;
|
@Inject NetworkConfigurationDao _networkProfileDao = null;
|
||||||
@Inject NicDao _nicDao;
|
@Inject NicDao _nicDao;
|
||||||
|
|
||||||
@Inject(adapter=NetworkProfiler.class)
|
@Inject(adapter=NetworkGuru.class)
|
||||||
Adapters<NetworkProfiler> _networkProfilers;
|
Adapters<NetworkGuru> _networkGurus;
|
||||||
@Inject(adapter=NetworkConcierge.class)
|
@Inject(adapter=NetworkConcierge.class)
|
||||||
Adapters<NetworkConcierge> _networkConcierges;
|
Adapters<NetworkConcierge> _networkConcierges;
|
||||||
|
|
||||||
@ -1794,7 +1801,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||||||
_executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("RouterMonitor"));
|
_executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("RouterMonitor"));
|
||||||
|
|
||||||
final ComponentLocator locator = ComponentLocator.getCurrentLocator();
|
final ComponentLocator locator = ComponentLocator.getCurrentLocator();
|
||||||
_networkProfilers = locator.getAdapters(NetworkProfiler.class);
|
_networkGurus = locator.getAdapters(NetworkGuru.class);
|
||||||
_networkConcierges = locator.getAdapters(NetworkConcierge.class);
|
_networkConcierges = locator.getAdapters(NetworkConcierge.class);
|
||||||
|
|
||||||
final Map<String, String> configs = _configDao.getConfiguration("AgentManager", params);
|
final Map<String, String> configs = _configDao.getConfiguration("AgentManager", params);
|
||||||
@ -2344,12 +2351,12 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NetworkConfigurationVO setupNetworkProfile(AccountVO owner, NetworkOfferingVO offering, DeploymentPlan plan) {
|
public NetworkConfigurationVO setupNetworkConfiguration(AccountVO owner, NetworkOfferingVO offering, DeploymentPlan plan) {
|
||||||
return setupNetworkProfile(owner, offering, new HashMap<String, String>(), plan);
|
return setupNetworkConfiguration(owner, offering, null, plan);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NetworkConfigurationVO setupNetworkProfile(AccountVO owner, NetworkOfferingVO offering, Map<String, String> params, DeploymentPlan plan) {
|
public NetworkConfigurationVO setupNetworkConfiguration(AccountVO owner, NetworkOfferingVO offering, NetworkConfiguration predefined, DeploymentPlan plan) {
|
||||||
List<NetworkConfigurationVO> configs = _networkProfileDao.listBy(owner.getId(), offering.getId(), plan.getDataCenterId());
|
List<NetworkConfigurationVO> configs = _networkProfileDao.listBy(owner.getId(), offering.getId(), plan.getDataCenterId());
|
||||||
if (configs.size() > 0) {
|
if (configs.size() > 0) {
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
@ -2358,8 +2365,8 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||||||
return configs.get(0);
|
return configs.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (NetworkProfiler profiler : _networkProfilers) {
|
for (NetworkGuru guru : _networkGurus) {
|
||||||
NetworkConfiguration profile = profiler.convert(offering, plan, params, owner);
|
NetworkConfiguration profile = guru.design(offering, plan, predefined, owner);
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -2372,7 +2379,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkConfigurationVO vo = new NetworkConfigurationVO(profile, offering.getId(), plan.getDataCenterId());
|
NetworkConfigurationVO vo = new NetworkConfigurationVO(profile, offering.getId(), plan.getDataCenterId(), guru.getName());
|
||||||
return _networkProfileDao.persist(vo, owner.getId());
|
return _networkProfileDao.persist(vo, owner.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2380,10 +2387,10 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<NetworkConfigurationVO> setupNetworkProfiles(AccountVO owner, List<NetworkOfferingVO> offerings, DeploymentPlan plan) {
|
public List<NetworkConfigurationVO> setupNetworkConfigurations(AccountVO owner, List<NetworkOfferingVO> offerings, DeploymentPlan plan) {
|
||||||
List<NetworkConfigurationVO> profiles = new ArrayList<NetworkConfigurationVO>(offerings.size());
|
List<NetworkConfigurationVO> profiles = new ArrayList<NetworkConfigurationVO>(offerings.size());
|
||||||
for (NetworkOfferingVO offering : offerings) {
|
for (NetworkOfferingVO offering : offerings) {
|
||||||
profiles.add(setupNetworkProfile(owner, offering, plan));
|
profiles.add(setupNetworkConfiguration(owner, offering, plan));
|
||||||
}
|
}
|
||||||
return profiles;
|
return profiles;
|
||||||
}
|
}
|
||||||
@ -2447,10 +2454,29 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <K extends VMInstanceVO> List<NicTO> prepare(K vm) {
|
public List<NicTO> prepare(VirtualMachineProfile vmProfile, DeployDestination dest) throws InsufficientAddressCapacityException, InsufficientVirtualNetworkCapcityException {
|
||||||
|
List<NicVO> nics = _nicDao.listBy(vmProfile.getId());
|
||||||
|
for (NicVO nic : nics) {
|
||||||
|
NetworkConfigurationVO config = _networkProfileDao.findById(nic.getNetworkConfigurationId());
|
||||||
|
|
||||||
|
if (nic.getReservationStrategy() == ReservationStrategy.Start) {
|
||||||
|
NetworkConcierge concierge = _networkConcierges.get(nic.getReserver());
|
||||||
|
nic.setState(Resource.State.Reserving);
|
||||||
|
_nicDao.update(nic.getId(), nic);
|
||||||
|
concierge.reserve(vmProfile.getId(), toNicProfile(nic), dest);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NicProfile toNicProfile(NicVO nic) {
|
||||||
|
NetworkConfiguration config = _networkProfileDao.findById(nic.getNetworkConfigurationId());
|
||||||
|
NicProfile profile = new NicProfile(nic, config);
|
||||||
|
return profile;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <K extends VMInstanceVO> void create(K vm) {
|
public <K extends VMInstanceVO> void create(K vm) {
|
||||||
for (NetworkConcierge concierge : _networkConcierges) {
|
for (NetworkConcierge concierge : _networkConcierges) {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package com.cloud.network.profiler;
|
package com.cloud.network.configuration;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -22,7 +22,6 @@ import com.cloud.network.Network.Mode;
|
|||||||
import com.cloud.network.Network.TrafficType;
|
import com.cloud.network.Network.TrafficType;
|
||||||
import com.cloud.network.NetworkConfiguration;
|
import com.cloud.network.NetworkConfiguration;
|
||||||
import com.cloud.network.NetworkConfigurationVO;
|
import com.cloud.network.NetworkConfigurationVO;
|
||||||
import com.cloud.network.NetworkProfiler;
|
|
||||||
import com.cloud.offering.NetworkOffering;
|
import com.cloud.offering.NetworkOffering;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.utils.component.AdapterBase;
|
import com.cloud.utils.component.AdapterBase;
|
||||||
@ -34,15 +33,15 @@ import com.cloud.vm.Nic;
|
|||||||
import com.cloud.vm.NicProfile;
|
import com.cloud.vm.NicProfile;
|
||||||
import com.cloud.vm.VirtualMachine;
|
import com.cloud.vm.VirtualMachine;
|
||||||
|
|
||||||
@Local(value={NetworkProfiler.class, NetworkConcierge.class})
|
@Local(value={NetworkGuru.class, NetworkConcierge.class})
|
||||||
public class ControlNetworkProfiler extends AdapterBase implements NetworkProfiler, NetworkConcierge {
|
public class ControlNetworkGuru extends AdapterBase implements NetworkGuru, NetworkConcierge {
|
||||||
private static final Logger s_logger = Logger.getLogger(ControlNetworkProfiler.class);
|
private static final Logger s_logger = Logger.getLogger(ControlNetworkGuru.class);
|
||||||
@Inject DataCenterDao _dcDao;
|
@Inject DataCenterDao _dcDao;
|
||||||
String _cidr;
|
String _cidr;
|
||||||
String _gateway;
|
String _gateway;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NetworkConfiguration convert(NetworkOffering offering, DeploymentPlan plan, Map<String, String> params, Account owner) {
|
public NetworkConfiguration design(NetworkOffering offering, DeploymentPlan plan, NetworkConfiguration specifiedConfig, Account owner) {
|
||||||
if (offering.getTrafficType() != TrafficType.Control) {
|
if (offering.getTrafficType() != TrafficType.Control) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -54,7 +53,7 @@ public class ControlNetworkProfiler extends AdapterBase implements NetworkProfil
|
|||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ControlNetworkProfiler() {
|
protected ControlNetworkGuru() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,4 +119,9 @@ public class ControlNetworkProfiler extends AdapterBase implements NetworkProfil
|
|||||||
_dcDao.releaseLinkLocalPrivateIpAddress(Long.parseLong(uniqueId));
|
_dcDao.releaseLinkLocalPrivateIpAddress(Long.parseLong(uniqueId));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NetworkConfiguration implement(NetworkConfiguration config, NetworkOffering offering, DeployDestination destination) {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -1,22 +1,20 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package com.cloud.network.profiler;
|
package com.cloud.network.configuration;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.ejb.Local;
|
import javax.ejb.Local;
|
||||||
|
|
||||||
import com.cloud.dc.DataCenterVO;
|
import com.cloud.dc.DataCenterVO;
|
||||||
import com.cloud.dc.dao.DataCenterDao;
|
import com.cloud.dc.dao.DataCenterDao;
|
||||||
import com.cloud.dc.dao.VlanDao;
|
import com.cloud.dc.dao.VlanDao;
|
||||||
|
import com.cloud.deploy.DeployDestination;
|
||||||
import com.cloud.deploy.DeploymentPlan;
|
import com.cloud.deploy.DeploymentPlan;
|
||||||
import com.cloud.network.Network.BroadcastDomainType;
|
import com.cloud.network.Network.BroadcastDomainType;
|
||||||
import com.cloud.network.Network.Mode;
|
import com.cloud.network.Network.Mode;
|
||||||
import com.cloud.network.Network.TrafficType;
|
import com.cloud.network.Network.TrafficType;
|
||||||
import com.cloud.network.NetworkConfiguration;
|
import com.cloud.network.NetworkConfiguration;
|
||||||
import com.cloud.network.NetworkConfigurationVO;
|
import com.cloud.network.NetworkConfigurationVO;
|
||||||
import com.cloud.network.NetworkProfiler;
|
|
||||||
import com.cloud.network.dao.NetworkConfigurationDao;
|
import com.cloud.network.dao.NetworkConfigurationDao;
|
||||||
import com.cloud.offering.NetworkOffering;
|
import com.cloud.offering.NetworkOffering;
|
||||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||||
@ -24,18 +22,18 @@ import com.cloud.user.Account;
|
|||||||
import com.cloud.utils.component.AdapterBase;
|
import com.cloud.utils.component.AdapterBase;
|
||||||
import com.cloud.utils.component.Inject;
|
import com.cloud.utils.component.Inject;
|
||||||
|
|
||||||
@Local(value=NetworkProfiler.class)
|
@Local(value=NetworkGuru.class)
|
||||||
public class GuestNetworkProfiler extends AdapterBase implements NetworkProfiler {
|
public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||||
@Inject protected NetworkConfigurationDao _profileDao;
|
@Inject protected NetworkConfigurationDao _profileDao;
|
||||||
@Inject protected DataCenterDao _dcDao;
|
@Inject protected DataCenterDao _dcDao;
|
||||||
@Inject protected VlanDao _vlanDao;
|
@Inject protected VlanDao _vlanDao;
|
||||||
|
|
||||||
protected GuestNetworkProfiler() {
|
protected GuestNetworkGuru() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NetworkConfiguration convert(NetworkOffering offering, DeploymentPlan plan, Map<String, String> params, Account owner) {
|
public NetworkConfiguration design(NetworkOffering offering, DeploymentPlan plan, NetworkConfiguration userSpecified, Account owner) {
|
||||||
if (offering.getTrafficType() != TrafficType.Guest) {
|
if (offering.getTrafficType() != TrafficType.Guest) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -57,4 +55,10 @@ public class GuestNetworkProfiler extends AdapterBase implements NetworkProfiler
|
|||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NetworkConfiguration implement(NetworkConfiguration config, NetworkOffering offering, DeployDestination destination) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.cloud.network.configuration;
|
||||||
|
|
||||||
|
public final class GuruUtils {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,9 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package com.cloud.network.profiler;
|
package com.cloud.network.configuration;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.ejb.Local;
|
import javax.ejb.Local;
|
||||||
|
|
||||||
@ -20,7 +18,6 @@ import com.cloud.network.Network.Mode;
|
|||||||
import com.cloud.network.Network.TrafficType;
|
import com.cloud.network.Network.TrafficType;
|
||||||
import com.cloud.network.NetworkConfiguration;
|
import com.cloud.network.NetworkConfiguration;
|
||||||
import com.cloud.network.NetworkConfigurationVO;
|
import com.cloud.network.NetworkConfigurationVO;
|
||||||
import com.cloud.network.NetworkProfiler;
|
|
||||||
import com.cloud.offering.NetworkOffering;
|
import com.cloud.offering.NetworkOffering;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.utils.component.AdapterBase;
|
import com.cloud.utils.component.AdapterBase;
|
||||||
@ -31,13 +28,13 @@ import com.cloud.vm.Nic;
|
|||||||
import com.cloud.vm.NicProfile;
|
import com.cloud.vm.NicProfile;
|
||||||
import com.cloud.vm.VirtualMachine;
|
import com.cloud.vm.VirtualMachine;
|
||||||
|
|
||||||
@Local(value={NetworkProfiler.class, NetworkConcierge.class})
|
@Local(value={NetworkGuru.class, NetworkConcierge.class})
|
||||||
public class PodBasedNetworkProfiler extends AdapterBase implements NetworkProfiler, NetworkConcierge {
|
public class PodBasedNetworkGuru extends AdapterBase implements NetworkGuru, NetworkConcierge {
|
||||||
private static final Logger s_logger = Logger.getLogger(PodBasedNetworkProfiler.class);
|
private static final Logger s_logger = Logger.getLogger(PodBasedNetworkGuru.class);
|
||||||
@Inject DataCenterDao _dcDao;
|
@Inject DataCenterDao _dcDao;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NetworkConfiguration convert(NetworkOffering offering, DeploymentPlan plan, Map<String, String> params, Account owner) {
|
public NetworkConfiguration design(NetworkOffering offering, DeploymentPlan plan, NetworkConfiguration userSpecified, Account owner) {
|
||||||
TrafficType type = offering.getTrafficType();
|
TrafficType type = offering.getTrafficType();
|
||||||
|
|
||||||
if (type != TrafficType.Management && type != TrafficType.Storage) {
|
if (type != TrafficType.Management && type != TrafficType.Storage) {
|
||||||
@ -49,7 +46,7 @@ public class PodBasedNetworkProfiler extends AdapterBase implements NetworkProfi
|
|||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected PodBasedNetworkProfiler() {
|
protected PodBasedNetworkGuru() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,4 +93,10 @@ public class PodBasedNetworkProfiler extends AdapterBase implements NetworkProfi
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NetworkConfiguration implement(NetworkConfiguration config, NetworkOffering offering, DeployDestination destination) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,12 +1,11 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package com.cloud.network.profiler;
|
package com.cloud.network.configuration;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.ejb.Local;
|
import javax.ejb.Local;
|
||||||
|
|
||||||
|
import com.cloud.dc.dao.DataCenterDao;
|
||||||
import com.cloud.deploy.DeployDestination;
|
import com.cloud.deploy.DeployDestination;
|
||||||
import com.cloud.deploy.DeploymentPlan;
|
import com.cloud.deploy.DeploymentPlan;
|
||||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||||
@ -16,21 +15,22 @@ import com.cloud.network.Network.Mode;
|
|||||||
import com.cloud.network.Network.TrafficType;
|
import com.cloud.network.Network.TrafficType;
|
||||||
import com.cloud.network.NetworkConfiguration;
|
import com.cloud.network.NetworkConfiguration;
|
||||||
import com.cloud.network.NetworkConfigurationVO;
|
import com.cloud.network.NetworkConfigurationVO;
|
||||||
import com.cloud.network.NetworkProfiler;
|
|
||||||
import com.cloud.offering.NetworkOffering;
|
import com.cloud.offering.NetworkOffering;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.utils.component.AdapterBase;
|
import com.cloud.utils.component.AdapterBase;
|
||||||
|
import com.cloud.utils.component.Inject;
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
import com.cloud.vm.NetworkConcierge;
|
import com.cloud.vm.NetworkConcierge;
|
||||||
import com.cloud.vm.Nic;
|
import com.cloud.vm.Nic;
|
||||||
import com.cloud.vm.NicProfile;
|
import com.cloud.vm.NicProfile;
|
||||||
import com.cloud.vm.VirtualMachine;
|
import com.cloud.vm.VirtualMachine;
|
||||||
|
|
||||||
@Local(value={NetworkProfiler.class, NetworkConcierge.class})
|
@Local(value={NetworkGuru.class, NetworkConcierge.class})
|
||||||
public class PublicNetworkProfiler extends AdapterBase implements NetworkProfiler, NetworkConcierge {
|
public class PublicNetworkProfiler extends AdapterBase implements NetworkGuru, NetworkConcierge {
|
||||||
|
@Inject DataCenterDao _dcDao;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NetworkConfiguration convert(NetworkOffering offering, DeploymentPlan plan, Map<String, String> params, Account owner) {
|
public NetworkConfiguration design(NetworkOffering offering, DeploymentPlan plan, NetworkConfiguration config, Account owner) {
|
||||||
if (offering.getTrafficType() != TrafficType.Public) {
|
if (offering.getTrafficType() != TrafficType.Public) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -77,4 +77,11 @@ public class PublicNetworkProfiler extends AdapterBase implements NetworkProfile
|
|||||||
public boolean release(String uniqueName, String uniqueId) {
|
public boolean release(String uniqueName, String uniqueId) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NetworkConfiguration implement(NetworkConfiguration config, NetworkOffering offering, DeployDestination destination) {
|
||||||
|
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -1,9 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package com.cloud.network.profiler;
|
|
||||||
|
|
||||||
public final class ProfilerUtils {
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -29,6 +29,7 @@ import javax.naming.ConfigurationException;
|
|||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.agent.AgentManager;
|
import com.cloud.agent.AgentManager;
|
||||||
|
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||||
import com.cloud.configuration.Config;
|
import com.cloud.configuration.Config;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
import com.cloud.deploy.DeployDestination;
|
import com.cloud.deploy.DeployDestination;
|
||||||
@ -55,6 +56,7 @@ import com.cloud.utils.component.Inject;
|
|||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.db.Transaction;
|
import com.cloud.utils.db.Transaction;
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
|
import com.cloud.vm.VirtualMachine.Event;
|
||||||
import com.cloud.vm.dao.VMInstanceDao;
|
import com.cloud.vm.dao.VMInstanceDao;
|
||||||
|
|
||||||
@Local(value=VmManager.class)
|
@Local(value=VmManager.class)
|
||||||
@ -85,14 +87,15 @@ public class MauriceMoss implements VmManager {
|
|||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Allocating entries for VM: " + vm);
|
s_logger.debug("Allocating entries for VM: " + vm);
|
||||||
}
|
}
|
||||||
VMInstanceVO instance = _vmDao.findById(vm.getId());
|
//VMInstanceVO vm = _vmDao.findById(vm.getId());
|
||||||
VirtualMachineProfile vmProfile = new VirtualMachineProfile(instance, serviceOffering);
|
VirtualMachineProfile vmProfile = new VirtualMachineProfile(vm, serviceOffering);
|
||||||
|
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
txn.start();
|
txn.start();
|
||||||
instance.setDataCenterId(plan.getDataCenterId());
|
vm.setDataCenterId(plan.getDataCenterId());
|
||||||
_vmDao.update(instance.getId(), instance);
|
_vmDao.update(vm.getId(), vm);
|
||||||
List<NicProfile> nics = _networkMgr.allocate(instance, networks);
|
|
||||||
|
List<NicProfile> nics = _networkMgr.allocate(vm, networks);
|
||||||
vmProfile.setNics(nics);
|
vmProfile.setNics(nics);
|
||||||
|
|
||||||
if (dataDiskOfferings == null) {
|
if (dataDiskOfferings == null) {
|
||||||
@ -101,32 +104,21 @@ public class MauriceMoss implements VmManager {
|
|||||||
|
|
||||||
List<DiskProfile> disks = new ArrayList<DiskProfile>(dataDiskOfferings.size() + 1);
|
List<DiskProfile> disks = new ArrayList<DiskProfile>(dataDiskOfferings.size() + 1);
|
||||||
if (template.getFormat() == ImageFormat.ISO) {
|
if (template.getFormat() == ImageFormat.ISO) {
|
||||||
disks.add(_storageMgr.allocateRawVolume(VolumeType.ROOT, "ROOT-" + vm.getId(), rootDiskOffering.first(), rootDiskOffering.second(), instance, owner));
|
disks.add(_storageMgr.allocateRawVolume(VolumeType.ROOT, "ROOT-" + vm.getId(), rootDiskOffering.first(), rootDiskOffering.second(), vm, owner));
|
||||||
} else {
|
} else {
|
||||||
disks.add(_storageMgr.allocateTemplatedVolume(VolumeType.ROOT, "ROOT-" + vm.getId(), rootDiskOffering.first(), template, instance, owner));
|
disks.add(_storageMgr.allocateTemplatedVolume(VolumeType.ROOT, "ROOT-" + vm.getId(), rootDiskOffering.first(), template, vm, owner));
|
||||||
}
|
}
|
||||||
for (Pair<DiskOfferingVO, Long> offering : dataDiskOfferings) {
|
for (Pair<DiskOfferingVO, Long> offering : dataDiskOfferings) {
|
||||||
disks.add(_storageMgr.allocateRawVolume(VolumeType.DATADISK, "DATA-" + vm.getId(), offering.first(), offering.second(), instance, owner));
|
disks.add(_storageMgr.allocateRawVolume(VolumeType.DATADISK, "DATA-" + vm.getId(), offering.first(), offering.second(), vm, owner));
|
||||||
}
|
}
|
||||||
vmProfile.setDisks(disks);
|
vmProfile.setDisks(disks);
|
||||||
|
|
||||||
|
_vmDao.updateIf(vm, Event.OperationSucceeded, null);
|
||||||
txn.commit();
|
txn.commit();
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Allocation completed for VM: " + vm);
|
s_logger.debug("Allocation completed for VM: " + vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean created = false;
|
|
||||||
try {
|
|
||||||
vmProfile = create(vmProfile, plan);
|
|
||||||
created = vmProfile != null;
|
|
||||||
} catch (InsufficientCapacityException e) {
|
|
||||||
throw e;
|
|
||||||
} finally {
|
|
||||||
if (!created) {
|
|
||||||
// TODO: Error handling
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return vmProfile;
|
return vmProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,8 +232,45 @@ public class MauriceMoss implements VmManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends VMInstanceVO> T start(T vm) {
|
public <T extends VMInstanceVO> T start(VirtualMachineProfile vmProfile, DeploymentPlan plan) throws InsufficientCapacityException {
|
||||||
// TODO Auto-generated method stub
|
if (s_logger.isDebugEnabled()) {
|
||||||
|
s_logger.debug("Creating actual resources for VM " + vmProfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
Journal journal = new Journal.LogJournal("Creating " + vmProfile, s_logger);
|
||||||
|
|
||||||
|
Set<DeployDestination> avoids = new HashSet<DeployDestination>();
|
||||||
|
int retry = _retry;
|
||||||
|
while (_retry-- > 0) {
|
||||||
|
DeployDestination context = null;
|
||||||
|
for (DeploymentDispatcher dispatcher : _dispatchers) {
|
||||||
|
context = dispatcher.plan(vmProfile, plan, avoids);
|
||||||
|
if (context != null) {
|
||||||
|
avoids.add(context);
|
||||||
|
journal.record("Deployment found ", vmProfile, context);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context == null) {
|
||||||
|
throw new CloudRuntimeException("Unable to create a deployment for " + vmProfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
VMInstanceVO vm = _vmDao.findById(vmProfile.getId());
|
||||||
|
|
||||||
|
vm.setDataCenterId(context.getDataCenter().getId());
|
||||||
|
vm.setPodId(context.getPod().getId());
|
||||||
|
_vmDao.updateIf(vm, Event.StartRequested, context.getHost().getId());
|
||||||
|
|
||||||
|
VirtualMachineTO vmTO = new VirtualMachineTO();
|
||||||
|
// _networkMgr.prepare(vmProfile);
|
||||||
|
// _storageMgr.prepare(vm);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s_logger.isDebugEnabled()) {
|
||||||
|
s_logger.debug("Creation complete for VM " + vmProfile);
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -157,6 +157,11 @@ public class NicVO implements Nic {
|
|||||||
public void setReserver(String reserver) {
|
public void setReserver(String reserver) {
|
||||||
this.reserver = reserver;
|
this.reserver = reserver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ReservationStrategy getReservationStrategy() {
|
||||||
|
return ReservationStrategy.Start;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getExpectedReservationInterval() {
|
public int getExpectedReservationInterval() {
|
||||||
|
|||||||
@ -62,7 +62,7 @@ public interface VmManager extends Manager {
|
|||||||
DeploymentPlan plan,
|
DeploymentPlan plan,
|
||||||
AccountVO owner) throws InsufficientCapacityException, StorageUnavailableException;
|
AccountVO owner) throws InsufficientCapacityException, StorageUnavailableException;
|
||||||
|
|
||||||
<T extends VMInstanceVO> T start(T vm) throws InsufficientCapacityException, StorageUnavailableException, ConcurrentOperationException;
|
<T extends VMInstanceVO> T start(VirtualMachineProfile p, DeploymentPlan plan) throws InsufficientCapacityException, StorageUnavailableException, ConcurrentOperationException;
|
||||||
|
|
||||||
<T extends VMInstanceVO> T stop(T vm) throws AgentUnavailableException, ConcurrentOperationException;
|
<T extends VMInstanceVO> T stop(T vm) throws AgentUnavailableException, ConcurrentOperationException;
|
||||||
|
|
||||||
|
|||||||
@ -100,7 +100,9 @@ CREATE TABLE `cloud`.`network_configurations` (
|
|||||||
`mode` varchar(32) COMMENT 'How to retrieve ip address in this network',
|
`mode` varchar(32) COMMENT 'How to retrieve ip address in this network',
|
||||||
`vlan_id` bigint unsigned NULL COMMENT 'vlan id if the broadcast_domain_type is the vlan',
|
`vlan_id` bigint unsigned NULL COMMENT 'vlan id if the broadcast_domain_type is the vlan',
|
||||||
`network_offering_id` bigint unsigned NOT NULL COMMENT 'network offering id that this configuration is created from',
|
`network_offering_id` bigint unsigned NOT NULL COMMENT 'network offering id that this configuration is created from',
|
||||||
`data_center_id` bigint unsigned NOT NULL COMMENT 'data center id that this configuration is used in',
|
`data_center_id` bigint unsigned NOT NULL COMMENT 'data center id that this configuration is used in',
|
||||||
|
`handler_name` varchar(255) NOT NULL COMMENT 'who is responsible for this type of network configuration',
|
||||||
|
`state` varchar(32) NOT NULL COMMENT 'what state is this configuration in',
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|||||||
@ -74,7 +74,7 @@ public class Adapters<T extends Adapter> implements Iterable<T> {
|
|||||||
this._adapters = adapters;
|
this._adapters = adapters;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected T get(String name) {
|
public T get(String name) {
|
||||||
return _map.get(name);
|
return _map.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -101,7 +101,7 @@ public interface GenericDao<T, ID extends Serializable> {
|
|||||||
* @return object if acquired; null if not. If null, you need to call findById to see if it is actually not found.
|
* @return object if acquired; null if not. If null, you need to call findById to see if it is actually not found.
|
||||||
*/
|
*/
|
||||||
T acquire(ID id);
|
T acquire(ID id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Acquires a database wide lock on the id of the entity. This ensures
|
* Acquires a database wide lock on the id of the entity. This ensures
|
||||||
* that only one is being used. The timeout is the configured default.
|
* that only one is being used. The timeout is the configured default.
|
||||||
@ -184,7 +184,15 @@ public interface GenericDao<T, ID extends Serializable> {
|
|||||||
boolean remove(ID id);
|
boolean remove(ID id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* remove the entity bean.
|
* Remove based on the search criteria. This will delete if the VO object
|
||||||
|
* does not have a REMOVED column.
|
||||||
|
* @param sc search criteria to match
|
||||||
|
* @return rows removed.
|
||||||
|
*/
|
||||||
|
int remove(SearchCriteria<T> sc);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expunge actually delete the row even if it's REMOVED.
|
||||||
* @param id
|
* @param id
|
||||||
* @return true if removed.
|
* @return true if removed.
|
||||||
*/
|
*/
|
||||||
@ -212,5 +220,4 @@ public interface GenericDao<T, ID extends Serializable> {
|
|||||||
*/
|
*/
|
||||||
boolean configure(String name, Map<String, Object> params) throws ConfigurationException;
|
boolean configure(String name, Map<String, Object> params) throws ConfigurationException;
|
||||||
|
|
||||||
int remove(SearchCriteria<T> sc);
|
|
||||||
}
|
}
|
||||||
@ -1370,4 +1370,5 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
|
|||||||
SearchBuilder<T> builder = createSearchBuilder();
|
SearchBuilder<T> builder = createSearchBuilder();
|
||||||
return builder.create();
|
return builder.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,7 +43,7 @@ import com.cloud.utils.exception.CloudRuntimeException;
|
|||||||
* @param <T> VO object this Search is build for.
|
* @param <T> VO object this Search is build for.
|
||||||
* @param <K> Result object that should contain the results.
|
* @param <K> Result object that should contain the results.
|
||||||
*/
|
*/
|
||||||
public class GenericSearchBuilder<T, K> implements DaoSearch<T, K>, MethodInterceptor {
|
public class GenericSearchBuilder<T, K> implements MethodInterceptor {
|
||||||
final protected Map<String, Attribute> _attrs;
|
final protected Map<String, Attribute> _attrs;
|
||||||
|
|
||||||
protected ArrayList<Condition> _conditions;
|
protected ArrayList<Condition> _conditions;
|
||||||
|
|||||||
31
utils/src/com/cloud/utils/db/StateMachine.java
Normal file
31
utils/src/com/cloud/utils/db/StateMachine.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.utils.db;
|
||||||
|
|
||||||
|
import static java.lang.annotation.ElementType.FIELD;
|
||||||
|
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||||
|
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Target(FIELD)
|
||||||
|
@Retention(RUNTIME)
|
||||||
|
public @interface StateMachine {
|
||||||
|
public Class<?> state();
|
||||||
|
public Class<?> event();
|
||||||
|
}
|
||||||
55
utils/src/com/cloud/utils/fsm/FiniteState.java
Normal file
55
utils/src/com/cloud/utils/fsm/FiniteState.java
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/**
|
||||||
|
* 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.utils.fsm;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for a state in the finite state machine.
|
||||||
|
*
|
||||||
|
* @param <S> State
|
||||||
|
* @param <E> Event
|
||||||
|
*/
|
||||||
|
public interface FiniteState<S, E> {
|
||||||
|
/**
|
||||||
|
* @return the state machine being used.
|
||||||
|
*/
|
||||||
|
StateMachine<S, E> getStateMachine();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get next state based on the event.
|
||||||
|
* @param event
|
||||||
|
* @return next State
|
||||||
|
*/
|
||||||
|
S getNextState(E event);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the states that could have traveled to the current state
|
||||||
|
* via this event.
|
||||||
|
* @param event
|
||||||
|
* @return array of states
|
||||||
|
*/
|
||||||
|
List<S> getFromStates(E event);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the possible events that can happen from the current state.
|
||||||
|
* @return array of events.
|
||||||
|
*/
|
||||||
|
Set<E> getPossibleEvents();
|
||||||
|
}
|
||||||
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||||
*
|
*
|
||||||
* This software is licensed under the GNU General Public License v3 or later.
|
* 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 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -15,7 +15,13 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package com.cloud.utils.db;
|
package com.cloud.utils.fsm;
|
||||||
|
|
||||||
public interface DaoSearch<T, K> {
|
public interface FiniteStateObject<S, E> {
|
||||||
|
/**
|
||||||
|
* @return finite state.
|
||||||
|
*/
|
||||||
|
FiniteState<S, E> getState();
|
||||||
|
|
||||||
|
void setState(S state);
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user