Search in sources :

Example 6 with IpAliasTO

use of com.cloud.agent.api.routing.IpAliasTO in project cloudstack by apache.

the class VirtualRoutingResourceTest method generateCreateIpAliasCommand.

protected CreateIpAliasCommand generateCreateIpAliasCommand() {
    final List<IpAliasTO> aliases = new ArrayList<>();
    aliases.add(new IpAliasTO("169.254.3.10", "255.255.255.0", "1"));
    aliases.add(new IpAliasTO("169.254.3.11", "255.255.255.0", "2"));
    aliases.add(new IpAliasTO("169.254.3.12", "255.255.255.0", "3"));
    final CreateIpAliasCommand cmd = new CreateIpAliasCommand("169.254.3.10", aliases);
    cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
    return cmd;
}
Also used : CreateIpAliasCommand(com.cloud.agent.api.routing.CreateIpAliasCommand) ArrayList(java.util.ArrayList) IpAliasTO(com.cloud.agent.api.routing.IpAliasTO)

Example 7 with IpAliasTO

use of com.cloud.agent.api.routing.IpAliasTO in project cloudstack by apache.

the class HypervDirectConnectResource method execute.

protected Answer execute(final CreateIpAliasCommand cmd) {
    if (s_logger.isInfoEnabled()) {
        s_logger.info("Executing createIpAlias command: " + s_gson.toJson(cmd));
    }
    cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
    final List<IpAliasTO> ipAliasTOs = cmd.getIpAliasList();
    final StringBuilder args = new StringBuilder();
    for (final IpAliasTO ipaliasto : ipAliasTOs) {
        args.append(ipaliasto.getAlias_count());
        args.append(":");
        args.append(ipaliasto.getRouterip());
        args.append(":");
        args.append(ipaliasto.getNetmask());
        args.append("-");
    }
    if (s_logger.isDebugEnabled()) {
        s_logger.debug("Run command on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + ", /root/createIpAlias " + args);
    }
    try {
        final String controlIp = getRouterSshControlIp(cmd);
        final Pair<Boolean, String> result = SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null, "/root/createIpAlias.sh " + args);
        if (!result.first()) {
            s_logger.error("CreateIpAlias command on domr " + controlIp + " failed, message: " + result.second());
            return new Answer(cmd, false, "createipAlias failed due to " + result.second());
        }
        if (s_logger.isInfoEnabled()) {
            s_logger.info("createIpAlias command on domain router " + controlIp + " completed");
        }
    } catch (final Throwable e) {
        final String msg = "createIpAlias failed due to " + e;
        s_logger.error(msg, e);
        return new Answer(cmd, false, msg);
    }
    return new Answer(cmd);
}
Also used : UnsupportedAnswer(com.cloud.agent.api.UnsupportedAnswer) CheckSshAnswer(com.cloud.agent.api.check.CheckSshAnswer) GetDomRVersionAnswer(com.cloud.agent.api.GetDomRVersionAnswer) CheckS2SVpnConnectionsAnswer(com.cloud.agent.api.CheckS2SVpnConnectionsAnswer) SetPortForwardingRulesAnswer(com.cloud.agent.api.routing.SetPortForwardingRulesAnswer) SetSourceNatAnswer(com.cloud.agent.api.routing.SetSourceNatAnswer) PlugNicAnswer(com.cloud.agent.api.PlugNicAnswer) GetVmConfigAnswer(com.cloud.agent.api.GetVmConfigAnswer) NetworkUsageAnswer(com.cloud.agent.api.NetworkUsageAnswer) Answer(com.cloud.agent.api.Answer) UnPlugNicAnswer(com.cloud.agent.api.UnPlugNicAnswer) SetStaticNatRulesAnswer(com.cloud.agent.api.routing.SetStaticNatRulesAnswer) IpAssocAnswer(com.cloud.agent.api.routing.IpAssocAnswer) SetFirewallRulesAnswer(com.cloud.agent.api.routing.SetFirewallRulesAnswer) CheckRouterAnswer(com.cloud.agent.api.CheckRouterAnswer) SetStaticRouteAnswer(com.cloud.agent.api.routing.SetStaticRouteAnswer) IpAliasTO(com.cloud.agent.api.routing.IpAliasTO)

Example 8 with IpAliasTO

use of com.cloud.agent.api.routing.IpAliasTO in project cloudstack by apache.

the class HypervDirectConnectResource method execute.

protected Answer execute(final DeleteIpAliasCommand cmd) {
    cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
    final List<IpAliasTO> revokedIpAliasTOs = cmd.getDeleteIpAliasTos();
    final List<IpAliasTO> activeIpAliasTOs = cmd.getCreateIpAliasTos();
    if (s_logger.isInfoEnabled()) {
        s_logger.info("Executing deleteIpAlias command: " + s_gson.toJson(cmd));
    }
    final StringBuilder args = new StringBuilder();
    for (final IpAliasTO ipAliasTO : revokedIpAliasTOs) {
        args.append(ipAliasTO.getAlias_count());
        args.append(":");
        args.append(ipAliasTO.getRouterip());
        args.append(":");
        args.append(ipAliasTO.getNetmask());
        args.append("-");
    }
    args.append("- ");
    for (final IpAliasTO ipAliasTO : activeIpAliasTOs) {
        args.append(ipAliasTO.getAlias_count());
        args.append(":");
        args.append(ipAliasTO.getRouterip());
        args.append(":");
        args.append(ipAliasTO.getNetmask());
        args.append("-");
    }
    if (s_logger.isDebugEnabled()) {
        s_logger.debug("Run command on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + ", /root/deleteIpAlias " + args);
    }
    try {
        final String controlIp = getRouterSshControlIp(cmd);
        final Pair<Boolean, String> result = SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null, "/root/deleteIpAlias.sh " + args);
        if (!result.first()) {
            s_logger.error("deleteIpAlias command on domr " + controlIp + " failed, message: " + result.second());
            return new Answer(cmd, false, "deleteIpAlias failed due to " + result.second());
        }
        if (s_logger.isInfoEnabled()) {
            s_logger.info("deleteIpAlias command on domain router " + controlIp + " completed");
        }
    } catch (final Throwable e) {
        final String msg = "deleteIpAlias failed due to " + e.getMessage();
        s_logger.error(msg, e);
        return new Answer(cmd, false, msg);
    }
    return new Answer(cmd);
}
Also used : UnsupportedAnswer(com.cloud.agent.api.UnsupportedAnswer) CheckSshAnswer(com.cloud.agent.api.check.CheckSshAnswer) GetDomRVersionAnswer(com.cloud.agent.api.GetDomRVersionAnswer) CheckS2SVpnConnectionsAnswer(com.cloud.agent.api.CheckS2SVpnConnectionsAnswer) SetPortForwardingRulesAnswer(com.cloud.agent.api.routing.SetPortForwardingRulesAnswer) SetSourceNatAnswer(com.cloud.agent.api.routing.SetSourceNatAnswer) PlugNicAnswer(com.cloud.agent.api.PlugNicAnswer) GetVmConfigAnswer(com.cloud.agent.api.GetVmConfigAnswer) NetworkUsageAnswer(com.cloud.agent.api.NetworkUsageAnswer) Answer(com.cloud.agent.api.Answer) UnPlugNicAnswer(com.cloud.agent.api.UnPlugNicAnswer) SetStaticNatRulesAnswer(com.cloud.agent.api.routing.SetStaticNatRulesAnswer) IpAssocAnswer(com.cloud.agent.api.routing.IpAssocAnswer) SetFirewallRulesAnswer(com.cloud.agent.api.routing.SetFirewallRulesAnswer) CheckRouterAnswer(com.cloud.agent.api.CheckRouterAnswer) SetStaticRouteAnswer(com.cloud.agent.api.routing.SetStaticRouteAnswer) IpAliasTO(com.cloud.agent.api.routing.IpAliasTO)

Example 9 with IpAliasTO

use of com.cloud.agent.api.routing.IpAliasTO in project cloudstack by apache.

the class ConfigHelperTest method generateDeleteIpAliasCommand.

protected DeleteIpAliasCommand generateDeleteIpAliasCommand() {
    final List<IpAliasTO> aliases = new ArrayList<>();
    aliases.add(new IpAliasTO("169.254.3.10", "255.255.255.0", "1"));
    aliases.add(new IpAliasTO("169.254.3.11", "255.255.255.0", "2"));
    aliases.add(new IpAliasTO("169.254.3.12", "255.255.255.0", "3"));
    final DeleteIpAliasCommand cmd = new DeleteIpAliasCommand("169.254.10.1", aliases, aliases);
    cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
    return cmd;
}
Also used : DeleteIpAliasCommand(com.cloud.agent.api.routing.DeleteIpAliasCommand) ArrayList(java.util.ArrayList) IpAliasTO(com.cloud.agent.api.routing.IpAliasTO)

Example 10 with IpAliasTO

use of com.cloud.agent.api.routing.IpAliasTO in project cloudstack by apache.

the class VirtualRoutingResourceTest method generateDeleteIpAliasCommand.

protected DeleteIpAliasCommand generateDeleteIpAliasCommand() {
    final List<IpAliasTO> aliases = new ArrayList<>();
    aliases.add(new IpAliasTO("169.254.3.10", "255.255.255.0", "1"));
    aliases.add(new IpAliasTO("169.254.3.11", "255.255.255.0", "2"));
    aliases.add(new IpAliasTO("169.254.3.12", "255.255.255.0", "3"));
    final DeleteIpAliasCommand cmd = new DeleteIpAliasCommand("169.254.10.1", aliases, aliases);
    cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
    return cmd;
}
Also used : DeleteIpAliasCommand(com.cloud.agent.api.routing.DeleteIpAliasCommand) ArrayList(java.util.ArrayList) IpAliasTO(com.cloud.agent.api.routing.IpAliasTO)

Aggregations

IpAliasTO (com.cloud.agent.api.routing.IpAliasTO)10 ArrayList (java.util.ArrayList)6 DeleteIpAliasCommand (com.cloud.agent.api.routing.DeleteIpAliasCommand)3 NicIpAliasVO (com.cloud.vm.dao.NicIpAliasVO)3 Answer (com.cloud.agent.api.Answer)2 CheckRouterAnswer (com.cloud.agent.api.CheckRouterAnswer)2 CheckS2SVpnConnectionsAnswer (com.cloud.agent.api.CheckS2SVpnConnectionsAnswer)2 GetDomRVersionAnswer (com.cloud.agent.api.GetDomRVersionAnswer)2 GetVmConfigAnswer (com.cloud.agent.api.GetVmConfigAnswer)2 NetworkUsageAnswer (com.cloud.agent.api.NetworkUsageAnswer)2 PlugNicAnswer (com.cloud.agent.api.PlugNicAnswer)2 UnPlugNicAnswer (com.cloud.agent.api.UnPlugNicAnswer)2 UnsupportedAnswer (com.cloud.agent.api.UnsupportedAnswer)2 CheckSshAnswer (com.cloud.agent.api.check.CheckSshAnswer)2 CreateIpAliasCommand (com.cloud.agent.api.routing.CreateIpAliasCommand)2 IpAssocAnswer (com.cloud.agent.api.routing.IpAssocAnswer)2 SetFirewallRulesAnswer (com.cloud.agent.api.routing.SetFirewallRulesAnswer)2 SetPortForwardingRulesAnswer (com.cloud.agent.api.routing.SetPortForwardingRulesAnswer)2 SetSourceNatAnswer (com.cloud.agent.api.routing.SetSourceNatAnswer)2 SetStaticNatRulesAnswer (com.cloud.agent.api.routing.SetStaticNatRulesAnswer)2