Search in sources :

Example 11 with HostPodVO

use of com.cloud.dc.HostPodVO in project cloudstack by apache.

the class StorageAllocatorTest method createDb.

protected void createDb() {
    DataCenterVO dc = new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24", null, null, NetworkType.Basic, null, null, true, true, null, null);
    dc = dcDao.persist(dc);
    dcId = dc.getId();
    HostPodVO pod = new HostPodVO(UUID.randomUUID().toString(), dc.getId(), "255.255.255.255", "", 8, "test");
    pod = podDao.persist(pod);
    podId = pod.getId();
    ClusterVO cluster = new ClusterVO(dc.getId(), pod.getId(), "devcloud cluster");
    cluster.setHypervisorType(HypervisorType.XenServer.toString());
    cluster.setClusterType(ClusterType.CloudManaged);
    cluster.setManagedState(ManagedState.Managed);
    cluster = clusterDao.persist(cluster);
    clusterId = cluster.getId();
    DataStoreProvider provider = providerMgr.getDataStoreProvider(DataStoreProvider.DEFAULT_PRIMARY);
    storage = new StoragePoolVO();
    storage.setDataCenterId(dcId);
    storage.setPodId(podId);
    storage.setPoolType(StoragePoolType.NetworkFilesystem);
    storage.setClusterId(clusterId);
    storage.setStatus(StoragePoolStatus.Up);
    storage.setScope(ScopeType.CLUSTER);
    storage.setUsedBytes(1000);
    storage.setCapacityBytes(20000);
    storage.setHostAddress(UUID.randomUUID().toString());
    storage.setPath(UUID.randomUUID().toString());
    storage.setStorageProviderName(provider.getName());
    storage = storagePoolDao.persist(storage);
    storagePoolId = storage.getId();
    storageMgr.createCapacityEntry(storage.getId());
    diskOffering = new DiskOfferingVO();
    diskOffering.setDiskSize(500);
    diskOffering.setName("test-disk");
    diskOffering.setSystemUse(false);
    diskOffering.setUseLocalStorage(false);
    diskOffering.setCustomized(false);
    diskOffering.setRecreatable(false);
    diskOffering = diskOfferingDao.persist(diskOffering);
    diskOfferingId = diskOffering.getId();
    volume = new VolumeVO(Volume.Type.ROOT, "volume", dcId, 1, 1, diskOffering.getId(), diskOffering.getDiskSize(), diskOffering.getMinIops(), diskOffering.getMaxIops(), "");
    volume = volumeDao.persist(volume);
    volumeId = volume.getId();
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) ClusterVO(com.cloud.dc.ClusterVO) VolumeVO(com.cloud.storage.VolumeVO) DiskOfferingVO(com.cloud.storage.DiskOfferingVO) DataStoreProvider(org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) HostPodVO(com.cloud.dc.HostPodVO)

Example 12 with HostPodVO

use of com.cloud.dc.HostPodVO in project cloudstack by apache.

the class SnapshotTest method setUp.

@Test(priority = -1)
public void setUp() {
    ComponentContext.initComponentsLifeCycle();
    host = hostDao.findByGuid(this.getHostGuid());
    if (host != null) {
        dcId = host.getDataCenterId();
        clusterId = host.getClusterId();
        podId = host.getPodId();
        imageStore = this.imageStoreDao.findByName(imageStoreName);
    } else {
        // create data center
        DataCenterVO dc = new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24", null, null, NetworkType.Basic, null, null, true, true, null, null);
        dc = dcDao.persist(dc);
        dcId = dc.getId();
        // create pod
        HostPodVO pod = new HostPodVO(UUID.randomUUID().toString(), dc.getId(), this.getHostGateway(), this.getHostCidr(), 8, "test");
        pod = podDao.persist(pod);
        podId = pod.getId();
        // create xenserver cluster
        ClusterVO cluster = new ClusterVO(dc.getId(), pod.getId(), "devcloud cluster");
        cluster.setHypervisorType(this.getHypervisor().toString());
        cluster.setClusterType(ClusterType.CloudManaged);
        cluster.setManagedState(ManagedState.Managed);
        cluster = clusterDao.persist(cluster);
        clusterId = cluster.getId();
        // create xenserver host
        host = new HostVO(this.getHostGuid());
        host.setName("devcloud xenserver host");
        host.setType(Host.Type.Routing);
        host.setPrivateIpAddress(this.getHostIp());
        host.setDataCenterId(dc.getId());
        host.setVersion("6.0.1");
        host.setAvailable(true);
        host.setSetup(true);
        host.setPodId(podId);
        host.setLastPinged(0);
        host.setResourceState(ResourceState.Enabled);
        host.setHypervisorType(this.getHypervisor());
        host.setClusterId(cluster.getId());
        host = hostDao.persist(host);
        imageStore = new ImageStoreVO();
        imageStore.setName(imageStoreName);
        imageStore.setDataCenterId(dcId);
        imageStore.setProviderName(DataStoreProvider.NFS_IMAGE);
        imageStore.setRole(DataStoreRole.Image);
        imageStore.setUrl(this.getSecondaryStorage());
        imageStore.setUuid(UUID.randomUUID().toString());
        imageStore.setProtocol("nfs");
        imageStore = imageStoreDao.persist(imageStore);
    }
    image = new VMTemplateVO();
    image.setTemplateType(TemplateType.USER);
    image.setUrl(this.getTemplateUrl());
    image.setUniqueName(UUID.randomUUID().toString());
    image.setName(UUID.randomUUID().toString());
    image.setPublicTemplate(true);
    image.setFeatured(true);
    image.setRequiresHvm(true);
    image.setBits(64);
    image.setFormat(Storage.ImageFormat.VHD);
    image.setEnablePassword(true);
    image.setEnableSshKey(true);
    image.setGuestOSId(1);
    image.setBootable(true);
    image.setPrepopulate(true);
    image.setCrossZones(true);
    image.setExtractable(true);
    image = imageDataDao.persist(image);
    /*
         * TemplateDataStoreVO templateStore = new TemplateDataStoreVO();
         *
         * templateStore.setDataStoreId(imageStore.getId());
         * templateStore.setDownloadPercent(100);
         * templateStore.setDownloadState(Status.DOWNLOADED);
         * templateStore.setDownloadUrl(imageStore.getUrl());
         * templateStore.setInstallPath(this.getImageInstallPath());
         * templateStore.setTemplateId(image.getId());
         * templateStoreDao.persist(templateStore);
         */
    DataStore store = this.dataStoreMgr.getDataStore(imageStore.getId(), DataStoreRole.Image);
    TemplateInfo template = templateFactory.getTemplate(image.getId(), DataStoreRole.Image);
    DataObject templateOnStore = store.create(template);
    TemplateObjectTO to = new TemplateObjectTO();
    to.setPath(this.getImageInstallPath());
    to.setFormat(ImageFormat.VHD);
    to.setSize(1000L);
    CopyCmdAnswer answer = new CopyCmdAnswer(to);
    templateOnStore.processEvent(Event.CreateOnlyRequested);
    templateOnStore.processEvent(Event.OperationSuccessed, answer);
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) TemplateInfo(org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo) ClusterVO(com.cloud.dc.ClusterVO) DataObject(org.apache.cloudstack.engine.subsystem.api.storage.DataObject) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) VMTemplateVO(com.cloud.storage.VMTemplateVO) ImageStoreVO(org.apache.cloudstack.storage.datastore.db.ImageStoreVO) TemplateObjectTO(org.apache.cloudstack.storage.to.TemplateObjectTO) HostPodVO(com.cloud.dc.HostPodVO) HostVO(com.cloud.host.HostVO) CopyCmdAnswer(org.apache.cloudstack.storage.command.CopyCmdAnswer) Test(org.testng.annotations.Test)

Example 13 with HostPodVO

use of com.cloud.dc.HostPodVO in project cloudstack by apache.

the class HypervServerDiscoverer method createHostVOForDirectConnectAgent.

// TODO: add test for method
@Override
public final HostVO createHostVOForDirectConnectAgent(final HostVO host, final StartupCommand[] startup, final ServerResource resource, final Map<String, String> details, final List<String> hostTags) {
    StartupCommand firstCmd = startup[0];
    if (!(firstCmd instanceof StartupRoutingCommand)) {
        return null;
    }
    StartupRoutingCommand ssCmd = ((StartupRoutingCommand) firstCmd);
    if (ssCmd.getHypervisorType() != HypervisorType.Hyperv) {
        return null;
    }
    s_logger.info("Host: " + host.getName() + " connected with hypervisor type: " + HypervisorType.Hyperv + ". Checking CIDR...");
    HostPodVO pod = _podDao.findById(host.getPodId());
    DataCenterVO dc = _dcDao.findById(host.getDataCenterId());
    _resourceMgr.checkCIDR(pod, dc, ssCmd.getPrivateIpAddress(), ssCmd.getPrivateNetmask());
    return _resourceMgr.fillRoutingHostVO(host, ssCmd, HypervisorType.Hyperv, details, hostTags);
}
Also used : StartupCommand(com.cloud.agent.api.StartupCommand) DataCenterVO(com.cloud.dc.DataCenterVO) StartupRoutingCommand(com.cloud.agent.api.StartupRoutingCommand) HostPodVO(com.cloud.dc.HostPodVO)

Example 14 with HostPodVO

use of com.cloud.dc.HostPodVO in project cloudstack by apache.

the class StorageNetworkManagerImpl method checkOverlapPrivateIpRange.

private void checkOverlapPrivateIpRange(long podId, String startIp, String endIp) {
    HostPodVO pod = _podDao.findById(podId);
    if (pod == null) {
        throw new CloudRuntimeException("Cannot find pod " + podId);
    }
    String[] IpRange = pod.getDescription().split("-");
    if ((IpRange[0] == null || IpRange[1] == null) || (!NetUtils.isValidIp(IpRange[0]) || !NetUtils.isValidIp(IpRange[1]))) {
        return;
    }
    if (NetUtils.ipRangesOverlap(startIp, endIp, IpRange[0], IpRange[1])) {
        throw new InvalidParameterValueException("The Storage network Start IP and endIP address range overlap with private IP :" + IpRange[0] + ":" + IpRange[1]);
    }
}
Also used : InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) HostPodVO(com.cloud.dc.HostPodVO)

Example 15 with HostPodVO

use of com.cloud.dc.HostPodVO in project cloudstack by apache.

the class HostPodDaoImpl method remove.

@Override
public boolean remove(Long id) {
    TransactionLegacy txn = TransactionLegacy.currentTxn();
    txn.start();
    HostPodVO pod = createForUpdate();
    pod.setName(null);
    update(id, pod);
    boolean result = super.remove(id);
    txn.commit();
    return result;
}
Also used : TransactionLegacy(com.cloud.utils.db.TransactionLegacy) HostPodVO(com.cloud.dc.HostPodVO)

Aggregations

HostPodVO (com.cloud.dc.HostPodVO)68 DataCenterVO (com.cloud.dc.DataCenterVO)32 HostVO (com.cloud.host.HostVO)32 ClusterVO (com.cloud.dc.ClusterVO)31 ArrayList (java.util.ArrayList)29 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)23 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)16 VolumeVO (com.cloud.storage.VolumeVO)14 VMInstanceVO (com.cloud.vm.VMInstanceVO)14 Account (com.cloud.user.Account)13 DB (com.cloud.utils.db.DB)12 Test (org.junit.Test)12 Random (java.util.Random)11 TransactionStatus (com.cloud.utils.db.TransactionStatus)10 ConfigurationException (javax.naming.ConfigurationException)10 HashMap (java.util.HashMap)8 List (java.util.List)8 DataCenter (com.cloud.dc.DataCenter)7 DedicatedResourceVO (com.cloud.dc.DedicatedResourceVO)7 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)6