bug 5764: checkin before I switch to work on 2.1.x

This commit is contained in:
Alex Huang 2010-08-24 14:40:29 -07:00
parent 5fb852f0ca
commit 415bc8ae20
10 changed files with 81 additions and 16 deletions

View File

@ -44,6 +44,7 @@ public class Network {
Native,
Vlan,
Vswitch,
LinkLocal,
Vnet;
};
@ -54,7 +55,7 @@ public class Network {
Public,
Guest,
Storage,
LinkLocal,
Control,
Vpn,
Management
};

View File

@ -700,7 +700,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
Pair<Network, String> getNetworkForTraffic(Connection conn, TrafficType type) throws XenAPIException, XmlRpcException {
if (type == TrafficType.Guest) {
return new Pair<Network, String>(Network.getByUuid(conn, _host.guestNetwork), _host.guestPif);
} else if (type == TrafficType.LinkLocal) {
} else if (type == TrafficType.Control) {
return new Pair<Network, String>(Network.getByUuid(conn, _host.linkLocalNetwork), null);
} else if (type == TrafficType.Management) {
return new Pair<Network, String>(Network.getByUuid(conn, _host.privateNetwork), _host.privatePif);

View File

@ -2357,7 +2357,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
_publicNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(_publicNetworkOffering);
_managementNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmManagementNetwork, TrafficType.Management, null);
_managementNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(_managementNetworkOffering);
_linkLocalNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmLinkLocalNetwork, TrafficType.LinkLocal, null);
_linkLocalNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmLinkLocalNetwork, TrafficType.Control, null);
_linkLocalNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(_linkLocalNetworkOffering);
_capacityScanScheduler.scheduleAtFixedRate(getCapacityScanTask(), STARTUP_DELAY, _capacityScanInterval, TimeUnit.MILLISECONDS);

View File

@ -53,15 +53,14 @@ import com.cloud.host.dao.HostDao;
import com.cloud.hypervisor.xen.resource.CitrixResourceBase;
import com.cloud.hypervisor.xen.resource.XcpServerResource;
import com.cloud.hypervisor.xen.resource.XenServerConnectionPool;
import com.cloud.hypervisor.xen.resource.XenServerResource;
import com.cloud.resource.Discoverer;
import com.cloud.resource.DiscovererBase;
import com.cloud.resource.ServerResource;
import com.cloud.storage.Storage.FileSystem;
import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.VMTemplateHostVO;
import com.cloud.storage.VMTemplateStorageResourceAssoc;
import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.Storage.FileSystem;
import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.storage.dao.VMTemplateHostDao;
import com.cloud.storage.template.TemplateInfo;
@ -383,8 +382,8 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
if(prodBrand.equals("XenCloudPlatform") && prodVersion.equals("0.1.1"))
return new XcpServerResource();
if(prodBrand.equals("XenServer") && prodVersion.equals("5.6.0"))
return new XenServerResource();
// if(prodBrand.equals("XenServer") && prodVersion.equals("5.6.0"))
// return new XenServerResource();
String msg = "Only support XCP 0.1.1 and Xerver 5.6.0, but this one is " + prodBrand + " " + prodVersion;
_alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, dcId, podId, msg, msg);

View File

@ -102,6 +102,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.SecurityGroupVMMapDao;
import com.cloud.offering.NetworkOffering;
import com.cloud.offering.NetworkOffering.GuestIpType;
@ -193,6 +194,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
@Inject ServiceOfferingDao _serviceOfferingDao = null;
@Inject UserStatisticsDao _statsDao = null;
@Inject NetworkOfferingDao _networkOfferingDao = null;
@Inject NetworkProfileDao _networkProfileDao = null;
Adapters<NetworkProfiler> _networkProfilers;
@ -1835,7 +1837,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
_publicNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(_publicNetworkOffering);
_managementNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmManagementNetwork, TrafficType.Management, null);
_managementNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(_managementNetworkOffering);
_linkLocalNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmLinkLocalNetwork, TrafficType.LinkLocal, null);
_linkLocalNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmLinkLocalNetwork, TrafficType.Control, null);
_linkLocalNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(_linkLocalNetworkOffering);
_guestNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmGuestNetwork, TrafficType.Guest, GuestIpType.Virtualized);
_guestNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(_guestNetworkOffering);
@ -1848,6 +1850,29 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
return true;
}
public void setupNetworkProfiles(List<NetworkOfferingVO> offerings, AccountVO account) {
List<? extends NetworkProfile> profiles = null;
for (NetworkProfiler profiler : _networkProfilers) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Sending network profiles to " + profiler.getName());
}
profiles = profiler.convert(offerings, account);
if (profiles != null) {
break;
}
}
if (profiles == null) {
s_logger.debug("Unable to resolve the network profiles");
throw new CloudRuntimeException("Uanble to convert network offerings to network profiles for that account");
}
for (NetworkProfile profile : profiles) {
NetworkProfileVO vo = new NetworkProfileVO(profile, account.getId());
vo = _networkProfileDao.persist(vo);
}
}
@Override
public String getName() {
@ -1861,9 +1886,12 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
offerings.add(_guestNetworkOffering);
offerings.add(_linkLocalNetworkOffering);
offerings.add(_managementNetworkOffering);
for (NetworkProfiler profiler : _networkProfilers) {
List<? extends NetworkProfile> profiles = profiler.convert(offerings, _accountMgr.getSystemAccount());
try {
setupNetworkProfiles(offerings, _accountMgr.getSystemAccount());
} catch (Exception e) {
s_logger.warn("Unable to setup the system network profiles");
return false;
}
_executor.scheduleAtFixedRate(new RouterCleanupTask(), _routerCleanupInterval, _routerCleanupInterval, TimeUnit.SECONDS);
_executor.scheduleAtFixedRate(new NetworkUsageTask(), _routerStatsInterval, _routerStatsInterval, TimeUnit.SECONDS);

View File

@ -57,8 +57,8 @@ public class NetworkProfileVO implements OwnedBy {
@Enumerated(value=EnumType.STRING)
TrafficType trafficType;
@Column(name="vlanIds")
String vlanIds;
@Column(name="vlan_id")
Long vlanId;
@Column(name="gateway")
String gateway;
@ -69,6 +69,10 @@ public class NetworkProfileVO implements OwnedBy {
public NetworkProfileVO() {
}
public NetworkProfileVO(NetworkProfile that, long accountId) {
this(accountId, that.getTrafficType(), that.getMode(), that.getBroadcastDomainType());
}
public NetworkProfileVO(long accountId, TrafficType trafficType, Mode mode, BroadcastDomainType broadcastDomainType) {
this.accountId = accountId;
this.trafficType = trafficType;
@ -129,4 +133,11 @@ public class NetworkProfileVO implements OwnedBy {
this.cidr = cidr;
}
public Long getVlanId() {
return vlanId;
}
public void setVlanId(Long vlanId) {
this.vlanId = vlanId;
}
}

View File

@ -27,6 +27,7 @@ public class NetworkProfilerImpl extends AdapterBase implements NetworkProfiler
@Override
public List<? extends NetworkProfile> convert(Collection<? extends NetworkOffering> networkOfferings, Account owner) {
List<NetworkProfileVO> profiles = _profileDao.listBy(owner.getId());
for (NetworkOffering offering : networkOfferings) {
}
return null;

View File

@ -17,9 +17,11 @@
*/
package com.cloud.network.dao;
import java.util.List;
import com.cloud.network.NetworkProfileVO;
import com.cloud.utils.db.GenericDao;
public interface NetworkProfileDao extends GenericDao<NetworkProfileVO, Long> {
List<NetworkProfileVO> listBy(long accountId);
}

View File

@ -17,8 +17,11 @@
*/
package com.cloud.network.dao;
import java.util.List;
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;
@ -29,6 +32,7 @@ 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;
protected NetworkProfileDaoImpl() {
super();
@ -38,10 +42,28 @@ public class NetworkProfileDaoImpl extends GenericDaoBase<NetworkProfileVO, Long
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);
ProfileSearch.done();
AccountSearch = createSearchBuilder();
AccountSearch.and("account", AccountSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
AccountSearch.done();
}
public NetworkProfileVO findBy(TrafficType trafficType, Mode mode, long accountId) {
public NetworkProfileVO findBy(TrafficType trafficType, Mode mode, BroadcastDomainType broadcastType, long accountId) {
SearchCriteria<NetworkProfileVO> sc = ProfileSearch.create();
sc.setParameters("account", accountId);
sc.setParameters("trafficType", trafficType);
sc.setParameters("broadcastType", broadcastType);
return null;
}
@Override
public List<NetworkProfileVO> listBy(long accountId) {
SearchCriteria<NetworkProfileVO> sc = AccountSearch.create();
sc.setParameters("account", accountId);
return listActiveBy(sc);
}
}

View File

@ -95,6 +95,7 @@ CREATE TABLE `cloud`.`network_profiles` (
`gateway` varchar(15) NOT NULL COMMENT 'gateway for this network profile',
`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',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;