mirror of https://github.com/apache/cloudstack.git
Merge branch '4.3-forward' into 4.3
This commit is contained in:
commit
f304df0be9
|
|
@ -201,10 +201,10 @@ public interface NetworkModel {
|
|||
List<? extends PhysicalNetwork> getPhysicalNtwksSupportingTrafficType(long zoneId, TrafficType trafficType);
|
||||
|
||||
/**
|
||||
* @param guestNic
|
||||
* @param ntwkId
|
||||
* @return
|
||||
*/
|
||||
boolean isPrivateGateway(Nic guestNic);
|
||||
boolean isPrivateGateway(long ntwkId);
|
||||
|
||||
Map<Service, Map<Capability, String>> getNetworkCapabilities(long networkId);
|
||||
|
||||
|
|
|
|||
|
|
@ -126,94 +126,6 @@
|
|||
<artifactId>CAStorSDK</artifactId>
|
||||
<version>1.3.1-CS40</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.rampart</groupId>
|
||||
<artifactId>rahas</artifactId>
|
||||
<version>${cs.rampart.version}</version>
|
||||
<type>mar</type>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk14</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.xalan</groupId>
|
||||
<artifactId>xalan</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.opensaml</groupId>
|
||||
<artifactId>opensaml</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.rampart</groupId>
|
||||
<artifactId>rampart</artifactId>
|
||||
<version>${cs.rampart.version}</version>
|
||||
<type>mar</type>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk14</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.xalan</groupId>
|
||||
<artifactId>xalan</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.opensaml</groupId>
|
||||
<artifactId>opensaml</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.rampart</groupId>
|
||||
<artifactId>rampart-core</artifactId>
|
||||
<version>${cs.rampart.version}</version>
|
||||
<scope>runtime</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.xalan</groupId>
|
||||
<artifactId>xalan</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.opensaml</groupId>
|
||||
<artifactId>opensaml</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.rampart</groupId>
|
||||
<artifactId>rampart-policy</artifactId>
|
||||
<version>${cs.rampart.version}</version>
|
||||
<scope>runtime</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.xalan</groupId>
|
||||
<artifactId>xalan</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.opensaml</groupId>
|
||||
<artifactId>opensaml</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.rampart</groupId>
|
||||
<artifactId>rampart-trust</artifactId>
|
||||
<version>${cs.rampart.version}</version>
|
||||
<scope>runtime</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.xalan</groupId>
|
||||
<artifactId>xalan</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.opensaml</groupId>
|
||||
<artifactId>opensaml</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-jdk14</artifactId>
|
||||
|
|
|
|||
|
|
@ -32,17 +32,17 @@ public class ConsoleProxyInfo {
|
|||
this.sslEnabled = sslEnabled;
|
||||
|
||||
if(sslEnabled) {
|
||||
StringBuffer sb = new StringBuffer(proxyIpAddress);
|
||||
for(int i = 0; i < sb.length(); i++)
|
||||
if(sb.charAt(i) == '.')
|
||||
sb.setCharAt(i, '-');
|
||||
if(consoleProxyUrlDomain!=null && consoleProxyUrlDomain.length()>0)
|
||||
{
|
||||
sb.append(".");
|
||||
sb.append(consoleProxyUrlDomain);
|
||||
}
|
||||
else
|
||||
StringBuffer sb = new StringBuffer();
|
||||
if (consoleProxyUrlDomain.startsWith("*")) {
|
||||
sb.append(proxyIpAddress);
|
||||
for (int i = 0; i < proxyIpAddress.length(); i++)
|
||||
if (sb.charAt(i) == '.')
|
||||
sb.setCharAt(i, '-');
|
||||
sb.append(consoleProxyUrlDomain.substring(1)); //skip the *
|
||||
} else {
|
||||
//LB address
|
||||
sb.append(".realhostip.com");
|
||||
}
|
||||
|
||||
proxyAddress = sb.toString();
|
||||
proxyPort = port;
|
||||
|
|
|
|||
|
|
@ -218,6 +218,7 @@
|
|||
<!-- simulator sql files -->
|
||||
<argument>${basedir}/target/db/create-schema-simulator.sql</argument>
|
||||
<argument>${basedir}/target/db/templates.simulator.sql</argument>
|
||||
<argument>${basedir}/target/db/hypervisor_capabilities.simulator.sql</argument>
|
||||
<!-- upgrade -->
|
||||
<argument>com.cloud.upgrade.DatabaseUpgradeChecker</argument>
|
||||
<argument>--database=simulator</argument>
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import com.cloud.storage.VMTemplateHostVO;
|
|||
import com.cloud.storage.VMTemplateStoragePoolVO;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
|
||||
/**
|
||||
* TemplateManager manages the templates stored on secondary storage. It is responsible for creating private/public templates.
|
||||
|
|
@ -115,7 +116,13 @@ public interface TemplateManager {
|
|||
|
||||
TemplateInfo prepareIso(long isoId, long dcId);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adds ISO definition to given vm profile
|
||||
*
|
||||
* @param VirtualMachineProfile
|
||||
*/
|
||||
void prepareIsoForVmProfile(VirtualMachineProfile profile);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2954,12 +2954,14 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
if (cmd instanceof PingRoutingCommand) {
|
||||
PingRoutingCommand ping = (PingRoutingCommand)cmd;
|
||||
if (ping.getNewStates() != null && ping.getNewStates().size() > 0) {
|
||||
Commands commands = deltaHostSync(agentId, ping.getNewStates());
|
||||
if (commands.size() > 0) {
|
||||
try {
|
||||
_agentMgr.send(agentId, commands, this);
|
||||
} catch (final AgentUnavailableException e) {
|
||||
s_logger.warn("Agent is now unavailable", e);
|
||||
if (!VmJobEnabled.value()) {
|
||||
Commands commands = deltaHostSync(agentId, ping.getNewStates());
|
||||
if (commands.size() > 0) {
|
||||
try {
|
||||
_agentMgr.send(agentId, commands, this);
|
||||
} catch (final AgentUnavailableException e) {
|
||||
s_logger.warn("Agent is now unavailable", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3983,6 +3985,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
s_logger.warn("VM " + vmId + " no longer exists when processing VM state report");
|
||||
}
|
||||
} else {
|
||||
s_logger.info("There is pending job working on the VM. vm id: " + vmId + ", postpone power-change report by resetting power-change counters");
|
||||
|
||||
// reset VM power state tracking so that we won't lost signal when VM has
|
||||
// been translated to
|
||||
_vmDao.resetVmPowerStateTracking(vmId);
|
||||
|
|
@ -3991,19 +3995,23 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
|
||||
private void handlePowerOnReportWithNoPendingJobsOnVM(VMInstanceVO vm) {
|
||||
//
|
||||
// 1) handle left-over transitional VM states
|
||||
// 1) handle left-over transitional VM states
|
||||
// 2) handle out of band VM live migration
|
||||
// 3) handle out of sync stationary states, marking VM from Stopped to Running with
|
||||
// alert messages
|
||||
//
|
||||
switch (vm.getState()) {
|
||||
case Starting:
|
||||
s_logger.info("VM " + vm.getInstanceName() + " is at " + vm.getState() + " and we received a power-on report while there is no pending jobs on it");
|
||||
|
||||
try {
|
||||
stateTransitTo(vm, VirtualMachine.Event.FollowAgentPowerOnReport, vm.getPowerHostId());
|
||||
} catch (NoTransitionException e) {
|
||||
s_logger.warn("Unexpected VM state transition exception, race-condition?", e);
|
||||
}
|
||||
|
||||
s_logger.info("VM " + vm.getInstanceName() + " is sync-ed to at Running state according to power-on report from hypervisor");
|
||||
|
||||
// we need to alert admin or user about this risky state transition
|
||||
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_SYNC, vm.getDataCenterId(), vm.getPodIdToDeployIn(),
|
||||
VM_SYNC_ALERT_SUBJECT, "VM " + vm.getHostName() + "(" + vm.getInstanceName()
|
||||
|
|
@ -4018,10 +4026,13 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
} catch (NoTransitionException e) {
|
||||
s_logger.warn("Unexpected VM state transition exception, race-condition?", e);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case Stopping:
|
||||
case Stopped:
|
||||
s_logger.info("VM " + vm.getInstanceName() + " is at " + vm.getState() + " and we received a power-on report while there is no pending jobs on it");
|
||||
|
||||
try {
|
||||
stateTransitTo(vm, VirtualMachine.Event.FollowAgentPowerOnReport, vm.getPowerHostId());
|
||||
} catch (NoTransitionException e) {
|
||||
|
|
@ -4030,6 +4041,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_SYNC, vm.getDataCenterId(), vm.getPodIdToDeployIn(),
|
||||
VM_SYNC_ALERT_SUBJECT, "VM " + vm.getHostName() + "(" + vm.getInstanceName() + ") state is sync-ed (" + vm.getState()
|
||||
+ " -> Running) from out-of-context transition. VM network environment may need to be reset");
|
||||
|
||||
s_logger.info("VM " + vm.getInstanceName() + " is sync-ed to at Running state according to power-on report from hypervisor");
|
||||
break;
|
||||
|
||||
case Destroyed:
|
||||
|
|
@ -4039,11 +4052,13 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
break;
|
||||
|
||||
case Migrating:
|
||||
s_logger.info("VM " + vm.getInstanceName() + " is at " + vm.getState() + " and we received a power-on report while there is no pending jobs on it");
|
||||
try {
|
||||
stateTransitTo(vm, VirtualMachine.Event.FollowAgentPowerOnReport, vm.getPowerHostId());
|
||||
} catch (NoTransitionException e) {
|
||||
s_logger.warn("Unexpected VM state transition exception, race-condition?", e);
|
||||
}
|
||||
s_logger.info("VM " + vm.getInstanceName() + " is sync-ed to at Running state according to power-on report from hypervisor");
|
||||
break;
|
||||
|
||||
case Error:
|
||||
|
|
@ -4056,7 +4071,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
|
||||
private void handlePowerOffReportWithNoPendingJobsOnVM(VMInstanceVO vm) {
|
||||
|
||||
// 1) handle left-over transitional VM states
|
||||
// 1) handle left-over transitional VM states
|
||||
// 2) handle out of sync stationary states, schedule force-stop to release resources
|
||||
//
|
||||
switch (vm.getState()) {
|
||||
|
|
@ -4065,14 +4080,19 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
case Running:
|
||||
case Stopped:
|
||||
case Migrating:
|
||||
s_logger.info("VM " + vm.getInstanceName() + " is at " + vm.getState() + " and we received a power-off report while there is no pending jobs on it");
|
||||
try {
|
||||
stateTransitTo(vm, VirtualMachine.Event.FollowAgentPowerOffReport, vm.getPowerHostId());
|
||||
} catch (NoTransitionException e) {
|
||||
s_logger.warn("Unexpected VM state transition exception, race-condition?", e);
|
||||
}
|
||||
|
||||
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_SYNC, vm.getDataCenterId(), vm.getPodIdToDeployIn(),
|
||||
VM_SYNC_ALERT_SUBJECT, "VM " + vm.getHostName() + "(" + vm.getInstanceName() + ") state is sync-ed (" + vm.getState()
|
||||
+ " -> Stopped) from out-of-context transition.");
|
||||
|
||||
s_logger.info("VM " + vm.getInstanceName() + " is sync-ed to at Stopped state according to power-on report from hypervisor");
|
||||
|
||||
// TODO: we need to forcely release all resource allocation
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -1017,10 +1017,12 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
|||
vm.addDisk(disk);
|
||||
}
|
||||
|
||||
if (vm.getType() == VirtualMachine.Type.User && vm.getTemplate().getFormat() == ImageFormat.ISO) {
|
||||
DataTO dataTO = tmplFactory.getTemplate(vm.getTemplate().getId(), DataStoreRole.Image, vm.getVirtualMachine().getDataCenterId()).getTO();
|
||||
DiskTO iso = new DiskTO(dataTO, 3L, null, Volume.Type.ISO);
|
||||
vm.addDisk(iso);
|
||||
//if (vm.getType() == VirtualMachine.Type.User && vm.getTemplate().getFormat() == ImageFormat.ISO) {
|
||||
if (vm.getType() == VirtualMachine.Type.User) {
|
||||
_tmpltMgr.prepareIsoForVmProfile(vm);
|
||||
//DataTO dataTO = tmplFactory.getTemplate(vm.getTemplate().getId(), DataStoreRole.Image, vm.getVirtualMachine().getDataCenterId()).getTO();
|
||||
//DiskTO iso = new DiskTO(dataTO, 3L, null, Volume.Type.ISO);
|
||||
//vm.addDisk(iso);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -222,6 +222,7 @@
|
|||
<bean id="PortableIpRangeDaoImpl" class="org.apache.cloudstack.region.PortableIpRangeDaoImpl" />
|
||||
<bean id="portForwardingRulesDaoImpl" class="com.cloud.network.rules.dao.PortForwardingRulesDaoImpl" />
|
||||
<bean id="portProfileDaoImpl" class="com.cloud.network.dao.PortProfileDaoImpl" />
|
||||
<bean id="storagePoolHostDaoImpl" class="com.cloud.storage.dao.StoragePoolHostDaoImpl" />
|
||||
<bean id="primaryDataStoreDaoImpl" class="org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDaoImpl" />
|
||||
<bean id="primaryDataStoreDetailsDaoImpl" class="org.apache.cloudstack.storage.volume.db.PrimaryDataStoreDetailsDaoImpl" />
|
||||
<bean id="privateIpDaoImpl" class="com.cloud.network.vpc.dao.PrivateIpDaoImpl" />
|
||||
|
|
@ -259,7 +260,6 @@
|
|||
<bean id="storageNetworkIpAddressDaoImpl" class="com.cloud.dc.dao.StorageNetworkIpAddressDaoImpl" />
|
||||
<bean id="storageNetworkIpRangeDaoImpl" class="com.cloud.dc.dao.StorageNetworkIpRangeDaoImpl" />
|
||||
<bean id="storagePoolDetailsDaoImpl" class="com.cloud.storage.dao.StoragePoolDetailsDaoImpl" />
|
||||
<bean id="storagePoolHostDaoImpl" class="com.cloud.storage.dao.StoragePoolHostDaoImpl" />
|
||||
<bean id="storagePoolJoinDaoImpl" class="com.cloud.api.query.dao.StoragePoolJoinDaoImpl" />
|
||||
<bean id="storagePoolWorkDaoImpl" class="com.cloud.storage.dao.StoragePoolWorkDaoImpl" />
|
||||
<bean id="templatePrimaryDataStoreDaoImpl" class="org.apache.cloudstack.storage.volume.db.TemplatePrimaryDataStoreDaoImpl" />
|
||||
|
|
|
|||
|
|
@ -114,4 +114,6 @@ public interface PrimaryDataStoreDao extends GenericDao<StoragePoolVO, Long> {
|
|||
List<StoragePoolVO> findZoneWideStoragePoolsByTags(long dcId, String[] tags);
|
||||
|
||||
List<StoragePoolVO> findZoneWideStoragePoolsByHypervisor(long dataCenterId, HypervisorType hypervisorType);
|
||||
|
||||
List<StoragePoolVO> findLocalStoragePoolsByHostAndTags(long hostId, String[] tags);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,19 +24,21 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.storage.ScopeType;
|
||||
import com.cloud.storage.StoragePoolHostVO;
|
||||
import com.cloud.storage.StoragePoolStatus;
|
||||
import com.cloud.storage.dao.StoragePoolHostDao;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.GenericSearchBuilder;
|
||||
import com.cloud.utils.db.JoinBuilder;
|
||||
import com.cloud.utils.db.QueryBuilder;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
|
@ -45,7 +47,6 @@ import com.cloud.utils.db.SearchCriteria.Op;
|
|||
import com.cloud.utils.db.TransactionLegacy;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
|
||||
@Local(value = { PrimaryDataStoreDao.class })
|
||||
@DB()
|
||||
public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO, Long> implements PrimaryDataStoreDao {
|
||||
|
|
@ -54,8 +55,12 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO, Long>
|
|||
protected final SearchBuilder<StoragePoolVO> DcPodAnyClusterSearch;
|
||||
protected final SearchBuilder<StoragePoolVO> DeleteLvmSearch;
|
||||
protected final GenericSearchBuilder<StoragePoolVO, Long> StatusCountSearch;
|
||||
protected SearchBuilder<StoragePoolVO> HostSearch;
|
||||
protected SearchBuilder<StoragePoolHostVO> HostPoolSearch;
|
||||
protected SearchBuilder<StoragePoolDetailVO> TagPoolSearch;
|
||||
|
||||
@Inject protected StoragePoolDetailsDao _detailsDao;
|
||||
@Inject protected StoragePoolHostDao _hostDao;
|
||||
|
||||
private final String DetailsSqlPrefix = "SELECT storage_pool.* from storage_pool LEFT JOIN storage_pool_details ON storage_pool.id = storage_pool_details.pool_id WHERE storage_pool.removed is null and storage_pool.status = 'Up' and storage_pool.data_center_id = ? and (storage_pool.pod_id = ? or storage_pool.pod_id is null) and storage_pool.scope = ? and (";
|
||||
private final String DetailsSqlSuffix = ") GROUP BY storage_pool_details.pool_id HAVING COUNT(storage_pool_details.name) >= ?";
|
||||
|
|
@ -112,6 +117,26 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO, Long>
|
|||
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
void init() {
|
||||
HostSearch = createSearchBuilder();
|
||||
TagPoolSearch = _detailsDao.createSearchBuilder();
|
||||
HostPoolSearch = _hostDao.createSearchBuilder();
|
||||
// Search for pools on the host
|
||||
HostPoolSearch.and("hostId", HostPoolSearch.entity().getHostId(), Op.EQ);
|
||||
// Set criteria for pools
|
||||
HostSearch.and("scope", HostSearch.entity().getScope(), Op.EQ);
|
||||
HostSearch.and("removed", HostSearch.entity().getRemoved(), Op.NULL);
|
||||
HostSearch.and("status", HostSearch.entity().getStatus(), Op.EQ);
|
||||
HostSearch.join("hostJoin", HostPoolSearch, HostSearch.entity().getId(), HostPoolSearch.entity().getPoolId(), JoinBuilder.JoinType.INNER);
|
||||
// Set criteria for tags
|
||||
TagPoolSearch.and("name", TagPoolSearch.entity().getName(), Op.EQ);
|
||||
TagPoolSearch.and("value", TagPoolSearch.entity().getValue(), Op.EQ);
|
||||
|
||||
HostSearch.join("tagJoin", TagPoolSearch, HostSearch.entity().getId(), TagPoolSearch.entity().getResourceId(), JoinBuilder.JoinType.INNER);
|
||||
HostSearch.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StoragePoolVO> findPoolByName(String name) {
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
|
|
@ -353,6 +378,23 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO, Long>
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StoragePoolVO> findLocalStoragePoolsByHostAndTags(long hostId, String[] tags) {
|
||||
|
||||
SearchCriteria<StoragePoolVO> sc = HostSearch.create();
|
||||
sc.setJoinParameters("hostJoin", "hostId", hostId );
|
||||
sc.setParameters("scope", ScopeType.HOST.toString());
|
||||
sc.setParameters("status", Status.Up.toString());
|
||||
if (!(tags == null || tags.length == 0 )) {
|
||||
Map<String, String> details = tagsToDetails(tags);
|
||||
for (Map.Entry<String, String> detail : details.entrySet()) {
|
||||
sc.setJoinParameters("tagJoin","name", detail.getKey());
|
||||
sc.setJoinParameters("tagJoin", "value", detail.getValue());
|
||||
}
|
||||
}
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public List<String> searchForStoragePoolDetails(long poolId, String value) {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import javax.naming.ConfigurationException;
|
|||
import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
@ -73,14 +72,13 @@ public class LocalStoragePoolAllocator extends AbstractStoragePoolAllocator {
|
|||
if (!dskCh.useLocalStorage()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<StoragePool> suitablePools = new ArrayList<StoragePool>();
|
||||
|
||||
// data disk and host identified from deploying vm (attach volume case)
|
||||
if (dskCh.getType() == Volume.Type.DATADISK && plan.getHostId() != null) {
|
||||
List<StoragePoolHostVO> hostPools = _poolHostDao.listByHostId(plan.getHostId());
|
||||
for (StoragePoolHostVO hostPool : hostPools) {
|
||||
StoragePoolVO pool = _storagePoolDao.findById(hostPool.getPoolId());
|
||||
List<StoragePoolVO> hostTagsPools = null;
|
||||
hostTagsPools =_storagePoolDao.findLocalStoragePoolsByHostAndTags(plan.getHostId(), dskCh.getTags());
|
||||
for (StoragePoolVO pool : hostTagsPools) {
|
||||
if (pool != null && pool.isLocal()) {
|
||||
StoragePool storagePool = (StoragePool) this.dataStoreMgr.getPrimaryDataStore(pool.getId());
|
||||
if (filter(avoid, storagePool, dskCh, plan)) {
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ import com.cloud.exception.ResourceAllocationException;
|
|||
import com.cloud.host.Host;
|
||||
import com.cloud.storage.DataStoreRole;
|
||||
import com.cloud.storage.ScopeType;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
import com.cloud.storage.StoragePool;
|
||||
import com.cloud.storage.VMTemplateStoragePoolVO;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc;
|
||||
|
|
@ -679,9 +680,16 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
|
||||
protected VolumeVO duplicateVolumeOnAnotherStorage(Volume volume, StoragePool pool) {
|
||||
Long lastPoolId = volume.getPoolId();
|
||||
String folder = pool.getPath();
|
||||
// For SMB, pool credentials are also stored in the uri query string. We trim the query string
|
||||
// part here to make sure the credentials do not get stored in the db unencrypted.
|
||||
if (pool.getPoolType() == StoragePoolType.SMB && folder != null && folder.contains("?")) {
|
||||
folder = folder.substring(0, folder.indexOf("?"));
|
||||
}
|
||||
|
||||
VolumeVO newVol = new VolumeVO(volume);
|
||||
newVol.setPoolId(pool.getId());
|
||||
newVol.setFolder(pool.getPath());
|
||||
newVol.setFolder(folder);
|
||||
newVol.setPodId(pool.getPodId());
|
||||
newVol.setPoolId(pool.getId());
|
||||
newVol.setLastPoolId(lastPoolId);
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ namespace CloudStack.Plugin.AgentShell
|
|||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
this.ServiceName = "CloudStack ServerResource";
|
||||
this.ServiceName = Program.serviceName;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -137,6 +137,10 @@
|
|||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
|
||||
<Target Name="BeforeBuild" Condition="'$(BuildWithMono)' == 'true' ">
|
||||
<RemoveDir Directories="$(ProjectDir)$(BaseIntermediateOutputPath)" Condition="Exists('$(ProjectDir)$(BaseIntermediateOutputPath)')"/>
|
||||
<RemoveDir Directories="$(ProjectDir)$(OutputPath)" Condition="Exists('$(ProjectDir)$(OutputPath)')"/>
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@
|
|||
</sectionGroup>
|
||||
</configSections>
|
||||
|
||||
<startup>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||
</startup>
|
||||
</startup>
|
||||
|
||||
<log4net>
|
||||
<appender name="FileAppender" type="log4net.Appender.FileAppender">
|
||||
|
|
@ -25,13 +25,14 @@
|
|||
</appender>
|
||||
<appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
|
||||
<appendToFile value="true" />
|
||||
<param name="ApplicationName" value="CloudStack Hyper-V Agent" />
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline"/>
|
||||
</layout>
|
||||
</appender>
|
||||
<root>
|
||||
<level value="ALL"/>
|
||||
<appender-ref ref="FileAppender"/>
|
||||
<appender-ref ref="EventLogAppender"/>
|
||||
</root>
|
||||
</log4net>
|
||||
|
||||
|
|
|
|||
|
|
@ -173,33 +173,35 @@ namespace HypervResource
|
|||
PrimaryDataStoreTO store = this.primaryDataStore;
|
||||
if (store.isLocal)
|
||||
{
|
||||
fileName = Path.Combine(store.Path, this.uuid);
|
||||
String volume = this.path;
|
||||
if (String.IsNullOrEmpty(volume))
|
||||
{
|
||||
volume = this.uuid;
|
||||
}
|
||||
fileName = Path.Combine(store.Path, volume);
|
||||
}
|
||||
else
|
||||
{
|
||||
fileName = @"\\" + store.uri.Host + store.uri.LocalPath + @"\" + this.uuid;
|
||||
String volume = this.path;
|
||||
if (String.IsNullOrEmpty(volume))
|
||||
{
|
||||
volume = this.uuid;
|
||||
}
|
||||
fileName = @"\\" + store.uri.Host + store.uri.LocalPath + @"\" + volume;
|
||||
fileName = Utils.NormalizePath(fileName);
|
||||
}
|
||||
}
|
||||
else if (this.nfsDataStore != null)
|
||||
{
|
||||
if (this.path != null && File.Exists(this.path))
|
||||
fileName = this.nfsDataStore.UncPath;
|
||||
if (this.path != null)
|
||||
{
|
||||
fileName = this.path;
|
||||
fileName = Utils.NormalizePath(fileName + @"\" + this.path);
|
||||
}
|
||||
else
|
||||
{
|
||||
fileName = this.nfsDataStore.UncPath;
|
||||
if (this.path != null)
|
||||
{
|
||||
fileName += @"\" + this.path;
|
||||
}
|
||||
|
||||
fileName = Utils.NormalizePath(fileName);
|
||||
if (Directory.Exists(fileName))
|
||||
{
|
||||
fileName = Utils.NormalizePath(fileName + @"\" + this.uuid);
|
||||
}
|
||||
if (fileName != null && !File.Exists(fileName))
|
||||
{
|
||||
fileName = Utils.NormalizePath(fileName + @"\" + this.uuid);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -344,8 +346,17 @@ namespace HypervResource
|
|||
}
|
||||
else if (this.nfsDataStoreTO != null)
|
||||
{
|
||||
NFSTO store = this.nfsDataStoreTO;
|
||||
fileName = store.UncPath + @"\" + this.path + @"\" + this.uuid;
|
||||
fileName = this.nfsDataStoreTO.UncPath;
|
||||
if (this.path != null)
|
||||
{
|
||||
fileName = Utils.NormalizePath(fileName + @"\" + this.path);
|
||||
}
|
||||
|
||||
if (fileName != null && !File.Exists(fileName))
|
||||
{
|
||||
fileName = Utils.NormalizePath(fileName + @"\" + this.uuid);
|
||||
}
|
||||
|
||||
if (!this.format.Equals("RAW"))
|
||||
{
|
||||
fileName = fileName + '.' + this.format.ToLowerInvariant();
|
||||
|
|
|
|||
|
|
@ -94,6 +94,10 @@
|
|||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
|
||||
<Target Name="BeforeBuild" Condition="'$(BuildWithMono)' == 'true' ">
|
||||
<RemoveDir Directories="$(ProjectDir)$(BaseIntermediateOutputPath)" Condition="Exists('$(ProjectDir)$(BaseIntermediateOutputPath)')"/>
|
||||
<RemoveDir Directories="$(ProjectDir)$(OutputPath)" Condition="Exists('$(ProjectDir)$(OutputPath)')"/>
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ namespace HypervResource
|
|||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.SetupCommand + cmd.ToString());
|
||||
logger.Info(CloudStackTypes.SetupCommand + Utils.CleanString(cmd.ToString()));
|
||||
|
||||
string details = null;
|
||||
bool result = false;
|
||||
|
|
@ -323,7 +323,7 @@ namespace HypervResource
|
|||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.RebootCommand + cmd.ToString());
|
||||
logger.Info(CloudStackTypes.RebootCommand + Utils.CleanString(cmd.ToString()));
|
||||
|
||||
string details = null;
|
||||
bool result = false;
|
||||
|
|
@ -367,7 +367,7 @@ namespace HypervResource
|
|||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.DestroyCommand + cmd.ToString());
|
||||
logger.Info(CloudStackTypes.DestroyCommand + Utils.CleanString(cmd.ToString()));
|
||||
|
||||
string details = null;
|
||||
bool result = false;
|
||||
|
|
@ -375,7 +375,7 @@ namespace HypervResource
|
|||
try
|
||||
{
|
||||
// Assert
|
||||
String errMsg = "No 'volume' details in " + CloudStackTypes.DestroyCommand + " " + cmd.ToString();
|
||||
String errMsg = "No 'volume' details in " + CloudStackTypes.DestroyCommand + " " + Utils.CleanString(cmd.ToString());
|
||||
if (cmd.volume == null)
|
||||
{
|
||||
logger.Error(errMsg);
|
||||
|
|
@ -430,7 +430,7 @@ namespace HypervResource
|
|||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.DestroyCommand + cmd.ToString());
|
||||
logger.Info(CloudStackTypes.DestroyCommand + Utils.CleanString(cmd.ToString()));
|
||||
|
||||
string details = null;
|
||||
bool result = false;
|
||||
|
|
@ -756,7 +756,7 @@ namespace HypervResource
|
|||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.CheckHealthCommand + cmd.ToString());
|
||||
logger.Info(CloudStackTypes.CheckHealthCommand + Utils.CleanString(cmd.ToString()));
|
||||
object ansContent = new
|
||||
{
|
||||
result = true,
|
||||
|
|
@ -774,7 +774,7 @@ namespace HypervResource
|
|||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.CheckOnHostCommand + cmd.ToString());
|
||||
logger.Info(CloudStackTypes.CheckOnHostCommand + Utils.CleanString(cmd.ToString()));
|
||||
object ansContent = new
|
||||
{
|
||||
result = true,
|
||||
|
|
@ -793,7 +793,7 @@ namespace HypervResource
|
|||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.CheckSshCommand + cmd.ToString());
|
||||
logger.Info(CloudStackTypes.CheckSshCommand + Utils.CleanString(cmd.ToString()));
|
||||
object ansContent = new
|
||||
{
|
||||
result = true,
|
||||
|
|
@ -811,7 +811,7 @@ namespace HypervResource
|
|||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.CheckVirtualMachineCommand + cmd.ToString());
|
||||
logger.Info(CloudStackTypes.CheckVirtualMachineCommand + Utils.CleanString(cmd.ToString()));
|
||||
string details = null;
|
||||
bool result = false;
|
||||
string vmName = cmd.vmName;
|
||||
|
|
@ -848,7 +848,7 @@ namespace HypervResource
|
|||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.DeleteStoragePoolCommand + cmd.ToString());
|
||||
logger.Info(CloudStackTypes.DeleteStoragePoolCommand + Utils.CleanString(cmd.ToString()));
|
||||
object ansContent = new
|
||||
{
|
||||
result = true,
|
||||
|
|
@ -992,7 +992,7 @@ namespace HypervResource
|
|||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.CleanupNetworkRulesCmd + cmd.ToString());
|
||||
logger.Info(CloudStackTypes.CleanupNetworkRulesCmd + Utils.CleanString(cmd.ToString()));
|
||||
object ansContent = new
|
||||
{
|
||||
result = false,
|
||||
|
|
@ -1010,7 +1010,7 @@ namespace HypervResource
|
|||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.CheckNetworkCommand + cmd.ToString());
|
||||
logger.Info(CloudStackTypes.CheckNetworkCommand + Utils.CleanString(cmd.ToString()));
|
||||
object ansContent = new
|
||||
{
|
||||
result = true,
|
||||
|
|
@ -1028,7 +1028,7 @@ namespace HypervResource
|
|||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.ReadyCommand + cmd.ToString());
|
||||
logger.Info(CloudStackTypes.ReadyCommand + Utils.CleanString(cmd.ToString()));
|
||||
object ansContent = new
|
||||
{
|
||||
result = true,
|
||||
|
|
@ -1113,7 +1113,7 @@ namespace HypervResource
|
|||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.StopCommand + cmd.ToString());
|
||||
logger.Info(CloudStackTypes.StopCommand + Utils.CleanString(cmd.ToString()));
|
||||
string details = null;
|
||||
bool result = false;
|
||||
|
||||
|
|
@ -1169,7 +1169,7 @@ namespace HypervResource
|
|||
volumePath = Utils.NormalizePath(volumePath);
|
||||
Utils.ConnectToRemote(primary.UncPath, primary.Domain, primary.User, primary.Password);
|
||||
}
|
||||
volume.path = volumePath;
|
||||
volume.path = volume.uuid;
|
||||
wmiCallsV2.CreateDynamicVirtualHardDisk(volumeSize, volumePath);
|
||||
if (File.Exists(volumePath))
|
||||
{
|
||||
|
|
@ -1209,7 +1209,7 @@ namespace HypervResource
|
|||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.MaintainCommand + cmd.ToString());
|
||||
logger.Info(CloudStackTypes.MaintainCommand + Utils.CleanString(cmd.ToString()));
|
||||
|
||||
object ansContent = new
|
||||
{
|
||||
|
|
@ -1232,7 +1232,7 @@ namespace HypervResource
|
|||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.PingRoutingCommand + cmd.ToString());
|
||||
logger.Info(CloudStackTypes.PingRoutingCommand + Utils.CleanString(cmd.ToString()));
|
||||
|
||||
object ansContent = new
|
||||
{
|
||||
|
|
@ -1254,7 +1254,7 @@ namespace HypervResource
|
|||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.PingCommand + cmd.ToString());
|
||||
logger.Info(CloudStackTypes.PingCommand + Utils.CleanString(cmd.ToString()));
|
||||
|
||||
object ansContent = new
|
||||
{
|
||||
|
|
@ -1275,7 +1275,7 @@ namespace HypervResource
|
|||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.GetVmStatsCommand + cmd.ToString());
|
||||
logger.Info(CloudStackTypes.GetVmStatsCommand + Utils.CleanString(cmd.ToString()));
|
||||
bool result = false;
|
||||
JArray vmNamesJson = cmd.vmNames;
|
||||
string[] vmNames = vmNamesJson.ToObject<string[]>();
|
||||
|
|
@ -1478,7 +1478,7 @@ namespace HypervResource
|
|||
{
|
||||
// TODO: thin provision instead of copying the full file.
|
||||
File.Copy(srcFile, destFile);
|
||||
destVolumeObjectTO.path = destFile;
|
||||
destVolumeObjectTO.path = destVolumeObjectTO.uuid;
|
||||
JObject ansObj = Utils.CreateCloudStackObject(CloudStackTypes.VolumeObjectTO, destVolumeObjectTO);
|
||||
newData = ansObj;
|
||||
result = true;
|
||||
|
|
@ -1512,8 +1512,25 @@ namespace HypervResource
|
|||
// doesn't do anything if the directory is already present.
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(destFile));
|
||||
File.Copy(srcFile, destFile);
|
||||
|
||||
if (srcVolumeObjectTO.nfsDataStore != null && srcVolumeObjectTO.primaryDataStore == null)
|
||||
{
|
||||
logger.Info("Copied volume from secondary data store to primary. Path: " + destVolumeObjectTO.path);
|
||||
}
|
||||
else if (srcVolumeObjectTO.primaryDataStore != null && srcVolumeObjectTO.nfsDataStore == null)
|
||||
{
|
||||
destVolumeObjectTO.path = destVolumeObjectTO.path + "/" + destVolumeObjectTO.uuid;
|
||||
if (destVolumeObjectTO.format != null)
|
||||
{
|
||||
destVolumeObjectTO.path += "." + destVolumeObjectTO.format.ToLower();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Error("Destination volume path wasn't set. Unsupported source volume data store.");
|
||||
}
|
||||
|
||||
// Create volumeto object deserialize and send it
|
||||
destVolumeObjectTO.path = destFile;
|
||||
JObject ansObj = Utils.CreateCloudStackObject(CloudStackTypes.VolumeObjectTO, destVolumeObjectTO);
|
||||
newData = ansObj;
|
||||
result = true;
|
||||
|
|
@ -1556,7 +1573,11 @@ namespace HypervResource
|
|||
TemplateObjectTO destTemplateObject = new TemplateObjectTO();
|
||||
destTemplateObject.size = srcVolumeObjectTO.size.ToString();
|
||||
destTemplateObject.format = srcVolumeObjectTO.format;
|
||||
destTemplateObject.path = destFile;
|
||||
destTemplateObject.path = destTemplateObjectTO.path + "/" + destTemplateObjectTO.uuid;
|
||||
if (destTemplateObject.format != null)
|
||||
{
|
||||
destTemplateObject.path += "." + destTemplateObject.format.ToLower();
|
||||
}
|
||||
destTemplateObject.nfsDataStoreTO = destTemplateObjectTO.nfsDataStoreTO;
|
||||
destTemplateObject.checksum = destTemplateObjectTO.checksum;
|
||||
newData = destTemplateObject;
|
||||
|
|
@ -1765,7 +1786,7 @@ namespace HypervResource
|
|||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.GetHostStatsCommand + cmd.ToString());
|
||||
logger.Info(CloudStackTypes.GetHostStatsCommand + Utils.CleanString(cmd.ToString()));
|
||||
bool result = false;
|
||||
string details = null;
|
||||
object hostStats = null;
|
||||
|
|
@ -1827,7 +1848,7 @@ namespace HypervResource
|
|||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.PrepareForMigrationCommand + cmd.ToString());
|
||||
logger.Info(CloudStackTypes.PrepareForMigrationCommand + Utils.CleanString(cmd.ToString()));
|
||||
|
||||
string details = null;
|
||||
bool result = true;
|
||||
|
|
@ -1861,7 +1882,7 @@ namespace HypervResource
|
|||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.MigrateCommand + cmd.ToString());
|
||||
logger.Info(CloudStackTypes.MigrateCommand + Utils.CleanString(cmd.ToString()));
|
||||
|
||||
string details = null;
|
||||
bool result = false;
|
||||
|
|
@ -2012,7 +2033,7 @@ namespace HypervResource
|
|||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.GetVncPortCommand + cmd.ToString());
|
||||
logger.Info(CloudStackTypes.GetVncPortCommand + Utils.CleanString(cmd.ToString()));
|
||||
|
||||
string details = null;
|
||||
bool result = false;
|
||||
|
|
|
|||
|
|
@ -167,8 +167,8 @@ namespace HypervResource
|
|||
public static string CleanString(string stringToClean)
|
||||
{
|
||||
string cleanString = null;
|
||||
string regexQueryString = "(&|%26)?(password|accesskey|secretkey)(=|%3D).*?(?=(%26|[&'\"]))";
|
||||
string regexJson = "\"(password|accesskey|secretkey)\":\".*?\",?";
|
||||
string regexQueryString = "(&|%26)?(password|accesskey|secretkey|Password)(=|%3D).*?(?=(%26|[&'\"]))";
|
||||
string regexJson = "\"(password|accesskey|secretkey|Password)\":\\s?\".*?\",?";
|
||||
cleanString = System.Text.RegularExpressions.Regex.Replace(stringToClean, regexQueryString, "");
|
||||
cleanString = System.Text.RegularExpressions.Regex.Replace(cleanString, regexJson, "");
|
||||
return cleanString;
|
||||
|
|
|
|||
|
|
@ -121,6 +121,10 @@
|
|||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
|
||||
<Target Name="BeforeBuild" Condition="'$(BuildWithMono)' == 'true' ">
|
||||
<RemoveDir Directories="$(ProjectDir)$(BaseIntermediateOutputPath)" Condition="Exists('$(ProjectDir)$(BaseIntermediateOutputPath)')"/>
|
||||
<RemoveDir Directories="$(ProjectDir)$(OutputPath)" Condition="Exists('$(ProjectDir)$(OutputPath)')"/>
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
|
|
|||
|
|
@ -177,6 +177,10 @@
|
|||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
|
||||
<Target Name="BeforeBuild" Condition="'$(BuildWithMono)' == 'true' ">
|
||||
<RemoveDir Directories="$(ProjectDir)$(BaseIntermediateOutputPath)" Condition="Exists('$(ProjectDir)$(BaseIntermediateOutputPath)')"/>
|
||||
<RemoveDir Directories="$(ProjectDir)$(OutputPath)" Condition="Exists('$(ProjectDir)$(OutputPath)')"/>
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import java.io.File;
|
|||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.net.URI;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
|
|
@ -117,7 +116,13 @@ public class BridgeVifDriver extends VifDriverBase {
|
|||
intf.defBridgeNet(brName, null, nic.getMac(), getGuestNicModel(guestOsType), networkRateKBps);
|
||||
}
|
||||
} else {
|
||||
intf.defBridgeNet(_bridges.get("guest"), null, nic.getMac(), getGuestNicModel(guestOsType), networkRateKBps);
|
||||
String brname = "";
|
||||
if (trafficLabel != null && !trafficLabel.isEmpty()) {
|
||||
brname = trafficLabel;
|
||||
} else {
|
||||
brname = _bridges.get("guest");
|
||||
}
|
||||
intf.defBridgeNet(brname, null, nic.getMac(), getGuestNicModel(guestOsType), networkRateKBps);
|
||||
}
|
||||
} else if (nic.getType() == Networks.TrafficType.Control) {
|
||||
/* Make sure the network is still there */
|
||||
|
|
|
|||
|
|
@ -2987,6 +2987,7 @@ ServerResource {
|
|||
}
|
||||
|
||||
List<InterfaceDef> ifaces = null;
|
||||
List<DiskDef> disks = null;
|
||||
|
||||
Domain dm = null;
|
||||
Connect dconn = null;
|
||||
|
|
@ -2996,6 +2997,7 @@ ServerResource {
|
|||
try {
|
||||
conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName());
|
||||
ifaces = getInterfaces(conn, vmName);
|
||||
disks = getDisks(conn, vmName);
|
||||
dm = conn.domainLookupByName(vmName);
|
||||
/*
|
||||
We replace the private IP address with the address of the destination host.
|
||||
|
|
@ -3021,7 +3023,9 @@ ServerResource {
|
|||
destDomain = dm.migrate(dconn, (1 << 0) | (1 << 3), xmlDesc, vmName, "tcp:"
|
||||
+ cmd.getDestinationIp(), _migrateSpeed);
|
||||
|
||||
_storagePoolMgr.disconnectPhysicalDisksViaVmSpec(cmd.getVirtualMachine());
|
||||
for (DiskDef disk : disks) {
|
||||
cleanupDisk(disk);
|
||||
}
|
||||
} catch (LibvirtException e) {
|
||||
s_logger.debug("Can't migrate domain: " + e.getMessage());
|
||||
result = e.getMessage();
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ import com.cloud.agent.api.routing.DhcpEntryCommand;
|
|||
import com.cloud.agent.api.routing.IpAssocCommand;
|
||||
import com.cloud.agent.api.routing.IpAssocVpcCommand;
|
||||
import com.cloud.agent.api.routing.LoadBalancerConfigCommand;
|
||||
import com.cloud.agent.api.routing.RemoteAccessVpnCfgCommand;
|
||||
import com.cloud.agent.api.routing.SavePasswordCommand;
|
||||
import com.cloud.agent.api.routing.SetFirewallRulesCommand;
|
||||
import com.cloud.agent.api.routing.SetNetworkACLCommand;
|
||||
|
|
@ -80,6 +81,7 @@ import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
|
|||
import com.cloud.agent.api.routing.SetStaticRouteCommand;
|
||||
import com.cloud.agent.api.routing.Site2SiteVpnCfgCommand;
|
||||
import com.cloud.agent.api.routing.VmDataCommand;
|
||||
import com.cloud.agent.api.routing.VpnUsersCfgCommand;
|
||||
import com.cloud.agent.api.storage.CopyVolumeCommand;
|
||||
import com.cloud.agent.api.storage.CreateCommand;
|
||||
import com.cloud.agent.api.storage.DestroyCommand;
|
||||
|
|
@ -362,7 +364,9 @@ public class SimulatorManagerImpl extends ManagerBase implements SimulatorManage
|
|||
} else if (cmd instanceof PvlanSetupCommand) {
|
||||
return _mockNetworkMgr.setupPVLAN((PvlanSetupCommand) cmd);
|
||||
} else if (cmd instanceof StorageSubSystemCommand) {
|
||||
return this.storageHandler.handleStorageCommands((StorageSubSystemCommand)cmd);
|
||||
return this.storageHandler.handleStorageCommands((StorageSubSystemCommand) cmd);
|
||||
} else if (cmd instanceof VpnUsersCfgCommand || cmd instanceof RemoteAccessVpnCfgCommand) {
|
||||
return new Answer(cmd);
|
||||
} else {
|
||||
s_logger.error("Simulator does not implement command of type "+cmd.toString());
|
||||
return Answer.createUnsupportedCommandAnswer(cmd);
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import java.util.UUID;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.storage.command.CommandResult;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
|
||||
|
|
@ -80,6 +81,11 @@ public class SimulatorImageStoreDriverImpl extends BaseImageStoreDriverImpl {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAsync(DataStore dataStore, DataObject data, AsyncCompletionCallback<CommandResult> callback) {
|
||||
callback.complete(new CommandResult());
|
||||
}
|
||||
|
||||
protected void createTemplate(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
|
||||
CreateContext<CreateCmdResult> context = new CreateContext<CreateCmdResult>(callback, data);
|
||||
AsyncCallbackDispatcher<SimulatorImageStoreDriverImpl, DownloadAnswer> caller = AsyncCallbackDispatcher
|
||||
|
|
|
|||
|
|
@ -132,8 +132,8 @@ import com.cloud.vm.DomainRouterVO;
|
|||
public class VmwareManagerImpl extends ManagerBase implements VmwareManager, VmwareStorageMount, Listener, VmwareDatacenterService {
|
||||
private static final Logger s_logger = Logger.getLogger(VmwareManagerImpl.class);
|
||||
|
||||
private static final int STARTUP_DELAY = 60000; // 60 seconds
|
||||
private static final long DEFAULT_HOST_SCAN_INTERVAL = 600000; // every 10 minutes
|
||||
private static final int STARTUP_DELAY = 60000; // 60 seconds
|
||||
private static final long DEFAULT_HOST_SCAN_INTERVAL = 600000; // every 10 minutes
|
||||
|
||||
private long _hostScanInterval = DEFAULT_HOST_SCAN_INTERVAL;
|
||||
int _timeout;
|
||||
|
|
@ -173,7 +173,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
|||
String _managemetPortGroupName;
|
||||
String _defaultSystemVmNicAdapterType = VirtualEthernetCardType.E1000.toString();
|
||||
String _recycleHungWorker = "false";
|
||||
long _hungWorkerTimeout = 7200000; // 2 hour
|
||||
long _hungWorkerTimeout = 7200000; // 2 hour
|
||||
int _additionalPortRangeStart;
|
||||
int _additionalPortRangeSize;
|
||||
int _routerExtraPublicNics = 2;
|
||||
|
|
@ -296,10 +296,10 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
|||
if(_recycleHungWorker == null || _recycleHungWorker.isEmpty()) {
|
||||
_recycleHungWorker = "false";
|
||||
}
|
||||
|
||||
|
||||
value = _configDao.getValue(Config.VmwareHungWorkerTimeout.key());
|
||||
if(value != null)
|
||||
_hungWorkerTimeout = Long.parseLong(value) * 1000;
|
||||
_hungWorkerTimeout = Long.parseLong(value) * 1000;
|
||||
|
||||
_rootDiskController = _configDao.getValue(Config.VmwareRootDiskControllerType.key());
|
||||
if(_rootDiskController == null || _rootDiskController.isEmpty()) {
|
||||
|
|
@ -459,7 +459,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
|||
hostSpec.setUserName(userName);
|
||||
hostSpec.setPassword(password);
|
||||
hostSpec.setHostName(host);
|
||||
hostSpec.setForce(true); // forcely take over the host
|
||||
hostSpec.setForce(true); // forcely take over the host
|
||||
|
||||
ManagedObjectReference morTask = serviceContext.getService().addHostTask(morCluster, hostSpec, true, null, null);
|
||||
boolean taskResult = vclient.waitForTask(morTask);
|
||||
|
|
@ -547,49 +547,49 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
|||
public void gcLeftOverVMs(VmwareContext context) {
|
||||
VmwareCleanupMaid.gcLeftOverVMs(context);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean needRecycle(String workerTag) {
|
||||
if(s_logger.isInfoEnabled())
|
||||
s_logger.info("Check to see if a worker VM with tag " + workerTag + " needs to be recycled");
|
||||
|
||||
if(workerTag == null || workerTag.isEmpty()) {
|
||||
s_logger.error("Invalid worker VM tag " + workerTag);
|
||||
return false;
|
||||
}
|
||||
|
||||
String tokens[] = workerTag.split("-");
|
||||
if(tokens.length != 3) {
|
||||
s_logger.error("Invalid worker VM tag " + workerTag);
|
||||
return false;
|
||||
}
|
||||
|
||||
long startTick = Long.parseLong(tokens[0]);
|
||||
long msid = Long.parseLong(tokens[1]);
|
||||
long runid = Long.parseLong(tokens[2]);
|
||||
|
||||
if (s_logger.isInfoEnabled())
|
||||
s_logger.info("Check to see if a worker VM with tag " + workerTag + " needs to be recycled");
|
||||
|
||||
if (workerTag == null || workerTag.isEmpty()) {
|
||||
s_logger.error("Invalid worker VM tag " + workerTag);
|
||||
return false;
|
||||
}
|
||||
|
||||
String tokens[] = workerTag.split("-");
|
||||
if (tokens.length != 3) {
|
||||
s_logger.error("Invalid worker VM tag " + workerTag);
|
||||
return false;
|
||||
}
|
||||
|
||||
long startTick = Long.parseLong(tokens[0]);
|
||||
long msid = Long.parseLong(tokens[1]);
|
||||
long runid = Long.parseLong(tokens[2]);
|
||||
|
||||
if(_mshostPeerDao.countStateSeenInPeers(msid, runid, ManagementServerHost.State.Down) > 0) {
|
||||
if(s_logger.isInfoEnabled())
|
||||
s_logger.info("Worker VM's owner management server node has been detected down from peer nodes, recycle it");
|
||||
return true;
|
||||
if (s_logger.isInfoEnabled())
|
||||
s_logger.info("Worker VM's owner management server node has been detected down from peer nodes, recycle it");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if(msid == _clusterMgr.getManagementNodeId() && runid != _clusterMgr.getCurrentRunId()) {
|
||||
if(s_logger.isInfoEnabled())
|
||||
s_logger.info("Worker VM's owner management server has changed runid, recycle it");
|
||||
return true;
|
||||
if (s_logger.isInfoEnabled())
|
||||
s_logger.info("Worker VM's owner management server has changed runid, recycle it");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// disable time-out check until we have found out a VMware API that can check if
|
||||
// there are pending tasks on the subject VM
|
||||
/*
|
||||
if(System.currentTimeMillis() - startTick > _hungWorkerTimeout) {
|
||||
if(s_logger.isInfoEnabled())
|
||||
s_logger.info("Worker VM expired, seconds elapsed: " + (System.currentTimeMillis() - startTick) / 1000);
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
return false;
|
||||
/*
|
||||
if(System.currentTimeMillis() - startTick > _hungWorkerTimeout) {
|
||||
if(s_logger.isInfoEnabled())
|
||||
s_logger.info("Worker VM expired, seconds elapsed: " + (System.currentTimeMillis() - startTick) / 1000);
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -619,6 +619,9 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
|||
", destination: " + destIso.getAbsolutePath());
|
||||
try {
|
||||
FileUtil.copyfile(srcIso, destIso);
|
||||
|
||||
s_logger.info("System VM patch ISO file is copied to secondary storage. source ISO: " + srcIso.getAbsolutePath() +
|
||||
", destination: " + destIso.getAbsolutePath());
|
||||
} catch(IOException e) {
|
||||
s_logger.error("Unexpected exception ", e);
|
||||
|
||||
|
|
|
|||
|
|
@ -763,9 +763,6 @@ class ubuntuFirewallConfigServer(firewallConfigServer):
|
|||
for port in self.ports:
|
||||
self.allowPort(port)
|
||||
|
||||
#FIXME: urgly make /root writable
|
||||
bash("sudo chmod 0777 /root")
|
||||
|
||||
return True
|
||||
except:
|
||||
raise
|
||||
|
|
|
|||
|
|
@ -16,10 +16,15 @@
|
|||
// under the License.
|
||||
package com.cloud.api.doc;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public class Argument implements Comparable{
|
||||
private String name;
|
||||
public class Argument implements Comparable<Object>, Serializable{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -5696100838854848492L;
|
||||
private String name;
|
||||
private String description;
|
||||
private Boolean required;
|
||||
private String type;
|
||||
|
|
@ -42,7 +47,7 @@ public class Argument implements Comparable{
|
|||
}
|
||||
|
||||
public String getType() {
|
||||
return this.type;
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
|
|
@ -89,11 +94,12 @@ public class Argument implements Comparable{
|
|||
this.sinceVersion = sinceVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object anotherAgrument) throws ClassCastException {
|
||||
if (!(anotherAgrument instanceof Argument))
|
||||
throw new ClassCastException("An Argument object expected.");
|
||||
Argument argument = (Argument)anotherAgrument;
|
||||
return this.getName().compareToIgnoreCase(argument.getName());
|
||||
return getName().compareToIgnoreCase(argument.getName());
|
||||
}
|
||||
|
||||
public boolean hasArguments() {
|
||||
|
|
|
|||
|
|
@ -503,7 +503,7 @@ VirtualMachineGuru, SystemVmLoadScanHandler<Long>, ResourceStateAdapter {
|
|||
byte[] details = proxy.getSessionDetails();
|
||||
status = gson.fromJson(details != null ? new String(details, Charset.forName("US-ASCII")) : null, ConsoleProxyStatus.class);
|
||||
} catch (Throwable e) {
|
||||
s_logger.warn("Unable to parse proxy session details : " + proxy.getSessionDetails());
|
||||
s_logger.warn("Unable to parse proxy session details : " + Arrays.toString(proxy.getSessionDetails()));
|
||||
}
|
||||
|
||||
if (status != null && status.getConnections() != null) {
|
||||
|
|
@ -1714,7 +1714,7 @@ VirtualMachineGuru, SystemVmLoadScanHandler<Long>, ResourceStateAdapter {
|
|||
|
||||
@Inject
|
||||
public void setConsoleProxyAllocators(List<ConsoleProxyAllocator> consoleProxyAllocators) {
|
||||
this._consoleProxyAllocators = consoleProxyAllocators;
|
||||
_consoleProxyAllocators = consoleProxyAllocators;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,6 @@ import javax.naming.ConfigurationException;
|
|||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.Listener;
|
||||
import com.cloud.agent.api.AgentControlAnswer;
|
||||
|
|
@ -41,7 +39,6 @@ import com.cloud.agent.api.StartupCommand;
|
|||
import com.cloud.agent.api.StartupRoutingCommand;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.dc.ClusterVO;
|
||||
import com.cloud.dc.dao.ClusterDao;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.DiscoveredWithErrorException;
|
||||
import com.cloud.exception.DiscoveryException;
|
||||
|
|
@ -49,10 +46,8 @@ import com.cloud.exception.OperationTimedoutException;
|
|||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.PhysicalNetworkSetupInfo;
|
||||
import com.cloud.resource.Discoverer;
|
||||
import com.cloud.resource.DiscovererBase;
|
||||
|
|
@ -71,18 +66,11 @@ public abstract class LibvirtServerDiscoverer extends DiscovererBase implements
|
|||
private String _kvmPublicNic;
|
||||
private String _kvmGuestNic;
|
||||
@Inject
|
||||
HostDao _hostDao = null;
|
||||
@Inject
|
||||
ClusterDao _clusterDao;
|
||||
@Inject
|
||||
ResourceManager _resourceMgr;
|
||||
@Inject
|
||||
AgentManager _agentMgr;
|
||||
@Inject
|
||||
ConfigurationDao _configDao;
|
||||
@Inject
|
||||
NetworkModel _networkMgr;
|
||||
|
||||
@Override
|
||||
public abstract Hypervisor.HypervisorType getHypervisorType();
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ import com.cloud.utils.exception.CloudRuntimeException;
|
|||
@Local(value=IpAddrAllocator.class)
|
||||
public class ExternalIpAddressAllocator extends AdapterBase implements IpAddrAllocator{
|
||||
private static final Logger s_logger = Logger.getLogger(ExternalIpAddressAllocator.class);
|
||||
String _name;
|
||||
@Inject ConfigurationDao _configDao = null;
|
||||
@Inject IPAddressDao _ipAddressDao = null;
|
||||
@Inject VlanDao _vlanDao;
|
||||
|
|
@ -50,10 +49,10 @@ public class ExternalIpAddressAllocator extends AdapterBase implements IpAddrAll
|
|||
|
||||
@Override
|
||||
public IpAddr getPrivateIpAddress(String macAddr, long dcId, long podId) {
|
||||
if (_externalIpAllocatorUrl == null || this._externalIpAllocatorUrl.equalsIgnoreCase("")) {
|
||||
if (_externalIpAllocatorUrl == null || _externalIpAllocatorUrl.equalsIgnoreCase("")) {
|
||||
return new IpAddr();
|
||||
}
|
||||
String urlString = this._externalIpAllocatorUrl + "?command=getIpAddr&mac=" + macAddr + "&dc=" + dcId + "&pod=" + podId;
|
||||
String urlString = _externalIpAllocatorUrl + "?command=getIpAddr&mac=" + macAddr + "&dc=" + dcId + "&pod=" + podId;
|
||||
s_logger.debug("getIP:" + urlString);
|
||||
|
||||
BufferedReader in = null;
|
||||
|
|
@ -99,11 +98,11 @@ public class ExternalIpAddressAllocator extends AdapterBase implements IpAddrAll
|
|||
@Override
|
||||
public boolean releasePrivateIpAddress(String ip, long dcId, long podId) {
|
||||
/*TODO: call API to release the ip address from external DHCP server*/
|
||||
if (_externalIpAllocatorUrl == null || this._externalIpAllocatorUrl.equalsIgnoreCase("")) {
|
||||
if (_externalIpAllocatorUrl == null || _externalIpAllocatorUrl.equalsIgnoreCase("")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String urlString = this._externalIpAllocatorUrl + "?command=releaseIpAddr&ip=" + ip + "&dc=" + dcId + "&pod=" + podId;
|
||||
String urlString = _externalIpAllocatorUrl + "?command=releaseIpAddr&ip=" + ip + "&dc=" + dcId + "&pod=" + podId;
|
||||
|
||||
s_logger.debug("releaseIP:" + urlString);
|
||||
BufferedReader in = null;
|
||||
|
|
|
|||
|
|
@ -1656,8 +1656,8 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrivateGateway(Nic guestNic) {
|
||||
Network network = getNetwork(guestNic.getNetworkId());
|
||||
public boolean isPrivateGateway(long ntwkId) {
|
||||
Network network = getNetwork(ntwkId);
|
||||
if (network.getTrafficType() != TrafficType.Guest || network.getNetworkOfferingId() != _privateOfferingId.longValue()) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3590,15 +3590,17 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
|
|||
|
||||
// For public traffic, get isolation method of physical network and update the public network accordingly
|
||||
// each broadcast type will individually need to be qualified for support of public traffic
|
||||
List<String> isolationMethods = network.getIsolationMethods();
|
||||
if ((isolationMethods.size() == 1 && isolationMethods.get(0).toLowerCase().equals("vxlan"))
|
||||
|| (isolationMethod != null && isolationMethods.contains(isolationMethod) && isolationMethod.toLowerCase().equals("vxlan"))) {
|
||||
// find row in networks table that is defined as 'Public', created when zone was deployed
|
||||
NetworkVO publicNetwork = _networksDao.listByZoneAndTrafficType(network.getDataCenterId(),TrafficType.Public).get(0);
|
||||
if (publicNetwork != null) {
|
||||
s_logger.debug("setting public network " + publicNetwork + " to broadcast type vxlan");
|
||||
publicNetwork.setBroadcastDomainType(BroadcastDomainType.Vxlan);
|
||||
_networksDao.persist(publicNetwork);
|
||||
if (TrafficType.Public.equals(trafficType)){
|
||||
List<String> isolationMethods = network.getIsolationMethods();
|
||||
if ((isolationMethods.size() == 1 && isolationMethods.get(0).toLowerCase().equals("vxlan"))
|
||||
|| (isolationMethod != null && isolationMethods.contains(isolationMethod) && isolationMethod.toLowerCase().equals("vxlan"))) {
|
||||
// find row in networks table that is defined as 'Public', created when zone was deployed
|
||||
NetworkVO publicNetwork = _networksDao.listByZoneAndTrafficType(network.getDataCenterId(),TrafficType.Public).get(0);
|
||||
if (publicNetwork != null) {
|
||||
s_logger.debug("setting public network " + publicNetwork + " to broadcast type vxlan");
|
||||
publicNetwork.setBroadcastDomainType(BroadcastDomainType.Vxlan);
|
||||
_networksDao.persist(publicNetwork);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -414,13 +414,13 @@ public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGur
|
|||
@Override
|
||||
public void shutdown(NetworkProfile profile, NetworkOffering offering) {
|
||||
|
||||
if (profile.getBroadcastDomainType() == BroadcastDomainType.Vlan &&
|
||||
if ((profile.getBroadcastDomainType() == BroadcastDomainType.Vlan || profile.getBroadcastDomainType() == BroadcastDomainType.Vxlan) &&
|
||||
profile.getBroadcastUri() != null && !offering.getSpecifyVlan()) {
|
||||
s_logger.debug("Releasing vnet for the network id=" + profile.getId());
|
||||
_dcDao.releaseVnet(BroadcastDomainType.getValue(profile.getBroadcastUri()), profile.getDataCenterId(),
|
||||
profile.getPhysicalNetworkId(), profile.getAccountId(), profile.getReservationId());
|
||||
ActionEventUtils.onCompletedActionEvent(CallContext.current().getCallingUserId(), profile.getAccountId(),
|
||||
EventVO.LEVEL_INFO, EventTypes.EVENT_ZONE_VLAN_RELEASE, "Released Zone Vlan: "
|
||||
EventVO.LEVEL_INFO, EventTypes.EVENT_ZONE_VLAN_RELEASE, "Released Zone vnet: "
|
||||
+ BroadcastDomainType.getValue(profile.getBroadcastUri()) + " for Network: " + profile.getId(), 0);
|
||||
}
|
||||
profile.setBroadcastUri(null);
|
||||
|
|
|
|||
|
|
@ -805,7 +805,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
PlugNicCommand plugNicCmd = new PlugNicCommand(getNicTO(router, guestNic.getNetworkId(), null), router.getInstanceName(), router.getType());
|
||||
cmds.addCommand(plugNicCmd);
|
||||
|
||||
if (!_networkModel.isPrivateGateway(guestNic)) {
|
||||
if (!_networkModel.isPrivateGateway(guestNic.getNetworkId())) {
|
||||
//set guest network
|
||||
VirtualMachine vm = _vmDao.findById(router.getId());
|
||||
NicProfile nicProfile = _networkModel.getNicProfile(vm, guestNic.getNetworkId(), null);
|
||||
|
|
@ -1237,6 +1237,9 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
//3) allocate nic for guest gateway if needed
|
||||
List<? extends Network> guestNetworks = _vpcMgr.getVpcNetworks(vpcId);
|
||||
for (Network guestNetwork : guestNetworks) {
|
||||
if (_networkModel.isPrivateGateway(guestNetwork.getId())) {
|
||||
continue;
|
||||
}
|
||||
if (guestNetwork.getState() == Network.State.Implemented || guestNetwork.getState() == Network.State.Setup) {
|
||||
NicProfile guestNic = createGuestNicProfileForVpcRouter(guestNetwork);
|
||||
networks.put(guestNetwork, new ArrayList<NicProfile>(Arrays.asList(guestNic)));
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
|
|
@ -39,12 +39,17 @@ import javax.mail.URLName;
|
|||
import javax.mail.internet.InternetAddress;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.sun.mail.smtp.SMTPMessage;
|
||||
import com.sun.mail.smtp.SMTPSSLTransport;
|
||||
import com.sun.mail.smtp.SMTPTransport;
|
||||
|
||||
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.api.query.dao.ProjectAccountJoinDao;
|
||||
|
|
@ -77,7 +82,6 @@ import com.cloud.user.User;
|
|||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.utils.DateUtil;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.component.Manager;
|
||||
import com.cloud.utils.component.ManagerBase;
|
||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||
import com.cloud.utils.db.DB;
|
||||
|
|
@ -87,9 +91,6 @@ import com.cloud.utils.db.TransactionCallbackNoReturn;
|
|||
import com.cloud.utils.db.TransactionCallbackWithExceptionNoReturn;
|
||||
import com.cloud.utils.db.TransactionStatus;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.sun.mail.smtp.SMTPMessage;
|
||||
import com.sun.mail.smtp.SMTPSSLTransport;
|
||||
import com.sun.mail.smtp.SMTPTransport;
|
||||
|
||||
@Component
|
||||
@Local(value = { ProjectService.class, ProjectManager.class })
|
||||
|
|
@ -108,7 +109,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager {
|
|||
@Inject
|
||||
DomainManager _domainMgr;
|
||||
@Inject
|
||||
ConfigurationManager _configMgr;
|
||||
ConfigurationManager _configMgr;
|
||||
@Inject
|
||||
ResourceLimitService _resourceLimitMgr;
|
||||
@Inject
|
||||
|
|
@ -257,7 +258,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager {
|
|||
|
||||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_PROJECT_DELETE, eventDescription = "deleting project", async = true)
|
||||
@ActionEvent(eventType = EventTypes.EVENT_PROJECT_DELETE, eventDescription = "deleting project", async = true)
|
||||
public boolean deleteProject(long projectId) {
|
||||
CallContext ctx = CallContext.current();
|
||||
|
||||
|
|
@ -269,7 +270,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager {
|
|||
|
||||
_accountMgr.checkAccess(ctx.getCallingAccount(),AccessType.ModifyProject, true, _accountMgr.getAccount(project.getProjectAccountId()));
|
||||
|
||||
return deleteProject(ctx.getCallingAccount(), ctx.getCallingUserId(), project);
|
||||
return deleteProject(ctx.getCallingAccount(), ctx.getCallingUserId(), project);
|
||||
}
|
||||
|
||||
@DB
|
||||
|
|
@ -309,7 +310,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager {
|
|||
|
||||
@DB
|
||||
private boolean cleanupProject(final Project project, AccountVO caller, Long callerUserId) {
|
||||
boolean result=true;
|
||||
boolean result=true;
|
||||
//Delete project's account
|
||||
AccountVO account = _accountDao.findById(project.getProjectAccountId());
|
||||
s_logger.debug("Deleting projects " + project + " internal account id=" + account.getId() + " as a part of project cleanup...");
|
||||
|
|
@ -527,7 +528,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager {
|
|||
|
||||
if (project == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find project with specified id");
|
||||
ex.addProxyObject(String.valueOf(projectId), "projectId");
|
||||
ex.addProxyObject(String.valueOf(projectId), "projectId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -586,7 +587,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager {
|
|||
} else {
|
||||
s_logger.warn("Failed to generate invitation for account " + account.getAccountName() + " to project id=" + project);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (email != null) {
|
||||
|
|
@ -597,7 +598,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager {
|
|||
} else {
|
||||
s_logger.warn("Failed to generate invitation for email " + email + " to project id=" + project);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -613,7 +614,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager {
|
|||
|
||||
if (project == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find project with specified id");
|
||||
ex.addProxyObject(String.valueOf(projectId), "projectId");
|
||||
ex.addProxyObject(String.valueOf(projectId), "projectId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -626,7 +627,8 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager {
|
|||
if ( domain != null ){
|
||||
domainUuid = domain.getUuid();
|
||||
}
|
||||
ex.addProxyObject(domainUuid, "domainId");
|
||||
ex.addProxyObject(domainUuid, "domainId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
//verify permissions
|
||||
|
|
@ -654,7 +656,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager {
|
|||
|
||||
|
||||
|
||||
public ProjectInvitation createAccountInvitation(Project project, Long accountId) {
|
||||
public ProjectInvitation createAccountInvitation(Project project, Long accountId) {
|
||||
if (activeInviteExists(project, accountId, null)) {
|
||||
throw new InvalidParameterValueException("There is already a pending invitation for account id=" + accountId + " to the project id=" + project);
|
||||
}
|
||||
|
|
@ -678,7 +680,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager {
|
|||
}
|
||||
|
||||
if (invite != null) {
|
||||
if (invite.getState() == ProjectInvitation.State.Completed ||
|
||||
if (invite.getState() == ProjectInvitation.State.Completed ||
|
||||
(invite.getState() == ProjectInvitation.State.Pending && _projectInvitationDao.isActive(invite.getId(), _invitationTimeOut))) {
|
||||
return true;
|
||||
} else {
|
||||
|
|
@ -796,7 +798,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager {
|
|||
if (projectAccount != null) {
|
||||
s_logger.debug("Account " + accountNameFinal + " already added to the project id=" + projectId);
|
||||
} else {
|
||||
assignAccountToProject(project, accountIdFinal, ProjectAccount.Role.Regular);
|
||||
assignAccountToProject(project, accountIdFinal, ProjectAccount.Role.Regular);
|
||||
}
|
||||
} else {
|
||||
s_logger.warn("Failed to update project invitation " + inviteFinal + " with state " + newState);
|
||||
|
|
@ -842,7 +844,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager {
|
|||
if (currentState == State.Active) {
|
||||
s_logger.debug("The project id=" + projectId + " is already active, no need to activate it again");
|
||||
return project;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentState != State.Suspended) {
|
||||
throw new InvalidParameterValueException("Can't activate the project in " + currentState + " state");
|
||||
|
|
@ -966,7 +968,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager {
|
|||
}
|
||||
}
|
||||
|
||||
public void sendInvite(String token, String email, long projectId) throws MessagingException, UnsupportedEncodingException {
|
||||
public void sendInvite(String token, String email, long projectId) throws MessagingException, UnsupportedEncodingException {
|
||||
if (_smtpSession != null) {
|
||||
InternetAddress address = null;
|
||||
if (email != null) {
|
||||
|
|
@ -1025,7 +1027,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager {
|
|||
return true;
|
||||
} else {
|
||||
s_logger.debug("Failed to remove project invitation id=" + id);
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
|||
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
|
||||
import org.apache.cloudstack.storage.image.datastore.ImageStoreEntity;
|
||||
import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.api.Answer;
|
||||
|
|
@ -159,6 +160,7 @@ import com.cloud.storage.download.DownloadMonitor;
|
|||
import com.cloud.storage.secondary.SecondaryStorageVmManager;
|
||||
import com.cloud.storage.upload.UploadMonitor;
|
||||
import com.cloud.template.TemplateAdapter.TemplateAdapterType;
|
||||
import com.cloud.template.VirtualMachineTemplate.BootloaderType;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.AccountService;
|
||||
|
|
@ -184,6 +186,7 @@ import com.cloud.vm.UserVmManager;
|
|||
import com.cloud.vm.UserVmVO;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
import com.cloud.vm.dao.UserVmDetailsDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
|
@ -492,6 +495,38 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
|||
return tmpltStore.createEntityExtractUrl(templateObject.getInstallPath(), template.getFormat(), templateObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepareIsoForVmProfile(VirtualMachineProfile profile) {
|
||||
UserVmVO vm = _userVmDao.findById(profile.getId());
|
||||
if (vm.getIsoId() != null) {
|
||||
TemplateInfo template = prepareIso(vm.getIsoId(), vm.getDataCenterId());
|
||||
if (template == null){
|
||||
s_logger.error("Failed to prepare ISO on secondary or cache storage");
|
||||
throw new CloudRuntimeException("Failed to prepare ISO on secondary or cache storage");
|
||||
}
|
||||
if (template.isBootable()) {
|
||||
profile.setBootLoaderType(BootloaderType.CD);
|
||||
}
|
||||
|
||||
GuestOSVO guestOS = _guestOSDao.findById(template.getGuestOSId());
|
||||
String displayName = null;
|
||||
if (guestOS != null) {
|
||||
displayName = guestOS.getDisplayName();
|
||||
}
|
||||
|
||||
TemplateObjectTO iso = (TemplateObjectTO)template.getTO();
|
||||
iso.setGuestOsType(displayName);
|
||||
DiskTO disk = new DiskTO(iso, 3L, null, Volume.Type.ISO);
|
||||
profile.addDisk(disk);
|
||||
} else {
|
||||
TemplateObjectTO iso = new TemplateObjectTO();
|
||||
iso.setFormat(ImageFormat.ISO);
|
||||
DiskTO disk = new DiskTO(iso, 3L, null, Volume.Type.ISO);
|
||||
profile.addDisk(disk);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void prepareTemplateInAllStoragePools(final VMTemplateVO template, long zoneId) {
|
||||
List<StoragePoolVO> pools = _poolDao.listByStatus(StoragePoolStatus.Up);
|
||||
for (final StoragePoolVO pool : pools) {
|
||||
|
|
|
|||
|
|
@ -67,7 +67,6 @@ import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationSe
|
|||
import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService;
|
||||
import org.apache.cloudstack.engine.service.api.OrchestrationService;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateDataFactory;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService;
|
||||
|
|
@ -80,7 +79,6 @@ import org.apache.cloudstack.framework.jobs.AsyncJobManager;
|
|||
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
||||
import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
|
@ -94,7 +92,6 @@ import com.cloud.agent.api.PvlanSetupCommand;
|
|||
import com.cloud.agent.api.StartAnswer;
|
||||
import com.cloud.agent.api.VmDiskStatsEntry;
|
||||
import com.cloud.agent.api.VmStatsEntry;
|
||||
import com.cloud.agent.api.to.DiskTO;
|
||||
import com.cloud.agent.api.to.NicTO;
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
import com.cloud.agent.manager.Commands;
|
||||
|
|
@ -219,7 +216,6 @@ import com.cloud.storage.snapshot.SnapshotManager;
|
|||
import com.cloud.tags.dao.ResourceTagDao;
|
||||
import com.cloud.template.TemplateManager;
|
||||
import com.cloud.template.VirtualMachineTemplate;
|
||||
import com.cloud.template.VirtualMachineTemplate.BootloaderType;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.AccountService;
|
||||
|
|
@ -412,7 +408,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||
@Inject
|
||||
VpcManager _vpcMgr;
|
||||
@Inject
|
||||
TemplateManager templateMgr;
|
||||
TemplateManager _templateMgr;
|
||||
@Inject
|
||||
protected GuestOSCategoryDao _guestOSCategoryDao;
|
||||
@Inject
|
||||
|
|
@ -3182,34 +3178,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||
UserVmVO vm = _vmDao.findById(profile.getId());
|
||||
Map<String, String> details = _vmDetailsDao.listDetailsKeyPairs(vm.getId());
|
||||
vm.setDetails(details);
|
||||
|
||||
if (vm.getIsoId() != null) {
|
||||
TemplateInfo template = templateMgr.prepareIso(vm.getIsoId(), vm.getDataCenterId());
|
||||
if (template == null){
|
||||
s_logger.error("Failed to prepare ISO on secondary or cache storage");
|
||||
throw new CloudRuntimeException("Failed to prepare ISO on secondary or cache storage");
|
||||
}
|
||||
if (template.isBootable()) {
|
||||
profile.setBootLoaderType(BootloaderType.CD);
|
||||
}
|
||||
|
||||
GuestOSVO guestOS = _guestOSDao.findById(template.getGuestOSId());
|
||||
String displayName = null;
|
||||
if (guestOS != null) {
|
||||
displayName = guestOS.getDisplayName();
|
||||
}
|
||||
|
||||
TemplateObjectTO iso = (TemplateObjectTO)template.getTO();
|
||||
iso.setGuestOsType(displayName);
|
||||
DiskTO disk = new DiskTO(iso, 3L, null, Volume.Type.ISO);
|
||||
profile.addDisk(disk);
|
||||
} else {
|
||||
TemplateObjectTO iso = new TemplateObjectTO();
|
||||
iso.setFormat(ImageFormat.ISO);
|
||||
DiskTO disk = new DiskTO(iso, 3L, null, Volume.Type.ISO);
|
||||
profile.addDisk(disk);
|
||||
}
|
||||
|
||||
_templateMgr.prepareIsoForVmProfile(profile);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,6 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
|
|||
|
||||
public static final String VM_WORK_JOB_HANDLER = VMSnapshotManagerImpl.class.getSimpleName();
|
||||
|
||||
String _name;
|
||||
@Inject
|
||||
VMInstanceDao _vmInstanceDao;
|
||||
@Inject VMSnapshotDao _vmSnapshotDao;
|
||||
|
|
|
|||
|
|
@ -596,7 +596,7 @@ public class MockNetworkModelImpl extends ManagerBase implements NetworkModel {
|
|||
* @see com.cloud.network.NetworkModel#isPrivateGateway(com.cloud.vm.Nic)
|
||||
*/
|
||||
@Override
|
||||
public boolean isPrivateGateway(Nic guestNic) {
|
||||
public boolean isPrivateGateway(long ntwkId) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -610,7 +610,7 @@ public class MockNetworkModelImpl extends ManagerBase implements NetworkModel {
|
|||
* @see com.cloud.network.NetworkModel#isPrivateGateway(com.cloud.vm.Nic)
|
||||
*/
|
||||
@Override
|
||||
public boolean isPrivateGateway(Nic guestNic) {
|
||||
public boolean isPrivateGateway(long ntwkId) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,4 +46,6 @@
|
|||
<bean id="UservmDetailsDaoImpl" class="com.cloud.vm.dao.UserVmDetailsDaoImpl" />
|
||||
<bean id="usageEventDaoImpl" class="com.cloud.event.dao.UsageEventDaoImpl" />
|
||||
<bean id="usageEventDetailsDaoImpl" class="com.cloud.event.dao.UsageEventDetailsDaoImpl" />
|
||||
<bean id="storagePoolHostDaoImpl" class="com.cloud.storage.dao.StoragePoolHostDaoImpl" />
|
||||
<bean id="primaryDataStoreDaoImpl" class="org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDaoImpl" />
|
||||
</beans>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you under the Apache License, Version 2.0 (the
|
||||
-- "License"); you may not use this file except in compliance
|
||||
-- with the License. You may obtain a copy of the License at
|
||||
--
|
||||
-- http://www.apache.org/licenses/LICENSE-2.0
|
||||
--
|
||||
-- Unless required by applicable law or agreed to in writing,
|
||||
-- software distributed under the License is distributed on an
|
||||
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
-- KIND, either express or implied. See the License for the
|
||||
-- specific language governing permissions and limitations
|
||||
-- under the License.
|
||||
|
||||
|
||||
INSERT INTO `cloud`.`hypervisor_capabilities` (uuid, hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled, max_data_volumes_limit, max_hosts_per_cluster, storage_motion_supported, vm_snapshot_enabled) values (UUID(), 'Simulator', 'default', 50, 1, 6, NULL, 0, 1);
|
||||
|
|
@ -0,0 +1,452 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
""" Tests for Multiple IPs per NIC feature
|
||||
|
||||
Test Plan: https://cwiki.apache.org/confluence/display/CLOUDSTACK/Multiple+IPs+per+NIC+Test+Plan
|
||||
|
||||
Issue Link: https://issues.apache.org/jira/browse/CLOUDSTACK-4840
|
||||
|
||||
Design Document: https://cwiki.apache.org/confluence/display/CLOUDSTACK/Multiple+IP+address+per+NIC
|
||||
"""
|
||||
from marvin.cloudstackTestCase import cloudstackTestCase
|
||||
from marvin.integration.lib.utils import (cleanup_resources,
|
||||
validateList,
|
||||
random_gen)
|
||||
from marvin.integration.lib.base import (Account,
|
||||
ServiceOffering,
|
||||
Network,
|
||||
VirtualMachine,
|
||||
VpcOffering,
|
||||
VPC,
|
||||
NIC,
|
||||
Domain,
|
||||
PublicIPAddress)
|
||||
from marvin.integration.lib.common import (get_domain,
|
||||
get_zone,
|
||||
get_template,
|
||||
get_free_vlan,
|
||||
setSharedNetworkParams,
|
||||
createEnabledNetworkOffering,
|
||||
shouldTestBeSkipped)
|
||||
|
||||
from nose.plugins.attrib import attr
|
||||
from marvin.codes import PASS, ISOLATED_NETWORK, VPC_NETWORK, SHARED_NETWORK
|
||||
from ddt import ddt, data
|
||||
|
||||
def createNetwork(self, networkType):
|
||||
"""Create a network of given type (isolated/shared/isolated in VPC)"""
|
||||
|
||||
network = None
|
||||
|
||||
if networkType == ISOLATED_NETWORK:
|
||||
try:
|
||||
network = Network.create(self.apiclient,self.services["isolated_network"],
|
||||
networkofferingid=self.isolated_network_offering.id,
|
||||
accountid=self.account.name,domainid=self.account.domainid,
|
||||
zoneid=self.zone.id)
|
||||
except Exception as e:
|
||||
self.fail("Isolated network creation failed because: %s" % e)
|
||||
|
||||
elif networkType == SHARED_NETWORK:
|
||||
physical_network, vlan = get_free_vlan(self.api_client, self.zone.id)
|
||||
|
||||
#create network using the shared network offering created
|
||||
self.services["shared_network"]["acltype"] = "domain"
|
||||
self.services["shared_network"]["vlan"] = vlan
|
||||
self.services["shared_network"]["networkofferingid"] = self.shared_network_offering.id
|
||||
self.services["shared_network"]["physicalnetworkid"] = physical_network.id
|
||||
|
||||
self.services["shared_network"] = setSharedNetworkParams(self.services["shared_network"])
|
||||
|
||||
try:
|
||||
network = Network.create(self.api_client, self.services["shared_network"],
|
||||
networkofferingid=self.shared_network_offering.id, zoneid=self.zone.id)
|
||||
self.cleanup.append(network)
|
||||
except Exception as e:
|
||||
self.fail("Shared Network creation failed because: %s" % e)
|
||||
|
||||
elif networkType == VPC_NETWORK:
|
||||
self.services["vpc"]["cidr"] = "10.1.1.1/16"
|
||||
self.debug("creating a VPC network in the account: %s" %
|
||||
self.account.name)
|
||||
vpc = VPC.create(self.apiclient, self.services["vpc"],
|
||||
vpcofferingid=self.vpc_off.id, zoneid=self.zone.id,
|
||||
account=self.account.name, domainid=self.account.domainid)
|
||||
vpcs = VPC.list(self.apiclient, id=vpc.id)
|
||||
self.assertEqual(validateList(vpcs)[0], PASS, "VPC list validation failed, vpc list is %s" % vpcs)
|
||||
|
||||
network = Network.create(self.api_client,self.services["isolated_network"],
|
||||
networkofferingid=self.isolated_network_offering_vpc.id,
|
||||
accountid=self.account.name,domainid=self.account.domainid,
|
||||
zoneid=self.zone.id, vpcid=vpc.id, gateway="10.1.1.1", netmask="255.255.255.0")
|
||||
return network
|
||||
|
||||
def CreateEnabledNetworkOffering(apiclient, networkServices):
|
||||
"""Create network offering of given services and enable it"""
|
||||
|
||||
result = createEnabledNetworkOffering(apiclient, networkServices)
|
||||
assert result[0] == PASS, "Network offering creation/enabling failed due to %s" % result[2]
|
||||
return result[1]
|
||||
|
||||
@ddt
|
||||
class TestBasicOperations(cloudstackTestCase):
|
||||
"""Test Basic operations (add/remove/list) IP to/from NIC
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cloudstackTestClient = super(TestBasicOperations,cls).getClsTestClient()
|
||||
cls.api_client = cloudstackTestClient.getApiClient()
|
||||
|
||||
# Fill services from the external config file
|
||||
cls.services = cloudstackTestClient.getConfigParser().parsedDict
|
||||
|
||||
# Get Zone, Domain and templates
|
||||
cls.domain = get_domain(cls.api_client, cls.services)
|
||||
cls.zone = get_zone(cls.api_client, cls.services)
|
||||
cls.mode = str(cls.zone.networktype).lower()
|
||||
cls.template = get_template(
|
||||
cls.api_client,
|
||||
cls.zone.id,
|
||||
cls.services["ostype"]
|
||||
)
|
||||
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
|
||||
cls.services["virtual_machine"]["template"] = cls.template.id
|
||||
cls.service_offering = ServiceOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["service_offering"]
|
||||
)
|
||||
cls._cleanup = [cls.service_offering]
|
||||
cls.services["shared_network_offering"]["specifyVlan"] = "True"
|
||||
cls.services["shared_network_offering"]["specifyIpRanges"] = "True"
|
||||
|
||||
cls.shared_network_offering = CreateEnabledNetworkOffering(cls.api_client,
|
||||
cls.services["shared_network_offering"])
|
||||
cls._cleanup.append(cls.shared_network_offering)
|
||||
|
||||
if cls.mode == "advanced":
|
||||
cls.isolated_network_offering = CreateEnabledNetworkOffering(cls.api_client,
|
||||
cls.services["isolated_network_offering"])
|
||||
cls._cleanup.append(cls.isolated_network_offering)
|
||||
cls.isolated_network_offering_vpc = CreateEnabledNetworkOffering(cls.api_client,
|
||||
cls.services["nw_offering_isolated_vpc"])
|
||||
cls._cleanup.append(cls.isolated_network_offering_vpc)
|
||||
cls.vpc_off = VpcOffering.create(cls.api_client, cls.services["vpc_offering"])
|
||||
cls.vpc_off.update(cls.api_client, state='Enabled')
|
||||
cls._cleanup.append(cls.vpc_off)
|
||||
return
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
try:
|
||||
# Cleanup resources used
|
||||
cleanup_resources(cls.api_client, cls._cleanup)
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
return
|
||||
|
||||
def setUp(self):
|
||||
self.apiclient = self.testClient.getApiClient()
|
||||
self.dbclient = self.testClient.getDbConnection()
|
||||
self.cleanup = [ ]
|
||||
return
|
||||
|
||||
def tearDown(self):
|
||||
try:
|
||||
# Clean up, terminate the resources created
|
||||
cleanup_resources(self.apiclient, self.cleanup)
|
||||
self.cleanup[:] = []
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
return
|
||||
|
||||
def VerifyStaticNatForPublicIp(self, ipaddressid, natrulestatus):
|
||||
""" List public IP and verify that NAT rule status for the IP is as desired """
|
||||
|
||||
publiciplist = PublicIPAddress.list(self.apiclient, id=ipaddressid, listall=True)
|
||||
self.assertEqual(validateList(publiciplist)[0], PASS, "Public IP list validation failed")
|
||||
self.assertEqual(publiciplist[0].isstaticnat, natrulestatus, "isstaticnat should be %s, it is %s" %
|
||||
(natrulestatus, publiciplist[0].isstaticnat))
|
||||
|
||||
return
|
||||
|
||||
@data(ISOLATED_NETWORK, SHARED_NETWORK, VPC_NETWORK)
|
||||
@attr(tags=["basic","advanced"])
|
||||
def test_add_ip_to_nic(self, value):
|
||||
""" Add secondary IP to NIC of a VM"""
|
||||
|
||||
# Steps:
|
||||
# 1. Create Account and create network in it (isoalted/ shared/ vpc)
|
||||
# 2. Deploy a VM in this network and account
|
||||
# 3. Add secondary IP to the default nic of VM
|
||||
# 4. Try to add the same IP again
|
||||
# 5. Try to add secondary IP providing wrong virtual machine id
|
||||
# 6. Try to add secondary IP with correct virtual machine id but wrong IP address
|
||||
|
||||
# Validations:
|
||||
# 1. Step 3 should succeed
|
||||
# 2. Step 4 should fail
|
||||
# 3. Step 5 should should fail
|
||||
# 4. Step 6 should fail
|
||||
|
||||
self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id)
|
||||
self.cleanup.append(self.account)
|
||||
|
||||
if(shouldTestBeSkipped(networkType=value, zoneType=self.mode)):
|
||||
self.skipTest("Skipping test as %s network is not supported in basic zone" % value)
|
||||
|
||||
network = createNetwork(self, value)
|
||||
|
||||
try:
|
||||
virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
|
||||
networkids=[network.id],serviceofferingid=self.service_offering.id,
|
||||
accountid=self.account.name,domainid=self.account.domainid)
|
||||
except Exception as e:
|
||||
self.fail("vm creation failed: %s" % e)
|
||||
|
||||
try:
|
||||
ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
|
||||
except Exception as e:
|
||||
self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
|
||||
|
||||
try:
|
||||
NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id, ipaddress=ipaddress_1.ipaddress)
|
||||
self.debug("Adding already added secondary IP %s to NIC of vm %s succeeded, should have failed" %
|
||||
(ipaddress_1.ipaddress, virtual_machine.id))
|
||||
except Exception as e:
|
||||
self.debug("Failed while adding already added secondary IP to NIC of vm %s" % virtual_machine.id)
|
||||
|
||||
try:
|
||||
NIC.addIp(self.apiclient, id=(virtual_machine.nic[0].id + random_gen()))
|
||||
self.fail("Adding secondary IP with wrong NIC id succeded, it shoud have failed")
|
||||
except Exception as e:
|
||||
self.debug("Failed while adding secondary IP to wrong NIC")
|
||||
|
||||
try:
|
||||
NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id, ipaddress = "255.255.255.300")
|
||||
self.fail("Adding secondary IP with wrong ipaddress succeded, it should have failed")
|
||||
except Exception as e:
|
||||
self.debug("Failed while adding wrong secondary IP to NIC of VM %s" % virtual_machine.id)
|
||||
return
|
||||
|
||||
@data(ISOLATED_NETWORK, SHARED_NETWORK, VPC_NETWORK)
|
||||
@attr(tags=["basic","advanced"])
|
||||
def test_remove_ip_from_nic(self, value):
|
||||
""" Remove secondary IP from NIC of a VM"""
|
||||
|
||||
# Steps:
|
||||
# 1. Create Account and create network in it (isoalted/ shared/ vpc)
|
||||
# 2. Deploy a VM in this network and account
|
||||
# 3. Add secondary IP to the default nic of VM
|
||||
# 4. Remove the secondary IP
|
||||
# 5. Try to remove secondary ip by giving incorrect ipaddress id
|
||||
|
||||
# Validations:
|
||||
# 1. Step 4 should succeed
|
||||
# 2. Step 5 should fail
|
||||
|
||||
self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id)
|
||||
self.cleanup.append(self.account)
|
||||
|
||||
if(shouldTestBeSkipped(networkType=value, zoneType=self.mode)):
|
||||
self.skipTest("Skipping test as %s network is not supported in basic zone" % value)
|
||||
|
||||
network = createNetwork(self, value)
|
||||
|
||||
try:
|
||||
virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
|
||||
networkids=[network.id],serviceofferingid=self.service_offering.id,
|
||||
accountid=self.account.name,domainid=self.account.domainid)
|
||||
except Exception as e:
|
||||
self.fail("vm creation failed: %s" % e)
|
||||
|
||||
try:
|
||||
ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
|
||||
except Exception as e:
|
||||
self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
|
||||
|
||||
try:
|
||||
NIC.removeIp(self.apiclient, ipaddressid=ipaddress_1.id)
|
||||
except Exception as e:
|
||||
self.fail("Removing seondary IP %s from NIC failed as expected with Exception %s" % (ipaddress_1.id,e))
|
||||
|
||||
try:
|
||||
NIC.removeIp(self.apiclient, ipaddressid=(ipaddress_1.id + random_gen()))
|
||||
self.fail("Removing invalid IP address, it should have failed")
|
||||
except Exception as e:
|
||||
self.debug("Removing invalid IP failed as expected with Exception %s" % e)
|
||||
return
|
||||
|
||||
@attr(tags=["basic","advanced"])
|
||||
def test_remove_invalid_ip(self):
|
||||
""" Remove invalid ip"""
|
||||
|
||||
# Steps:
|
||||
# 1. Try to remove secondary ip without passing ip address id
|
||||
|
||||
# Validations:
|
||||
# 1. Step 1 should fail
|
||||
|
||||
try:
|
||||
NIC.removeIp(self.apiclient, ipaddressid="")
|
||||
self.fail("Removing IP address without passing IP succeeded, it should have failed")
|
||||
except Exception as e:
|
||||
self.debug("Removing IP from NIC without passing ipaddressid failed as expected with Exception %s" % e)
|
||||
return
|
||||
|
||||
@data(ISOLATED_NETWORK, SHARED_NETWORK, VPC_NETWORK)
|
||||
@attr(tags=["basic","advanced"])
|
||||
def test_list_nics(self, value):
|
||||
"""Test listing nics associated with the ip address"""
|
||||
|
||||
# Steps:
|
||||
# 1. Create Account and create network in it (isoalted/ shared/ vpc)
|
||||
# 2. Deploy a VM in this network and account
|
||||
# 3. Add secondary IP to the default nic of VM
|
||||
# 4. Try to list the secondary ips without passing vm id
|
||||
# 5. Try to list secondary IPs by passing correct vm id
|
||||
# 6. Try to list secondary IPs by passing correct vm id and its nic id
|
||||
# 7. Try to list secondary IPs by passing incorrect vm id and correct nic id
|
||||
# 8. Try to list secondary IPs by passing correct vm id and incorrect nic id
|
||||
# 9. Try to list secondary IPs by passing incorrect vm id and incorrect nic id
|
||||
|
||||
# Validations:
|
||||
# 1. Step 4 should fail
|
||||
# 2. Step 5 should succeed
|
||||
# 3. Step 6 should succeed
|
||||
# 4. Step 7 should fail
|
||||
# 5. Step 8 should fail
|
||||
# 6. Step 9 should fail
|
||||
|
||||
|
||||
self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id)
|
||||
self.cleanup.append(self.account)
|
||||
|
||||
if(shouldTestBeSkipped(networkType=value, zoneType=self.mode)):
|
||||
self.skipTest("Skipping test as %s network is not supported in basic zone" % value)
|
||||
|
||||
network = createNetwork(self, value)
|
||||
|
||||
try:
|
||||
virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
|
||||
networkids=[network.id],serviceofferingid=self.service_offering.id,
|
||||
accountid=self.account.name,domainid=self.account.domainid)
|
||||
except Exception as e:
|
||||
self.fail("vm creation failed: %s" % e)
|
||||
|
||||
try:
|
||||
NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
|
||||
except Exception as e:
|
||||
self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
|
||||
|
||||
try:
|
||||
nics = NIC.list(self.apiclient)
|
||||
self.fail("Listing NICs without passign VM id succeeded, it should have failed, list is %s" % nics)
|
||||
except Exception as e:
|
||||
self.debug("Listing NICs without passing virtual machine id failed as expected")
|
||||
|
||||
try:
|
||||
NIC.list(self.apiclient, virtualmachineid=virtual_machine.id)
|
||||
except Exception as e:
|
||||
self.fail("Listing NICs for virtual machine %s failed with Exception %s" % (virtual_machine.id, e))
|
||||
|
||||
try:
|
||||
NIC.list(self.apiclient, virtualmachineid=virtual_machine.id, nicid=virtual_machine.nic[0].id)
|
||||
except Exception as e:
|
||||
self.fail("Listing NICs for virtual machine %s and nic id %s failed with Exception %s" %
|
||||
(virtual_machine.id, virtual_machine.nic[0].id, e))
|
||||
|
||||
try:
|
||||
nics = NIC.list(self.apiclient, virtualmachineid=(virtual_machine.id + random_gen()), nicid=virtual_machine.nic[0].id)
|
||||
self.fail("Listing NICs with wrong virtual machine id and right nic id succeeded, should have failed")
|
||||
except Exception as e:
|
||||
self.debug("Listing NICs with wrong virtual machine id and right nic failed as expected with Exception %s" % e)
|
||||
|
||||
try:
|
||||
nics = NIC.list(self.apiclient, virtualmachineid=virtual_machine.id, nicid=(virtual_machine.nic[0].id + random_gen()))
|
||||
self.fail("Listing NICs with correct virtual machine id but wrong nic id succeeded, should have failed")
|
||||
except Exception as e:
|
||||
self.debug("Listing NICs with correct virtual machine id but wrong nic id failed as expected with Exception %s" % e)
|
||||
|
||||
try:
|
||||
nics = NIC.list(self.apiclient, virtualmachineid=(virtual_machine.id+random_gen()), nicid=(virtual_machine.nic[0].id + random_gen()))
|
||||
self.fail("Listing NICs with wrong virtual machine id and wrong nic id succeeded, should have failed")
|
||||
except Exception as e:
|
||||
self.debug("Listing NICs with wrong virtual machine id and wrong nic id failed as expected with Exception %s" % e)
|
||||
|
||||
return
|
||||
|
||||
@data(ISOLATED_NETWORK, SHARED_NETWORK, VPC_NETWORK)
|
||||
@attr(tags=["basic","advanced"])
|
||||
def test_operations_non_root_admin_api_client(self, value):
|
||||
"""Test basic operations using non root admin apii client"""
|
||||
|
||||
# Steps:
|
||||
# 1. Create Domain and Account in it
|
||||
# 2. Create network in it (isoalted/ shared/ vpc)
|
||||
# 3. Create User API client of this account
|
||||
# 4. Deploy a VM in this network and account
|
||||
# 5. Add secondary IP to the default nic of VM using non root admin api client
|
||||
# 6. List secondary IPs using non root admin api client
|
||||
# 7. Remove secondary IP using non root admin api client
|
||||
|
||||
# Validations:
|
||||
# 1. All the operations should be successful
|
||||
|
||||
child_domain = Domain.create(self.apiclient,services=self.services["domain"],
|
||||
parentdomainid=self.domain.id)
|
||||
|
||||
self.account = Account.create(self.apiclient,self.services["account"],domainid=child_domain.id)
|
||||
self.cleanup.append(self.account)
|
||||
self.cleanup.append(child_domain)
|
||||
|
||||
apiclient = self.testClient.createUserApiClient(UserName=self.account.name, DomainName=self.account.domain)
|
||||
|
||||
if(shouldTestBeSkipped(networkType=value, zoneType=self.mode)):
|
||||
self.skipTest("Skipping test as %s network is not supported in basic zone" % value)
|
||||
|
||||
network = createNetwork(self, value)
|
||||
|
||||
try:
|
||||
virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
|
||||
networkids=[network.id],serviceofferingid=self.service_offering.id,
|
||||
accountid=self.account.name,domainid=self.account.domainid)
|
||||
except Exception as e:
|
||||
self.fail("vm creation failed: %s" % e)
|
||||
|
||||
try:
|
||||
ipaddress_1 = NIC.addIp(apiclient, id=virtual_machine.nic[0].id)
|
||||
except Exception as e:
|
||||
self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
|
||||
|
||||
try:
|
||||
NIC.list(apiclient, virtualmachineid=virtual_machine.id)
|
||||
except Exception as e:
|
||||
self.fail("Listing NICs for virtual machine %s failed with Exception %s" % (virtual_machine.id, e))
|
||||
|
||||
try:
|
||||
NIC.list(apiclient, virtualmachineid=virtual_machine.id, nicid=virtual_machine.nic[0].id)
|
||||
except Exception as e:
|
||||
self.fail("Listing NICs for virtual machine %s and nic id %s failed with Exception %s" %
|
||||
(virtual_machine.id, virtual_machine.nic[0].id, e))
|
||||
|
||||
try:
|
||||
NIC.removeIp(apiclient, ipaddressid=ipaddress_1.id)
|
||||
except Exception as e:
|
||||
self.fail("Removing seondary IP %s from NIC failed as expected with Exception %s" % (ipaddress_1.id,e))
|
||||
|
||||
return
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -15,14 +15,31 @@
|
|||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
""" Tests for Portable public IP Ranges feature
|
||||
|
||||
Test Plan: https://cwiki.apache.org/confluence/display/CLOUDSTACK/Portable+IP+Test+Execution
|
||||
|
||||
Feature Specifications: https://cwiki.apache.org/confluence/display/CLOUDSTACK/portable+public+IP
|
||||
"""
|
||||
from marvin.cloudstackTestCase import *
|
||||
from marvin.cloudstackAPI import *
|
||||
from marvin.cloudstackException import cloudstackAPIException
|
||||
from marvin.integration.lib.utils import *
|
||||
from marvin.integration.lib.base import *
|
||||
from marvin.integration.lib.common import *
|
||||
from netaddr import *
|
||||
from marvin.cloudstackTestCase import cloudstackTestCase
|
||||
from marvin.integration.lib.utils import cleanup_resources
|
||||
from marvin.integration.lib.base import (Account,
|
||||
NetworkOffering,
|
||||
ServiceOffering,
|
||||
Network,
|
||||
VirtualMachine,
|
||||
PublicIPAddress,
|
||||
FireWallRule,
|
||||
NATRule,
|
||||
PortablePublicIpRange,
|
||||
StaticNATRule)
|
||||
from marvin.integration.lib.common import (get_zone,
|
||||
get_pod,
|
||||
get_domain,
|
||||
get_region,
|
||||
get_template,
|
||||
get_portable_ip_range_services,
|
||||
is_public_ip_in_correct_state)
|
||||
from netaddr import IPAddress
|
||||
from marvin.sshClient import SshClient
|
||||
|
||||
from nose.plugins.attrib import attr
|
||||
|
|
@ -147,7 +164,7 @@ class TestCreatePortablePublicIpRanges(cloudstackTestCase):
|
|||
cls.services["domainid"] = cls.domain.id
|
||||
cls.services["zoneid"] = cls.zone.id
|
||||
cls.services["regionid"] = cls.region.id
|
||||
|
||||
|
||||
cls._cleanup = []
|
||||
return
|
||||
|
||||
|
|
@ -255,7 +272,7 @@ class TestCreatePortablePublicIpRanges(cloudstackTestCase):
|
|||
|
||||
portable_ip_range_services["regionid"] = -1
|
||||
|
||||
#create new portable ip range
|
||||
#create new portable ip range
|
||||
self.debug("Trying to create portable ip range with wrong region id")
|
||||
|
||||
with self.assertRaises(Exception):
|
||||
|
|
@ -655,7 +672,7 @@ class TestAssociatePublicIp(cloudstackTestCase):
|
|||
self.portable_ip_range.id))
|
||||
|
||||
self.cleanup.append(self.portable_ip_range)
|
||||
|
||||
|
||||
return
|
||||
|
||||
def tearDown(self):
|
||||
|
|
@ -715,7 +732,7 @@ class TestAssociatePublicIp(cloudstackTestCase):
|
|||
publicipaddressportable.delete(self.apiclient)
|
||||
|
||||
return
|
||||
|
||||
|
||||
@attr(tags=["advanced"])
|
||||
def test_associate_ip_address_invalid_zone(self):
|
||||
""" Test Associate IP with invalid zone id
|
||||
|
|
@ -739,7 +756,6 @@ class TestAssociatePublicIp(cloudstackTestCase):
|
|||
self.debug("Associating ip address failed")
|
||||
return
|
||||
|
||||
@unittest.skip("SSH failing to portable ip, need to investigate the issue")
|
||||
@attr(tags=["advanced"])
|
||||
def test_associate_ip_address_services_enable_disable(self):
|
||||
""" Test enabling and disabling NAT, Firewall services on portable ip
|
||||
|
|
@ -785,9 +801,15 @@ class TestAssociatePublicIp(cloudstackTestCase):
|
|||
)
|
||||
self.debug("created public ip address (portable): %s" % portableip.ipaddress.ipaddress)
|
||||
|
||||
# Open up firewall port for SSH
|
||||
self.debug("Opening firewall on the portable public ip")
|
||||
fw_rule = FireWallRule.create(
|
||||
ipInCorrectState = is_public_ip_in_correct_state(self.apiclient, portableip.ipaddress.id, state="allocated")
|
||||
if not ipInCorrectState:
|
||||
portableip.delete(self.apiclient)
|
||||
self.fail("Portable IP not in allocated state even after 10 mins")
|
||||
|
||||
try:
|
||||
# Open up firewall port for SSH
|
||||
self.debug("Opening firewall on the portable public ip")
|
||||
fw_rule = FireWallRule.create(
|
||||
self.apiclient,
|
||||
ipaddressid=portableip.ipaddress.id,
|
||||
protocol=self.services["natrule"]["protocol"],
|
||||
|
|
@ -796,14 +818,17 @@ class TestAssociatePublicIp(cloudstackTestCase):
|
|||
endport=self.services["natrule"]["publicport"]
|
||||
)
|
||||
|
||||
#Create NAT rule
|
||||
self.debug("Creating NAT rule on the portable public ip")
|
||||
nat_rule = NATRule.create(
|
||||
#Create NAT rule
|
||||
self.debug("Creating NAT rule on the portable public ip")
|
||||
nat_rule = NATRule.create(
|
||||
self.apiclient,
|
||||
self.virtual_machine,
|
||||
self.services["natrule"],
|
||||
portableip.ipaddress.id
|
||||
)
|
||||
except Exception as e:
|
||||
portableip.delete(self.apiclient)
|
||||
self.fail("Error: %s" % e)
|
||||
|
||||
try:
|
||||
|
||||
|
|
@ -991,7 +1016,7 @@ class TestDisassociatePublicIp(cloudstackTestCase):
|
|||
new_portable_ip_range.id))
|
||||
|
||||
self.cleanup.append(new_portable_ip_range)
|
||||
|
||||
|
||||
return
|
||||
|
||||
def tearDown(self):
|
||||
|
|
@ -1002,7 +1027,7 @@ class TestDisassociatePublicIp(cloudstackTestCase):
|
|||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
return
|
||||
|
||||
|
||||
@attr(tags=["advanced"])
|
||||
def test_disassociate_ip_address_no_services(self):
|
||||
""" Test disassociating portable ip
|
||||
|
|
@ -1054,9 +1079,15 @@ class TestDisassociatePublicIp(cloudstackTestCase):
|
|||
)
|
||||
self.debug("created public ip address (portable): %s" % portableip.ipaddress.ipaddress)
|
||||
|
||||
# Open up firewall port for SSH
|
||||
self.debug("Opening firewall on the portable public ip")
|
||||
FireWallRule.create(
|
||||
ipInCorrectState = is_public_ip_in_correct_state(self.apiclient, portableip.ipaddress.id, state="allocated")
|
||||
if not ipInCorrectState:
|
||||
portableip.delete(self.apiclient)
|
||||
self.fail("Portable IP not in allocated state even after 10 mins")
|
||||
|
||||
try:
|
||||
# Open up firewall port for SSH
|
||||
self.debug("Opening firewall on the portable public ip")
|
||||
FireWallRule.create(
|
||||
self.apiclient,
|
||||
ipaddressid=portableip.ipaddress.id,
|
||||
protocol=self.services["natrule"]["protocol"],
|
||||
|
|
@ -1065,14 +1096,17 @@ class TestDisassociatePublicIp(cloudstackTestCase):
|
|||
endport=self.services["natrule"]["publicport"]
|
||||
)
|
||||
|
||||
#Create NAT rule
|
||||
self.debug("Creating NAT rule on the portable public ip")
|
||||
NATRule.create(
|
||||
#Create NAT rule
|
||||
self.debug("Creating NAT rule on the portable public ip")
|
||||
NATRule.create(
|
||||
self.apiclient,
|
||||
self.virtual_machine,
|
||||
self.services["natrule"],
|
||||
portableip.ipaddress.id
|
||||
)
|
||||
except Exception as e:
|
||||
portableip.delete(self.apiclient)
|
||||
self.fail("Error: %s" % e)
|
||||
|
||||
try:
|
||||
self.debug("Disassociating portable ip: %s with id: %s" %
|
||||
|
|
@ -1310,9 +1344,16 @@ class TestDeleteAccount(cloudstackTestCase):
|
|||
)
|
||||
self.debug("created public ip address (portable): %s" % portableip.ipaddress.ipaddress)
|
||||
|
||||
# Open up firewall port for SSH
|
||||
self.debug("Opening firewall on the portable public ip")
|
||||
FireWallRule.create(
|
||||
ipInCorrectState = is_public_ip_in_correct_state(self.apiclient, portableip.ipaddress.id, state="allocated")
|
||||
if not ipInCorrectState:
|
||||
portableip.delete(self.apiclient)
|
||||
self.account.delete(self.apiclient)
|
||||
self.fail("Portable IP not in allocated state even after 10 mins")
|
||||
|
||||
try:
|
||||
# Open up firewall port for SSH
|
||||
self.debug("Opening firewall on the portable public ip")
|
||||
FireWallRule.create(
|
||||
self.apiclient,
|
||||
ipaddressid=portableip.ipaddress.id,
|
||||
protocol=self.services["natrule"]["protocol"],
|
||||
|
|
@ -1321,14 +1362,18 @@ class TestDeleteAccount(cloudstackTestCase):
|
|||
endport=self.services["natrule"]["publicport"]
|
||||
)
|
||||
|
||||
#Create NAT rule
|
||||
self.debug("Creating NAT rule on the portable public ip")
|
||||
NATRule.create(
|
||||
#Create NAT rule
|
||||
self.debug("Creating NAT rule on the portable public ip")
|
||||
NATRule.create(
|
||||
self.apiclient,
|
||||
self.virtual_machine,
|
||||
self.services["natrule"],
|
||||
portableip.ipaddress.id
|
||||
)
|
||||
except Exception as e:
|
||||
portableip.delete(self.apiclient)
|
||||
self.account.delete(self.apiclient)
|
||||
self.fail("Error %s" % e)
|
||||
|
||||
self.debug("Deleting account: %s :" % self.account.name)
|
||||
|
||||
|
|
@ -1494,19 +1539,28 @@ class TestPortableIpTransferAcrossNetworks(cloudstackTestCase):
|
|||
networkid=self.network1.id,
|
||||
isportable=True
|
||||
)
|
||||
|
||||
ipInCorrectState = is_public_ip_in_correct_state(self.apiclient, portableip.ipaddress.id, state="allocated")
|
||||
if not ipInCorrectState:
|
||||
portableip.delete(self.apiclient)
|
||||
self.fail("Portable IP not in allocated state even after 10 mins")
|
||||
|
||||
self.debug("created public ip address (portable): %s" % portableip.ipaddress.ipaddress)
|
||||
#Create NAT rule
|
||||
self.debug("Creating NAT rule on the portable public ip")
|
||||
# Enable Static NAT for VM
|
||||
StaticNATRule.enable(
|
||||
|
||||
try:
|
||||
# Enable Static NAT for VM
|
||||
StaticNATRule.enable(
|
||||
self.apiclient,
|
||||
portableip.ipaddress.id,
|
||||
self.virtual_machine2.id,
|
||||
networkid=self.network2.id
|
||||
)
|
||||
# Open up firewall port for SSH
|
||||
self.debug("Opening firewall on the portable public ip")
|
||||
fw_rule = FireWallRule.create(
|
||||
|
||||
# Open up firewall port for SSH
|
||||
self.debug("Opening firewall on the portable public ip")
|
||||
FireWallRule.create(
|
||||
self.apiclient,
|
||||
ipaddressid=portableip.ipaddress.id,
|
||||
protocol=self.services["natrule"]["protocol"],
|
||||
|
|
@ -1514,6 +1568,10 @@ class TestPortableIpTransferAcrossNetworks(cloudstackTestCase):
|
|||
startport=self.services["natrule"]["publicport"],
|
||||
endport=self.services["natrule"]["publicport"]
|
||||
)
|
||||
except Exception as e:
|
||||
portableip.delete(self.apiclient)
|
||||
self.fail("Error: %s" % e)
|
||||
|
||||
static_nat_list = PublicIPAddress.list(
|
||||
self.apiclient,
|
||||
associatednetworkid=self.network2.id,
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -17,12 +17,27 @@
|
|||
""" BVT tests for Virtual Machine Life Cycle
|
||||
"""
|
||||
#Import Local Modules
|
||||
import marvin
|
||||
from marvin.cloudstackTestCase import *
|
||||
from marvin.cloudstackAPI import *
|
||||
from marvin.integration.lib.utils import *
|
||||
from marvin.integration.lib.base import *
|
||||
from marvin.integration.lib.common import *
|
||||
from marvin.cloudstackTestCase import cloudstackTestCase
|
||||
from marvin.cloudstackAPI import (detachIso,
|
||||
attachIso,
|
||||
recoverVirtualMachine,
|
||||
destroyVirtualMachine)
|
||||
from marvin.integration.lib.utils import (cleanup_resources,
|
||||
validateList,
|
||||
get_hypervisor_type)
|
||||
from marvin.integration.lib.base import (Account,
|
||||
ServiceOffering,
|
||||
VirtualMachine,
|
||||
Iso,
|
||||
Host)
|
||||
from marvin.integration.lib.common import (get_domain,
|
||||
get_zone,
|
||||
get_template,
|
||||
list_virtual_machines,
|
||||
list_configurations,
|
||||
list_routers,
|
||||
list_isos)
|
||||
from marvin.codes import PASS
|
||||
from nose.plugins.attrib import attr
|
||||
#Import System modules
|
||||
import time
|
||||
|
|
@ -44,12 +59,12 @@ class Services:
|
|||
"firstname": "Test",
|
||||
"lastname": "User",
|
||||
"username": "test",
|
||||
# Random characters are appended in create account to
|
||||
# Random characters are appended in create account to
|
||||
# ensure unique username generated each time
|
||||
"password": "password",
|
||||
},
|
||||
"small":
|
||||
# Create a small virtual machine instance with disk offering
|
||||
# Create a small virtual machine instance with disk offering
|
||||
{
|
||||
"displayname": "testserver",
|
||||
"username": "root", # VM creds for SSH
|
||||
|
|
@ -60,7 +75,7 @@ class Services:
|
|||
"publicport": 22,
|
||||
"protocol": 'TCP',
|
||||
},
|
||||
"medium": # Create a medium virtual machine instance
|
||||
"medium": # Create a medium virtual machine instance
|
||||
{
|
||||
"displayname": "testserver",
|
||||
"username": "root",
|
||||
|
|
@ -83,7 +98,7 @@ class Services:
|
|||
},
|
||||
"small":
|
||||
{
|
||||
# Small service offering ID to for change VM
|
||||
# Small service offering ID to for change VM
|
||||
# service offering from medium to small
|
||||
"name": "Small Instance",
|
||||
"displaytext": "Small Instance",
|
||||
|
|
@ -109,7 +124,7 @@ class Services:
|
|||
"url": "http://people.apache.org/~tsp/dummy.iso",
|
||||
# Source URL where ISO is located
|
||||
"ostype": 'CentOS 5.3 (64-bit)',
|
||||
"mode": 'HTTP_DOWNLOAD', # Downloading existing ISO
|
||||
"mode": 'HTTP_DOWNLOAD', # Downloading existing ISO
|
||||
},
|
||||
"template": {
|
||||
"displaytext": "Cent OS Template",
|
||||
|
|
@ -126,7 +141,6 @@ class Services:
|
|||
# CentOS 5.3 (64-bit)
|
||||
}
|
||||
|
||||
|
||||
class TestDeployVM(cloudstackTestCase):
|
||||
|
||||
@classmethod
|
||||
|
|
@ -378,7 +392,7 @@ class TestVMLifeCycle(cloudstackTestCase):
|
|||
cleanup_resources(self.apiclient, self.cleanup)
|
||||
return
|
||||
|
||||
|
||||
|
||||
@attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg"])
|
||||
def test_01_stop_vm(self):
|
||||
"""Test Stop Virtual Machine
|
||||
|
|
@ -575,31 +589,37 @@ class TestVMLifeCycle(cloudstackTestCase):
|
|||
# 2. DeployVM on suitable host (with another host in the cluster)
|
||||
# 3. Migrate the VM and assert migration successful
|
||||
|
||||
suitable_hosts = None
|
||||
|
||||
hosts = Host.list(
|
||||
self.apiclient,
|
||||
zoneid=self.zone.id,
|
||||
type='Routing'
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(hosts, list),
|
||||
True,
|
||||
"Check the number of hosts in the zone"
|
||||
)
|
||||
self.assertGreaterEqual(
|
||||
len(hosts),
|
||||
2,
|
||||
"Atleast 2 hosts should be present for VM migration"
|
||||
)
|
||||
self.assertEqual(validateList(hosts)[0], PASS, "hosts list validation failed")
|
||||
|
||||
#identify suitable host
|
||||
clusters = [h.clusterid for h in hosts]
|
||||
#find hosts withe same clusterid
|
||||
clusters = [cluster for index, cluster in enumerate(clusters) if clusters.count(cluster) > 1]
|
||||
if len(hosts) < 2:
|
||||
self.skipTest("At least two hosts should be present in the zone for migration")
|
||||
|
||||
if len(clusters) <= 1:
|
||||
self.skipTest("Migration needs a cluster with at least two hosts")
|
||||
hypervisor = str(get_hypervisor_type(self.apiclient)).lower()
|
||||
|
||||
# For KVM, two hosts used for migration should be present in same cluster
|
||||
# For XenServer and VMware, migration is possible between hosts belonging to different clusters
|
||||
# with the help of XenMotion and Vmotion respectively.
|
||||
|
||||
if hypervisor == "kvm":
|
||||
#identify suitable host
|
||||
clusters = [h.clusterid for h in hosts]
|
||||
#find hosts withe same clusterid
|
||||
clusters = [cluster for index, cluster in enumerate(clusters) if clusters.count(cluster) > 1]
|
||||
|
||||
if len(clusters) <= 1:
|
||||
self.skipTest("In KVM, Live Migration needs two hosts within same cluster")
|
||||
|
||||
suitable_hosts = [host for host in hosts if host.clusterid == clusters[0]]
|
||||
else:
|
||||
suitable_hosts = hosts
|
||||
|
||||
suitable_hosts = [host for host in hosts if host.clusterid == clusters[0]]
|
||||
target_host = suitable_hosts[0]
|
||||
migrate_host = suitable_hosts[1]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
# Update the box
|
||||
apt-get -y update
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
export DEBIAN_PRIORITY=critical
|
||||
|
||||
apt-get -q -y --force-yes update
|
||||
#apt-get -y install linux-headers-$(uname -r) build-essential
|
||||
#apt-get -y install zlib1g-dev libssl-dev libreadline-gplv2-dev
|
||||
apt-get -y install curl unzip
|
||||
apt-get -q -y --force-yes install curl unzip
|
||||
apt-get clean
|
||||
|
||||
# Set up sudo
|
||||
echo 'vagrant ALL=NOPASSWD:/bin/chmod, /bin/cp, /bin/mkdir, /bin/mount, /bin/umount' > /etc/sudoers.d/vagrant
|
||||
|
|
|
|||
|
|
@ -334,6 +334,11 @@ d-i finish-install/reboot_in_progress note
|
|||
# debconf-get-selections --installer > file
|
||||
# debconf-get-selections >> file
|
||||
|
||||
libssl1.0.0 libssl1.0.0/restart-services string
|
||||
libssl1.0.0:amd64 libssl1.0.0/restart-services string
|
||||
|
||||
libssl1.0.0 libssl1.0.0/restart-failed error
|
||||
libssl1.0.0:amd64 libssl1.0.0/restart-failed error
|
||||
|
||||
#### Advanced options
|
||||
### Running custom commands during the installation
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
# Update the box
|
||||
apt-get -y update
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
export DEBIAN_PRIORITY=critical
|
||||
|
||||
apt-get -q -y --force-yes update
|
||||
#below are needed for ruby perhaps
|
||||
#apt-get -y install linux-headers-$(uname -r) build-essential
|
||||
#apt-get -y install zlib1g-dev libssl-dev libreadline-gplv2-dev
|
||||
apt-get -y install curl unzip
|
||||
apt-get -q -y --force-yes install curl unzip
|
||||
|
||||
apt-get clean
|
||||
|
||||
# Set up sudo, TODO: Check security concerns
|
||||
|
|
|
|||
|
|
@ -335,6 +335,12 @@ d-i finish-install/reboot_in_progress note
|
|||
# debconf-get-selections >> file
|
||||
|
||||
|
||||
libssl1.0.0 libssl1.0.0/restart-services string
|
||||
libssl1.0.0:i386 libssl1.0.0/restart-services string
|
||||
|
||||
libssl1.0.0 libssl1.0.0/restart-failed error
|
||||
libssl1.0.0:i386 libssl1.0.0/restart-failed error
|
||||
|
||||
#### Advanced options
|
||||
### Running custom commands during the installation
|
||||
# d-i preseeding is inherently not secure. Nothing in the installer checks
|
||||
|
|
|
|||
|
|
@ -47,3 +47,7 @@ YES = "yes"
|
|||
FAILED = "FAILED"
|
||||
UNKNOWN_ERROR = "Unknown Error"
|
||||
EXCEPTION = "EXCEPTION"
|
||||
BASIC_ZONE = "basic"
|
||||
ISOLATED_NETWORK = "ISOLATED"
|
||||
SHARED_NETWORK = "SHARED"
|
||||
VPC_NETWORK = "VPC"
|
||||
|
|
|
|||
|
|
@ -146,6 +146,239 @@
|
|||
"ostype": "CentOS 5.3 (64-bit)",
|
||||
"sleep": 90,
|
||||
"timeout": 10,
|
||||
"netscaler_VPX": {
|
||||
"ipaddress": "10.223.240.174",
|
||||
"username": "nsroot",
|
||||
"password": "nsroot",
|
||||
"networkdevicetype": "NetscalerVPXLoadBalancer",
|
||||
"publicinterface": "1/1",
|
||||
"privateinterface": "1/2",
|
||||
"numretries": 2,
|
||||
"lbdevicededicated": "True",
|
||||
"lbdevicecapacity": 2,
|
||||
"port": 22
|
||||
},
|
||||
"nw_offering_shared_persistent": {
|
||||
"name": "Network offering for Shared Persistent Network",
|
||||
"displaytext": "Network offering-DA services",
|
||||
"guestiptype": "Shared",
|
||||
"supportedservices": "Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat",
|
||||
"traffictype": "GUEST",
|
||||
"availability": "Optional",
|
||||
"ispersistent": "True",
|
||||
"serviceProviderList": {
|
||||
"Dhcp": "VirtualRouter",
|
||||
"Dns": "VirtualRouter",
|
||||
"SourceNat": "VirtualRouter",
|
||||
"PortForwarding": "VirtualRouter",
|
||||
"Vpn": "VirtualRouter",
|
||||
"Firewall": "VirtualRouter",
|
||||
"Lb": "VirtualRouter",
|
||||
"UserData": "VirtualRouter",
|
||||
"StaticNat": "VirtualRouter"
|
||||
}
|
||||
},
|
||||
"nw_off_isolated_persistent": {
|
||||
"name": "Network offering for Isolated Persistent Network",
|
||||
"displaytext": "Network Offering for Isolated Persistent Network",
|
||||
"guestiptype": "Isolated",
|
||||
"supportedservices": "Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat",
|
||||
"traffictype":"GUEST",
|
||||
"availability":"Optional",
|
||||
"ispersistent": "True",
|
||||
"serviceProviderList": {
|
||||
"Dhcp": "VirtualRouter",
|
||||
"Dns": "VirtualRouter",
|
||||
"SourceNat": "VirtualRouter",
|
||||
"PortForwarding": "VirtualRouter",
|
||||
"Vpn": "VirtualRouter",
|
||||
"Firewall": "VirtualRouter",
|
||||
"Lb": "VirtualRouter",
|
||||
"UserData": "VirtualRouter",
|
||||
"StaticNat": "VirtualRouter"
|
||||
}
|
||||
},
|
||||
"nw_off_isolated_persistent_netscaler": {
|
||||
"name": "Network offering for Isolated Persistent Network",
|
||||
"displaytext": "Network Offering for Isolated Persistent Network",
|
||||
"guestiptype": "Isolated",
|
||||
"supportedservices": "Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat",
|
||||
"traffictype": "GUEST",
|
||||
"availability": "Optional",
|
||||
"ispersistent": "True",
|
||||
"serviceProviderList": {
|
||||
"Dhcp": "VirtualRouter",
|
||||
"Dns": "VirtualRouter",
|
||||
"SourceNat": "VirtualRouter",
|
||||
"PortForwarding": "VirtualRouter",
|
||||
"Vpn": "VirtualRouter",
|
||||
"Firewall": "VirtualRouter",
|
||||
"Lb": "Netscaler",
|
||||
"UserData": "VirtualRouter",
|
||||
"StaticNat": "VirtualRouter"
|
||||
}
|
||||
},
|
||||
"nw_offering_isolated": {
|
||||
"name": "Network offering for Isolated Persistent Network",
|
||||
"displaytext": "Network offering-DA services",
|
||||
"guestiptype": "Isolated",
|
||||
"supportedservices": "Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat",
|
||||
"traffictype": "GUEST",
|
||||
"availability": "Optional",
|
||||
"serviceProviderList": {
|
||||
"Dhcp": "VirtualRouter",
|
||||
"Dns": "VirtualRouter",
|
||||
"SourceNat": "VirtualRouter",
|
||||
"PortForwarding": "VirtualRouter",
|
||||
"Vpn": "VirtualRouter",
|
||||
"Firewall": "VirtualRouter",
|
||||
"Lb": "VirtualRouter",
|
||||
"UserData": "VirtualRouter",
|
||||
"StaticNat": "VirtualRouter"
|
||||
}
|
||||
},
|
||||
"nw_off_isolated_netscaler": {
|
||||
"name": "Network offering for Isolated Persistent Network",
|
||||
"displaytext": "Network offering-DA services",
|
||||
"guestiptype": "Isolated",
|
||||
"supportedservices": "Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat",
|
||||
"traffictype": "GUEST",
|
||||
"availability": "Optional",
|
||||
"serviceProviderList": {
|
||||
"Dhcp": "VirtualRouter",
|
||||
"Dns": "VirtualRouter",
|
||||
"SourceNat": "VirtualRouter",
|
||||
"PortForwarding": "VirtualRouter",
|
||||
"Vpn": "VirtualRouter",
|
||||
"Firewall": "VirtualRouter",
|
||||
"Lb": "Netscaler",
|
||||
"UserData": "VirtualRouter",
|
||||
"StaticNat": "VirtualRouter"
|
||||
}
|
||||
},
|
||||
"nw_off_persistent_RVR": {
|
||||
"name": "Network offering-RVR services",
|
||||
"displaytext": "Network off-RVR services",
|
||||
"guestiptype": "Isolated",
|
||||
"supportedservices": "Vpn,Dhcp,Dns,SourceNat,PortForwarding,Firewall,Lb,UserData,StaticNat",
|
||||
"traffictype": "GUEST",
|
||||
"availability": "Optional",
|
||||
"ispersistent": "True",
|
||||
"serviceProviderList": {
|
||||
"Vpn": "VirtualRouter",
|
||||
"Dhcp": "VirtualRouter",
|
||||
"Dns": "VirtualRouter",
|
||||
"SourceNat": "VirtualRouter",
|
||||
"PortForwarding": "VirtualRouter",
|
||||
"Firewall": "VirtualRouter",
|
||||
"Lb": "VirtualRouter",
|
||||
"UserData": "VirtualRouter",
|
||||
"StaticNat": "VirtualRouter"
|
||||
},
|
||||
"serviceCapabilityList": {
|
||||
"SourceNat": {
|
||||
"SupportedSourceNatTypes": "peraccount",
|
||||
"RedundantRouter": "true"
|
||||
},
|
||||
"lb": {
|
||||
"SupportedLbIsolation": "dedicated"
|
||||
}
|
||||
}
|
||||
},
|
||||
"nw_off_persistent_VPCVR_NoLB": {
|
||||
"name": "Persistent Network VPC No LB",
|
||||
"displaytext": "Persistent Network VPC No LB",
|
||||
"guestiptype": "Isolated",
|
||||
"supportedservices": "Dhcp,Dns,SourceNat,PortForwarding,Vpn,UserData,StaticNat,NetworkACL",
|
||||
"traffictype": "GUEST",
|
||||
"availability": "Optional",
|
||||
"ispersistent": "False",
|
||||
"useVpc": "on",
|
||||
"serviceProviderList": {
|
||||
"Dhcp": "VpcVirtualRouter",
|
||||
"Dns": "VpcVirtualRouter",
|
||||
"SourceNat": "VpcVirtualRouter",
|
||||
"PortForwarding": "VpcVirtualRouter",
|
||||
"Vpn": "VpcVirtualRouter",
|
||||
"UserData": "VpcVirtualRouter",
|
||||
"StaticNat": "VpcVirtualRouter",
|
||||
"NetworkACL": "VpcVirtualRouter"
|
||||
}
|
||||
},
|
||||
"nw_off_persistent_VPCVR_LB": {
|
||||
"name": "Persistent Network VPC with LB",
|
||||
"displaytext": "Persistent Network VPC No LB",
|
||||
"guestiptype": "Isolated",
|
||||
"supportedservices": "Dhcp,Dns,SourceNat,PortForwarding,Vpn,Lb,UserData,StaticNat,NetworkACL",
|
||||
"traffictype": "GUEST",
|
||||
"availability": "Optional",
|
||||
"ispersistent": "False",
|
||||
"useVpc": "on",
|
||||
"serviceProviderList": {
|
||||
"Dhcp": "VpcVirtualRouter",
|
||||
"Dns": "VpcVirtualRouter",
|
||||
"SourceNat": "VpcVirtualRouter",
|
||||
"PortForwarding": "VpcVirtualRouter",
|
||||
"Vpn": "VpcVirtualRouter",
|
||||
"Lb": "VpcVirtualRouter",
|
||||
"UserData": "VpcVirtualRouter",
|
||||
"StaticNat": "VpcVirtualRouter",
|
||||
"NetworkACL": "VpcVirtualRouter"
|
||||
}
|
||||
},
|
||||
"nw_offering_isolated_vpc": {
|
||||
"name": "Isolated Network for VPC",
|
||||
"displaytext": "Isolated Network for VPC",
|
||||
"guestiptype": "Isolated",
|
||||
"supportedservices": "Dhcp,Dns,SourceNat,PortForwarding,Vpn,UserData,StaticNat,NetworkACL",
|
||||
"traffictype": "GUEST",
|
||||
"availability": "Optional",
|
||||
"ispersistent": "False",
|
||||
"useVpc": "on",
|
||||
"serviceProviderList": {
|
||||
"Dhcp": "VpcVirtualRouter",
|
||||
"Dns": "VpcVirtualRouter",
|
||||
"SourceNat": "VpcVirtualRouter",
|
||||
"PortForwarding": "VpcVirtualRouter",
|
||||
"Vpn": "VpcVirtualRouter",
|
||||
"UserData": "VpcVirtualRouter",
|
||||
"StaticNat": "VpcVirtualRouter",
|
||||
"NetworkACL": "VpcVirtualRouter"
|
||||
}
|
||||
},
|
||||
"natrule": {
|
||||
"privateport": 22,
|
||||
"publicport": 22,
|
||||
"startport": 22,
|
||||
"endport": 22,
|
||||
"protocol": "TCP",
|
||||
"cidrlist": "0.0.0.0/0"
|
||||
},
|
||||
"fwrule": {
|
||||
"startport": 22,
|
||||
"endport": 22,
|
||||
"cidr": "0.0.0.0/0",
|
||||
"protocol": "TCP"
|
||||
},
|
||||
"lbrule": {
|
||||
"name": "SSH",
|
||||
"alg": "leastconn",
|
||||
# Algorithm used for load balancing
|
||||
"privateport": 22,
|
||||
"publicport": 22,
|
||||
"openfirewall": "False",
|
||||
"startport": 22,
|
||||
"endport": 22,
|
||||
"protocol": "TCP",
|
||||
"cidrlist": "0.0.0.0/0"
|
||||
},
|
||||
"icmprule": {
|
||||
"icmptype": -1,
|
||||
"icmpcode": -1,
|
||||
"cidrlist": "0.0.0.0/0",
|
||||
"protocol": "ICMP"
|
||||
},
|
||||
"host_password": "password",
|
||||
"advanced_sg": {
|
||||
"zone": {
|
||||
"name": "",
|
||||
|
|
|
|||
|
|
@ -131,6 +131,13 @@ class Account:
|
|||
[setattr(cmd, k, v) for k, v in kwargs.items()]
|
||||
return(apiclient.listAccounts(cmd))
|
||||
|
||||
def disable(self, apiclient, lock=False):
|
||||
"""Disable an account"""
|
||||
cmd = disableAccount.disableAccountCmd()
|
||||
cmd.id = self.id
|
||||
cmd.lock = lock
|
||||
apiclient.disableAccount(cmd)
|
||||
|
||||
|
||||
class User:
|
||||
""" User Life Cycle """
|
||||
|
|
@ -3626,3 +3633,32 @@ class Resources:
|
|||
cmd = updateResourceCount.updateResourceCountCmd()
|
||||
[setattr(cmd, k, v) for k, v in kwargs.items()]
|
||||
return(apiclient.updateResourceCount(cmd))
|
||||
|
||||
class NIC:
|
||||
"""NIC related API"""
|
||||
def __init__(self, items):
|
||||
self.__dict__.update(items)
|
||||
|
||||
@classmethod
|
||||
def addIp(cls, apiclient, id, ipaddress=None):
|
||||
"""Add Ip (secondary) to NIC"""
|
||||
cmd = addIpToNic.addIpToNicCmd()
|
||||
cmd.nicid = id
|
||||
if ipaddress:
|
||||
cmd.ipaddress = ipaddress
|
||||
return(apiclient.addIpToNic(cmd))
|
||||
|
||||
@classmethod
|
||||
def removeIp(cls,apiclient,ipaddressid):
|
||||
"""Remove secondary Ip from NIC"""
|
||||
cmd = removeIpFromNic.removeIpFromNicCmd()
|
||||
cmd.id = ipaddressid
|
||||
return(apiclient.addIpToNic(cmd))
|
||||
|
||||
@classmethod
|
||||
def list(cls, apiclient, **kwargs):
|
||||
"""List NICs belonging to a virtual machine"""
|
||||
|
||||
cmd = listNics.listNicsCmd()
|
||||
[setattr(cmd, k, v) for k, v in kwargs.items()]
|
||||
return(apiclient.listNics(cmd))
|
||||
|
|
|
|||
|
|
@ -62,11 +62,16 @@ from marvin.integration.lib.base import (Configurations,
|
|||
Template,
|
||||
Resources,
|
||||
PhysicalNetwork,
|
||||
Host)
|
||||
Host,
|
||||
PublicIPAddress,
|
||||
NetworkOffering,
|
||||
Network)
|
||||
from marvin.integration.lib.utils import (get_process_status,
|
||||
xsplit)
|
||||
xsplit,
|
||||
validateList)
|
||||
|
||||
from marvin.sshClient import SshClient
|
||||
from marvin.codes import PASS, ISOLATED_NETWORK, VPC_NETWORK, BASIC_ZONE, FAIL
|
||||
import random
|
||||
|
||||
#Import System modules
|
||||
|
|
@ -212,17 +217,7 @@ def get_pod(apiclient, zoneid, services=None):
|
|||
def get_template(apiclient, zoneid, ostype, services=None,
|
||||
templatefilter='featured',
|
||||
templatetype='BUILTIN'):
|
||||
"Returns a template"
|
||||
|
||||
cmd = listOsTypes.listOsTypesCmd()
|
||||
cmd.description = ostype
|
||||
ostypes = apiclient.listOsTypes(cmd)
|
||||
|
||||
if isinstance(ostypes, list):
|
||||
ostypeid = ostypes[0].id
|
||||
else:
|
||||
raise Exception(
|
||||
"Failed to find OS type with description: %s" % ostype)
|
||||
"Returns a featured built in template in given zone"
|
||||
|
||||
cmd = listTemplates.listTemplatesCmd()
|
||||
cmd.templatefilter = templatefilter
|
||||
|
|
@ -235,13 +230,13 @@ def get_template(apiclient, zoneid, ostype, services=None,
|
|||
list_templates = apiclient.listTemplates(cmd)
|
||||
|
||||
if isinstance(list_templates, list):
|
||||
assert len(list_templates) > 0, "received empty response on template of type %s"%ostype
|
||||
assert len(list_templates) > 0, "received empty response on featured templates"
|
||||
for template in list_templates:
|
||||
if template.ostypeid == ostypeid and template.isready and template.templatetype == templatetype:
|
||||
if template.isready and template.templatetype == templatetype:
|
||||
return template
|
||||
|
||||
raise Exception("Exception: Failed to find template of type %s with OSTypeID and which is in "
|
||||
"ready state: %s" %(templatetype, ostypeid))
|
||||
raise Exception("Exception: Failed to find built in template which is in "
|
||||
"ready state: %s" % templatetype)
|
||||
return
|
||||
|
||||
|
||||
|
|
@ -907,3 +902,81 @@ def setNonContiguousVlanIds(apiclient, zoneid):
|
|||
return None, None
|
||||
|
||||
return physical_network, vlan
|
||||
|
||||
def is_public_ip_in_correct_state(apiclient, ipaddressid, state):
|
||||
""" Check if the given IP is in the correct state (given)
|
||||
and return True/False accordingly"""
|
||||
retriesCount = 10
|
||||
while True:
|
||||
portableips = PublicIPAddress.list(apiclient, id=ipaddressid)
|
||||
assert validateList(portableips)[0] == PASS, "IPs list validation failed"
|
||||
if str(portableips[0].state).lower() == state:
|
||||
break
|
||||
elif retriesCount == 0:
|
||||
return False
|
||||
else:
|
||||
retriesCount -= 1
|
||||
time.sleep(60)
|
||||
continue
|
||||
return True
|
||||
|
||||
def setSharedNetworkParams(networkServices, range=20):
|
||||
"""Fill up the services dictionary for shared network using random subnet"""
|
||||
|
||||
# @range: range decides the endip. Pass the range as "x" if you want the difference between the startip
|
||||
# and endip as "x"
|
||||
# Set the subnet number of shared networks randomly prior to execution
|
||||
# of each test case to avoid overlapping of ip addresses
|
||||
shared_network_subnet_number = random.randrange(1,254)
|
||||
|
||||
networkServices["gateway"] = "172.16."+str(shared_network_subnet_number)+".1"
|
||||
networkServices["startip"] = "172.16."+str(shared_network_subnet_number)+".2"
|
||||
networkServices["endip"] = "172.16."+str(shared_network_subnet_number)+"."+str(range+1)
|
||||
networkServices["netmask"] = "255.255.255.0"
|
||||
return networkServices
|
||||
|
||||
def createEnabledNetworkOffering(apiclient, networkServices):
|
||||
"""Create and enable network offering according to the type
|
||||
|
||||
@output: List, containing [ Result,Network Offering,Reason ]
|
||||
Ist Argument('Result') : FAIL : If exception or assertion error occurs
|
||||
PASS : If network offering
|
||||
is created and enabled successfully
|
||||
IInd Argument(Net Off) : Enabled network offering
|
||||
In case of exception or
|
||||
assertion error, it will be None
|
||||
IIIrd Argument(Reason) : Reason for failure,
|
||||
default to None
|
||||
"""
|
||||
try:
|
||||
resultSet = [FAIL, None, None]
|
||||
# Create network offering
|
||||
network_offering = NetworkOffering.create(apiclient, networkServices, conservemode=False)
|
||||
|
||||
# Update network offering state from disabled to enabled.
|
||||
NetworkOffering.update(network_offering, apiclient, id=network_offering.id,
|
||||
state="enabled")
|
||||
except Exception as e:
|
||||
resultSet[2] = e
|
||||
return resultSet
|
||||
return [PASS, network_offering, None]
|
||||
|
||||
def shouldTestBeSkipped(networkType, zoneType):
|
||||
"""Decide which test to skip, according to type of network and zone type"""
|
||||
|
||||
# If network type is isolated or vpc and zone type is basic, then test should be skipped
|
||||
skipIt = False
|
||||
if ((networkType.lower() == str(ISOLATED_NETWORK).lower() or networkType.lower() == str(VPC_NETWORK).lower())
|
||||
and (zoneType.lower() == BASIC_ZONE)):
|
||||
skipIt = True
|
||||
return skipIt
|
||||
|
||||
def verifyNetworkState(apiclient, networkid, state):
|
||||
"""List networks and check if the network state matches the given state"""
|
||||
try:
|
||||
networks = Network.list(apiclient, id=networkid)
|
||||
except Exception as e:
|
||||
raise Exception("Failed while fetching network list with error: %s" % e)
|
||||
assert validateList(networks)[0] == PASS, "Networks list validation failed, list is %s" % networks
|
||||
assert str(networks[0].state).lower() == state, "network state should be %s, it is %s" % (state, networks[0].state)
|
||||
return
|
||||
|
|
|
|||
Loading…
Reference in New Issue