use of com.cloud.vm.DomainRouterVO in project cloudstack by apache.
the class VirtualRouterElement method applyIps.
@Override
public boolean applyIps(final Network network, final List<? extends PublicIpAddress> ipAddress, final Set<Service> services) throws ResourceUnavailableException {
boolean canHandle = true;
for (final Service service : services) {
if (!canHandle(network, service)) {
canHandle = false;
break;
}
}
boolean result = true;
if (canHandle) {
final List<DomainRouterVO> routers = getRouters(network);
if (routers == null || routers.isEmpty()) {
s_logger.debug("Virtual router elemnt doesn't need to associate ip addresses on the backend; virtual " + "router doesn't exist in the network " + network.getId());
return true;
}
final DataCenterVO dcVO = _dcDao.findById(network.getDataCenterId());
final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(dcVO);
for (final DomainRouterVO domainRouterVO : routers) {
result = result && networkTopology.associatePublicIP(network, ipAddress, domainRouterVO);
}
}
return result;
}
use of com.cloud.vm.DomainRouterVO in project cloudstack by apache.
the class DomainRouterDaoImpl method persist.
@Override
@DB
public DomainRouterVO persist(final DomainRouterVO router, final List<Network> guestNetworks) {
final TransactionLegacy txn = TransactionLegacy.currentTxn();
txn.start();
// 1) create network
final DomainRouterVO newRouter = super.persist(router);
if (guestNetworks != null && !guestNetworks.isEmpty()) {
// 2) add router to the network
for (final Network guestNetwork : guestNetworks) {
addRouterToGuestNetwork(router, guestNetwork);
}
}
txn.commit();
return newRouter;
}
use of com.cloud.vm.DomainRouterVO in project cloudstack by apache.
the class DomainRouterDaoImpl method remove.
@Override
public boolean remove(final Long id) {
final TransactionLegacy txn = TransactionLegacy.currentTxn();
txn.start();
final DomainRouterVO router = createForUpdate();
router.setPublicIpAddress(null);
final UpdateBuilder ub = getUpdateBuilder(router);
ub.set(router, "state", State.Destroyed);
update(id, ub, router);
final boolean result = super.remove(id);
txn.commit();
return result;
}
use of com.cloud.vm.DomainRouterVO in project cloudstack by apache.
the class DomainRouterDaoImpl method listIsolatedByHostId.
@Override
public List<DomainRouterVO> listIsolatedByHostId(final Long hostId) {
final SearchCriteria<DomainRouterVO> sc = HostUpSearch.create();
if (hostId != null) {
sc.setParameters("host", hostId);
}
sc.setJoinParameters("networkRouter", "type", Network.GuestType.Isolated);
final List<DomainRouterVO> routerIds = listBy(sc);
final List<DomainRouterVO> routers = new ArrayList<DomainRouterVO>();
for (final DomainRouterVO router : routerIds) {
CollectionUtils.addIgnoreNull(routers, findById(router.getId()));
}
return routers;
}
use of com.cloud.vm.DomainRouterVO in project cloudstack by apache.
the class DomainRouterDaoImpl method listByStateAndNetworkType.
@Override
public List<DomainRouterVO> listByStateAndNetworkType(final State state, final Network.GuestType type, final long mgmtSrvrId) {
final SearchCriteria<DomainRouterVO> sc = StateNetworkTypeSearch.create();
sc.setParameters("state", state);
sc.setJoinParameters("networkRouter", "type", type);
sc.setJoinParameters("host", "mgmtServerId", mgmtSrvrId);
final List<DomainRouterVO> routerIds = listBy(sc);
final List<DomainRouterVO> routers = new ArrayList<DomainRouterVO>();
for (final DomainRouterVO router : routerIds) {
routers.add(findById(router.getId()));
}
return routers;
}
Aggregations