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>()));
}
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));
}
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;
}
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;
}
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);
}
Aggregations