本文整理汇总了Java中org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService类的典型用法代码示例。如果您正苦于以下问题:Java NetworkOrchestrationService类的具体用法?Java NetworkOrchestrationService怎么用?Java NetworkOrchestrationService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NetworkOrchestrationService类属于org.apache.cloudstack.engine.orchestration.service包,在下文中一共展示了NetworkOrchestrationService类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isCidrBlacklisted
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; //导入依赖的package包/类
protected boolean isCidrBlacklisted(final String cidr, final long zoneId) {
final String routesStr = NetworkOrchestrationService.GuestDomainSuffix.valueIn(zoneId);
if (routesStr != null && !routesStr.isEmpty()) {
final String[] cidrBlackList = routesStr.split(",");
if (cidrBlackList != null && cidrBlackList.length > 0) {
for (final String blackListedRoute : cidrBlackList) {
if (NetUtils.isNetworksOverlap(blackListedRoute, cidr)) {
return true;
}
}
}
}
return false;
}
示例2: getNetworkOfferingNetworkRate
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; //导入依赖的package包/类
@Override
public Integer getNetworkOfferingNetworkRate(final long networkOfferingId, final Long dataCenterId) {
// validate network offering information
final NetworkOffering no = _entityMgr.findById(NetworkOffering.class, networkOfferingId);
if (no == null) {
throw new InvalidParameterValueException("Unable to find network offering by id=" + networkOfferingId);
}
Integer networkRate;
if (no.getRateMbps() != null) {
networkRate = no.getRateMbps();
} else {
networkRate = NetworkOrchestrationService.NetworkThrottlingRate.valueIn(dataCenterId);
}
// networkRate is unsigned int in netowrkOfferings table, and can't be
// set to -1
// so 0 means unlimited; we convert it to -1, so we are consistent with
// all our other resources where -1 means unlimited
if (networkRate == 0) {
networkRate = -1;
}
return networkRate;
}
示例3: testLockFails
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; //导入依赖的package包/类
@Test(expected = ConcurrentOperationException.class)
public void testLockFails() {
// Prepare
when(mockNwDao.acquireInLockTable(NW_ID_1, NetworkOrchestrationService.NetworkLockTimeout.value()))
.thenReturn(null);
// Execute
try {
deployment.lock();
} finally {
// Assert
verify(mockNwDao, times(1)).acquireInLockTable(NW_ID_1, 600);
assertNull(deployment.tableLockId);
}
}
示例4: testApplyRules
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; //导入依赖的package包/类
@Ignore("Requires database to be set up")
@Test
public void testApplyRules() {
List<FirewallRuleVO> ruleList = new ArrayList<FirewallRuleVO>();
FirewallRuleVO rule = new FirewallRuleVO("rule1", 1, 80, "TCP", 1, 2, 1, FirewallRule.Purpose.Firewall, null, null, null, null);
ruleList.add(rule);
FirewallManagerImpl firewallMgr = (FirewallManagerImpl)_firewallMgr;
NetworkOrchestrationService netMgr = mock(NetworkOrchestrationService.class);
IpAddressManager addrMgr = mock(IpAddressManager.class);
firewallMgr._networkMgr = netMgr;
try {
firewallMgr.applyRules(ruleList, false, false);
verify(addrMgr).applyRules(any(List.class), any(FirewallRule.Purpose.class), any(NetworkRuleApplier.class), anyBoolean());
} catch (ResourceUnavailableException e) {
Assert.fail("Unreachable code");
}
}
示例5: setUp
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; //导入依赖的package包/类
@Before
public void setUp() {
_element._configDao = mock(ConfigurationDao.class);
_element._dcDao = mock(DataCenterDao.class);
_element._hostDao = mock(HostDao.class);
_element._networkMgr = mock(NetworkOrchestrationService.class);
_element._networkModel = mock(NetworkModel.class);
_element._nicDao = mock(NicDao.class);
_element._physicalNetworkDao = mock(PhysicalNetworkDao.class);
_element._physicalNetworkServiceProviderDao = mock(PhysicalNetworkServiceProviderDao.class);
_element._resourceMgr = mock(ResourceManager.class);
_element._ntwkSrvcDao = mock(NetworkServiceMapDao.class);
_element._sspCredentialDao = mock(SspCredentialDao.class);
_element._sspTenantDao = mock(SspTenantDao.class);
_element._sspUuidDao = mock(SspUuidDao.class);
}
示例6: getDefaultSecurityDetails
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; //导入依赖的package包/类
public static Map<NetworkOffering.Detail, String> getDefaultSecurityDetails() {
final Map<NetworkOffering.Detail, String> details = new HashMap<>();
details.put(NetworkOffering.Detail.PromiscuousMode, NetworkOrchestrationService.PromiscuousMode.value().toString());
details.put(NetworkOffering.Detail.MacAddressChanges, NetworkOrchestrationService.MacAddressChanges.value().toString());
details.put(NetworkOffering.Detail.ForgedTransmits, NetworkOrchestrationService.ForgedTransmits.value().toString());
return details;
}
示例7: sendCommandsToRouter
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; //导入依赖的package包/类
@Override
public boolean sendCommandsToRouter(final VirtualRouter router, final Commands cmds) throws AgentUnavailableException, ResourceUnavailableException {
if (!checkRouterVersion(router)) {
s_logger.debug("Router requires upgrade. Unable to send command to router:" + router.getId() + ", router template version : " + router.getTemplateVersion()
+ ", minimal required version : " + NetworkOrchestrationService.MinVRVersion.valueIn(router.getDataCenterId()));
throw new ResourceUnavailableException("Unable to send command. Router requires upgrade", VirtualRouter.class, router.getId());
}
Answer[] answers = null;
try {
answers = _agentMgr.send(router.getHostId(), cmds);
} catch (final OperationTimedoutException e) {
s_logger.warn("Timed Out", e);
throw new AgentUnavailableException("Unable to send commands to virtual router ", router.getHostId(), e);
}
if (answers == null || answers.length != cmds.size()) {
return false;
}
// FIXME: Have to return state for individual command in the future
boolean result = true;
for (final Answer answer : answers) {
if (!answer.getResult()) {
result = false;
break;
}
}
return result;
}
示例8: checkRouterVersion
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; //导入依赖的package包/类
@Override
public boolean checkRouterVersion(final VirtualRouter router) {
if (!VirtualNetworkApplianceManagerImpl.routerVersionCheckEnabled.value()) {
// Router version check is disabled.
return true;
}
if (router.getTemplateVersion() == null) {
return false;
}
final long dcid = router.getDataCenterId();
final String trimmedVersion = Version.trimRouterVersion(router.getTemplateVersion());
return Version.compare(trimmedVersion, NetworkOrchestrationService.MinVRVersion.valueIn(dcid)) >= 0;
}
示例9: getServiceOfferingNetworkRate
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; //导入依赖的package包/类
@Override
public Integer getServiceOfferingNetworkRate(final long serviceOfferingId, final Long dataCenterId) {
// validate network offering information
final ServiceOffering offering = _serviceOfferingDao.findById(serviceOfferingId);
if (offering == null) {
throw new InvalidParameterValueException("Unable to find service offering by id=" + serviceOfferingId);
}
Integer networkRate;
if (offering.getRateMbps() != null) {
networkRate = offering.getRateMbps();
} else {
// for domain router service offering, get network rate from
if (offering.getSystemVmType() != null && offering.getSystemVmType().equalsIgnoreCase(VirtualMachine.Type.DomainRouter.toString())) {
networkRate = NetworkOrchestrationService.NetworkThrottlingRate.valueIn(dataCenterId);
} else {
networkRate = Integer.parseInt(_configDao.getValue(Config.VmNetworkThrottlingRate.key()));
}
}
// networkRate is unsigned int in serviceOffering table, and can't be
// set to -1
// so 0 means unlimited; we convert it to -1, so we are consistent with
// all our other resources where -1 means unlimited
if (networkRate == 0) {
networkRate = -1;
}
return networkRate;
}
示例10: testLock
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; //导入依赖的package包/类
@Test
public void testLock() {
// Prepare
when(mockNwDao.acquireInLockTable(NW_ID_1, NetworkOrchestrationService.NetworkLockTimeout.value()))
.thenReturn(mockNw);
// Execute
deployment.lock();
// Assert
verify(mockNwDao, times(1)).acquireInLockTable(NW_ID_1, 600);
assertNotNull(LOCK_NOT_CORRECTLY_GOT, deployment.tableLockId);
assertEquals(LOCK_NOT_CORRECTLY_GOT, NW_ID_1, NW_ID_1, deployment.tableLockId.longValue());
}
示例11: getConfigComponentName
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; //导入依赖的package包/类
@Override
public String getConfigComponentName() {
return NetworkOrchestrationService.class.getSimpleName();
}
示例12: toVirtualMachineTO
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; //导入依赖的package包/类
protected VirtualMachineTO toVirtualMachineTO(VirtualMachineProfile vmProfile) {
ServiceOffering offering = _serviceOfferingDao.findById(vmProfile.getId(), vmProfile.getServiceOfferingId());
VirtualMachine vm = vmProfile.getVirtualMachine();
Long minMemory = (long)(offering.getRamSize() / vmProfile.getMemoryOvercommitRatio());
int minspeed = (int)(offering.getSpeed() / vmProfile.getCpuOvercommitRatio());
int maxspeed = (offering.getSpeed());
VirtualMachineTO to = new VirtualMachineTO(vm.getId(), vm.getInstanceName(), vm.getType(), offering.getCpu(), minspeed, maxspeed, minMemory * 1024l * 1024l,
offering.getRamSize() * 1024l * 1024l, null, null, vm.isHaEnabled(), vm.limitCpuUse(), vm.getVncPassword());
to.setBootArgs(vmProfile.getBootArgs());
List<NicProfile> nicProfiles = vmProfile.getNics();
NicTO[] nics = new NicTO[nicProfiles.size()];
int i = 0;
for (NicProfile nicProfile : nicProfiles) {
if (vm.getType() == VirtualMachine.Type.NetScalerVm) {
nicProfile.setBroadcastType(BroadcastDomainType.Native);
}
NicTO nicTo = toNicTO(nicProfile);
final NetworkVO network = _networkDao.findByUuid(nicTo.getNetworkUuid());
if (network != null) {
final Map<NetworkOffering.Detail, String> details = networkOfferingDetailsDao.getNtwkOffDetails(network.getNetworkOfferingId());
if (details != null) {
details.putIfAbsent(NetworkOffering.Detail.PromiscuousMode, NetworkOrchestrationService.PromiscuousMode.value().toString());
details.putIfAbsent(NetworkOffering.Detail.MacAddressChanges, NetworkOrchestrationService.MacAddressChanges.value().toString());
details.putIfAbsent(NetworkOffering.Detail.ForgedTransmits, NetworkOrchestrationService.ForgedTransmits.value().toString());
}
nicTo.setDetails(details);
}
nics[i++] = nicTo;
}
to.setNics(nics);
to.setDisks(vmProfile.getDisks().toArray(new DiskTO[vmProfile.getDisks().size()]));
if (vmProfile.getTemplate().getBits() == 32) {
to.setArch("i686");
} else {
to.setArch("x86_64");
}
Map<String, String> detailsInVm = _userVmDetailsDao.listDetailsKeyPairs(vm.getId());
if (detailsInVm != null) {
to.setDetails(detailsInVm);
}
// Set GPU details
ServiceOfferingDetailsVO offeringDetail = null;
if ((offeringDetail = _serviceOfferingDetailsDao.findDetail(offering.getId(), GPU.Keys.vgpuType.toString())) != null) {
ServiceOfferingDetailsVO groupName = _serviceOfferingDetailsDao.findDetail(offering.getId(), GPU.Keys.pciDevice.toString());
to.setGpuDevice(_resourceMgr.getGPUDevice(vm.getHostId(), groupName.getValue(), offeringDetail.getValue()));
}
// Workaround to make sure the TO has the UUID we need for Niciri integration
VMInstanceVO vmInstance = _virtualMachineDao.findById(to.getId());
// check if XStools/VMWare tools are present in the VM and dynamic scaling feature is enabled (per zone/global)
Boolean isDynamicallyScalable = vmInstance.isDynamicallyScalable() && UserVmManager.EnableDynamicallyScaleVm.valueIn(vm.getDataCenterId());
to.setEnableDynamicallyScaleVm(isDynamicallyScalable);
to.setUuid(vmInstance.getUuid());
to.setVmData(vmProfile.getVmData());
to.setConfigDriveLabel(vmProfile.getConfigDriveLabel());
to.setConfigDriveIsoRootFolder(vmProfile.getConfigDriveIsoRootFolder());
to.setConfigDriveIsoFile(vmProfile.getConfigDriveIsoFile());
return to;
}
示例13: networkManager
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; //导入依赖的package包/类
@Bean
public NetworkOrchestrationService networkManager() {
return Mockito.mock(NetworkOrchestrationService.class);
}
示例14: getDomRVersion
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; //导入依赖的package包/类
@Override
public GetDomRVersionAnswer getDomRVersion(final GetDomRVersionCmd cmd) {
final String template_version = "CloudStack Release "+ NetworkOrchestrationService.MinVRVersion.defaultValue();
return new GetDomRVersionAnswer(cmd, null, template_version, UUID.randomUUID().toString());
}