Search in sources :

Example 6 with HostVO

use of com.cloud.host.HostVO in project cloudstack by apache.

the class NuageVspElementTest method testApplyStaticNats.

@Test
public void testApplyStaticNats() throws CloudException {
    final Network network = mock(Network.class);
    when(network.getUuid()).thenReturn("aaaaaa");
    when(network.getVpcId()).thenReturn(null);
    when(network.getNetworkOfferingId()).thenReturn(NETWORK_ID);
    when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
    when(network.getDomainId()).thenReturn(NETWORK_ID);
    final DomainVO domVo = mock(DomainVO.class);
    when(_domainDao.findById(41l)).thenReturn(domVo);
    final NetworkOfferingVO ntwkoffer = mock(NetworkOfferingVO.class);
    when(ntwkoffer.getId()).thenReturn(NETWORK_ID);
    when(_networkOfferingDao.findById(NETWORK_ID)).thenReturn(ntwkoffer);
    final HostVO host = mock(HostVO.class);
    when(host.getId()).thenReturn(NETWORK_ID);
    final NuageVspDeviceVO nuageVspDevice = mock(NuageVspDeviceVO.class);
    when(nuageVspDevice.getHostId()).thenReturn(NETWORK_ID);
    when(_nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NuageVspDeviceVO[] { nuageVspDevice }));
    when(_hostDao.findById(NETWORK_ID)).thenReturn(host);
    when(_nuageVspManager.getNuageVspHost(NETWORK_ID)).thenReturn(host);
    when(_domainDao.findById(NETWORK_ID)).thenReturn(mock(DomainVO.class));
    final Answer answer = mock(Answer.class);
    when(answer.getResult()).thenReturn(true);
    when(_agentManager.easySend(eq(NETWORK_ID), (Command) any())).thenReturn(answer);
    assertTrue(_nuageVspElement.applyStaticNats(network, new ArrayList<StaticNat>()));
}
Also used : NuageVspDeviceVO(com.cloud.network.NuageVspDeviceVO) DomainVO(com.cloud.domain.DomainVO) Answer(com.cloud.agent.api.Answer) Network(com.cloud.network.Network) PhysicalNetwork(com.cloud.network.PhysicalNetwork) ArrayList(java.util.ArrayList) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) HostVO(com.cloud.host.HostVO) NuageTest(com.cloud.NuageTest) Test(org.junit.Test)

Example 7 with HostVO

use of com.cloud.host.HostVO in project cloudstack by apache.

the class NuageVspElementTest method testImplement.

@Test
public void testImplement() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException, URISyntaxException {
    final Network network = mock(Network.class);
    when(network.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Vsp);
    when(network.getId()).thenReturn(NETWORK_ID);
    when(network.getVpcId()).thenReturn(null);
    when(network.getBroadcastUri()).thenReturn(new URI(""));
    when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
    when(network.getDomainId()).thenReturn(NETWORK_ID);
    when(network.getDataCenterId()).thenReturn(NETWORK_ID);
    when(_networkModel.isProviderForNetwork(Provider.NuageVsp, NETWORK_ID)).thenReturn(true);
    final NetworkOffering offering = mock(NetworkOffering.class);
    when(offering.getId()).thenReturn(NETWORK_ID);
    when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
    when(offering.getGuestType()).thenReturn(GuestType.Isolated);
    DeployDestination deployDest = mock(DeployDestination.class);
    final DomainVO dom = mock(DomainVO.class);
    when(dom.getName()).thenReturn("domain");
    when(_domainDao.findById(NETWORK_ID)).thenReturn(dom);
    final Account acc = mock(Account.class);
    when(acc.getAccountName()).thenReturn("accountname");
    final ReservationContext context = mock(ReservationContext.class);
    when(context.getDomain()).thenReturn(dom);
    when(context.getAccount()).thenReturn(acc);
    final HostVO host = mock(HostVO.class);
    when(host.getId()).thenReturn(NETWORK_ID);
    final NuageVspDeviceVO nuageVspDevice = mock(NuageVspDeviceVO.class);
    when(nuageVspDevice.getHostId()).thenReturn(NETWORK_ID);
    when(_nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NuageVspDeviceVO[] { nuageVspDevice }));
    when(_hostDao.findById(NETWORK_ID)).thenReturn(host);
    when(_nuageVspManager.getNuageVspHost(NETWORK_ID)).thenReturn(host);
    when(_firewallRulesDao.listByNetworkPurposeTrafficType(NETWORK_ID, FirewallRule.Purpose.Firewall, FirewallRule.TrafficType.Ingress)).thenReturn(new ArrayList<FirewallRuleVO>());
    when(_firewallRulesDao.listByNetworkPurposeTrafficType(NETWORK_ID, FirewallRule.Purpose.Firewall, FirewallRule.TrafficType.Egress)).thenReturn(new ArrayList<FirewallRuleVO>());
    when(_ipAddressDao.listStaticNatPublicIps(NETWORK_ID)).thenReturn(new ArrayList<IPAddressVO>());
    when(_nuageVspManager.getDnsDetails(network.getDataCenterId())).thenReturn(new ArrayList<String>());
    assertTrue(_nuageVspElement.implement(network, offering, deployDest, context));
}
Also used : NuageVspDeviceVO(com.cloud.network.NuageVspDeviceVO) Account(com.cloud.user.Account) NetworkOffering(com.cloud.offering.NetworkOffering) URI(java.net.URI) HostVO(com.cloud.host.HostVO) FirewallRuleVO(com.cloud.network.rules.FirewallRuleVO) ReservationContext(com.cloud.vm.ReservationContext) DomainVO(com.cloud.domain.DomainVO) DeployDestination(com.cloud.deploy.DeployDestination) Network(com.cloud.network.Network) PhysicalNetwork(com.cloud.network.PhysicalNetwork) IPAddressVO(com.cloud.network.dao.IPAddressVO) NuageTest(com.cloud.NuageTest) Test(org.junit.Test)

Example 8 with HostVO

use of com.cloud.host.HostVO in project cloudstack by apache.

the class NuageVspManagerImpl method createNuageVspDeviceResponse.

@Override
public NuageVspDeviceResponse createNuageVspDeviceResponse(NuageVspDeviceVO nuageVspDeviceVO) {
    HostVO nuageVspHost = _hostDao.findById(nuageVspDeviceVO.getHostId());
    _hostDao.loadDetails(nuageVspHost);
    NuageVspResourceConfiguration resourceConfiguration = NuageVspResourceConfiguration.fromConfiguration(nuageVspHost.getDetails());
    NuageVspDeviceResponse response = new NuageVspDeviceResponse();
    response.setDeviceName(nuageVspDeviceVO.getDeviceName());
    PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(nuageVspDeviceVO.getPhysicalNetworkId());
    if (pnw != null) {
        response.setPhysicalNetworkId(pnw.getUuid());
    }
    response.setId(nuageVspDeviceVO.getUuid());
    response.setProviderName(nuageVspDeviceVO.getProviderName());
    response.setHostName(resourceConfiguration.hostName());
    response.setPort(Integer.parseInt(resourceConfiguration.port()));
    String apiRelativePath = resourceConfiguration.apiRelativePath();
    response.setApiVersion(apiRelativePath.substring(apiRelativePath.lastIndexOf('/') + 1));
    response.setApiRetryCount(Integer.parseInt(resourceConfiguration.retryCount()));
    response.setApiRetryInterval(Long.parseLong(resourceConfiguration.retryInterval()));
    response.setCmsId(resourceConfiguration.nuageVspCmsId());
    response.setObjectName("nuagevspdevice");
    return response;
}
Also used : NuageVspResourceConfiguration(com.cloud.network.resource.NuageVspResourceConfiguration) PhysicalNetwork(com.cloud.network.PhysicalNetwork) HostVO(com.cloud.host.HostVO) NuageVspDeviceResponse(com.cloud.api.response.NuageVspDeviceResponse)

Example 9 with HostVO

use of com.cloud.host.HostVO in project cloudstack by apache.

the class NuageVspManagerImpl method findNuageVspHost.

private HostVO findNuageVspHost(long hostId) {
    HostVO host = _hostDao.findById(hostId);
    _hostDao.loadDetails(host);
    return host;
}
Also used : HostVO(com.cloud.host.HostVO)

Example 10 with HostVO

use of com.cloud.host.HostVO in project cloudstack by apache.

the class VMTemplateHostDaoImpl method findLocalSecondaryStorageByHostTemplate.

// Based on computing node host id, and template id, find out the
// corresponding template_host_ref, assuming local secondary storage and
// computing node is in the same zone, and private ip
@Override
public VMTemplateHostVO findLocalSecondaryStorageByHostTemplate(long hostId, long templateId) {
    HostVO computingHost = _hostDao.findById(hostId);
    SearchCriteria<VMTemplateHostVO> sc = LocalSecondaryStorageSearch.create();
    sc.setJoinParameters("host", "private_ip_address", computingHost.getPrivateIpAddress());
    sc.setJoinParameters("host", "state", com.cloud.host.Status.Up);
    sc.setJoinParameters("host", "data_center_id", computingHost.getDataCenterId());
    sc.setJoinParameters("host", "type", Host.Type.LocalSecondaryStorage);
    sc.setParameters("template_id", templateId);
    sc.setParameters("state", VMTemplateHostVO.Status.DOWNLOADED);
    sc.setParameters("destroyed", false);
    return findOneBy(sc);
}
Also used : VMTemplateHostVO(com.cloud.storage.VMTemplateHostVO) VMTemplateHostVO(com.cloud.storage.VMTemplateHostVO) HostVO(com.cloud.host.HostVO)

Aggregations

HostVO (com.cloud.host.HostVO)631 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)223 ArrayList (java.util.ArrayList)178 Answer (com.cloud.agent.api.Answer)105 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)95 StoragePoolHostVO (com.cloud.storage.StoragePoolHostVO)91 Test (org.junit.Test)81 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)75 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)74 ClusterVO (com.cloud.dc.ClusterVO)72 Account (com.cloud.user.Account)67 HashMap (java.util.HashMap)67 VMInstanceVO (com.cloud.vm.VMInstanceVO)60 ConfigurationException (javax.naming.ConfigurationException)60 NoTransitionException (com.cloud.utils.fsm.NoTransitionException)58 DataCenterVO (com.cloud.dc.DataCenterVO)50 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)48 HostPodVO (com.cloud.dc.HostPodVO)47 DB (com.cloud.utils.db.DB)47 StoragePoolVO (org.apache.cloudstack.storage.datastore.db.StoragePoolVO)46