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;
}
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);
}
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);
}
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;
}
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;
}
Aggregations