Forgot what i change but must be important

This commit is contained in:
Alex Huang 2010-12-10 16:03:44 -08:00
parent d9c77e0d16
commit 790bf40be6
16 changed files with 111 additions and 90 deletions

View File

@ -17,6 +17,7 @@
*/
package com.cloud.exception;
import com.cloud.host.Host;
import com.cloud.utils.SerialVersionUID;
/**
@ -28,18 +29,11 @@ public class AgentUnavailableException extends ResourceUnavailableException {
private static final long serialVersionUID = SerialVersionUID.AgentUnavailableException;
long _agentId;
public AgentUnavailableException(String msg, long agentId) {
super("Host " + agentId + ": " + msg);
_agentId = agentId;
super("Host " + agentId + ": " + msg, Host.class, agentId);
}
public AgentUnavailableException(long agentId) {
this("Unable to reach host.", agentId);
}
public long getAgentId() {
return _agentId;
}
}

View File

@ -34,11 +34,21 @@ public class ResourceUnavailableException extends CloudRuntimeException {
super(msg, cause);
}
public ResourceUnavailableException(String msg, Class<?> scope, long resourceId) {
this(msg, scope, resourceId, null);
}
public ResourceUnavailableException(String msg, Class<?> scope, long resourceId, Throwable cause) {
super(msg, cause);
_scope = scope;
_id = resourceId;
}
public Class<?> getScope() {
return _scope;
}
public long getScopeId() {
public long getResourceId() {
return _id;
}
}

View File

@ -17,6 +17,7 @@
*/
package com.cloud.exception;
import com.cloud.storage.StoragePool;
import com.cloud.utils.SerialVersionUID;
/**
@ -27,32 +28,17 @@ import com.cloud.utils.SerialVersionUID;
*
*/
public class StorageUnavailableException extends ResourceUnavailableException {
Object _obj;
private static final long serialVersionUID = SerialVersionUID.StorageUnavailableException;
public StorageUnavailableException(String msg) {
super(msg);
}
public StorageUnavailableException(String msg, Throwable cause) {
super(msg, cause);
}
public StorageUnavailableException(String msg, Object cause) {
super(msg);
_obj = cause;
}
public StorageUnavailableException(String msg, Object obj, Throwable cause) {
super(msg, cause);
_obj = obj;
public StorageUnavailableException(String msg) {
super(msg);
}
public StorageUnavailableException(String msg, long poolId) {
this(msg, poolId, null);
}
public StorageUnavailableException(String msg, long poolId, Throwable cause) {
super(msg, StoragePool.class, poolId, cause);
}
/**
* @return object that caused this problem. It can either be a StoragePool or volume.
*/
public Object getOffendingObject() {
return _obj;
}
}

View File

@ -2,6 +2,6 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/console-common"/>
<classpathentry combineaccessrules="false" kind="src" path="/console"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -158,9 +158,9 @@ import com.cloud.vm.State;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineGuru;
import com.cloud.vm.VirtualMachineManager;
import com.cloud.vm.VirtualMachineName;
import com.cloud.vm.VirtualMachineProfile;
import com.cloud.vm.VirtualMachineManager;
import com.cloud.vm.dao.ConsoleProxyDao;
import com.cloud.vm.dao.NicDao;
import com.cloud.vm.dao.VMInstanceDao;
@ -1202,7 +1202,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
if (_IpAllocator != null && _IpAllocator.exteralIpAddressAllocatorEnabled()) {
return _IpAllocator.getPrivateIpAddress(macAddr, dcId, podId).ipaddr;
} else {
return _dcDao.allocatePrivateIpAddress(dcId, podId, proxyId, null);
return _dcDao.allocatePrivateIpAddress(dcId, podId, proxyId, null).first();
}
}
@ -2300,7 +2300,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
if (!_storageMgr.share(proxy, vols, routingHost, false)) {
s_logger.warn("Can not share " + proxy.getHostName());
throw new StorageUnavailableException("Can not share " + proxy.getHostName(), vol);
throw new StorageUnavailableException("Can not share " + proxy.getHostName(), vol.getPoolId());
}
Answer answer = _agentMgr.easySend(routingHost.getId(), cmd);
@ -2510,8 +2510,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
boolean externalDhcp = false;
String externalDhcpStr = _configDao.getValue("direct.attach.network.externalIpAllocator.enabled");
if(externalDhcpStr != null && externalDhcpStr.equalsIgnoreCase("true"))
externalDhcp = true;
if(externalDhcpStr != null && externalDhcpStr.equalsIgnoreCase("true")) {
externalDhcp = true;
}
NicProfile controlNic = null;
NicProfile managementNic = null;
@ -2537,14 +2538,16 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
buf.append(" localgw=").append(dest.getPod().getGateway());
managementNic = nic;
} else if (nic.getTrafficType() == TrafficType.Control) {
if(nic.getIp4Address() != null)
controlNic = nic;
if(nic.getIp4Address() != null) {
controlNic = nic;
}
}
}
/*External DHCP mode*/
if(externalDhcp)
buf.append(" bootproto=dhcp");
if(externalDhcp) {
buf.append(" bootproto=dhcp");
}
if(controlNic == null) {
assert(managementNic != null);

View File

@ -22,6 +22,7 @@ import java.util.List;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.DataCenterVnetVO;
import com.cloud.utils.Pair;
import com.cloud.utils.db.GenericDao;
public interface DataCenterDao extends GenericDao<DataCenterVO, Long> {
@ -33,7 +34,7 @@ public interface DataCenterDao extends GenericDao<DataCenterVO, Long> {
*/
String[] getNextAvailableMacAddressPair(long id);
String[] getNextAvailableMacAddressPair(long id, long mask);
String allocatePrivateIpAddress(long id, long podId, long instanceId, String reservationId);
Pair<String, Long> allocatePrivateIpAddress(long id, long podId, long instanceId, String reservationId);
String allocateLinkLocalIpAddress(long id, long podId, long instanceId, String reservationId);
String allocateVnet(long dcId, long accountId, String reservationId);

View File

@ -34,6 +34,7 @@ import com.cloud.dc.DataCenterVO;
import com.cloud.dc.DataCenterVnetVO;
import com.cloud.dc.PodVlanVO;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.Pair;
import com.cloud.utils.component.ComponentLocator;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
@ -172,12 +173,12 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
}
@Override
public String allocatePrivateIpAddress(long dcId, long podId, long instanceId, String reservationId) {
public Pair<String, Long> allocatePrivateIpAddress(long dcId, long podId, long instanceId, String reservationId) {
DataCenterIpAddressVO vo = _ipAllocDao.takeIpAddress(dcId, podId, instanceId, reservationId);
if (vo == null) {
return null;
}
return vo.getIpAddress();
return new Pair<String, Long>(vo.getIpAddress(), vo.getMacAddress());
}
@Override

View File

@ -67,9 +67,9 @@ public class InvestigatorImpl implements Investigator {
/*TODO: checking vm status for external dhcp mode*/
s_logger.debug("It's external dhcp mode, how to checking the vm is alive?");
return true;
} else {
return testUserVM(vm, routerId);
}
else
return testUserVM(vm, routerId);
} else if ((vm.getType() == VirtualMachine.Type.DomainRouter) || (vm.getType() == VirtualMachine.Type.ConsoleProxy)) {
// get the data center IP address, find a host on the pod, use that host to ping the data center IP address
HostVO vmHost = _hostDao.findById(vm.getHostId());
@ -203,7 +203,7 @@ public class InvestigatorImpl implements Investigator {
}
} catch (AgentUnavailableException e) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Couldn't reach " + e.getAgentId());
s_logger.debug("Couldn't reach " + e.getResourceId());
}
continue;
} catch (OperationTimedoutException e) {

View File

@ -241,7 +241,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
txn.commit();
long macAddress = addr.getMacAddress() | 0x060000000000l | (((long)_rand.nextInt(32768) << 25) & 0x00fffe000000l);
long macAddress = NetUtils.createSequenceBasedMacAddress(addr.getMacAddress());
return new PublicIp(addr, _vlanDao.findById(addr.getVlanId()), macAddress);
}
@ -1099,6 +1099,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
NicProfile profile = null;
if (nic.getReservationStrategy() == ReservationStrategy.Start) {
nic.setState(Resource.State.Reserving);
nic.setReservationId(context.getReservationId());
_nicDao.update(nic.getId(), nic);
URI broadcastUri = nic.getBroadcastUri();
if (broadcastUri == null) {

View File

@ -3,6 +3,8 @@
*/
package com.cloud.network.guru;
import java.util.Random;
import javax.ejb.Local;
import org.apache.log4j.Logger;
@ -24,6 +26,7 @@ import com.cloud.network.Networks.TrafficType;
import com.cloud.offering.NetworkOffering;
import com.cloud.resource.Resource.ReservationStrategy;
import com.cloud.user.Account;
import com.cloud.utils.Pair;
import com.cloud.utils.component.AdapterBase;
import com.cloud.utils.component.Inject;
import com.cloud.utils.net.NetUtils;
@ -37,6 +40,7 @@ public class PodBasedNetworkGuru extends AdapterBase implements NetworkGuru {
private static final Logger s_logger = Logger.getLogger(PodBasedNetworkGuru.class);
@Inject DataCenterDao _dcDao;
@Inject NetworkManager _networkMgr;
Random _rand = new Random(System.currentTimeMillis());
@Override
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
@ -68,14 +72,11 @@ public class PodBasedNetworkGuru extends AdapterBase implements NetworkGuru {
assert (trafficType == TrafficType.Storage || trafficType == TrafficType.Management) : "Well, I can't take care of this config now can I? " + config;
if (nic != null) {
nic.setStrategy(ReservationStrategy.Start);
nic.setStrategy(nic.getIp4Address() != null ? ReservationStrategy.Create : ReservationStrategy.Start);
} else {
nic = new NicProfile(ReservationStrategy.Start, null, null, null, null);
}
String mac = _networkMgr.getNextAvailableMacAddressInNetwork(config.getId());
nic.setMacAddress(mac);
return nic;
}
@ -84,21 +85,30 @@ public class PodBasedNetworkGuru extends AdapterBase implements NetworkGuru {
InsufficientAddressCapacityException {
Pod pod = dest.getPod();
String ip = _dcDao.allocatePrivateIpAddress(dest.getDataCenter().getId(), dest.getPod().getId(), nic.getId(), context.getReservationId());
Pair<String, Long> ip = _dcDao.allocatePrivateIpAddress(dest.getDataCenter().getId(), dest.getPod().getId(), nic.getId(), context.getReservationId());
if (ip == null) {
throw new InsufficientAddressCapacityException("Unable to get a management ip address", Pod.class, pod.getId());
}
nic.setIp4Address(ip);
nic.setIp4Address(ip.first());
nic.setMacAddress(NetUtils.long2Mac(ip.second()));
nic.setGateway(pod.getGateway());
nic.setFormat(AddressFormat.Ip4);
String netmask = NetUtils.getCidrSubNet(pod.getCidrAddress(), pod.getCidrSize());
nic.setNetmask(netmask);
nic.setBroadcastType(BroadcastDomainType.Native);
nic.setBroadcastUri(null);
nic.setIsolationUri(null);
nic.setFormat(AddressFormat.Ip4);
s_logger.debug("Allocated a nic " + nic + " for " + vm);
}
@Override
public boolean release(NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, String reservationId) {
_dcDao.releasePrivateIpAddress(nic.getId(), reservationId);
_dcDao.releasePrivateIpAddress(nic.getId(), nic.getReservationId());
nic.deallocate();
return true;
}

View File

@ -940,7 +940,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
privateIpAddress = _dcDao.allocateLinkLocalIpAddress(router.getDataCenterId(), routingHost.getPodId(), router.getId(), null);
privateNetMask = NetUtils.getLinkLocalNetMask();
} else {
privateIpAddress = _dcDao.allocatePrivateIpAddress(router.getDataCenterId(), routingHost.getPodId(), router.getId(), null);
privateIpAddress = _dcDao.allocatePrivateIpAddress(router.getDataCenterId(), routingHost.getPodId(), router.getId(), null).first();
privateNetMask = NetUtils.getCidrNetmask(pod.getCidrSize());
}
@ -1805,7 +1805,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
if( ! _storageMgr.share(router, vols, routingHost, false) ) {
s_logger.warn("Can not share " + vol.getPath() + " to " + router.getHostName() );
throw new StorageUnavailableException("Can not share " + vol.getPath() + " to " + router.getHostName(), vol);
throw new StorageUnavailableException("Can not share " + vol.getPath() + " to " + router.getHostName(), sp.getId());
}
final Answer answer = _agentMgr.easySend(routingHost.getId(), cmd);

View File

@ -2431,7 +2431,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
}
if (primaryStorage.getStatus().equals(Status.Up)) {
throw new StorageUnavailableException("Primary storage with id " + primaryStorageId + " is not ready to complete migration, as the status is:" + primaryStorage.getStatus().toString());
throw new StorageUnavailableException("Primary storage with id " + primaryStorageId + " is not ready to complete migration, as the status is:" + primaryStorage.getStatus().toString(), primaryStorageId);
}
//set state to cancelmaintenance
@ -2658,10 +2658,11 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
vol.setInstanceId(vm.getId());
}
if(type.equals(VolumeType.ROOT))
vol.setDeviceId(0l);
else
vol.setDeviceId(1l);
if(type.equals(VolumeType.ROOT)) {
vol.setDeviceId(0l);
} else {
vol.setDeviceId(1l);
}
vol = _volsDao.persist(vol);
@ -2689,10 +2690,11 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
}
vol.setTemplateId(template.getId());
if(type.equals(VolumeType.ROOT))
vol.setDeviceId(0l);
else
vol.setDeviceId(1l);
if(type.equals(VolumeType.ROOT)) {
vol.setDeviceId(0l);
} else {
vol.setDeviceId(1l);
}
vol = _volsDao.persist(vol);
@ -2739,7 +2741,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
}
recreateVols.add(vol);
} else {
throw new StorageUnavailableException("Volume " + vol + " is not available on the storage pool.", pool);
throw new StorageUnavailableException("Volume " + vol + " is not available on the storage pool.", pool.getId());
}
} else {
if (s_logger.isDebugEnabled()) {
@ -2753,7 +2755,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
}
recreateVols.add(vol);
} else {
throw new StorageUnavailableException("Volume " + vol + " can not be used", vol);
throw new StorageUnavailableException("Volume " + vol + " can not be used", vol.getPoolId());
}
}
@ -2771,7 +2773,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
try {
_volsDao.update(newVol, Volume.Event.Create);
} catch(ConcurrentOperationException e) {
throw new StorageUnavailableException("Unable to create " + newVol, newVol);
throw new StorageUnavailableException("Unable to create " + newVol, newVol.getPoolId());
}
Pair<VolumeTO, StoragePool> created = createVolume(newVol, _diskOfferingDao.findById(newVol.getDiskOfferingId()), vm, vols, dest);
if (created == null) {
@ -2781,7 +2783,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
} catch (ConcurrentOperationException e) {
throw new CloudRuntimeException("Unable to update the failure on a volume: " + newVol, e);
}
throw new StorageUnavailableException("Unable to create " + newVol, newVol);
throw new StorageUnavailableException("Unable to create " + newVol, newVol.getPoolId());
}
created.first().setDeviceId(newVol.getDeviceId().intValue());
newVol.setStatus(AsyncInstanceCreateStatus.Created);
@ -2813,7 +2815,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
txn.commit();
return newVolume;
} catch (ConcurrentOperationException e) {
throw new StorageUnavailableException("Unable to duplicate the volume " + existingVolume, existingVolume, e);
throw new StorageUnavailableException("Unable to duplicate the volume " + existingVolume, existingVolume.getPoolId(), e);
}
}

View File

@ -20,7 +20,6 @@ package com.cloud.storage.download;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -31,13 +30,13 @@ import javax.ejb.Local;
import org.apache.log4j.Logger;
import com.cloud.agent.AgentManager;
import com.cloud.agent.Listener;
import com.cloud.agent.api.Command;
import com.cloud.agent.api.storage.DeleteTemplateCommand;
import com.cloud.agent.api.storage.DownloadCommand;
import com.cloud.agent.api.storage.DownloadProgressCommand;
import com.cloud.agent.api.storage.DownloadProgressCommand.RequestType;
import com.cloud.agent.AgentManager;
import com.cloud.alert.AlertManager;
import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.dc.DataCenterVO;
@ -178,7 +177,8 @@ public class DownloadMonitorImpl implements DownloadMonitor {
return (downloadsInProgress.size() == 0);
}
public void copyTemplate(VMTemplateVO template, HostVO sourceServer, HostVO destServer) throws InvalidParameterValueException, StorageUnavailableException{
@Override
public void copyTemplate(VMTemplateVO template, HostVO sourceServer, HostVO destServer) throws InvalidParameterValueException, StorageUnavailableException{
boolean downloadJobExists = false;
VMTemplateHostVO destTmpltHost = null;
@ -191,7 +191,7 @@ public class DownloadMonitorImpl implements DownloadMonitor {
String url = generateCopyUrl(sourceServer, srcTmpltHost);
if (url == null) {
s_logger.warn("Unable to start/resume copy of template " + template.getUniqueName() + " to " + destServer.getName() + ", no secondary storage vm in running state in source zone");
throw new StorageUnavailableException("No secondary VM in running state in zone " + sourceServer.getDataCenterId());
throw new StorageUnavailableException("No secondary VM in running state in zone " + sourceServer.getDataCenterId(), srcTmpltHost.getPoolId());
}
destTmpltHost = _vmTemplateHostDao.findByHostTemplate(destServer.getId(), template.getId());
if (destTmpltHost == null) {
@ -424,8 +424,9 @@ public class DownloadMonitorImpl implements DownloadMonitor {
if (rtngTmplts != null) {
for (VMTemplateVO rtngTmplt : rtngTmplts) {
if (!allTemplates.contains(rtngTmplt))
allTemplates.add(rtngTmplt);
if (!allTemplates.contains(rtngTmplt)) {
allTemplates.add(rtngTmplt);
}
}
}

View File

@ -137,9 +137,9 @@ import com.cloud.vm.SecondaryStorageVmVO;
import com.cloud.vm.State;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineGuru;
import com.cloud.vm.VirtualMachineManager;
import com.cloud.vm.VirtualMachineName;
import com.cloud.vm.VirtualMachineProfile;
import com.cloud.vm.VirtualMachineManager;
import com.cloud.vm.dao.NicDao;
import com.cloud.vm.dao.SecondaryStorageVmDao;
import com.cloud.vm.dao.UserVmDao;
@ -957,7 +957,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
if (_IpAllocator != null && _IpAllocator.exteralIpAddressAllocatorEnabled()) {
return _IpAllocator.getPrivateIpAddress(macAddr, dcId, podId).ipaddr;
} else {
return _dcDao.allocatePrivateIpAddress(dcId, podId, proxyId, null);
return _dcDao.allocatePrivateIpAddress(dcId, podId, proxyId, null).first();
}
}
@ -1985,7 +1985,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
if( !_storageMgr.share(secStorageVm, vols, routingHost, false) ) {
s_logger.warn("Can not share " + vol.getPath() + " to " + secStorageVm.getHostName());
throw new StorageUnavailableException("Can not share " + vol.getPath() + " to " + secStorageVm.getHostName(), vol);
throw new StorageUnavailableException("Can not share " + vol.getPath() + " to " + secStorageVm.getHostName(), vol.getPoolId());
}
Answer answer = _agentMgr.easySend(routingHost.getId(), cmd);
@ -2109,8 +2109,9 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
boolean externalDhcp = false;
String externalDhcpStr = _configDao.getValue("direct.attach.network.externalIpAllocator.enabled");
if(externalDhcpStr != null && externalDhcpStr.equalsIgnoreCase("true"))
externalDhcp = true;
if(externalDhcpStr != null && externalDhcpStr.equalsIgnoreCase("true")) {
externalDhcp = true;
}
for (NicProfile nic : profile.getNics()) {
int deviceId = nic.getDeviceId();
@ -2131,16 +2132,18 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
managementNic = nic;
buf.append(" private.network.device=").append("eth").append(deviceId);
} else if (nic.getTrafficType() == TrafficType.Control) {
if(nic.getIp4Address() != null)
controlNic = nic;
if(nic.getIp4Address() != null) {
controlNic = nic;
}
} else if(nic.getTrafficType() == TrafficType.Public) {
buf.append(" public.network.device=").append("eth").append(deviceId);
}
}
/*External DHCP mode*/
if(externalDhcp)
buf.append(" bootproto=dhcp");
if(externalDhcp) {
buf.append(" bootproto=dhcp");
}
if(controlNic == null) {
assert(managementNic != null);

View File

@ -401,6 +401,7 @@ CREATE TABLE `cloud`.`data_center` (
`lb_provider` char(64) NOT NULL DEFAULT 'VirtualRouter',
`vpn_provider` char(64) NOT NULL DEFAULT 'VirtualRouter',
`userdata_provider` char(64) NOT NULL DEFAULT 'VirtualRouter',
`enable` tinyint NOT NULL DEFAULT 1 COMMENT 'Is this data center enabled for activities',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@ -412,6 +413,7 @@ CREATE TABLE `cloud`.`op_dc_ip_address_alloc` (
`instance_id` bigint unsigned NULL COMMENT 'instance id',
`reservation_id` char(40) NULL COMMENT 'reservation id',
`taken` datetime COMMENT 'Date taken',
`mac_address` bigint unsigned NOT NULL COMMENT 'mac address for management ips',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@ -434,6 +436,7 @@ CREATE TABLE `cloud`.`host_pod_ref` (
`cidr_address` varchar(15) NOT NULL COMMENT 'CIDR address for the pod',
`cidr_size` bigint unsigned NOT NULL COMMENT 'CIDR size for the pod',
`description` varchar(255) COMMENT 'store private ip range in startIP-endIP format',
`enabled` tinyint NOT NULL DEFAULT 1 COMMENT 'Is this Pod enabled for activity',
PRIMARY KEY (`id`),
UNIQUE KEY (`name`, `data_center_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -29,6 +29,7 @@ import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Formatter;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;
@ -52,6 +53,11 @@ public class NetUtils {
public final static String ICMP_PROTO = "icmp";
public final static String NAT_PROTO = "nat"; //special value for one-to-one NAT
private final static Random _rand = new Random(System.currentTimeMillis());
public static long createSequenceBasedMacAddress(long macAddress) {
return macAddress | 0x060000000000l | (((long)_rand.nextInt(32768) << 25) & 0x00fffe000000l);
}
public static String getHostName() {
try {