Search in sources :

Example 26 with VirtualRouter

use of com.cloud.network.router.VirtualRouter in project cloudstack by apache.

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 27 with VirtualRouter

use of com.cloud.network.router.VirtualRouter in project cloudstack by apache.

the class BasicNetworkVisitor method visit.

@Override
public boolean visit(final DhcpSubNetRules subnet) throws ResourceUnavailableException {
    final VirtualRouter router = subnet.getRouter();
    final Network network = subnet.getNetwork();
    final NicIpAliasVO nicAlias = subnet.getNicAlias();
    final String routerAliasIp = subnet.getRouterAliasIp();
    final Commands cmds = new Commands(Command.OnError.Stop);
    final List<IpAliasTO> ipaliasTo = new ArrayList<IpAliasTO>();
    ipaliasTo.add(new IpAliasTO(routerAliasIp, nicAlias.getNetmask(), nicAlias.getAliasCount().toString()));
    _commandSetupHelper.createIpAlias(router, ipaliasTo, nicAlias.getNetworkId(), cmds);
    // also add the required configuration to the dnsmasq for supporting
    // dhcp and dns on the new ip.
    _commandSetupHelper.configDnsMasq(router, network, cmds);
    return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
}
Also used : Network(com.cloud.network.Network) Commands(com.cloud.agent.manager.Commands) ArrayList(java.util.ArrayList) IpAliasTO(com.cloud.agent.api.routing.IpAliasTO) NicIpAliasVO(com.cloud.vm.dao.NicIpAliasVO) VirtualRouter(com.cloud.network.router.VirtualRouter)

Example 28 with VirtualRouter

use of com.cloud.network.router.VirtualRouter in project cloudstack by apache.

the class BasicNetworkVisitor method visit.

@Override
public boolean visit(final UserdataPwdRules userdata) throws ResourceUnavailableException {
    final VirtualRouter router = userdata.getRouter();
    final Commands commands = new Commands(Command.OnError.Stop);
    final VirtualMachineProfile profile = userdata.getProfile();
    final NicVO nicVo = userdata.getNicVo();
    final UserVmVO userVM = userdata.getUserVM();
    final DeployDestination destination = userdata.getDestination();
    if (router.getPodIdToDeployIn().longValue() == destination.getPod().getId()) {
        _commandSetupHelper.createPasswordCommand(router, profile, nicVo, commands);
        _commandSetupHelper.createVmDataCommand(router, userVM, nicVo, userVM.getDetail("SSH.PublicKey"), commands);
        return _networkGeneralHelper.sendCommandsToRouter(router, commands);
    }
    return true;
}
Also used : UserVmVO(com.cloud.vm.UserVmVO) DeployDestination(com.cloud.deploy.DeployDestination) Commands(com.cloud.agent.manager.Commands) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) NicVO(com.cloud.vm.NicVO) VirtualRouter(com.cloud.network.router.VirtualRouter)

Example 29 with VirtualRouter

use of com.cloud.network.router.VirtualRouter in project cloudstack by apache.

the class StopNetScalerVMCmd method execute.

@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
    CallContext.current().setEventDetails("NetScaler vm Id: " + getId());
    VirtualRouter result = null;
    VirtualRouter vm = _routerService.findRouter(getId());
    if (vm == null || vm.getRole() != Role.NETSCALER_VM) {
        throw new InvalidParameterValueException("Can't find NetScaler lb vm by id");
    } else {
        result = _netsclarLbService.stopNetscalerServiceVm(getId(), isForced(), CallContext.current().getCallingAccount(), CallContext.current().getCallingUserId());
    }
    if (result != null) {
        DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to stop Netscaler vm");
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) DomainRouterResponse(org.apache.cloudstack.api.response.DomainRouterResponse) VirtualRouter(com.cloud.network.router.VirtualRouter)

Example 30 with VirtualRouter

use of com.cloud.network.router.VirtualRouter in project cloudstack by apache.

the class DestroyRouterCmd method execute.

@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
    CallContext ctx = CallContext.current();
    ctx.setEventDetails("Router Id: " + this._uuidMgr.getUuid(VirtualMachine.class, getId()));
    VirtualRouter result = _routerService.destroyRouter(getId(), ctx.getCallingAccount(), ctx.getCallingUserId());
    if (result != null) {
        DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to destroy router");
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) CallContext(org.apache.cloudstack.context.CallContext) DomainRouterResponse(org.apache.cloudstack.api.response.DomainRouterResponse) 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