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;
}
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 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 VirtualNetworkApplianceManagerImpl method upgradeRouterTemplate.
@Override
public List<Long> upgradeRouterTemplate(final UpgradeRouterTemplateCmd cmd) {
List<DomainRouterVO> routers = new ArrayList<DomainRouterVO>();
int params = 0;
final Long routerId = cmd.getId();
if (routerId != null) {
params++;
final DomainRouterVO router = _routerDao.findById(routerId);
if (router != null) {
routers.add(router);
}
}
final Long domainId = cmd.getDomainId();
if (domainId != null) {
final String accountName = cmd.getAccount();
// List by account, if account Name is specified along with domainId
if (accountName != null) {
final Account account = _accountMgr.getActiveAccountByName(accountName, domainId);
if (account == null) {
throw new InvalidParameterValueException("Account :" + accountName + " does not exist in domain: " + domainId);
}
routers = _routerDao.listRunningByAccountId(account.getId());
} else {
// List by domainId, account name not specified
routers = _routerDao.listRunningByDomain(domainId);
}
params++;
}
final Long clusterId = cmd.getClusterId();
if (clusterId != null) {
params++;
routers = _routerDao.listRunningByClusterId(clusterId);
}
final Long podId = cmd.getPodId();
if (podId != null) {
params++;
routers = _routerDao.listRunningByPodId(podId);
}
final Long zoneId = cmd.getZoneId();
if (zoneId != null) {
params++;
routers = _routerDao.listRunningByDataCenter(zoneId);
}
if (params > 1) {
throw new InvalidParameterValueException("Multiple parameters not supported. Specify only one among routerId/zoneId/podId/clusterId/accountId/domainId");
}
if (routers != null) {
return rebootRouters(routers);
}
return null;
}
Aggregations