use of com.cloud.utils.db.TransactionLegacy in project cloudstack by apache.
the class DedicateGuestVlanRangesTest method runDedicateGuestVlanRangeInvalidFormat.
void runDedicateGuestVlanRangeInvalidFormat() throws Exception {
TransactionLegacy txn = TransactionLegacy.open("runDedicateGuestVlanRangeInvalidFormat");
Field dedicateVlanField = _dedicateGuestVlanRangeClass.getDeclaredField("vlan");
dedicateVlanField.setAccessible(true);
dedicateVlanField.set(dedicateGuestVlanRangesCmd, "2");
PhysicalNetworkVO physicalNetwork = new PhysicalNetworkVO(1L, 1L, "2-5", "200", 1L, null, "testphysicalnetwork");
physicalNetwork.addIsolationMethod("VLAN");
when(networkService._physicalNetworkDao.findById(anyLong())).thenReturn(physicalNetwork);
try {
networkService.dedicateGuestVlanRange(dedicateGuestVlanRangesCmd);
} catch (Exception e) {
Assert.assertTrue(e.getMessage().contains("Invalid format for parameter value vlan"));
} finally {
txn.close("runDedicateGuestVlanRangeInvalidFormat");
}
}
use of com.cloud.utils.db.TransactionLegacy in project cloudstack by apache.
the class DedicateGuestVlanRangesTest method runDedicateGuestVlanRangeDedicatedRange.
void runDedicateGuestVlanRangeDedicatedRange() throws Exception {
TransactionLegacy txn = TransactionLegacy.open("runDedicateGuestVlanRangeDedicatedRange");
Field dedicateVlanField = _dedicateGuestVlanRangeClass.getDeclaredField("vlan");
dedicateVlanField.setAccessible(true);
dedicateVlanField.set(dedicateGuestVlanRangesCmd, "2-5");
PhysicalNetworkVO physicalNetwork = new PhysicalNetworkVO(1L, 1L, "2-5", "200", 1L, null, "testphysicalnetwork");
physicalNetwork.addIsolationMethod("VLAN");
when(networkService._physicalNetworkDao.findById(anyLong())).thenReturn(physicalNetwork);
when(networkService._datacneterVnet.listAllocatedVnetsInRange(anyLong(), anyLong(), anyInt(), anyInt())).thenReturn(null);
List<AccountGuestVlanMapVO> guestVlanMaps = new ArrayList<AccountGuestVlanMapVO>();
AccountGuestVlanMapVO accountGuestVlanMap = new AccountGuestVlanMapVO(1L, 1L);
accountGuestVlanMap.setGuestVlanRange("2-5");
guestVlanMaps.add(accountGuestVlanMap);
when(networkService._accountGuestVlanMapDao.listAccountGuestVlanMapsByPhysicalNetwork(anyLong())).thenReturn(guestVlanMaps);
try {
networkService.dedicateGuestVlanRange(dedicateGuestVlanRangesCmd);
} catch (Exception e) {
Assert.assertTrue(e.getMessage().contains("Vlan range is already dedicated"));
} finally {
txn.close("runDedicateGuestVlanRangeDedicatedRange");
}
}
use of com.cloud.utils.db.TransactionLegacy in project cloudstack by apache.
the class DedicateGuestVlanRangesTest method runDedicateGuestVlanRangeInvalidRangeValue.
void runDedicateGuestVlanRangeInvalidRangeValue() throws Exception {
TransactionLegacy txn = TransactionLegacy.open("runDedicateGuestVlanRangeInvalidRangeValue");
Field dedicateVlanField = _dedicateGuestVlanRangeClass.getDeclaredField("vlan");
dedicateVlanField.setAccessible(true);
dedicateVlanField.set(dedicateGuestVlanRangesCmd, "2-5");
PhysicalNetworkVO physicalNetwork = new PhysicalNetworkVO(1L, 1L, "6-10", "200", 1L, null, "testphysicalnetwork");
physicalNetwork.addIsolationMethod("VLAN");
when(networkService._physicalNetworkDao.findById(anyLong())).thenReturn(physicalNetwork);
try {
networkService.dedicateGuestVlanRange(dedicateGuestVlanRangesCmd);
} catch (Exception e) {
Assert.assertTrue(e.getMessage().contains("Unable to find guest vlan by range"));
} finally {
txn.close("runDedicateGuestVlanRangeInvalidRangeValue");
}
}
use of com.cloud.utils.db.TransactionLegacy in project cloudstack by apache.
the class DedicateGuestVlanRangesTest method runDedicateGuestVlanRangeAllocatedVlans.
void runDedicateGuestVlanRangeAllocatedVlans() throws Exception {
TransactionLegacy txn = TransactionLegacy.open("runDedicateGuestVlanRangeAllocatedVlans");
Field dedicateVlanField = _dedicateGuestVlanRangeClass.getDeclaredField("vlan");
dedicateVlanField.setAccessible(true);
dedicateVlanField.set(dedicateGuestVlanRangesCmd, "2-5");
PhysicalNetworkVO physicalNetwork = new PhysicalNetworkVO(1L, 1L, "2-5", "200", 1L, null, "testphysicalnetwork");
physicalNetwork.addIsolationMethod("VLAN");
when(networkService._physicalNetworkDao.findById(anyLong())).thenReturn(physicalNetwork);
List<DataCenterVnetVO> dataCenterList = new ArrayList<DataCenterVnetVO>();
DataCenterVnetVO dataCenter = new DataCenterVnetVO("2-5", 1L, 1L);
dataCenter.setAccountId(1L);
dataCenterList.add(dataCenter);
when(networkService._datacneterVnet.listAllocatedVnetsInRange(anyLong(), anyLong(), anyInt(), anyInt())).thenReturn(dataCenterList);
try {
networkService.dedicateGuestVlanRange(dedicateGuestVlanRangesCmd);
} catch (Exception e) {
Assert.assertTrue(e.getMessage().contains("is allocated to a different account"));
} finally {
txn.close("runDedicateGuestVlanRangeAllocatedVlans");
}
}
use of com.cloud.utils.db.TransactionLegacy in project cloudstack by apache.
the class ConfigurationManagerTest method runDedicatePublicIpRangePostiveTest.
void runDedicatePublicIpRangePostiveTest() throws Exception {
TransactionLegacy txn = TransactionLegacy.open("runDedicatePublicIpRangePostiveTest");
when(configurationMgr._vlanDao.findById(anyLong())).thenReturn(vlan);
when(configurationMgr._accountVlanMapDao.listAccountVlanMapsByAccount(anyLong())).thenReturn(null);
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.Advanced, null, null, true, true, null, null);
when(configurationMgr._zoneDao.findById(anyLong())).thenReturn(dc);
List<IPAddressVO> ipAddressList = new ArrayList<IPAddressVO>();
IPAddressVO ipAddress = new IPAddressVO(new Ip("75.75.75.75"), 1, 0xaabbccddeeffL, 10, false);
ipAddressList.add(ipAddress);
when(configurationMgr._publicIpAddressDao.listByVlanId(anyLong())).thenReturn(ipAddressList);
try {
Vlan result = configurationMgr.dedicatePublicIpRange(dedicatePublicIpRangesCmd);
Assert.assertNotNull(result);
} catch (Exception e) {
s_logger.info("exception in testing runDedicatePublicIpRangePostiveTest message: " + e.toString());
} finally {
txn.close("runDedicatePublicIpRangePostiveTest");
}
}
Aggregations