moved account id, service offering id, and domain id into isntance

This commit is contained in:
Alex Huang 2010-09-17 15:36:54 -07:00
parent 55b33120e7
commit 286e78c849
15 changed files with 128 additions and 101 deletions

View File

@ -23,7 +23,7 @@ public interface NetworkConcierge extends Concierge<Nic> {
boolean create(Nic nic) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException; boolean create(Nic nic) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
String reserve(long vmId, NicProfile ch, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException; String reserve(VirtualMachine vm, NicProfile ch, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
boolean release(String uniqueName, String uniqueId); boolean release(String uniqueName, String uniqueId);
} }

View File

@ -19,11 +19,14 @@ package com.cloud.vm;
import java.util.Date; import java.util.Date;
import com.cloud.domain.PartOf;
import com.cloud.user.OwnedBy;
/** /**
* VirtualMachine describes the properties held by a virtual machine * VirtualMachine describes the properties held by a virtual machine
* *
*/ */
public interface VirtualMachine extends RunningOn { public interface VirtualMachine extends RunningOn, OwnedBy, PartOf {
public enum Event { public enum Event {
CreateRequested, CreateRequested,
StartRequested, StartRequested,

View File

@ -97,13 +97,14 @@ public class ConsoleProxyVO extends VMInstanceVO implements ConsoleProxy {
/** /**
* Correct constructor to use. * Correct constructor to use.
*/ */
public ConsoleProxyVO(long id, String name, long templateId, long guestOSId, long dataCenterId, int activeSession) { public ConsoleProxyVO(long id, long serviceOfferingId, String name, long templateId, long guestOSId, long dataCenterId, long domainId, long accountId, int activeSession) {
super(id, name, name, Type.ConsoleProxy, templateId, guestOSId, false); super(id, serviceOfferingId, name, name, Type.ConsoleProxy, templateId, guestOSId, domainId, accountId, false);
this.activeSession = activeSession; this.activeSession = activeSession;
} }
public ConsoleProxyVO( public ConsoleProxyVO(
long id, long id,
long serviceOfferingId,
String name, String name,
String guestMacAddress, String guestMacAddress,
String guestIpAddress, String guestIpAddress,
@ -119,7 +120,9 @@ public class ConsoleProxyVO extends VMInstanceVO implements ConsoleProxy {
Long vlanDbId, Long vlanDbId,
String vlanId, String vlanId,
long podId, long podId,
long dataCenterId, long dataCenterId,
long domainId,
long accountId,
String gateway, String gateway,
Long hostId, Long hostId,
String dns1, String dns1,
@ -127,8 +130,8 @@ public class ConsoleProxyVO extends VMInstanceVO implements ConsoleProxy {
String domain, String domain,
int ramSize, int ramSize,
int activeSession) { int activeSession) {
super(id, name, name, Type.ConsoleProxy, templateId, guestOSId, super(id, serviceOfferingId, name, name, Type.ConsoleProxy, templateId, guestOSId,
privateMacAddress, privateIpAddress, privateNetmask, dataCenterId, podId, true, hostId); privateMacAddress, privateIpAddress, privateNetmask, dataCenterId, podId, domainId, accountId, true, hostId);
this.gateway = gateway; this.gateway = gateway;
this.publicIpAddress = publicIpAddress; this.publicIpAddress = publicIpAddress;
this.publicNetmask = publicNetmask; this.publicNetmask = publicNetmask;

View File

@ -35,12 +35,6 @@ import com.cloud.utils.net.NetUtils;
@PrimaryKeyJoinColumn(name="id") @PrimaryKeyJoinColumn(name="id")
@DiscriminatorValue(value="DomainRouter") @DiscriminatorValue(value="DomainRouter")
public class DomainRouterVO extends VMInstanceVO implements DomainRouter { public class DomainRouterVO extends VMInstanceVO implements DomainRouter {
@Column(name="account_id", updatable=false, nullable=false)
private long accountId = -1;
@Column(name="domain_id", updatable=false, nullable=false)
private long domainId = 0;
@Column(name="ram_size", updatable=false, nullable=false) @Column(name="ram_size", updatable=false, nullable=false)
private int ramSize; private int ramSize;
@ -94,6 +88,7 @@ public class DomainRouterVO extends VMInstanceVO implements DomainRouter {
private Role role = Role.DHCP_FIREWALL_LB_PASSWD_USERDATA; private Role role = Role.DHCP_FIREWALL_LB_PASSWD_USERDATA;
public DomainRouterVO(long id, public DomainRouterVO(long id,
long serviceOfferingId,
String name, String name,
String instanceName, String instanceName,
String privateMacAddress, String privateMacAddress,
@ -120,7 +115,7 @@ public class DomainRouterVO extends VMInstanceVO implements DomainRouter {
Long hostId, Long hostId,
String dns1, String dns1,
String dns2) { String dns2) {
super(id, name, instanceName, Type.DomainRouter, templateId, guestOSId, privateMacAddress, privateIpAddress, privateNetmask, dataCenterId, podId, true, hostId); super(id, serviceOfferingId, name, instanceName, Type.DomainRouter, templateId, guestOSId, privateMacAddress, privateIpAddress, privateNetmask, dataCenterId, podId, domainId, accountId, true, hostId);
this.privateMacAddress = privateMacAddress; this.privateMacAddress = privateMacAddress;
this.guestMacAddress = guestMacAddress; this.guestMacAddress = guestMacAddress;
this.guestIpAddress = guestIpAddress; this.guestIpAddress = guestIpAddress;
@ -142,6 +137,7 @@ public class DomainRouterVO extends VMInstanceVO implements DomainRouter {
} }
public DomainRouterVO(long id, public DomainRouterVO(long id,
long serviceOfferingId,
String name, String name,
String privateMacAddress, String privateMacAddress,
String privateIpAddress, String privateIpAddress,
@ -164,15 +160,7 @@ public class DomainRouterVO extends VMInstanceVO implements DomainRouter {
String domain, String domain,
String dns1, String dns1,
String dns2) { String dns2) {
this(id, name, name, privateMacAddress, privateIpAddress, privateNetmask, templateId, guestOSId, guestMacAddress, guestIpAddress, guestNetmask, null, accountId, domainId, publicMacAddress, publicIpAddress, publicNetMask, vlanDbId, vlanId, podId, dataCenterId, ramSize, gateway, domain, null, dns1, dns2); this(id, serviceOfferingId, name, name, privateMacAddress, privateIpAddress, privateNetmask, templateId, guestOSId, guestMacAddress, guestIpAddress, guestNetmask, null, accountId, domainId, publicMacAddress, publicIpAddress, publicNetMask, vlanDbId, vlanId, podId, dataCenterId, ramSize, gateway, domain, null, dns1, dns2);
}
public long getAccountId() {
return accountId;
}
public long getDomainId() {
return domainId;
} }
public void setGateway(String gateway) { public void setGateway(String gateway) {
@ -319,6 +307,7 @@ public class DomainRouterVO extends VMInstanceVO implements DomainRouter {
this.zoneVlan = zoneVlan; this.zoneVlan = zoneVlan;
} }
@Override
public String getZoneVlan() { public String getZoneVlan() {
return zoneVlan; return zoneVlan;
} }
@ -327,6 +316,7 @@ public class DomainRouterVO extends VMInstanceVO implements DomainRouter {
this.guestZoneMacAddress = guestZoneMacAddress; this.guestZoneMacAddress = guestZoneMacAddress;
} }
@Override
public String getGuestZoneMacAddress() { public String getGuestZoneMacAddress() {
return guestZoneMacAddress; return guestZoneMacAddress;
} }

View File

@ -89,7 +89,8 @@ public class SecondaryStorageVmVO extends VMInstanceVO implements SecondaryStora
public SecondaryStorageVmVO( public SecondaryStorageVmVO(
long id, long id,
long serviceOfferingId,
String name, String name,
String guestMacAddress, String guestMacAddress,
String guestIpAddress, String guestIpAddress,
@ -105,7 +106,9 @@ public class SecondaryStorageVmVO extends VMInstanceVO implements SecondaryStora
Long vlanDbId, Long vlanDbId,
String vlanId, String vlanId,
long podId, long podId,
long dataCenterId, long dataCenterId,
long domainId,
long accountId,
String gateway, String gateway,
Long hostId, Long hostId,
String dns1, String dns1,
@ -114,8 +117,8 @@ public class SecondaryStorageVmVO extends VMInstanceVO implements SecondaryStora
int ramSize, int ramSize,
String guid, String guid,
String nfsShare) { String nfsShare) {
super(id, name, name, Type.SecondaryStorageVm, templateId, guestOSId, super(id, serviceOfferingId, name, name, Type.SecondaryStorageVm, templateId, guestOSId,
privateMacAddress, privateIpAddress, privateNetmask, dataCenterId, podId, true, hostId); privateMacAddress, privateIpAddress, privateNetmask, dataCenterId, podId, domainId, accountId, true, hostId);
this.gateway = gateway; this.gateway = gateway;
this.publicIpAddress = publicIpAddress; this.publicIpAddress = publicIpAddress;
this.publicNetmask = publicNetmask; this.publicNetmask = publicNetmask;

View File

@ -31,12 +31,6 @@ import com.cloud.uservm.UserVm;
@PrimaryKeyJoinColumn(name="id") @PrimaryKeyJoinColumn(name="id")
public class UserVmVO extends VMInstanceVO implements UserVm { public class UserVmVO extends VMInstanceVO implements UserVm {
@Column(name="account_id", updatable=false, nullable=false)
private long accountId = -1;
@Column(name="domain_id", updatable=false, nullable=false)
private long domainId = -1;
@Column(name="domain_router_id", updatable=true, nullable=true) @Column(name="domain_router_id", updatable=true, nullable=true)
Long domainRouterId; Long domainRouterId;
@ -74,15 +68,6 @@ public class UserVmVO extends VMInstanceVO implements UserVm {
private String displayName; private String displayName;
@Override @Override
public long getAccountId() {
return accountId;
}
@Override
public long getDomainId() {
return domainId;
}
public String getGuestIpAddress() { public String getGuestIpAddress() {
return guestIpAddress; return guestIpAddress;
} }
@ -92,7 +77,8 @@ public class UserVmVO extends VMInstanceVO implements UserVm {
setPrivateIpAddress(guestIpAddress); setPrivateIpAddress(guestIpAddress);
} }
public String getGuestMacAddress() { @Override
public String getGuestMacAddress() {
return guestMacAddress; return guestMacAddress;
} }
@ -153,7 +139,7 @@ public class UserVmVO extends VMInstanceVO implements UserVm {
long accountId, long accountId,
long serviceOfferingId, long serviceOfferingId,
String userData) { String userData) {
super(id, displayName, instanceName, Type.User, templateId, guestOsId, haEnabled); super(id, serviceOfferingId, displayName, instanceName, Type.User, templateId, guestOsId, domainId, accountId, haEnabled);
this.userData = userData; this.userData = userData;
this.displayName = displayName; this.displayName = displayName;
@ -178,11 +164,8 @@ public class UserVmVO extends VMInstanceVO implements UserVm {
boolean haEnabled, boolean haEnabled,
String displayName, String displayName,
String userData) { String userData) {
super(id, name, name, Type.User, templateId, guestOSId, guestMacAddress, guestIpAddress, guestNetMask, dcId, podId, haEnabled, null); super(id, serviceOfferingId, name, name, Type.User, templateId, guestOSId, guestMacAddress, guestIpAddress, guestNetMask, dcId, podId, domainId, accountId, haEnabled, null);
this.serviceOfferingId = serviceOfferingId;
this.domainRouterId = routerId; this.domainRouterId = routerId;
this.accountId = accountId;
this.domainId = domainId;
this.guestIpAddress = guestIpAddress; this.guestIpAddress = guestIpAddress;
this.guestNetmask = guestNetMask; this.guestNetmask = guestNetMask;
this.guestMacAddress = guestMacAddress; this.guestMacAddress = guestMacAddress;

View File

@ -125,13 +125,24 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
@Temporal(value=TemporalType.TIMESTAMP) @Temporal(value=TemporalType.TIMESTAMP)
Date updateTime; Date updateTime;
@Column(name="domain_id")
long domainId;
@Column(name="account_id")
long accountId;
@Column(name="service_offering_id")
long serviceOfferingId;
public VMInstanceVO(long id, public VMInstanceVO(long id,
long serviceOfferingId,
String name, String name,
String instanceName, String instanceName,
Type type, Type type,
Long vmTemplateId, Long vmTemplateId,
long guestOSId, long guestOSId,
long domainId,
long accountId,
boolean haEnabled) { boolean haEnabled) {
this.id = id; this.id = id;
this.name = name; this.name = name;
@ -145,10 +156,14 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
this.mirroredVols = false; this.mirroredVols = false;
this.vncPassword = Long.toHexString(new Random().nextLong()); this.vncPassword = Long.toHexString(new Random().nextLong());
this.state = State.Creating; this.state = State.Creating;
this.accountId = accountId;
this.domainId = domainId;
this.serviceOfferingId = serviceOfferingId;
} }
public VMInstanceVO(long id, public VMInstanceVO(long id,
long serviceOfferingId,
String name, String name,
String instanceName, String instanceName,
Type type, Type type,
@ -158,7 +173,9 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
String privateIpAddress, String privateIpAddress,
String privateNetmask, String privateNetmask,
long dataCenterId, long dataCenterId,
long podId, long podId,
long domainId,
long accountId,
boolean haEnabled, boolean haEnabled,
Long hostId) { Long hostId) {
super(); super();
@ -182,6 +199,9 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
this.updateTime = new Date(); this.updateTime = new Date();
this.vncPassword = Long.toHexString(new Random().nextLong()); this.vncPassword = Long.toHexString(new Random().nextLong());
this.state = State.Creating; this.state = State.Creating;
this.serviceOfferingId = serviceOfferingId;
this.domainId = domainId;
this.accountId = accountId;
} }
protected VMInstanceVO() { protected VMInstanceVO() {
@ -189,6 +209,16 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
public Date getRemoved() { public Date getRemoved() {
return removed; return removed;
}
@Override
public long getDomainId() {
return domainId;
}
@Override
public long getAccountId() {
return accountId;
} }
@Override @Override
@ -275,6 +305,10 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
return vncPassword; return vncPassword;
} }
public long getServiceOfferingId() {
return serviceOfferingId;
}
public Long getProxyId() { public Long getProxyId() {
return proxyId; return proxyId;
} }

View File

@ -845,7 +845,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
if (s_logger.isDebugEnabled()) if (s_logger.isDebugEnabled())
s_logger.debug("Assign console proxy from a newly started instance for request from data center : " + dataCenterId); s_logger.debug("Assign console proxy from a newly started instance for request from data center : " + dataCenterId);
Map<String, Object> context = createProxyInstance(dataCenterId); Map<String, Object> context = createProxyInstance2(dataCenterId);
long proxyVmId = (Long) context.get("proxyVmId"); long proxyVmId = (Long) context.get("proxyVmId");
if (proxyVmId == 0) { if (proxyVmId == 0) {
@ -884,7 +884,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
if (s_logger.isDebugEnabled()) if (s_logger.isDebugEnabled())
s_logger.debug("Assign console proxy from a newly started instance for request from data center : " + dataCenterId); s_logger.debug("Assign console proxy from a newly started instance for request from data center : " + dataCenterId);
Map<String, Object> context = createProxyInstance(dataCenterId); Map<String, Object> context = createProxyInstance2(dataCenterId);
long proxyVmId = (Long) context.get("proxyVmId"); long proxyVmId = (Long) context.get("proxyVmId");
if (proxyVmId == 0) { if (proxyVmId == 0) {
@ -979,13 +979,15 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
String vlanGateway = publicIpAndVlan._gateWay; String vlanGateway = publicIpAndVlan._gateWay;
String vlanNetmask = publicIpAndVlan._netMask; String vlanNetmask = publicIpAndVlan._netMask;
AccountVO systemAccount = _accountMgr.getSystemAccount();
txn.start(); txn.start();
ConsoleProxyVO proxy; ConsoleProxyVO proxy;
String name = VirtualMachineName.getConsoleProxyName(id, _instance).intern(); String name = VirtualMachineName.getConsoleProxyName(id, _instance).intern();
proxy = new ConsoleProxyVO(id, name, guestMacAddress, null, NetUtils.getLinkLocalNetMask(), privateMacAddress, null, cidrNetmask, proxy = new ConsoleProxyVO(id, _serviceOffering.getId(), name, guestMacAddress, null, NetUtils.getLinkLocalNetMask(), privateMacAddress, null, cidrNetmask,
_template.getId(), _template.getGuestOSId(), publicMacAddress, publicIpAddress, vlanNetmask, publicIpAndVlan._vlanDbId, _template.getId(), _template.getGuestOSId(), publicMacAddress, publicIpAddress, vlanNetmask, publicIpAndVlan._vlanDbId,
publicIpAndVlan._vlanid, pod.first().getId(), dataCenterId, vlanGateway, null, dc.getDns1(), dc.getDns2(), _domain, publicIpAndVlan._vlanid, pod.first().getId(), dataCenterId, systemAccount.getDomainId(), systemAccount.getId(), vlanGateway, null, dc.getDns1(), dc.getDns2(), _domain,
_proxyRamSize, 0); _proxyRamSize, 0);
proxy.setLastHostId(pod.second()); proxy.setLastHostId(pod.second());
@ -1016,6 +1018,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
long id = _consoleProxyDao.getNextInSequence(Long.class, "id"); long id = _consoleProxyDao.getNextInSequence(Long.class, "id");
String name = VirtualMachineName.getConsoleProxyName(id, _instance); String name = VirtualMachineName.getConsoleProxyName(id, _instance);
DataCenterVO dc = _dcDao.findById(dataCenterId); DataCenterVO dc = _dcDao.findById(dataCenterId);
AccountVO systemAcct = _accountMgr.getSystemAccount();
DataCenterDeployment plan = new DataCenterDeployment(dataCenterId, 1); DataCenterDeployment plan = new DataCenterDeployment(dataCenterId, 1);
@ -1024,7 +1027,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
for (NetworkOfferingVO offering : offerings) { for (NetworkOfferingVO offering : offerings) {
profiles.add(_networkMgr.setupNetworkConfiguration(_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, _serviceOffering.getId(), name, _template.getId(), _template.getGuestOSId(), dataCenterId, systemAcct.getDomainId(), systemAcct.getId(), 0);
proxy = _consoleProxyDao.persist(proxy); proxy = _consoleProxyDao.persist(proxy);
try { try {
VirtualMachineProfile vmProfile = _vmMgr.allocate(proxy, _template, _serviceOffering, profiles, plan, _accountMgr.getSystemAccount()); VirtualMachineProfile vmProfile = _vmMgr.allocate(proxy, _template, _serviceOffering, profiles, plan, _accountMgr.getSystemAccount());

View File

@ -427,6 +427,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
router = router =
new DomainRouterVO(id, new DomainRouterVO(id,
_offering.getId(),
name, name,
mgmtMacAddress, mgmtMacAddress,
null, null,
@ -612,6 +613,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
} }
router = new DomainRouterVO(id, router = new DomainRouterVO(id,
_offering.getId(),
name, name,
privateMacAddress, privateMacAddress,
null, null,
@ -2475,7 +2477,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
NetworkConcierge concierge = _networkConcierges.get(nic.getReserver()); NetworkConcierge concierge = _networkConcierges.get(nic.getReserver());
nic.setState(Resource.State.Reserving); nic.setState(Resource.State.Reserving);
_nicDao.update(nic.getId(), nic); _nicDao.update(nic.getId(), nic);
concierge.reserve(vmProfile.getId(), toNicProfile(nic), dest); concierge.reserve(null, toNicProfile(nic), dest);
} else { } else {
} }

View File

@ -106,9 +106,9 @@ public class ControlNetworkGuru extends AdapterBase implements NetworkGuru, Netw
} }
@Override @Override
public String reserve(long vmId, NicProfile nic, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException, public String reserve(VirtualMachine vm, NicProfile nic, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException,
InsufficientAddressCapacityException { InsufficientAddressCapacityException {
String ip = _dcDao.allocateLinkLocalPrivateIpAddress(dest.getDataCenter().getId(), dest.getPod().getId(), vmId); 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");
return Long.toString(nic.getId()); return Long.toString(nic.getId());

View File

@ -77,7 +77,7 @@ public class PodBasedNetworkGuru extends AdapterBase implements NetworkGuru, Net
} }
@Override @Override
public String reserve(long vmId, NicProfile nic, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException, public String reserve(VirtualMachine vm, NicProfile nic, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException,
InsufficientAddressCapacityException { InsufficientAddressCapacityException {
Pod pod = dest.getPod(); Pod pod = dest.getPod();
String ip = _dcDao.allocatePrivateIpAddress(dest.getDataCenter().getId(), dest.getPod().getId(), nic.getId()); String ip = _dcDao.allocatePrivateIpAddress(dest.getDataCenter().getId(), dest.getPod().getId(), nic.getId());

View File

@ -5,9 +5,15 @@ package com.cloud.network.configuration;
import javax.ejb.Local; import javax.ejb.Local;
import org.apache.log4j.Logger;
import com.cloud.dc.Vlan.VlanType;
import com.cloud.dc.VlanVO;
import com.cloud.dc.dao.DataCenterDao; import com.cloud.dc.dao.DataCenterDao;
import com.cloud.dc.dao.VlanDao;
import com.cloud.deploy.DeployDestination; import com.cloud.deploy.DeployDestination;
import com.cloud.deploy.DeploymentPlan; import com.cloud.deploy.DeploymentPlan;
import com.cloud.domain.DomainVO;
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.BroadcastDomainType; import com.cloud.network.Network.BroadcastDomainType;
@ -17,6 +23,7 @@ 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.user.Account; import com.cloud.user.Account;
import com.cloud.utils.Pair;
import com.cloud.utils.component.AdapterBase; import com.cloud.utils.component.AdapterBase;
import com.cloud.utils.component.Inject; import com.cloud.utils.component.Inject;
import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.exception.CloudRuntimeException;
@ -27,7 +34,10 @@ import com.cloud.vm.VirtualMachine;
@Local(value={NetworkGuru.class, NetworkConcierge.class}) @Local(value={NetworkGuru.class, NetworkConcierge.class})
public class PublicNetworkGuru extends AdapterBase implements NetworkGuru, NetworkConcierge { public class PublicNetworkGuru extends AdapterBase implements NetworkGuru, NetworkConcierge {
private static final Logger s_logger = Logger.getLogger(PublicNetworkGuru.class);
@Inject DataCenterDao _dcDao; @Inject DataCenterDao _dcDao;
@Inject VlanDao _vlanDao;
@Override @Override
public NetworkConfiguration design(NetworkOffering offering, DeploymentPlan plan, NetworkConfiguration config, Account owner) { public NetworkConfiguration design(NetworkOffering offering, DeploymentPlan plan, NetworkConfiguration config, Account owner) {
@ -67,10 +77,25 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru, Netwo
} }
@Override @Override
public String reserve(long vmId, NicProfile ch, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException, public String reserve(VirtualMachine vm, NicProfile ch, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
InsufficientAddressCapacityException { long dcId = dest.getDataCenter().getId();
long podId = dest.getPod().getId();
return null;
Pair<String, VlanVO> ipAndVlan = _vlanDao.assignIpAddress(dcId, vm.getAccountId(), vm.getDomainId(), VlanType.VirtualNetwork, true);
if (ipAndVlan == null) {
s_logger.debug("Unable to get public ip address (type=Virtual) for console proxy vm for data center : " + dcId);
ipAndVlan = _vlanDao.assignPodDirectAttachIpAddress(dcId, podId, Account.ACCOUNT_ID_SYSTEM, DomainVO.ROOT_DOMAIN);
if (ipAndVlan == null)
s_logger.debug("Unable to get public ip address (type=DirectAttach) for console proxy vm for data center : " + dcId);
}
if (ipAndVlan != null) {
VlanVO vlan = ipAndVlan.second();
return null;
// networkInfo net = new networkInfo(ipAndVlan.first(), vlan.getVlanNetmask(), vlan.getVlanGateway(), vlan.getId(), vlan.getVlanId());
// return net;
}
return null;
} }
@Override @Override
@ -80,8 +105,6 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru, Netwo
@Override @Override
public NetworkConfiguration implement(NetworkConfiguration config, NetworkOffering offering, DeployDestination destination) { public NetworkConfiguration implement(NetworkConfiguration config, NetworkOffering offering, DeployDestination destination) {
return config;
// TODO Auto-generated method stub
return null;
} }
} }

View File

@ -59,8 +59,8 @@ import com.cloud.configuration.Config;
import com.cloud.configuration.dao.ConfigurationDao; import com.cloud.configuration.dao.ConfigurationDao;
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.Vlan.VlanType; import com.cloud.dc.Vlan.VlanType;
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;
@ -83,19 +83,18 @@ import com.cloud.info.RunningHostCountInfo;
import com.cloud.info.RunningHostInfoAgregator; import com.cloud.info.RunningHostInfoAgregator;
import com.cloud.info.RunningHostInfoAgregator.ZoneHostInfo; import com.cloud.info.RunningHostInfoAgregator.ZoneHostInfo;
import com.cloud.network.IpAddrAllocator; import com.cloud.network.IpAddrAllocator;
import com.cloud.network.NetworkManager;
import com.cloud.network.IpAddrAllocator.networkInfo; import com.cloud.network.IpAddrAllocator.networkInfo;
import com.cloud.network.NetworkManager;
import com.cloud.network.dao.IPAddressDao; import com.cloud.network.dao.IPAddressDao;
import com.cloud.offering.NetworkOffering; import com.cloud.offering.NetworkOffering;
import com.cloud.offering.NetworkOffering.GuestIpType;
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;
import com.cloud.storage.StoragePoolVO; import com.cloud.storage.StoragePoolVO;
import com.cloud.storage.VMTemplateHostVO; import com.cloud.storage.VMTemplateHostVO;
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
import com.cloud.storage.VMTemplateVO; import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.VolumeVO; import com.cloud.storage.VolumeVO;
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
import com.cloud.storage.dao.StoragePoolDao; import com.cloud.storage.dao.StoragePoolDao;
import com.cloud.storage.dao.StoragePoolHostDao; import com.cloud.storage.dao.StoragePoolHostDao;
import com.cloud.storage.dao.VMTemplateDao; import com.cloud.storage.dao.VMTemplateDao;
@ -103,6 +102,7 @@ import com.cloud.storage.dao.VMTemplateHostDao;
import com.cloud.storage.dao.VolumeDao; import com.cloud.storage.dao.VolumeDao;
import com.cloud.storage.template.TemplateConstants; import com.cloud.storage.template.TemplateConstants;
import com.cloud.user.Account; import com.cloud.user.Account;
import com.cloud.user.AccountManager;
import com.cloud.user.AccountVO; import com.cloud.user.AccountVO;
import com.cloud.user.User; import com.cloud.user.User;
import com.cloud.user.dao.AccountDao; import com.cloud.user.dao.AccountDao;
@ -123,9 +123,9 @@ import com.cloud.utils.net.NetUtils;
import com.cloud.vm.SecondaryStorageVmVO; import com.cloud.vm.SecondaryStorageVmVO;
import com.cloud.vm.State; import com.cloud.vm.State;
import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachine;
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.VirtualMachine.Event;
import com.cloud.vm.dao.SecondaryStorageVmDao; import com.cloud.vm.dao.SecondaryStorageVmDao;
import com.cloud.vm.dao.UserVmDao; import com.cloud.vm.dao.UserVmDao;
import com.cloud.vm.dao.VMInstanceDao; import com.cloud.vm.dao.VMInstanceDao;
@ -204,6 +204,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
@Inject private ConfigurationDao _configDao; @Inject private ConfigurationDao _configDao;
@Inject private EventDao _eventDao; @Inject private EventDao _eventDao;
@Inject private ServiceOfferingDao _offeringDao; @Inject private ServiceOfferingDao _offeringDao;
@Inject private AccountManager _accountMgr;
private IpAddrAllocator _IpAllocator; private IpAddrAllocator _IpAllocator;
@ -525,7 +526,8 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
return null; return null;
} }
public boolean generateFirewallConfiguration(Long hostId){ @Override
public boolean generateFirewallConfiguration(Long hostId){
if (hostId == null) { if (hostId == null) {
return true; return true;
} }
@ -740,14 +742,15 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
String vlanGateway = publicIpAndVlan._gateWay; String vlanGateway = publicIpAndVlan._gateWay;
String vlanNetmask = publicIpAndVlan._netMask; String vlanNetmask = publicIpAndVlan._netMask;
AccountVO systemAcct = _accountMgr.getSystemAccount();
txn.start(); txn.start();
SecondaryStorageVmVO secStorageVm; SecondaryStorageVmVO secStorageVm;
String name = VirtualMachineName.getSystemVmName(id, _instance, "s").intern(); String name = VirtualMachineName.getSystemVmName(id, _instance, "s").intern();
secStorageVm = new SecondaryStorageVmVO(id, name, guestMacAddress, null, NetUtils.getLinkLocalNetMask(), secStorageVm = new SecondaryStorageVmVO(id, _serviceOffering.getId(), name, guestMacAddress, null, NetUtils.getLinkLocalNetMask(),
privateMacAddress, null, cidrNetmask, _template.getId(), _template.getGuestOSId(), privateMacAddress, null, cidrNetmask, _template.getId(), _template.getGuestOSId(),
publicMacAddress, publicIpAddress, vlanNetmask, publicIpAndVlan._vlanDbId, publicIpAndVlan._vlanid, publicMacAddress, publicIpAddress, vlanNetmask, publicIpAndVlan._vlanDbId, publicIpAndVlan._vlanid,
pod.first().getId(), dataCenterId, vlanGateway, null, pod.first().getId(), dataCenterId, systemAcct.getDomainId(), systemAcct.getId(), vlanGateway, null,
dc.getInternalDns1(), dc.getInternalDns2(), _domain, _secStorageVmRamSize, secHost.getGuid(), secHost.getStorageUrl()); dc.getInternalDns1(), dc.getInternalDns2(), _domain, _secStorageVmRamSize, secHost.getGuid(), secHost.getStorageUrl());
secStorageVm.setLastHostId(pod.second()); secStorageVm.setLastHostId(pod.second());

View File

@ -119,6 +119,8 @@ ALTER TABLE `cloud`.`vm_instance` ADD INDEX `i_vm_instance__last_host_id`(`last_
ALTER TABLE `cloud`.`vm_instance` ADD CONSTRAINT `fk_vm_instance__template_id` FOREIGN KEY `fk_vm_instance__template_id` (`vm_template_id`) REFERENCES `vm_template` (`id`); ALTER TABLE `cloud`.`vm_instance` ADD CONSTRAINT `fk_vm_instance__template_id` FOREIGN KEY `fk_vm_instance__template_id` (`vm_template_id`) REFERENCES `vm_template` (`id`);
ALTER TABLE `cloud`.`vm_instance` ADD INDEX `i_vm_instance__template_id`(`vm_template_id`); ALTER TABLE `cloud`.`vm_instance` ADD INDEX `i_vm_instance__template_id`(`vm_template_id`);
ALTER TABLE `cloud`.`vm_instance` ADD CONSTRAINT `fk_vm_instance__account_id` FOREIGN KEY `fk_vm_instance__account_id` (`account_id`) REFERENCES `account` (`id`);
ALTER TABLE `cloud`.`vm_instance` ADD INDEX `i_vm_instance__account_id`(`account_id`);
ALTER TABLE `cloud`.`service_offering` ADD CONSTRAINT `fk_service_offering__id` FOREIGN KEY `fk_service_offering__id`(`id`) REFERENCES `disk_offering`(`id`) ON DELETE CASCADE; ALTER TABLE `cloud`.`service_offering` ADD CONSTRAINT `fk_service_offering__id` FOREIGN KEY `fk_service_offering__id`(`id`) REFERENCES `disk_offering`(`id`) ON DELETE CASCADE;
@ -127,8 +129,6 @@ ALTER TABLE `cloud`.`user_vm` ADD INDEX `i_user_vm__domain_router_id`(`domain_ro
ALTER TABLE `cloud`.`user_vm` ADD CONSTRAINT `fk_user_vm__service_offering_id` FOREIGN KEY `fk_user_vm__service_offering_id` (`service_offering_id`) REFERENCES `service_offering` (`id`); ALTER TABLE `cloud`.`user_vm` ADD CONSTRAINT `fk_user_vm__service_offering_id` FOREIGN KEY `fk_user_vm__service_offering_id` (`service_offering_id`) REFERENCES `service_offering` (`id`);
ALTER TABLE `cloud`.`user_vm` ADD INDEX `i_user_vm__service_offering_id`(`service_offering_id`); ALTER TABLE `cloud`.`user_vm` ADD INDEX `i_user_vm__service_offering_id`(`service_offering_id`);
ALTER TABLE `cloud`.`user_vm` ADD CONSTRAINT `fk_user_vm__id` FOREIGN KEY `fk_user_vm__id` (`id`) REFERENCES `vm_instance`(`id`) ON DELETE CASCADE; ALTER TABLE `cloud`.`user_vm` ADD CONSTRAINT `fk_user_vm__id` FOREIGN KEY `fk_user_vm__id` (`id`) REFERENCES `vm_instance`(`id`) ON DELETE CASCADE;
ALTER TABLE `cloud`.`user_vm` ADD CONSTRAINT `fk_user_vm__account_id` FOREIGN KEY `fk_user_vm__account_id` (`account_id`) REFERENCES `account` (`id`);
ALTER TABLE `cloud`.`user_vm` ADD INDEX `i_user_vm__account_id`(`account_id`);
ALTER TABLE `cloud`.`user_vm` ADD CONSTRAINT `fk_user_vm__external_ip_address` FOREIGN KEY `fk_user_vm__external_ip_address` (`external_ip_address`) REFERENCES `user_ip_address` (`public_ip_address`); ALTER TABLE `cloud`.`user_vm` ADD CONSTRAINT `fk_user_vm__external_ip_address` FOREIGN KEY `fk_user_vm__external_ip_address` (`external_ip_address`) REFERENCES `user_ip_address` (`public_ip_address`);
ALTER TABLE `cloud`.`user_vm` ADD INDEX `i_user_vm__external_ip_address`(`external_ip_address`); ALTER TABLE `cloud`.`user_vm` ADD INDEX `i_user_vm__external_ip_address`(`external_ip_address`);
ALTER TABLE `cloud`.`user_vm` ADD CONSTRAINT `fk_user_vm__external_vlan_db_id` FOREIGN KEY `fk_user_vm__external_vlan_db_id` (`external_vlan_db_id`) REFERENCES `vlan` (`id`); ALTER TABLE `cloud`.`user_vm` ADD CONSTRAINT `fk_user_vm__external_vlan_db_id` FOREIGN KEY `fk_user_vm__external_vlan_db_id` (`external_vlan_db_id`) REFERENCES `vlan` (`id`);

View File

@ -539,26 +539,6 @@ CREATE TABLE `cloud`.`vm_template` (
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`vm_instance2` (
`id` bigint unsigned UNIQUE NOT NULL,
`instance_name` varchar(255) NOT NULL COMMENT 'name of the vm instance running on the hosts',
`state` varchar(32) NOT NULL,
`update_count` bigint unsigned NOT NULL DEFAULT 0 COMMENT 'date state was updated',
`vm_template_id` bigint unsigned,
`guest_os_id` bigint unsigned NOT NULL,
`host_id` bigint unsigned,
`last_host_id` bigint unsigned COMMENT 'tentative host for first run or last host that it has been running on',
`proxy_id` bigint unsigned NULL COMMENT 'console proxy allocated in previous session',
`proxy_assign_time` DATETIME NULL COMMENT 'time when console proxy was assigned',
`vnc_password` varchar(255) NOT NULL COMMENT 'vnc password',
`ha_enabled` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Should HA be enabled for this VM',
`update_time` datetime COMMENT 'date the destroy was requested',
`created` datetime NOT NULL COMMENT 'date created',
`removed` datetime COMMENT 'date removed if not null',
`type` varchar(32) NOT NULL COMMENT 'type of vm it is',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`vm_instance` ( CREATE TABLE `cloud`.`vm_instance` (
`id` bigint unsigned UNIQUE NOT NULL, `id` bigint unsigned UNIQUE NOT NULL,
`name` varchar(255) NOT NULL, `name` varchar(255) NOT NULL,
@ -583,6 +563,9 @@ CREATE TABLE `cloud`.`vm_instance` (
`created` datetime NOT NULL COMMENT 'date created', `created` datetime NOT NULL COMMENT 'date created',
`removed` datetime COMMENT 'date removed if not null', `removed` datetime COMMENT 'date removed if not null',
`type` varchar(32) NOT NULL COMMENT 'type of vm it is', `type` varchar(32) NOT NULL COMMENT 'type of vm it is',
`account_id` bigint unsigned NOT NULL COMMENT 'user id of owner',
`domain_id` bigint unsigned NOT NULL,
`service_offering_id` bigint unsigned NOT NULL COMMENT 'service offering id',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@ -593,8 +576,6 @@ CREATE TABLE `cloud`.`user_vm` (
`domain_router_id` bigint unsigned COMMENT 'router id', `domain_router_id` bigint unsigned COMMENT 'router id',
`vnet` varchar(18) COMMENT 'vnet', `vnet` varchar(18) COMMENT 'vnet',
`dc_vlan` varchar(18) COMMENT 'zone vlan', `dc_vlan` varchar(18) COMMENT 'zone vlan',
`account_id` bigint unsigned NOT NULL COMMENT 'user id of owner',
`domain_id` bigint unsigned NOT NULL,
`guest_ip_address` varchar(15) COMMENT 'ip address within the guest network', `guest_ip_address` varchar(15) COMMENT 'ip address within the guest network',
`guest_mac_address` varchar(17) COMMENT 'mac address within the guest network', `guest_mac_address` varchar(17) COMMENT 'mac address within the guest network',
`guest_netmask` varchar(15) COMMENT 'netmask within the guest network', `guest_netmask` varchar(15) COMMENT 'netmask within the guest network',
@ -602,7 +583,6 @@ CREATE TABLE `cloud`.`user_vm` (
`external_mac_address` varchar(17) COMMENT 'mac address within the external network', `external_mac_address` varchar(17) COMMENT 'mac address within the external network',
`external_vlan_db_id` bigint unsigned COMMENT 'foreign key into vlan table', `external_vlan_db_id` bigint unsigned COMMENT 'foreign key into vlan table',
`user_data` varchar(2048), `user_data` varchar(2048),
`service_offering_id` bigint unsigned NOT NULL COMMENT 'service offering id',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;