switched from networkprofile to network configuration

This commit is contained in:
root 2010-09-09 17:48:24 -07:00
parent 5d185ad82f
commit 077690cf15
17 changed files with 132 additions and 124 deletions

View File

@ -19,7 +19,9 @@ package com.cloud.deploy;
public class DataCenterDeployment implements DeploymentPlan {
long _dcId;
public DataCenterDeployment(long dataCenterId) {
int _count;
public DataCenterDeployment(long dataCenterId, int count) {
_dcId = dataCenterId;
}
@ -27,4 +29,9 @@ public class DataCenterDeployment implements DeploymentPlan {
public long getDataCenterId() {
return _dcId;
}
@Override
public int getCount() {
return _count;
}
}

View File

@ -23,5 +23,5 @@ package com.cloud.deploy;
*/
public interface DeploymentPlan {
public long getDataCenterId();
public int getCount();
}

View File

@ -6,13 +6,12 @@ package com.cloud.network;
import com.cloud.network.Network.BroadcastDomainType;
import com.cloud.network.Network.Mode;
import com.cloud.network.Network.TrafficType;
import com.cloud.user.OwnedBy;
/**
* A NetworkProfile defines the specifics of a network
* owned by an account.
*/
public interface NetworkProfile extends OwnedBy {
public interface NetworkConfiguration {
/**
* @return id of the network profile. Null means the network profile is not from the database.

View File

@ -7,6 +7,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
import com.cloud.deploy.DeploymentPlan;
import com.cloud.exception.ConflictingNetworkSettingsException;
import com.cloud.offering.NetworkOffering;
import com.cloud.offering.ServiceOffering;
@ -21,8 +22,8 @@ import com.cloud.vm.VirtualMachine;
*
*/
public interface NetworkProfiler extends Adapter {
NetworkProfile convert(NetworkOffering offering, Map<String, String> params, Account owner);
NetworkConfiguration convert(NetworkOffering offering, DeploymentPlan plan, Map<String, String> params, Account owner);
List<? extends NetworkProfile> convert(Collection<? extends NetworkOffering> networkOfferings, Account owner);
boolean check(VirtualMachine vm, ServiceOffering serviceOffering, Collection<? extends NetworkProfile> networkProfiles) throws ConflictingNetworkSettingsException;
List<? extends NetworkConfiguration> convert(Collection<? extends NetworkOffering> networkOfferings, Account owner);
boolean check(VirtualMachine vm, ServiceOffering serviceOffering, Collection<? extends NetworkConfiguration> networkProfiles) throws ConflictingNetworkSettingsException;
}

View File

@ -5,7 +5,7 @@ package com.cloud.vm;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
import com.cloud.network.NetworkProfile;
import com.cloud.network.NetworkConfiguration;
import com.cloud.utils.Pair;
import com.cloud.utils.component.Adapter;
@ -19,7 +19,7 @@ import com.cloud.utils.component.Adapter;
public interface NetworkConcierge extends Adapter {
String getUniqueName();
Nic allocate(VirtualMachine vm, NetworkProfile profile, Nic nic);
Nic allocate(VirtualMachine vm, NetworkConfiguration profile, Nic nic);
Pair<String, String> reserve(long vmId, NetworkCharacteristics ch) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;

View File

@ -333,7 +333,7 @@ public class AlertManagerImpl implements AlertManager {
List<CapacityVO> newCapacities = new ArrayList<CapacityVO>();
// get all hosts..
SearchCriteria sc = _hostDao.createSearchCriteria();
SearchCriteria<HostVO> sc = _hostDao.createSearchCriteria();
sc.addAnd("status", SearchCriteria.Op.EQ, Status.Up.toString());
List<HostVO> hosts = _hostDao.search(sc, null);

View File

@ -22,6 +22,7 @@ import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.SocketChannel;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
@ -83,8 +84,8 @@ import com.cloud.exception.OperationTimedoutException;
import com.cloud.exception.StorageUnavailableException;
import com.cloud.ha.HighAvailabilityManager;
import com.cloud.host.Host;
import com.cloud.host.HostVO;
import com.cloud.host.Host.Type;
import com.cloud.host.HostVO;
import com.cloud.host.dao.HostDao;
import com.cloud.info.ConsoleProxyConnectionInfo;
import com.cloud.info.ConsoleProxyInfo;
@ -96,8 +97,8 @@ import com.cloud.info.RunningHostInfoAgregator.ZoneHostInfo;
import com.cloud.maid.StackMaid;
import com.cloud.network.IpAddrAllocator;
import com.cloud.network.IpAddrAllocator.networkInfo;
import com.cloud.network.NetworkConfigurationVO;
import com.cloud.network.NetworkManager;
import com.cloud.network.NetworkProfileVO;
import com.cloud.network.dao.IPAddressDao;
import com.cloud.offering.NetworkOffering;
import com.cloud.offerings.NetworkOfferingVO;
@ -1016,7 +1017,8 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
ConsoleProxyVO proxy = new ConsoleProxyVO(id, name, _template.getId(), _template.getGuestOSId(), dataCenterId, 0);
proxy = _consoleProxyDao.persist(proxy);
List<NetworkProfileVO> profiles = _networkMgr.getSystemAccountNetworkProfiles(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());
try {
proxy = _vmMgr.allocate(proxy, _template, _serviceOffering, profiles, dc, _accountMgr.getSystemAccount());
proxy = _vmMgr.create(proxy);

View File

@ -36,8 +36,8 @@ import com.cloud.vm.NetworkCharacteristics;
*
*/
@Entity
@Table(name="network_profiles")
public class NetworkProfileVO implements NetworkProfile {
@Table(name="network_configurations")
public class NetworkConfigurationVO implements NetworkConfiguration {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
Long id;
@ -46,9 +46,6 @@ public class NetworkProfileVO implements NetworkProfile {
@Enumerated(value=EnumType.STRING)
Mode mode;
@Column(name="account_id")
long accountId;
@Column(name="broadcast_domain_type")
@Enumerated(value=EnumType.STRING)
BroadcastDomainType broadcastDomainType;
@ -69,15 +66,17 @@ public class NetworkProfileVO implements NetworkProfile {
@Column(name="network_offering_id")
long networkOfferingId;
public NetworkProfileVO() {
@Column(name="data_center_id")
long dataCenterId;
public NetworkConfigurationVO() {
}
public NetworkProfileVO(NetworkProfile that, long accountId, long offeringId) {
this(accountId, that.getTrafficType(), that.getMode(), that.getBroadcastDomainType(), offeringId);
public NetworkConfigurationVO(NetworkConfiguration that, long accountId, long offeringId) {
this(that.getTrafficType(), that.getMode(), that.getBroadcastDomainType(), offeringId);
}
public NetworkProfileVO(long accountId, TrafficType trafficType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId) {
this.accountId = accountId;
public NetworkConfigurationVO(TrafficType trafficType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId) {
this.trafficType = trafficType;
this.mode = mode;
this.broadcastDomainType = broadcastDomainType;
@ -103,15 +102,6 @@ public class NetworkProfileVO implements NetworkProfile {
this.mode = mode;
}
@Override
public long getAccountId() {
return accountId;
}
public void setAccountId(long accountId) {
this.accountId = accountId;
}
@Override
public BroadcastDomainType getBroadcastDomainType() {
return broadcastDomainType;

View File

@ -213,13 +213,13 @@ public interface NetworkManager extends Manager {
*/
List<IPAddressVO> listPublicIpAddressesInVirtualNetwork(long accountId, long dcId, Boolean sourceNat);
NetworkProfileVO setupNetworkProfile(AccountVO account, NetworkOfferingVO offering);
NetworkProfileVO setupNetworkProfile(AccountVO account, NetworkOfferingVO offering, Map<String, String> params);
List<NetworkProfileVO> setupNetworkProfiles(AccountVO account, List<NetworkOfferingVO> offerings);
NetworkConfigurationVO setupNetworkProfile(AccountVO account, NetworkOfferingVO offering);
NetworkConfigurationVO setupNetworkProfile(AccountVO account, NetworkOfferingVO offering, Map<String, String> params);
List<NetworkConfigurationVO> setupNetworkProfiles(AccountVO account, List<NetworkOfferingVO> offerings);
List<NetworkProfileVO> getSystemAccountNetworkProfiles(String... offeringNames);
List<NetworkOfferingVO> getSystemAccountNetworkOfferings(String... offeringNames);
<K extends VMInstanceVO> List<NicVO> allocate(K vm, List<Pair<NetworkProfileVO, NicVO>> networks) throws InsufficientCapacityException;
<K extends VMInstanceVO> List<NicVO> allocate(K vm, List<Pair<NetworkConfigurationVO, NicVO>> networks) throws InsufficientCapacityException;
<K extends VMInstanceVO> List<NicTO> prepare(K vm);

View File

@ -79,6 +79,7 @@ import com.cloud.dc.VlanVO;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.dc.dao.HostPodDao;
import com.cloud.dc.dao.VlanDao;
import com.cloud.deploy.DeploymentPlan;
import com.cloud.domain.DomainVO;
import com.cloud.domain.dao.DomainDao;
import com.cloud.event.EventState;
@ -104,7 +105,7 @@ import com.cloud.network.Network.TrafficType;
import com.cloud.network.dao.FirewallRulesDao;
import com.cloud.network.dao.IPAddressDao;
import com.cloud.network.dao.LoadBalancerDao;
import com.cloud.network.dao.NetworkProfileDao;
import com.cloud.network.dao.NetworkConfigurationDao;
import com.cloud.network.dao.SecurityGroupVMMapDao;
import com.cloud.offering.NetworkOffering;
import com.cloud.offering.NetworkOffering.GuestIpType;
@ -201,7 +202,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
@Inject ServiceOfferingDao _serviceOfferingDao = null;
@Inject UserStatisticsDao _statsDao = null;
@Inject NetworkOfferingDao _networkOfferingDao = null;
@Inject NetworkProfileDao _networkProfileDao = null;
@Inject NetworkConfigurationDao _networkProfileDao = null;
@Inject NicDao _nicDao;
Adapters<NetworkProfiler> _networkProfilers;
@ -216,7 +217,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
int _routerCleanupInterval = 3600;
int _routerStatsInterval = 300;
private ServiceOfferingVO _offering;
private HashMap<String, Pair<NetworkOfferingVO, NetworkProfileVO>> _systemNetworks = new HashMap<String, Pair<NetworkOfferingVO, NetworkProfileVO>>(5);
private HashMap<String, NetworkOfferingVO> _systemNetworks = new HashMap<String, NetworkOfferingVO>(5);
private VMTemplateVO _template;
@ -1846,19 +1847,19 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
NetworkOfferingVO publicNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmPublicNetwork, TrafficType.Public, null);
publicNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(publicNetworkOffering);
_systemNetworks.put(NetworkOfferingVO.SystemVmPublicNetwork, new Pair<NetworkOfferingVO, NetworkProfileVO>(publicNetworkOffering, null));
_systemNetworks.put(NetworkOfferingVO.SystemVmPublicNetwork, publicNetworkOffering);
NetworkOfferingVO managementNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmManagementNetwork, TrafficType.Management, null);
managementNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(managementNetworkOffering);
_systemNetworks.put(NetworkOfferingVO.SystemVmManagementNetwork, new Pair<NetworkOfferingVO, NetworkProfileVO>(managementNetworkOffering, null));
_systemNetworks.put(NetworkOfferingVO.SystemVmManagementNetwork, managementNetworkOffering);
NetworkOfferingVO controlNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmControlNetwork, TrafficType.Control, null);
controlNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(controlNetworkOffering);
_systemNetworks.put(NetworkOfferingVO.SystemVmControlNetwork, new Pair<NetworkOfferingVO, NetworkProfileVO>(controlNetworkOffering, null));
_systemNetworks.put(NetworkOfferingVO.SystemVmControlNetwork, controlNetworkOffering);
NetworkOfferingVO guestNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmGuestNetwork, TrafficType.Guest, GuestIpType.Virtualized);
guestNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(guestNetworkOffering);
_systemNetworks.put(NetworkOfferingVO.SystemVmGuestNetwork, new Pair<NetworkOfferingVO, NetworkProfileVO>(guestNetworkOffering, null));
_systemNetworks.put(NetworkOfferingVO.SystemVmGuestNetwork, guestNetworkOffering);
NetworkOfferingVO storageNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmStorageNetwork, TrafficType.Storage, null);
storageNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(storageNetworkOffering);
_systemNetworks.put(NetworkOfferingVO.SystemVmGuestNetwork, new Pair<NetworkOfferingVO, NetworkProfileVO>(storageNetworkOffering, null));
_systemNetworks.put(NetworkOfferingVO.SystemVmGuestNetwork, storageNetworkOffering);
s_logger.info("Network Manager is configured.");
@ -1872,17 +1873,6 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
@Override
public boolean start() {
AccountVO systemAccount = _accountMgr.getSystemAccount();
/*
for (Pair<NetworkOfferingVO, NetworkProfileVO> network : _systemNetworks.values()) {
network.second(setupNetworkProfile(systemAccount, network.first()));
if (network.second() == null) {
s_logger.warn("Unable to setup system account's network profile for " + network.first().getName());
return false;
}
}
*/
_executor.scheduleAtFixedRate(new RouterCleanupTask(), _routerCleanupInterval, _routerCleanupInterval, TimeUnit.SECONDS);
_executor.scheduleAtFixedRate(new NetworkUsageTask(), _routerStatsInterval, _routerStatsInterval, TimeUnit.SECONDS);
return true;
@ -2352,27 +2342,27 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
}
@Override
public NetworkProfileVO setupNetworkProfile(AccountVO owner, NetworkOfferingVO offering) {
public NetworkConfigurationVO setupNetworkProfile(AccountVO owner, NetworkOfferingVO offering) {
return setupNetworkProfile(owner, offering, new HashMap<String, String>());
}
@Override
public NetworkProfileVO setupNetworkProfile(AccountVO owner, NetworkOfferingVO offering, Map<String, String> params) {
public NetworkConfigurationVO setupNetworkProfile(AccountVO owner, NetworkOfferingVO offering, Map<String, String> params) {
for (NetworkProfiler profiler : _networkProfilers) {
NetworkProfile profile = profiler.convert(offering, params, owner);
NetworkConfiguration profile = profiler.convert(offering, null, params, owner);
if (profile == null) {
continue;
}
if (profile.getId() != null) {
if (profile instanceof NetworkProfileVO) {
return (NetworkProfileVO)profile;
if (profile instanceof NetworkConfigurationVO) {
return (NetworkConfigurationVO)profile;
} else {
return _networkProfileDao.findById(profile.getId());
}
}
NetworkProfileVO vo = new NetworkProfileVO(profile, owner.getId(), offering.getId());
NetworkConfigurationVO vo = new NetworkConfigurationVO(profile, owner.getId(), offering.getId());
return _networkProfileDao.persist(vo);
}
@ -2380,8 +2370,8 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
}
@Override
public List<NetworkProfileVO> setupNetworkProfiles(AccountVO owner, List<NetworkOfferingVO> offerings) {
List<NetworkProfileVO> profiles = new ArrayList<NetworkProfileVO>(offerings.size());
public List<NetworkConfigurationVO> setupNetworkProfiles(AccountVO owner, List<NetworkOfferingVO> offerings) {
List<NetworkConfigurationVO> profiles = new ArrayList<NetworkConfigurationVO>(offerings.size());
for (NetworkOfferingVO offering : offerings) {
profiles.add(setupNetworkProfile(owner, offering));
}
@ -2389,27 +2379,31 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
}
@Override
public List<NetworkProfileVO> getSystemAccountNetworkProfiles(String... offeringNames) {
List<NetworkProfileVO> profiles = new ArrayList<NetworkProfileVO>(offeringNames.length);
public List<NetworkOfferingVO> getSystemAccountNetworkOfferings(String... offeringNames) {
List<NetworkOfferingVO> offerings = new ArrayList<NetworkOfferingVO>(offeringNames.length);
for (String offeringName : offeringNames) {
Pair<NetworkOfferingVO, NetworkProfileVO> network = _systemNetworks.get(offeringName);
NetworkOfferingVO network = _systemNetworks.get(offeringName);
if (network == null) {
throw new CloudRuntimeException("Unable to find system network profile for " + offeringName);
}
profiles.add(network.second());
offerings.add(network);
}
return profiles;
return offerings;
}
public NetworkConfigurationVO createNetworkConfiguration(NetworkOfferingVO offering, DeploymentPlan plan, AccountVO owner) {
return null;
}
@Override @DB
public <K extends VMInstanceVO> List<NicVO> allocate(K vm, List<Pair<NetworkProfileVO, NicVO>> networks) throws InsufficientCapacityException {
public <K extends VMInstanceVO> List<NicVO> allocate(K vm, List<Pair<NetworkConfigurationVO, NicVO>> networks) throws InsufficientCapacityException {
List<NicVO> nics = new ArrayList<NicVO>(networks.size());
Transaction txn = Transaction.currentTxn();
txn.start();
for (Pair<NetworkProfileVO, NicVO> network : networks) {
for (Pair<NetworkConfigurationVO, NicVO> network : networks) {
for (NetworkConcierge concierge : _networkConcierges) {
Nic nic = concierge.allocate(vm, network.first(), network.second());
if (nic == null) {

View File

@ -9,32 +9,35 @@ import java.util.Map;
import javax.ejb.Local;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.deploy.DeploymentPlan;
import com.cloud.exception.ConflictingNetworkSettingsException;
import com.cloud.network.Network.BroadcastDomainType;
import com.cloud.network.Network.Mode;
import com.cloud.network.dao.NetworkProfileDao;
import com.cloud.network.dao.NetworkConfigurationDao;
import com.cloud.offering.NetworkOffering;
import com.cloud.offering.NetworkOffering.GuestIpType;
import com.cloud.offering.ServiceOffering;
import com.cloud.user.Account;
import com.cloud.utils.component.AdapterBase;
import com.cloud.utils.component.Inject;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.vm.VirtualMachine;
@Local(value=NetworkProfiler.class)
public class NetworkProfilerImpl extends AdapterBase implements NetworkProfiler {
@Inject protected NetworkProfileDao _profileDao;
@Inject protected NetworkConfigurationDao _profileDao;
@Inject protected DataCenterDao _dcDao;
protected NetworkProfilerImpl() {
super();
}
@Override
public NetworkProfile convert(NetworkOffering offering, Map<String, String> params, Account owner) {
List<NetworkProfileVO> profiles = _profileDao.listBy(owner.getId(), offering.getId());
public NetworkConfiguration convert(NetworkOffering offering, DeploymentPlan plan, Map<String, String> params, Account owner) {
List<NetworkConfigurationVO> profiles = _profileDao.listBy(owner.getId(), offering.getId());
for (NetworkProfileVO profile : profiles) {
for (NetworkConfigurationVO profile : profiles) {
// FIXME: We should do more comparisons such as if the specific cidr matches.
return profile;
}
@ -46,22 +49,25 @@ public class NetworkProfilerImpl extends AdapterBase implements NetworkProfiler
mode = Mode.Dhcp;
broadcastType = BroadcastDomainType.Vlan;
} else {
throw new CloudRuntimeException("Unable to convert " + ipType);
broadcastType = BroadcastDomainType.Native;
mode = Mode.Dhcp;
}
return new NetworkProfileVO(owner.getId(), offering.getTrafficType(), mode, broadcastType, offering.getId());
NetworkConfigurationVO profile = new NetworkConfigurationVO(offering.getTrafficType(), mode, broadcastType, offering.getId());
DataCenterVO dc = _dcDao.findById(plan.getDataCenterId());
return profile;
}
@Override
public List<? extends NetworkProfile> convert(Collection<? extends NetworkOffering> networkOfferings, Account owner) {
List<NetworkProfileVO> profiles = _profileDao.listBy(owner.getId());
public List<? extends NetworkConfiguration> convert(Collection<? extends NetworkOffering> networkOfferings, Account owner) {
List<NetworkConfigurationVO> profiles = _profileDao.listBy(owner.getId());
for (NetworkOffering offering : networkOfferings) {
}
return null;
}
@Override
public boolean check(VirtualMachine vm, ServiceOffering serviceOffering, Collection<? extends NetworkProfile> networkProfiles) throws ConflictingNetworkSettingsException {
public boolean check(VirtualMachine vm, ServiceOffering serviceOffering, Collection<? extends NetworkConfiguration> networkProfiles) throws ConflictingNetworkSettingsException {
return false;
}

View File

@ -19,10 +19,10 @@ package com.cloud.network.dao;
import java.util.List;
import com.cloud.network.NetworkProfileVO;
import com.cloud.network.NetworkConfigurationVO;
import com.cloud.utils.db.GenericDao;
public interface NetworkProfileDao extends GenericDao<NetworkProfileVO, Long> {
List<NetworkProfileVO> listBy(long accountId);
List<NetworkProfileVO> listBy(long accountId, long offeringId);
public interface NetworkConfigurationDao extends GenericDao<NetworkConfigurationVO, Long> {
List<NetworkConfigurationVO> listBy(long accountId);
List<NetworkConfigurationVO> listBy(long accountId, long offeringId);
}

View File

@ -24,57 +24,65 @@ import javax.ejb.Local;
import com.cloud.network.Network.BroadcastDomainType;
import com.cloud.network.Network.Mode;
import com.cloud.network.Network.TrafficType;
import com.cloud.network.NetworkProfileVO;
import com.cloud.network.NetworkAccountDaoImpl;
import com.cloud.network.NetworkAccountVO;
import com.cloud.network.NetworkConfigurationVO;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
@Local(value=NetworkProfileDao.class)
public class NetworkProfileDaoImpl extends GenericDaoBase<NetworkProfileVO, Long> implements NetworkProfileDao {
final SearchBuilder<NetworkProfileVO> ProfileSearch;
final SearchBuilder<NetworkProfileVO> AccountSearch;
@Local(value=NetworkConfigurationDao.class)
public class NetworkConfigurationDaoImpl extends GenericDaoBase<NetworkConfigurationVO, Long> implements NetworkConfigurationDao {
final SearchBuilder<NetworkConfigurationVO> ProfileSearch;
final SearchBuilder<NetworkConfigurationVO> AccountSearch;
NetworkAccountDaoImpl _accountsDao = new NetworkAccountDaoImpl();
protected NetworkProfileDaoImpl() {
protected NetworkConfigurationDaoImpl() {
super();
ProfileSearch = createSearchBuilder();
ProfileSearch.and("account", ProfileSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
ProfileSearch.and("trafficType", ProfileSearch.entity().getTrafficType(), SearchCriteria.Op.EQ);
ProfileSearch.and("cidr", ProfileSearch.entity().getCidr(), SearchCriteria.Op.EQ);
ProfileSearch.and("broadcastType", ProfileSearch.entity().getBroadcastDomainType(), SearchCriteria.Op.EQ);
SearchBuilder<NetworkAccountVO> join = _accountsDao.createSearchBuilder();
join.and("account", join.entity().getAccountId(), SearchCriteria.Op.EQ);
ProfileSearch.join("accounts", join, ProfileSearch.entity().getId(), join.entity().getNetworkConfigurationId());
ProfileSearch.done();
AccountSearch = createSearchBuilder();
AccountSearch.and("account", AccountSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
AccountSearch.and("offering", AccountSearch.entity().getNetworkOfferingId(), SearchCriteria.Op.EQ);
join = _accountsDao.createSearchBuilder();
join.and("account", join.entity().getAccountId(), SearchCriteria.Op.EQ);
AccountSearch.join("accounts", join, AccountSearch.entity().getId(), join.entity().getNetworkConfigurationId());
AccountSearch.done();
}
public NetworkProfileVO findBy(TrafficType trafficType, Mode mode, BroadcastDomainType broadcastType, long accountId) {
SearchCriteria<NetworkProfileVO> sc = ProfileSearch.create();
sc.setParameters("account", accountId);
public NetworkConfigurationVO findBy(TrafficType trafficType, Mode mode, BroadcastDomainType broadcastType, long accountId) {
SearchCriteria<NetworkConfigurationVO> sc = ProfileSearch.create();
sc.setParameters("trafficType", trafficType);
sc.setParameters("broadcastType", broadcastType);
sc.setJoinParameters("accounts", "account", accountId);
return null;
}
@Override
public List<NetworkProfileVO> listBy(long accountId) {
SearchCriteria<NetworkProfileVO> sc = AccountSearch.create();
public List<NetworkConfigurationVO> listBy(long accountId) {
SearchCriteria<NetworkConfigurationVO> sc = AccountSearch.create();
sc.setParameters("account", accountId);
sc.setJoinParameters("accounts", "account", accountId);
return listActiveBy(sc);
}
@Override
public List<NetworkProfileVO> listBy(long accountId, long offeringId) {
SearchCriteria<NetworkProfileVO> sc = AccountSearch.create();
public List<NetworkConfigurationVO> listBy(long accountId, long offeringId) {
SearchCriteria<NetworkConfigurationVO> sc = AccountSearch.create();
sc.setParameters("offering", offeringId);
sc.setParameters("account", accountId);
sc.setJoinParameters("accounts", "account", accountId);
return listActiveBy(sc);
}

View File

@ -33,7 +33,7 @@ import com.cloud.dc.DataCenterVO;
import com.cloud.exception.AgentUnavailableException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.network.NetworkManager;
import com.cloud.network.NetworkProfileVO;
import com.cloud.network.NetworkConfigurationVO;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.Storage.ImageFormat;
@ -68,7 +68,7 @@ public class MauriceMoss implements VmManager {
ServiceOfferingVO serviceOffering,
Pair<? extends DiskOfferingVO, Long> rootDiskOffering,
List<Pair<DiskOfferingVO, Long>> dataDiskOfferings,
List<Pair<NetworkProfileVO, NicVO>> networks,
List<Pair<NetworkConfigurationVO, NicVO>> networks,
DataCenterVO dc,
AccountVO owner) throws InsufficientCapacityException {
if (s_logger.isDebugEnabled()) {
@ -96,7 +96,7 @@ public class MauriceMoss implements VmManager {
ServiceOfferingVO serviceOffering,
Long rootSize,
Pair<DiskOfferingVO, Long> dataDiskOffering,
List<Pair<NetworkProfileVO, NicVO>> networks,
List<Pair<NetworkConfigurationVO, NicVO>> networks,
DataCenterVO dc,
AccountVO owner) throws InsufficientCapacityException {
List<Pair<DiskOfferingVO, Long>> diskOfferings = new ArrayList<Pair<DiskOfferingVO, Long>>(1);
@ -110,11 +110,11 @@ public class MauriceMoss implements VmManager {
public <T extends VMInstanceVO> T allocate(T vm,
VMTemplateVO template,
ServiceOfferingVO serviceOffering,
List<NetworkProfileVO> networkProfiles,
List<NetworkConfigurationVO> networkProfiles,
DataCenterVO dc, AccountVO owner) throws InsufficientCapacityException {
List<Pair<NetworkProfileVO, NicVO>> networks = new ArrayList<Pair<NetworkProfileVO, NicVO>>(networkProfiles.size());
for (NetworkProfileVO profile : networkProfiles) {
networks.add(new Pair<NetworkProfileVO, NicVO>(profile, null));
List<Pair<NetworkConfigurationVO, NicVO>> networks = new ArrayList<Pair<NetworkConfigurationVO, NicVO>>(networkProfiles.size());
for (NetworkConfigurationVO profile : networkProfiles) {
networks.add(new Pair<NetworkConfigurationVO, NicVO>(profile, null));
}
return allocate(vm, template, serviceOffering, new Pair<DiskOfferingVO, Long>(serviceOffering, null), null, networks, dc, owner);
}

View File

@ -24,7 +24,7 @@ import com.cloud.exception.AgentUnavailableException;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.StorageUnavailableException;
import com.cloud.network.NetworkProfileVO;
import com.cloud.network.NetworkConfigurationVO;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.VMTemplateVO;
@ -42,7 +42,7 @@ public interface VmManager extends Manager {
ServiceOfferingVO serviceOffering,
Pair<? extends DiskOfferingVO, Long> rootDiskOffering,
List<Pair<DiskOfferingVO, Long>> dataDiskOfferings,
List<Pair<NetworkProfileVO, NicVO>> networks,
List<Pair<NetworkConfigurationVO, NicVO>> networks,
DataCenterVO dc,
AccountVO owner) throws InsufficientCapacityException;
@ -51,14 +51,14 @@ public interface VmManager extends Manager {
ServiceOfferingVO serviceOffering,
Long rootSize,
Pair<DiskOfferingVO, Long> dataDiskOffering,
List<Pair<NetworkProfileVO, NicVO>> networks,
List<Pair<NetworkConfigurationVO, NicVO>> networks,
DataCenterVO dc,
AccountVO owner) throws InsufficientCapacityException;
<T extends VMInstanceVO> T allocate(T vm,
VMTemplateVO template,
ServiceOfferingVO serviceOffering,
List<NetworkProfileVO> networkProfiles,
List<NetworkConfigurationVO> networkProfiles,
DataCenterVO dc,
AccountVO owner) throws InsufficientCapacityException;

View File

@ -26,10 +26,11 @@ ALTER TABLE `cloud`.`op_ha_work` ADD INDEX `i_op_ha_work__step`(`step`);
ALTER TABLE `cloud`.`op_ha_work` ADD INDEX `i_op_ha_work__type`(`type`);
ALTER TABLE `cloud`.`op_ha_work` ADD INDEX `i_op_ha_work__mgmt_server_id`(`mgmt_server_id`);
ALTER TABLE `cloud`.`network_profiles` ADD CONSTRAINT `fk_network_profiles__account_id` FOREIGN KEY `fk_network_profiles__account_id`(`account_id`) REFERENCES `account`(`id`) ON DELETE CASCADE;
ALTER TABLE `cloud`.`account_network_ref` ADD CONSTRAINT `fk_account_network_ref__account_id` FOREIGN KEY `fk_account_network_ref__account_id`(`account_id`) REFERENCES `account`(`id`) ON DELETE CASCADE;
ALTER TABLE `cloud`.`account_network_ref` ADD CONSTRAINT `fk_account_network_ref__network_configuration_id` FOREIGN KEY `fk_account_network_ref__network_configuration_id`(`network_configuration_id`) REFERENCES `network_configurations`(`id`) ON DELETE CASCADE;
ALTER TABLE `cloud`.`nics` ADD CONSTRAINT `fk_nics__instance_id` FOREIGN KEY `fk_nics__instance_id`(`instance_id`) REFERENCES `vm_instance`(`id`) ON DELETE CASCADE;
ALTER TABLE `cloud`.`nics` ADD CONSTRAINT `fk_nics__network_profile_id` FOREIGN KEY `fk_nics__network_profile_id`(`network_profile_id`) REFERENCES `network_profiles`(`id`);
ALTER TABLE `cloud`.`nics` ADD CONSTRAINT `fk_nics__network_configuration_id` FOREIGN KEY `fk_nics__network_configuration_id`(`network_configuration_id`) REFERENCES `network_configurations`(`id`);
ALTER TABLE `cloud`.`op_dc_ip_address_alloc` ADD INDEX `i_op_dc_ip_address_alloc__pod_id__data_center_id__taken` (`pod_id`, `data_center_id`, `taken`, `instance_id`);
ALTER TABLE `cloud`.`op_dc_ip_address_alloc` ADD UNIQUE `i_op_dc_ip_address_alloc__ip_address__data_center_id`(`ip_address`, `data_center_id`);

View File

@ -74,7 +74,7 @@ DROP TABLE IF EXISTS `cloud`.`storage_pool_details`;
DROP TABLE IF EXISTS `cloud`.`ext_lun_details`;
DROP TABLE IF EXISTS `cloud`.`cluster`;
DROP TABLE IF EXISTS `cloud`.`nics`;
DROP TABLE IF EXISTS `cloud`.`network_profiles`;
DROP TABLE IF EXISTS `cloud`.`network_configurations`;
DROP TABLE IF EXISTS `cloud`.`network_offerings`;
DROP TABLE IF EXISTS `cloud`.`host_master`;
DROP TABLE IF EXISTS `cloud`.`hypervisor_properties`;
@ -87,24 +87,24 @@ CREATE TABLE `cloud`.`hypervsior_properties` (
`max_network_devices` int(10) NOT NULL COMMENT 'maximum number of network devices'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`network_profiles` (
CREATE TABLE `cloud`.`network_configurations` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
`name` varchar(255) COMMENT 'name for this network',
`account_id` bigint unsigned NOT NULL COMMENT 'Owner of this network configuration',
`traffic_type` varchar(32) NOT NULL COMMENT 'type of traffic going through this network',
`broadcast_domain_type` varchar(32) NOT NULL COMMENT 'type of broadcast domain used',
`gateway` varchar(15) NOT NULL COMMENT 'gateway for this network profile',
`gateway` varchar(15) NOT NULL COMMENT 'gateway for this network configuration',
`cidr` varchar(32) NOT NULL COMMENT 'network cidr',
`mode` varchar(32) NOT NULL 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',
`network_offering_id` bigint unsigned NOT NULL COMMENT 'network offering id that this profile 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',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`account_network_ref` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
`account_id` bigint unsigned NOT NULL COMMENT 'account id',
`network_profile_id` bigint unsigned NOT NULL COMMENT 'network profile_id',
`network_configuration_id` bigint unsigned NOT NULL COMMENT 'network configuration id',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@ -113,7 +113,7 @@ CREATE TABLE `cloud`.`nics` (
`instance_id` bigint unsigned NOT NULL COMMENT 'vm instance id',
`ip4_address` varchar(15) COMMENT 'ip4 address',
`mac_address` varchar(17) COMMENT 'mac address',
`network_profile_id` bigint unsigned NOT NULL COMMENT 'network id',
`network_configuration_id` bigint unsigned NOT NULL COMMENT 'network configuration id',
`vlan` varchar(64) COMMENT 'Virtualized network identifier',
`state` varchar(32) NOT NULL COMMENT 'state of the creation',
`name` varchar(64) COMMENT 'Name of the component that reserved the ip address',
@ -125,13 +125,13 @@ CREATE TABLE `cloud`.`nics` (
CREATE TABLE `cloud`.`network_offerings` (
`id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT COMMENT 'id',
`name` varchar(64) NOT NULL unique COMMENT 'network offering',
`type` varchar(32) NOT NULL COMMENT 'type of network',
`type` varchar(32) COMMENT 'type of network',
`display_text` varchar(255) NOT NULL COMMENT 'text to display to users',
`nw_rate` smallint unsigned COMMENT 'network rate throttle mbits/s',
`mc_rate` smallint unsigned COMMENT 'mcast rate throttle mbits/s',
`concurrent_connections` int(10) unsigned COMMENT 'concurrent connections supported on this network',
`traffic_type` varchar(32) NOT NULL COMMENT 'traffic type carried on this network',
`tags` varchar(4096) NOT NULL COMMENT 'tags supported by this offering',
`tags` varchar(4096) COMMENT 'tags supported by this offering',
`system_only` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'Is this network offering for system use only',
`created` datetime NOT NULL COMMENT 'time the entry was created',
`removed` datetime DEFAULT NULL COMMENT 'time the entry was removed',