本文整理匯總了Java中com.cloud.vm.NicVO類的典型用法代碼示例。如果您正苦於以下問題:Java NicVO類的具體用法?Java NicVO怎麽用?Java NicVO使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
NicVO類屬於com.cloud.vm包,在下文中一共展示了NicVO類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateNic
import com.cloud.vm.NicVO; //導入依賴的package包/類
@DB
protected void updateNic(final NicVO nic, final long networkId, final int count) {
Transaction.execute(new TransactionCallbackNoReturn() {
@Override
public void doInTransactionWithoutResult(final TransactionStatus status) {
_nicDao.update(nic.getId(), nic);
if (nic.getVmType() == VirtualMachine.Type.User) {
s_logger.debug("Changing active number of nics for network id=" + networkId + " on " + count);
_networksDao.changeActiveNicsBy(networkId, count);
}
if (nic.getVmType() == VirtualMachine.Type.User
|| nic.getVmType() == VirtualMachine.Type.DomainRouter && _networksDao.findById(networkId).getTrafficType() == TrafficType.Guest) {
_networksDao.setCheckForGc(networkId);
}
}
});
}
示例2: getNicProfiles
import com.cloud.vm.NicVO; //導入依賴的package包/類
@Override
public List<NicProfile> getNicProfiles(final VirtualMachine vm) {
final List<NicVO> nics = _nicDao.listByVmId(vm.getId());
final List<NicProfile> profiles = new ArrayList<>();
if (nics != null) {
for (final Nic nic : nics) {
final NetworkVO network = _networksDao.findById(nic.getNetworkId());
final Integer networkRate = _networkModel.getNetworkRate(network.getId(), vm.getId());
final NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName());
final NicProfile profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), networkRate,
_networkModel.isSecurityGroupSupportedInNetwork(network), _networkModel.getNetworkTag(vm.getHypervisorType(), network));
guru.updateNicProfile(profile, network);
profiles.add(profile);
}
}
return profiles;
}
示例3: reallocate
import com.cloud.vm.NicVO; //導入依賴的package包/類
@DB
@Override
public boolean reallocate(final VirtualMachineProfile vm, final DataCenterDeployment dest) throws InsufficientCapacityException, ConcurrentOperationException {
final VMInstanceVO vmInstance = _vmDao.findById(vm.getId());
final Zone dc = _zoneRepository.findOne(vmInstance.getDataCenterId());
if (dc.getNetworkType() == com.cloud.model.enumeration.NetworkType.Basic) {
final List<NicVO> nics = _nicDao.listByVmId(vmInstance.getId());
final NetworkVO network = _networksDao.findById(nics.get(0).getNetworkId());
final LinkedHashMap<Network, List<? extends NicProfile>> profiles = new LinkedHashMap<>();
profiles.put(network, new ArrayList<>());
Transaction.execute(new TransactionCallbackWithExceptionNoReturn<InsufficientCapacityException>() {
@Override
public void doInTransactionWithoutResult(final TransactionStatus status) throws InsufficientCapacityException {
cleanupNics(vm);
allocate(vm, profiles);
}
});
}
return true;
}
示例4: testRemoveDhcpServiceWithNic
import com.cloud.vm.NicVO; //導入依賴的package包/類
@Test
public void testRemoveDhcpServiceWithNic() {
// make local mocks
final VirtualMachineProfile vm = mock(VirtualMachineProfile.class);
final NicVO nic = mock(NicVO.class);
final NetworkVO network = mock(NetworkVO.class);
// make sure that release dhcp will be called
when(vm.getType()).thenReturn(Type.User);
when(testOrchastrator._networkModel.areServicesSupportedInNetwork(network.getId(), Service.Dhcp)).thenReturn(true);
when(network.getTrafficType()).thenReturn(TrafficType.Guest);
when(network.getGuestType()).thenReturn(GuestType.Shared);
when(testOrchastrator._nicDao.listByNetworkIdTypeAndGatewayAndBroadcastUri(nic.getNetworkId(), VirtualMachine.Type.User, nic.getIPv4Gateway(), nic.getBroadcastUri()))
.thenReturn(new ArrayList<>());
when(network.getGuruName()).thenReturn(guruName);
when(testOrchastrator._networksDao.findById(nic.getNetworkId())).thenReturn(network);
testOrchastrator.removeNic(vm, nic);
verify(nic, times(1)).setState(Nic.State.Deallocating);
verify(testOrchastrator._networkModel, times(2)).getElementImplementingProvider(dhcpProvider);
verify(testOrchastrator._ntwkSrvcDao, times(2)).getProviderForServiceInNetwork(network.getId(), Service.Dhcp);
verify(testOrchastrator._networksDao, times(2)).findById(nic.getNetworkId());
}
示例5: testDontRemoveDhcpServiceFromDomainRouter
import com.cloud.vm.NicVO; //導入依賴的package包/類
@Test
public void testDontRemoveDhcpServiceFromDomainRouter() {
// make local mocks
final VirtualMachineProfile vm = mock(VirtualMachineProfile.class);
final NicVO nic = mock(NicVO.class);
final NetworkVO network = mock(NetworkVO.class);
// make sure that release dhcp won't be called
when(vm.getType()).thenReturn(Type.DomainRouter);
when(network.getGuruName()).thenReturn(guruName);
when(testOrchastrator._networksDao.findById(nic.getNetworkId())).thenReturn(network);
testOrchastrator.removeNic(vm, nic);
verify(nic, times(1)).setState(Nic.State.Deallocating);
verify(testOrchastrator._networkModel, never()).getElementImplementingProvider(dhcpProvider);
verify(testOrchastrator._ntwkSrvcDao, never()).getProviderForServiceInNetwork(network.getId(), Service.Dhcp);
verify(testOrchastrator._networksDao, times(1)).findById(nic.getNetworkId());
}
示例6: getFreeDeviceId
import com.cloud.vm.NicVO; //導入依賴的package包/類
@Override
public int getFreeDeviceId(final long instanceId) {
final Filter searchFilter = new Filter(NicVO.class, "deviceId", true, null, null);
final SearchCriteria<Integer> sc = deviceIdSearch.create();
sc.setParameters("instance", instanceId);
final List<Integer> deviceIds = customSearch(sc, searchFilter);
int freeDeviceId = 0;
for (final int deviceId : deviceIds) {
if (deviceId > freeDeviceId) {
break;
}
freeDeviceId++;
}
return freeDeviceId;
}
示例7: listNonRemovedVmsByTypeAndNetwork
import com.cloud.vm.NicVO; //導入依賴的package包/類
@Override
public List<VMInstanceVO> listNonRemovedVmsByTypeAndNetwork(final long networkId, final VirtualMachine.Type... types) {
if (_networkTypeSearch == null) {
final SearchBuilder<NicVO> nicSearch = _nicDao.createSearchBuilder();
nicSearch.and("networkId", nicSearch.entity().getNetworkId(), SearchCriteria.Op.EQ);
_networkTypeSearch = createSearchBuilder();
_networkTypeSearch.and("types", _networkTypeSearch.entity().getType(), SearchCriteria.Op.IN);
_networkTypeSearch.and("removed", _networkTypeSearch.entity().getRemoved(), SearchCriteria.Op.NULL);
_networkTypeSearch.join("nicSearch", nicSearch, _networkTypeSearch.entity().getId(), nicSearch.entity().getInstanceId(), JoinBuilder.JoinType.INNER);
_networkTypeSearch.done();
}
final SearchCriteria<VMInstanceVO> sc = _networkTypeSearch.create();
if (types != null && types.length != 0) {
sc.setParameters("types", (Object[]) types);
}
sc.setJoinParameters("nicSearch", "networkId", networkId);
return listBy(sc);
}
示例8: removeNicSecondaryIP
import com.cloud.vm.NicVO; //導入依賴的package包/類
private boolean removeNicSecondaryIP(final NicSecondaryIpVO ipVO, final boolean lastIp) {
final long nicId = ipVO.getNicId();
final NicVO nic = _nicDao.findById(nicId);
Transaction.execute(new TransactionCallbackNoReturn() {
@Override
public void doInTransactionWithoutResult(final TransactionStatus status) {
if (lastIp) {
nic.setSecondaryIp(false);
s_logger.debug("Setting nics secondary ip to false ...");
_nicDao.update(nicId, nic);
}
s_logger.debug("Revoving nic secondary ip entry ...");
_nicSecondaryIpDao.remove(ipVO.getId());
}
});
return true;
}
示例9: accept
import com.cloud.vm.NicVO; //導入依賴的package包/類
@Override
public boolean accept(final NetworkTopologyVisitor visitor, final VirtualRouter router) throws ResourceUnavailableException {
_router = router;
final UserVmDao userVmDao = visitor.getVirtualNetworkApplianceFactory().getUserVmDao();
final UserVmVO vm = userVmDao.findById(_profile.getId());
userVmDao.loadDetails(vm);
final NicDao nicDao = visitor.getVirtualNetworkApplianceFactory().getNicDao();
// check if this is not the primary subnet.
final NicVO domrGuestNic = nicDao.findByInstanceIdAndIpAddressAndVmtype(_router.getId(), nicDao.getIpAddress(_nic.getNetworkId(), _router.getId()),
VirtualMachine.Type.DomainRouter);
// check if the router ip address and the vm ip address belong to same
// subnet.
// if they do not belong to same netwoek check for the alias ips. if not
// create one.
// This should happen only in case of Basic and Advanced SG enabled
// networks.
if (!NetUtils.sameSubnet(domrGuestNic.getIPv4Address(), _nic.getIPv4Address(), _nic.getIPv4Netmask())) {
return true;
}
return true;
}
示例10: visit
import com.cloud.vm.NicVO; //導入依賴的package包/類
@Override
public boolean visit(final UserdataPwdRules userdata) throws ResourceUnavailableException {
final VirtualRouter router = userdata.getRouter();
final Commands commands = new Commands(Command.OnError.Stop);
final VirtualMachineProfile profile = userdata.getProfile();
final NicVO nicVO = userdata.getNicVo();
_commandSetupHelper.createPasswordCommand(router, profile, nicVO, commands);
final VMOverviewTO vmOverview = _commandSetupHelper.createVmOverviewFromRouter(router);
final UpdateVmOverviewCommand updateVmOverviewCommand = _commandSetupHelper.createUpdateVmOverviewCommand(router, vmOverview);
commands.addCommand(updateVmOverviewCommand);
return _networkGeneralHelper.sendCommandsToRouter(router, commands);
}
示例11: visit
import com.cloud.vm.NicVO; //導入依賴的package包/類
@Override
public boolean visit(final UserdataPwdRules userdata) throws ResourceUnavailableException {
final VirtualRouter router = userdata.getRouter();
final Commands commands = new Commands(Command.OnError.Stop);
final VirtualMachineProfile profile = userdata.getProfile();
final NicVO nicVO = userdata.getNicVo();
final DeployDestination destination = userdata.getDestination();
if (router.getPodIdToDeployIn() == destination.getPod().getId()) {
_commandSetupHelper.createPasswordCommand(router, profile, nicVO, commands);
final VMOverviewTO vmOverview = _commandSetupHelper.createVmOverviewFromRouter(router);
final UpdateVmOverviewCommand updateVmOverviewCommand = _commandSetupHelper.createUpdateVmOverviewCommand(router, vmOverview);
commands.addCommand(updateVmOverviewCommand);
return _networkGeneralHelper.sendCommandsToRouter(router, commands);
}
return true;
}
示例12: getDefaultNic
import com.cloud.vm.NicVO; //導入依賴的package包/類
@Override
public Nic getDefaultNic(final long vmId) {
final List<NicVO> nics = _nicDao.listByVmId(vmId);
Nic defaultNic = null;
if (nics != null) {
for (final Nic nic : nics) {
if (nic.isDefaultNic()) {
defaultNic = nic;
break;
}
}
} else {
s_logger.debug("Unable to find default network for the vm; vm doesn't have any nics");
return null;
}
if (defaultNic == null) {
s_logger.debug("Unable to find default network for the vm; vm doesn't have default nic");
}
return defaultNic;
}
示例13: getNicProfile
import com.cloud.vm.NicVO; //導入依賴的package包/類
@Override
public NicProfile getNicProfile(final VirtualMachine vm, final long networkId, final String broadcastUri) {
final NicVO nic;
if (broadcastUri != null) {
nic = _nicDao.findByNetworkIdInstanceIdAndBroadcastUri(networkId, vm.getId(), broadcastUri);
} else {
nic = _nicDao.findByNtwkIdAndInstanceId(networkId, vm.getId());
}
if (nic == null) {
return null;
}
final NetworkVO network = _networksDao.findById(networkId);
final Integer networkRate = getNetworkRate(network.getId(), vm.getId());
// NetworkGuru guru = _networkGurus.get(network.getGuruName());
final NicProfile profile =
new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), networkRate, isSecurityGroupSupportedInNetwork(network), getNetworkTag(
vm.getHypervisorType(), network));
// guru.updateNicProfile(profile, network);
return profile;
}
示例14: getRouterControlIp
import com.cloud.vm.NicVO; //導入依賴的package包/類
public String getRouterControlIp(final long routerId) {
String routerControlIpAddress = null;
final List<NicVO> nics = nicDao.listByVmId(routerId);
for (final NicVO n : nics) {
final NetworkVO nc = networkDao.findById(n.getNetworkId());
if (nc != null && nc.getTrafficType() == TrafficType.Control) {
routerControlIpAddress = n.getIPv4Address();
// router will have only one control ip
break;
}
}
if (routerControlIpAddress == null) {
logger.warn("Unable to find router's control ip in its attached NICs!. routerId: " + routerId);
final DomainRouterVO router = routerDao.findById(routerId);
return router.getPrivateIpAddress();
}
return routerControlIpAddress;
}
示例15: queryNicsTableResponse
import com.cloud.vm.NicVO; //導入依賴的package包/類
private void queryNicsTableResponse(final List<WhoHasThisAddressResponse> responsesList, final NicVO nic, final WhoHasThisAddressResponse response) {
response.setIpAddress(nic.getIPv4Address());
response.setUuid(nic.getUuid());
response.setCreated(nic.getCreated());
response.setMode(nic.getMode());
response.setBroadcastUri(nic.getBroadcastUri());
response.setNetmask(nic.getIPv4Netmask());
response.setMacAddress(nic.getMacAddress());
response.setState(nic.getState().toString());
final Network network = _networkDao.findById(nic.getNetworkId());
if (network != null) {
response.setNetworkUuid(network.getUuid());
if (!StringUtils.isEmpty(network.getName())) {
response.setNetworkName(network.getName());
}
}
final VMInstanceVO vm = _vmInstanceDao.findById(nic.getInstanceId());
getVMInfo(response, nic, vm);
responsesList.add(response);
}