Search in sources :

Example 26 with Commands

use of com.cloud.agent.manager.Commands in project cloudstack by apache.

the class BasicNetworkVisitor method visit.

@Override
public boolean visit(final StaticNatRules nat) throws ResourceUnavailableException {
    final Network network = nat.getNetwork();
    final VirtualRouter router = nat.getRouter();
    final List<? extends StaticNat> rules = nat.getRules();
    final Commands cmds = new Commands(Command.OnError.Continue);
    _commandSetupHelper.createApplyStaticNatCommands(rules, router, cmds, network.getId());
    return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
}
Also used : Network(com.cloud.network.Network) Commands(com.cloud.agent.manager.Commands) VirtualRouter(com.cloud.network.router.VirtualRouter)

Example 27 with Commands

use of com.cloud.agent.manager.Commands 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 28 with Commands

use of com.cloud.agent.manager.Commands in project cloudstack by apache.

the class AdvancedNetworkVisitor method visit.

@Override
public boolean visit(final VpcIpAssociationRules vpcip) throws ResourceUnavailableException {
    final VirtualRouter router = vpcip.getRouter();
    final Commands cmds = new Commands(Command.OnError.Continue);
    final Map<String, String> vlanMacAddress = vpcip.getVlanMacAddress();
    final List<PublicIpAddress> ipsToSend = vpcip.getIpsToSend();
    if (!ipsToSend.isEmpty()) {
        _commandSetupHelper.createVpcAssociatePublicIPCommands(router, ipsToSend, cmds, vlanMacAddress);
        return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
    } else {
        return true;
    }
}
Also used : PublicIpAddress(com.cloud.network.PublicIpAddress) Commands(com.cloud.agent.manager.Commands) VirtualRouter(com.cloud.network.router.VirtualRouter)

Example 29 with Commands

use of com.cloud.agent.manager.Commands in project cloudstack by apache.

the class AdvancedNetworkVisitor method visit.

@Override
public boolean visit(final DhcpPvlanRules dhcp) throws ResourceUnavailableException {
    final VirtualRouter router = dhcp.getRouter();
    final PvlanSetupCommand setupCommand = dhcp.getSetupCommand();
    // In fact we send command to the host of router, we're not programming
    // router but the host
    final Commands cmds = new Commands(Command.OnError.Stop);
    cmds.addCommand(setupCommand);
    try {
        return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
    } catch (final ResourceUnavailableException e) {
        s_logger.warn("Timed Out", e);
        return false;
    }
}
Also used : Commands(com.cloud.agent.manager.Commands) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) PvlanSetupCommand(com.cloud.agent.api.PvlanSetupCommand) VirtualRouter(com.cloud.network.router.VirtualRouter)

Example 30 with Commands

use of com.cloud.agent.manager.Commands in project cloudstack by apache.

the class AdvancedNetworkVisitor method visit.

@Override
public boolean visit(final AdvancedVpnRules vpnRules) throws ResourceUnavailableException {
    final VirtualRouter router = vpnRules.getRouter();
    final List<? extends VpnUser> users = vpnRules.getUsers();
    final Commands cmds = new Commands(Command.OnError.Continue);
    _commandSetupHelper.createApplyVpnUsersCommand(users, router, cmds);
    // results accordingly
    return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
}
Also used : Commands(com.cloud.agent.manager.Commands) VirtualRouter(com.cloud.network.router.VirtualRouter)

Aggregations

Commands (com.cloud.agent.manager.Commands)64 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)22 VirtualRouter (com.cloud.network.router.VirtualRouter)19 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)17 Answer (com.cloud.agent.api.Answer)16 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)13 Network (com.cloud.network.Network)13 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)11 NicVO (com.cloud.vm.NicVO)10 UnPlugNicAnswer (com.cloud.agent.api.UnPlugNicAnswer)9 ArrayList (java.util.ArrayList)9 PlugNicAnswer (com.cloud.agent.api.PlugNicAnswer)8 UserVmVO (com.cloud.vm.UserVmVO)8 DataCenter (com.cloud.dc.DataCenter)7 NoTransitionException (com.cloud.utils.fsm.NoTransitionException)7 VirtualMachineProfile (com.cloud.vm.VirtualMachineProfile)7 AgentControlAnswer (com.cloud.agent.api.AgentControlAnswer)6 RestoreVMSnapshotAnswer (com.cloud.agent.api.RestoreVMSnapshotAnswer)6 StartAnswer (com.cloud.agent.api.StartAnswer)6 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)6