Search in sources :

Example 66 with VirtualRouter

use of com.cloud.network.router.VirtualRouter in project cosmic by MissionCriticalCloud.

the class BasicNetworkVisitor method visit.

@Override
public boolean visit(final UserdataToRouterRules userdata) throws ResourceUnavailableException {
    final VirtualRouter router = userdata.getRouter();
    final Commands commands = new Commands(Command.OnError.Stop);
    final VMOverviewTO vmOverview = _commandSetupHelper.createVmOverviewFromRouter(router);
    final UpdateVmOverviewCommand updateVmOverviewCommand = _commandSetupHelper.createUpdateVmOverviewCommand(router, vmOverview);
    commands.addCommand(updateVmOverviewCommand);
    return _networkGeneralHelper.sendCommandsToRouter(router, commands);
}
Also used : VMOverviewTO(com.cloud.agent.api.to.overviews.VMOverviewTO) Commands(com.cloud.agent.manager.Commands) VirtualRouter(com.cloud.network.router.VirtualRouter) UpdateVmOverviewCommand(com.cloud.agent.api.UpdateVmOverviewCommand)

Example 67 with VirtualRouter

use of com.cloud.network.router.VirtualRouter in project cosmic by MissionCriticalCloud.

the class BasicNetworkVisitor method visit.

@Override
public boolean visit(final SshKeyToRouterRules sshkey) throws ResourceUnavailableException {
    final VirtualRouter router = sshkey.getRouter();
    final VirtualMachineProfile profile = sshkey.getProfile();
    final Commands commands = new Commands(Command.OnError.Stop);
    final NicVO nicVO = sshkey.getNicVo();
    final VMTemplateVO template = sshkey.getTemplate();
    if (template != null && template.getEnablePassword()) {
        _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);
}
Also used : VMOverviewTO(com.cloud.agent.api.to.overviews.VMOverviewTO) Commands(com.cloud.agent.manager.Commands) VMTemplateVO(com.cloud.storage.VMTemplateVO) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) NicVO(com.cloud.vm.NicVO) VirtualRouter(com.cloud.network.router.VirtualRouter) UpdateVmOverviewCommand(com.cloud.agent.api.UpdateVmOverviewCommand)

Example 68 with VirtualRouter

use of com.cloud.network.router.VirtualRouter in project cosmic by MissionCriticalCloud.

the class BasicNetworkVisitor method visit.

@Override
public boolean visit(final PasswordToRouterRules passwd) throws ResourceUnavailableException {
    final VirtualRouter router = passwd.getRouter();
    final NicVO nicVo = passwd.getNicVo();
    final VirtualMachineProfile profile = passwd.getProfile();
    final Commands cmds = new Commands(Command.OnError.Stop);
    _commandSetupHelper.createPasswordCommand(router, profile, nicVo, cmds);
    return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
}
Also used : Commands(com.cloud.agent.manager.Commands) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) NicVO(com.cloud.vm.NicVO) VirtualRouter(com.cloud.network.router.VirtualRouter)

Example 69 with VirtualRouter

use of com.cloud.network.router.VirtualRouter in project cosmic by MissionCriticalCloud.

the class VirtualRouterElement method savePassword.

@Override
public boolean savePassword(final Network network, final NicProfile nic, final VirtualMachineProfile vm) throws ResourceUnavailableException {
    if (!canHandle(network, null)) {
        return false;
    }
    final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);
    if (routers == null || routers.isEmpty()) {
        s_logger.debug("Can't find virtual router element in network " + network.getId());
        return true;
    }
    final VirtualMachineProfile uservm = vm;
    final Zone zone = zoneRepository.findOne(network.getDataCenterId());
    final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(zone);
    // save the password in DB
    for (final VirtualRouter router : routers) {
        if (router.getState() == State.Running) {
            return networkTopology.savePasswordToRouter(network, nic, uservm, router);
        }
    }
    final String password = (String) uservm.getParameter(VirtualMachineProfile.Param.VmPassword);
    final String password_encrypted = DBEncryptionUtil.encrypt(password);
    final UserVmVO userVmVO = _userVmDao.findById(vm.getId());
    _userVmDao.loadDetails(userVmVO);
    userVmVO.setDetail("password", password_encrypted);
    _userVmDao.saveDetails(userVmVO);
    userVmVO.setUpdateParameters(true);
    _userVmDao.update(userVmVO.getId(), userVmVO);
    return true;
}
Also used : UserVmVO(com.cloud.vm.UserVmVO) Zone(com.cloud.db.model.Zone) NetworkTopology(com.cloud.network.topology.NetworkTopology) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) DomainRouterVO(com.cloud.vm.DomainRouterVO) VirtualRouter(com.cloud.network.router.VirtualRouter)

Example 70 with VirtualRouter

use of com.cloud.network.router.VirtualRouter in project cosmic by MissionCriticalCloud.

the class VpcVirtualRouterElement method shutdown.

@Override
public boolean shutdown(final Network network, final ReservationContext context, final boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException {
    final Long vpcId = network.getVpcId();
    if (vpcId == null) {
        s_logger.debug("Network " + network + " doesn't belong to any vpc, so skipping unplug nic part");
        return true;
    }
    boolean success = true;
    final List<? extends VirtualRouter> routers = _routerDao.listByVpcId(vpcId);
    for (final VirtualRouter router : routers) {
        // 1) Check if router is already a part of the network
        if (!_networkMdl.isVmPartOfNetwork(router.getId(), network.getId())) {
            s_logger.debug("Router " + router + " is not a part the network " + network);
            continue;
        }
        // 2) Call unplugNics in the network service
        success = success && _vpcRouterMgr.removeVpcRouterFromGuestNetwork(router, network);
        if (!success) {
            s_logger.warn("Failed to unplug nic in network " + network + " for virtual router " + router);
        } else {
            s_logger.debug("Successfully unplugged nic in network " + network + " for virtual router " + router);
        }
    }
    return success;
}
Also used : VirtualRouter(com.cloud.network.router.VirtualRouter)

Aggregations

VirtualRouter (com.cloud.network.router.VirtualRouter)72 Commands (com.cloud.agent.manager.Commands)34 DomainRouterResponse (com.cloud.api.response.DomainRouterResponse)11 NicVO (com.cloud.vm.NicVO)11 ServerApiException (com.cloud.api.ServerApiException)10 UserVmVO (com.cloud.vm.UserVmVO)10 VirtualMachineProfile (com.cloud.vm.VirtualMachineProfile)10 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)9 ArrayList (java.util.ArrayList)9 ServerApiException (org.apache.cloudstack.api.ServerApiException)9 DataCenter (com.cloud.dc.DataCenter)8 Network (com.cloud.network.Network)8 DomainRouterResponse (org.apache.cloudstack.api.response.DomainRouterResponse)8 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)6 UpdateVmOverviewCommand (com.cloud.agent.api.UpdateVmOverviewCommand)5 VMOverviewTO (com.cloud.agent.api.to.overviews.VMOverviewTO)5 UpdateNetworkOverviewCommand (com.cloud.agent.api.UpdateNetworkOverviewCommand)4 NetworkOverviewTO (com.cloud.agent.api.to.overviews.NetworkOverviewTO)4 DeployDestination (com.cloud.deploy.DeployDestination)4 PvlanSetupCommand (com.cloud.agent.api.PvlanSetupCommand)2