mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
finalized guru design
This commit is contained in:
parent
0be5053c56
commit
979fcf8b78
@ -57,7 +57,28 @@ public class DeployDestination {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
assert false : "Not implemented correctly yet.";
|
DeployDestination that = (DeployDestination)obj;
|
||||||
return false;
|
if (this._dc == null || that._dc == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this._dc.getId() != that._dc.getId()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this._pod == null || that._pod == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this._pod.getId() != that._pod.getId()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this._cluster == null || that._cluster == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this._cluster.getId() != that._cluster.getId()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this._host == null || that._host == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return this._host.getId() == that._host.getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,9 +27,9 @@ public interface NetworkGuru extends Adapter {
|
|||||||
|
|
||||||
NicProfile allocate(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
|
NicProfile allocate(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
|
||||||
|
|
||||||
boolean create(NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
|
// NicProfile create(NicProfile nic, NetworkConfiguration config, VirtualMachineProfile vm, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
|
||||||
|
|
||||||
String reserve(NicProfile nic, VirtualMachineProfile vm, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
|
String reserve(NicProfile nic, NetworkConfiguration config, VirtualMachineProfile vm, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
|
||||||
|
|
||||||
boolean release(String uniqueId);
|
boolean release(String uniqueId);
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,11 @@
|
|||||||
package com.cloud.resource;
|
package com.cloud.resource;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.cloud.utils.fsm.FiniteState;
|
||||||
|
import com.cloud.utils.fsm.StateMachine;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates a resource in CloudStack.
|
* Indicates a resource in CloudStack.
|
||||||
@ -12,11 +17,50 @@ import java.util.Date;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface Resource {
|
public interface Resource {
|
||||||
enum State {
|
enum Event {
|
||||||
Allocated, // The resource is allocated but not re
|
ReservationRequested,
|
||||||
Reserving,
|
ReleaseRequested,
|
||||||
Reserved,
|
CancelRequested,
|
||||||
Releasing,
|
OperationCompleted,
|
||||||
|
OperationFailed,
|
||||||
|
}
|
||||||
|
|
||||||
|
enum State implements FiniteState<State, Event> {
|
||||||
|
Allocated, // Resource is allocated
|
||||||
|
Reserving, // Resource is being reserved right now.
|
||||||
|
Reserved, // Resource is reserved
|
||||||
|
Releasing, // Resource is being released.
|
||||||
|
Ready; // Resource is ready which means it does not need to go through reservation.
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StateMachine<State, Event> getStateMachine() {
|
||||||
|
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public State getNextState(Event event) {
|
||||||
|
return s_fsm.getNextState(this, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<State> getFromStates(Event event) {
|
||||||
|
return s_fsm.getFromStates(this, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Event> getPossibleEvents() {
|
||||||
|
return s_fsm.getPossibleEvents(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
final static private StateMachine<State, Event> s_fsm = new StateMachine<State, Event>();
|
||||||
|
static {
|
||||||
|
s_fsm.addTransition(State.Allocated, Event.ReservationRequested, State.Reserving);
|
||||||
|
s_fsm.addTransition(State.Reserving, Event.CancelRequested, State.Allocated);
|
||||||
|
s_fsm.addTransition(State.Reserving, Event.OperationCompleted, State.Reserved);
|
||||||
|
s_fsm.addTransition(State.Reserving, Event.OperationFailed, State.Allocated);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ReservationStrategy {
|
enum ReservationStrategy {
|
||||||
|
|||||||
@ -10,15 +10,15 @@ 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.resource.Resource;
|
||||||
|
import com.cloud.resource.Resource.ReservationStrategy;
|
||||||
|
|
||||||
public class NicProfile {
|
public class NicProfile {
|
||||||
long id;
|
long id;
|
||||||
BroadcastDomainType broadcastType;
|
BroadcastDomainType broadcastType;
|
||||||
String cidr;
|
|
||||||
Mode mode;
|
Mode mode;
|
||||||
long vmId;
|
long vmId;
|
||||||
String gateway;
|
String gateway;
|
||||||
int deviceId;
|
|
||||||
AddressFormat format;
|
AddressFormat format;
|
||||||
TrafficType trafficType;
|
TrafficType trafficType;
|
||||||
String ip4Address;
|
String ip4Address;
|
||||||
@ -27,6 +27,8 @@ public class NicProfile {
|
|||||||
URI isolationUri;
|
URI isolationUri;
|
||||||
String netmask;
|
String netmask;
|
||||||
URI broadcastUri;
|
URI broadcastUri;
|
||||||
|
ReservationStrategy strategy;
|
||||||
|
String reservationId;
|
||||||
|
|
||||||
public String getNetmask() {
|
public String getNetmask() {
|
||||||
return netmask;
|
return netmask;
|
||||||
@ -44,7 +46,7 @@ public class NicProfile {
|
|||||||
return broadcastUri;
|
return broadcastUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsolationUril(URI isolationUri) {
|
public void setIsolationUri(URI isolationUri) {
|
||||||
this.isolationUri = isolationUri;
|
this.isolationUri = isolationUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,10 +62,6 @@ public class NicProfile {
|
|||||||
this.broadcastType = broadcastType;
|
this.broadcastType = broadcastType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCidr(String cidr) {
|
|
||||||
this.cidr = cidr;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMode(Mode mode) {
|
public void setMode(Mode mode) {
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
}
|
}
|
||||||
@ -76,10 +74,6 @@ public class NicProfile {
|
|||||||
this.gateway = gateway;
|
this.gateway = gateway;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDeviceId(int deviceId) {
|
|
||||||
this.deviceId = deviceId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFormat(AddressFormat format) {
|
public void setFormat(AddressFormat format) {
|
||||||
this.format = format;
|
this.format = format;
|
||||||
}
|
}
|
||||||
@ -112,10 +106,6 @@ public class NicProfile {
|
|||||||
return broadcastType;
|
return broadcastType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCidr() {
|
|
||||||
return cidr;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMacAddress(String macAddress) {
|
public void setMacAddress(String macAddress) {
|
||||||
this.macAddress = macAddress;
|
this.macAddress = macAddress;
|
||||||
}
|
}
|
||||||
@ -128,10 +118,6 @@ public class NicProfile {
|
|||||||
return gateway;
|
return gateway;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDeviceId() {
|
|
||||||
return deviceId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AddressFormat getFormat() {
|
public AddressFormat getFormat() {
|
||||||
return format;
|
return format;
|
||||||
}
|
}
|
||||||
@ -158,8 +144,6 @@ public class NicProfile {
|
|||||||
|
|
||||||
public NicProfile(Nic nic, NetworkConfiguration network) {
|
public NicProfile(Nic nic, NetworkConfiguration network) {
|
||||||
this.id = nic.getId();
|
this.id = nic.getId();
|
||||||
this.deviceId = nic.getDeviceId();
|
|
||||||
this.cidr = network.getCidr();
|
|
||||||
this.gateway = network.getGateway();
|
this.gateway = network.getGateway();
|
||||||
this.mode = network.getMode();
|
this.mode = network.getMode();
|
||||||
this.format = null;
|
this.format = null;
|
||||||
@ -168,19 +152,35 @@ public class NicProfile {
|
|||||||
this.ip4Address = nic.getIp4Address();
|
this.ip4Address = nic.getIp4Address();
|
||||||
this.ip6Address = null;
|
this.ip6Address = null;
|
||||||
this.macAddress = nic.getMacAddress();
|
this.macAddress = nic.getMacAddress();
|
||||||
|
this.reservationId = nic.getReservationId();
|
||||||
|
this.strategy = nic.getReservationStrategy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public NicProfile(long id, BroadcastDomainType type, String cidr, Mode mode, long vmId) {
|
public NicProfile(long id, BroadcastDomainType type, Mode mode, long vmId) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.broadcastType = type;
|
this.broadcastType = type;
|
||||||
this.cidr = cidr;
|
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
this.vmId = vmId;
|
this.vmId = vmId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NicProfile(String ip4Address, String macAddress, String gateway) {
|
public NicProfile(Resource.ReservationStrategy strategy, String ip4Address, String macAddress, String gateway, String netmask) {
|
||||||
|
this.format = AddressFormat.Ip4;
|
||||||
this.ip4Address = ip4Address;
|
this.ip4Address = ip4Address;
|
||||||
this.macAddress = macAddress;
|
this.macAddress = macAddress;
|
||||||
this.gateway = gateway;
|
this.gateway = gateway;
|
||||||
|
this.netmask = netmask;
|
||||||
|
this.strategy = strategy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReservationStrategy getReservationStrategy() {
|
||||||
|
return strategy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getReservationId() {
|
||||||
|
return reservationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReservationId(String reservationId) {
|
||||||
|
this.reservationId = reservationId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,25 +17,15 @@
|
|||||||
*/
|
*/
|
||||||
package com.cloud.vm;
|
package com.cloud.vm;
|
||||||
|
|
||||||
|
import com.cloud.network.Network.IsolationType;
|
||||||
|
import com.cloud.network.Network.Mode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* VirtualNetwork describes from a management level the
|
* VirtualNetwork describes from a management level the
|
||||||
* things needed to provide the network to the virtual
|
* things needed to provide the network to the virtual
|
||||||
* machine.
|
* machine.
|
||||||
*/
|
*/
|
||||||
public class VirtualNetwork {
|
public class VirtualNetwork {
|
||||||
public enum Mode {
|
|
||||||
None,
|
|
||||||
Local,
|
|
||||||
Static,
|
|
||||||
Dhcp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum Isolation {
|
|
||||||
VNET,
|
|
||||||
VLAN,
|
|
||||||
OSWITCH,
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The gateway for this network.
|
* The gateway for this network.
|
||||||
*/
|
*/
|
||||||
@ -74,7 +64,7 @@ public class VirtualNetwork {
|
|||||||
/**
|
/**
|
||||||
* Isolation method for networking.
|
* Isolation method for networking.
|
||||||
*/
|
*/
|
||||||
public Isolation method;
|
public IsolationType method;
|
||||||
|
|
||||||
public boolean firewalled;
|
public boolean firewalled;
|
||||||
|
|
||||||
|
|||||||
@ -2488,7 +2488,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||||||
nic.setState(Resource.State.Reserving);
|
nic.setState(Resource.State.Reserving);
|
||||||
_nicDao.update(nic.getId(), nic);
|
_nicDao.update(nic.getId(), nic);
|
||||||
NicProfile profile = toNicProfile(nic);
|
NicProfile profile = toNicProfile(nic);
|
||||||
String reservationId = concierge.reserve(profile, vmProfile, dest);
|
String reservationId = concierge.reserve(profile, config, vmProfile, dest);
|
||||||
nic.setIp4Address(profile.getIp4Address());
|
nic.setIp4Address(profile.getIp4Address());
|
||||||
nic.setIp6Address(profile.getIp6Address());
|
nic.setIp6Address(profile.getIp6Address());
|
||||||
nic.setMacAddress(profile.getMacAddress());
|
nic.setMacAddress(profile.getMacAddress());
|
||||||
@ -2497,6 +2497,9 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||||||
nic.setReservationId(reservationId);
|
nic.setReservationId(reservationId);
|
||||||
nic.setReserver(concierge.getName());
|
nic.setReserver(concierge.getName());
|
||||||
nic.setState(Resource.State.Reserved);
|
nic.setState(Resource.State.Reserved);
|
||||||
|
nic.setNetmask(profile.getNetmask());
|
||||||
|
nic.setGateway(profile.getGateway());
|
||||||
|
nic.setAddressFormat(profile.getFormat());
|
||||||
_nicDao.update(nic.getId(), nic);
|
_nicDao.update(nic.getId(), nic);
|
||||||
for (NetworkElement element : _networkElements) {
|
for (NetworkElement element : _networkElements) {
|
||||||
if (!element.prepare(config, profile, vmProfile, null)) {
|
if (!element.prepare(config, profile, vmProfile, null)) {
|
||||||
|
|||||||
@ -17,12 +17,14 @@ 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;
|
||||||
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||||
|
import com.cloud.network.Network.AddressFormat;
|
||||||
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.offering.NetworkOffering;
|
import com.cloud.offering.NetworkOffering;
|
||||||
|
import com.cloud.resource.Resource.ReservationStrategy;
|
||||||
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.ComponentLocator;
|
import com.cloud.utils.component.ComponentLocator;
|
||||||
@ -90,21 +92,18 @@ public class ControlNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||||||
throw new CloudRuntimeException("Does not support nic specification at this time: " + nic);
|
throw new CloudRuntimeException("Does not support nic specification at this time: " + nic);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new NicProfile(null, null, null);
|
return new NicProfile(ReservationStrategy.Start, null, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean create(NicProfile nic, VirtualMachineProfile profile) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
|
public String reserve(NicProfile nic, NetworkConfiguration config, VirtualMachineProfile vm, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException,
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String reserve(NicProfile nic, VirtualMachineProfile vm, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException,
|
|
||||||
InsufficientAddressCapacityException {
|
InsufficientAddressCapacityException {
|
||||||
String ip = _dcDao.allocateLinkLocalPrivateIpAddress(dest.getDataCenter().getId(), dest.getPod().getId(), vm.getId());
|
String ip = _dcDao.allocateLinkLocalPrivateIpAddress(dest.getDataCenter().getId(), dest.getPod().getId(), vm.getId());
|
||||||
nic.setIp4Address(ip);
|
nic.setIp4Address(ip);
|
||||||
nic.setMacAddress("FE:FF:FF:FF:FF:FF");
|
nic.setMacAddress("FE:FF:FF:FF:FF:FF");
|
||||||
nic.setNetmask("255.255.0.0");
|
nic.setNetmask("255.255.0.0");
|
||||||
|
nic.setFormat(AddressFormat.Ip4);
|
||||||
|
|
||||||
return Long.toString(nic.getId());
|
return Long.toString(nic.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -73,14 +73,7 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean create(NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapcityException,
|
public String reserve(NicProfile nic, NetworkConfiguration config, VirtualMachineProfile vm, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException,
|
||||||
InsufficientAddressCapacityException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String reserve(NicProfile nic, VirtualMachineProfile vm, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException,
|
|
||||||
InsufficientAddressCapacityException {
|
InsufficientAddressCapacityException {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@ -14,12 +14,14 @@ 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;
|
||||||
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||||
|
import com.cloud.network.Network.AddressFormat;
|
||||||
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.offering.NetworkOffering;
|
import com.cloud.offering.NetworkOffering;
|
||||||
|
import com.cloud.resource.Resource.ReservationStrategy;
|
||||||
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.component.Inject;
|
||||||
@ -62,17 +64,12 @@ public class PodBasedNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||||||
throw new CloudRuntimeException("Does not support nic configuration");
|
throw new CloudRuntimeException("Does not support nic configuration");
|
||||||
}
|
}
|
||||||
|
|
||||||
NicProfile profile = new NicProfile(null, null, null);
|
NicProfile profile = new NicProfile(ReservationStrategy.Start, null, null, null, null);
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean create(NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
|
public String reserve(NicProfile nic, NetworkConfiguration config, VirtualMachineProfile vm, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException,
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String reserve(NicProfile nic, VirtualMachineProfile vm, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException,
|
|
||||||
InsufficientAddressCapacityException {
|
InsufficientAddressCapacityException {
|
||||||
DataCenter dc = dest.getDataCenter();
|
DataCenter dc = dest.getDataCenter();
|
||||||
Pod pod = dest.getPod();
|
Pod pod = dest.getPod();
|
||||||
@ -81,9 +78,9 @@ public class PodBasedNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||||||
String[] macs = _dcDao.getNextAvailableMacAddressPair(dc.getId());
|
String[] macs = _dcDao.getNextAvailableMacAddressPair(dc.getId());
|
||||||
|
|
||||||
nic.setIp4Address(ip);
|
nic.setIp4Address(ip);
|
||||||
nic.setCidr(pod.getCidrAddress() + "/" + pod.getCidrSize());
|
|
||||||
nic.setGateway(pod.getGateway());
|
nic.setGateway(pod.getGateway());
|
||||||
nic.setMacAddress(macs[0]);
|
nic.setMacAddress(macs[0]);
|
||||||
|
nic.setFormat(AddressFormat.Ip4);
|
||||||
String netmask = NetUtils.getCidrSubNet(pod.getCidrAddress(), pod.getCidrSize());
|
String netmask = NetUtils.getCidrSubNet(pod.getCidrAddress(), pod.getCidrSize());
|
||||||
nic.setNetmask(netmask);
|
nic.setNetmask(netmask);
|
||||||
|
|
||||||
|
|||||||
@ -3,9 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.cloud.network.configuration;
|
package com.cloud.network.configuration;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
|
|
||||||
import javax.ejb.Local;
|
import javax.ejb.Local;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
@ -18,12 +15,15 @@ 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;
|
||||||
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||||
|
import com.cloud.network.Network.AddressFormat;
|
||||||
import com.cloud.network.Network.BroadcastDomainType;
|
import com.cloud.network.Network.BroadcastDomainType;
|
||||||
|
import com.cloud.network.Network.IsolationType;
|
||||||
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.offering.NetworkOffering;
|
import com.cloud.offering.NetworkOffering;
|
||||||
|
import com.cloud.resource.Resource.ReservationStrategy;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.component.AdapterBase;
|
import com.cloud.utils.component.AdapterBase;
|
||||||
@ -63,18 +63,19 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||||||
throw new CloudRuntimeException("Unsupported nic settings");
|
throw new CloudRuntimeException("Unsupported nic settings");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new NicProfile(null, null, null);
|
return new NicProfile(ReservationStrategy.Create, null, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean create(NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
|
public String reserve(NicProfile ch, NetworkConfiguration configuration, VirtualMachineProfile vm, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
|
||||||
return true;
|
if (ch.getReservationId() != null) {
|
||||||
}
|
return ch.getReservationId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String reserve(NicProfile ch, VirtualMachineProfile vm, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
|
|
||||||
long dcId = dest.getDataCenter().getId();
|
long dcId = dest.getDataCenter().getId();
|
||||||
|
|
||||||
|
String[] macs = _dcDao.getNextAvailableMacAddressPair(dcId);
|
||||||
|
|
||||||
Pair<String, VlanVO> ipAndVlan = _vlanDao.assignIpAddress(dcId, vm.getVm().getAccountId(), vm.getVm().getDomainId(), VlanType.VirtualNetwork, true);
|
Pair<String, VlanVO> ipAndVlan = _vlanDao.assignIpAddress(dcId, vm.getVm().getAccountId(), vm.getVm().getDomainId(), VlanType.VirtualNetwork, true);
|
||||||
if (ipAndVlan == null) {
|
if (ipAndVlan == null) {
|
||||||
throw new InsufficientVirtualNetworkCapcityException("Unable to get public ip address in " + dcId);
|
throw new InsufficientVirtualNetworkCapcityException("Unable to get public ip address in " + dcId);
|
||||||
@ -83,12 +84,12 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||||||
ch.setIp4Address(ipAndVlan.first());
|
ch.setIp4Address(ipAndVlan.first());
|
||||||
ch.setGateway(vlan.getVlanGateway());
|
ch.setGateway(vlan.getVlanGateway());
|
||||||
ch.setNetmask(vlan.getVlanNetmask());
|
ch.setNetmask(vlan.getVlanNetmask());
|
||||||
try {
|
ch.setIsolationUri(IsolationType.Vlan.toUri(vlan.getVlanId()));
|
||||||
ch.setIsolationUril(new URI("vlan://" + vlan.getVlanId()));
|
|
||||||
} catch (URISyntaxException e) {
|
|
||||||
throw new CloudRuntimeException("URI Syntax: " + "vlan://" + vlan.getVlanId(), e);
|
|
||||||
}
|
|
||||||
ch.setBroadcastType(BroadcastDomainType.Vlan);
|
ch.setBroadcastType(BroadcastDomainType.Vlan);
|
||||||
|
ch.setBroadcastUri(BroadcastDomainType.Vlan.toUri(vlan.getVlanId()));
|
||||||
|
ch.setMacAddress(macs[1]);
|
||||||
|
ch.setFormat(AddressFormat.Ip4);
|
||||||
|
ch.setReservationId(Long.toString(vlan.getId()));
|
||||||
|
|
||||||
return Long.toString(vlan.getId());
|
return Long.toString(vlan.getId());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,6 +29,7 @@ import javax.persistence.GenerationType;
|
|||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import com.cloud.network.Network.AddressFormat;
|
||||||
import com.cloud.network.Network.Mode;
|
import com.cloud.network.Network.Mode;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@ -57,6 +58,9 @@ public class NicVO implements Nic {
|
|||||||
@Column(name="isolation_uri")
|
@Column(name="isolation_uri")
|
||||||
URI isolationUri;
|
URI isolationUri;
|
||||||
|
|
||||||
|
@Column(name="ip_type")
|
||||||
|
AddressFormat addressFormat;
|
||||||
|
|
||||||
@Column(name="broadcast_uri")
|
@Column(name="broadcast_uri")
|
||||||
URI broadcastUri;
|
URI broadcastUri;
|
||||||
|
|
||||||
@ -139,6 +143,14 @@ public class NicVO implements Nic {
|
|||||||
this.gateway = gateway;
|
this.gateway = gateway;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AddressFormat getAddressFormat() {
|
||||||
|
return addressFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddressFormat(AddressFormat format) {
|
||||||
|
this.addressFormat = format;
|
||||||
|
}
|
||||||
|
|
||||||
public void setNetmask(String netmask) {
|
public void setNetmask(String netmask) {
|
||||||
this.netmask = netmask;
|
this.netmask = netmask;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user