CLOUDSTACK-5779: Move ipAlias to use routerProxy

This commit is contained in:
Sheng Yang 2014-01-17 11:51:41 -08:00
parent 36920a3a3b
commit ce67e24d0a
9 changed files with 10 additions and 147 deletions

View File

@ -106,10 +106,7 @@ public class VirtualRoutingResource implements Manager {
private String _loadbPath; private String _loadbPath;
private String _publicEthIf; private String _publicEthIf;
private String _privateEthIf; private String _privateEthIf;
private String _bumpUpPriorityPath;
private String _routerProxyPath; private String _routerProxyPath;
private String _createIpAliasPath;
private String _deleteIpAliasPath;
private int _timeout; private int _timeout;
private int _startTimeout; private int _startTimeout;
@ -587,23 +584,18 @@ public class VirtualRoutingResource implements Manager {
protected Answer execute(final CreateIpAliasCommand cmd) { protected Answer execute(final CreateIpAliasCommand cmd) {
String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
final Script command = new Script(_createIpAliasPath, _timeout, s_logger);
List<IpAliasTO> ipAliasTOs = cmd.getIpAliasList(); List<IpAliasTO> ipAliasTOs = cmd.getIpAliasList();
String args = ""; String args = "";
command.add(routerIp);
for (IpAliasTO ipaliasto : ipAliasTOs) { for (IpAliasTO ipaliasto : ipAliasTOs) {
args = args + ipaliasto.getAlias_count() + ":" + ipaliasto.getRouterip() + ":" + ipaliasto.getNetmask() + "-"; args = args + ipaliasto.getAlias_count() + ":" + ipaliasto.getRouterip() + ":" + ipaliasto.getNetmask() + "-";
} }
command.add(args); final String result = routerProxy("createipAlias.sh", routerIp, args);
final String result = command.execute();
return new Answer(cmd, result == null, result); return new Answer(cmd, result == null, result);
} }
protected Answer execute(final DeleteIpAliasCommand cmd) { protected Answer execute(final DeleteIpAliasCommand cmd) {
final Script command = new Script(_deleteIpAliasPath, _timeout, s_logger);
String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
String args = ""; String args = "";
command.add(routerIp);
List<IpAliasTO> revokedIpAliasTOs = cmd.getDeleteIpAliasTos(); List<IpAliasTO> revokedIpAliasTOs = cmd.getDeleteIpAliasTos();
for (IpAliasTO ipAliasTO : revokedIpAliasTOs) { for (IpAliasTO ipAliasTO : revokedIpAliasTOs) {
args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-"; args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-";
@ -613,8 +605,7 @@ public class VirtualRoutingResource implements Manager {
for (IpAliasTO ipAliasTO : activeIpAliasTOs) { for (IpAliasTO ipAliasTO : activeIpAliasTOs) {
args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-"; args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-";
} }
command.add(args); final String result = routerProxy("deleteipAlias.sh", routerIp, args);
final String result = command.execute();
return new Answer(cmd, result == null, result); return new Answer(cmd, result == null, result);
} }
@ -1136,24 +1127,10 @@ public class VirtualRoutingResource implements Manager {
} }
_privateEthIf = _privateEthIf.toLowerCase(); _privateEthIf = _privateEthIf.toLowerCase();
_bumpUpPriorityPath = findScript("bumpUpPriority.sh");
if (_bumpUpPriorityPath == null) {
throw new ConfigurationException("Unable to find bumpUpPriority.sh");
}
_routerProxyPath = findScript("router_proxy.sh"); _routerProxyPath = findScript("router_proxy.sh");
if (_routerProxyPath == null) { if (_routerProxyPath == null) {
throw new ConfigurationException("Unable to find router_proxy.sh"); throw new ConfigurationException("Unable to find router_proxy.sh");
} }
_createIpAliasPath = findScript("createipAlias.sh");
if (_createIpAliasPath == null) {
throw new ConfigurationException("unable to find createipAlias.sh");
}
_deleteIpAliasPath = findScript("deleteipAlias.sh");
if (_deleteIpAliasPath == null) {
throw new ConfigurationException("unable to find deleteipAlias.sh");
}
return true; return true;
} }

View File

@ -2181,14 +2181,14 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
args = args + ipaliasto.getAlias_count() + ":" + ipaliasto.getRouterip() + ":" + ipaliasto.getNetmask() + "-"; args = args + ipaliasto.getAlias_count() + ":" + ipaliasto.getRouterip() + ":" + ipaliasto.getNetmask() + "-";
} }
if (s_logger.isDebugEnabled()) { if (s_logger.isDebugEnabled()) {
s_logger.debug("Run command on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + ", /root/createIpAlias " + args); s_logger.debug("Run command on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + ", /opt/cloud/bin/createIpAlias " + args);
} }
try { try {
VmwareManager mgr = getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME); VmwareManager mgr = getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
String controlIp = getRouterSshControlIp(cmd); String controlIp = getRouterSshControlIp(cmd);
Pair<Boolean, String> result = Pair<Boolean, String> result =
SshHelper.sshExecute(controlIp, DefaultDomRSshPort, "root", mgr.getSystemVMKeyFile(), null, "/root/createIpAlias.sh " + args); SshHelper.sshExecute(controlIp, DefaultDomRSshPort, "root", mgr.getSystemVMKeyFile(), null, "/opt/cloud/bin/createIpAlias.sh " + args);
if (!result.first()) { if (!result.first()) {
s_logger.error("CreateIpAlias command on domr " + controlIp + " failed, message: " + result.second()); s_logger.error("CreateIpAlias command on domr " + controlIp + " failed, message: " + result.second());
@ -2225,14 +2225,14 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-"; args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-";
} }
if (s_logger.isDebugEnabled()) { if (s_logger.isDebugEnabled()) {
s_logger.debug("Run command on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + ", /root/deleteIpAlias " + args); s_logger.debug("Run command on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + ", /opt/cloud/bin/deleteIpAlias " + args);
} }
try { try {
VmwareManager mgr = getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME); VmwareManager mgr = getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
String controlIp = getRouterSshControlIp(cmd); String controlIp = getRouterSshControlIp(cmd);
Pair<Boolean, String> result = Pair<Boolean, String> result =
SshHelper.sshExecute(controlIp, DefaultDomRSshPort, "root", mgr.getSystemVMKeyFile(), null, "/root/deleteIpAlias.sh " + args); SshHelper.sshExecute(controlIp, DefaultDomRSshPort, "root", mgr.getSystemVMKeyFile(), null, "/opt/cloud/bin/deleteIpAlias.sh " + args);
if (!result.first()) { if (!result.first()) {
s_logger.error("deleteIpAlias command on domr " + controlIp + " failed, message: " + result.second()); s_logger.error("deleteIpAlias command on domr " + controlIp + " failed, message: " + result.second());

View File

@ -2194,14 +2194,13 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
} }
protected Answer execute(final CreateIpAliasCommand cmd) { protected Answer execute(final CreateIpAliasCommand cmd) {
Connection conn = getConnection();
String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
List<IpAliasTO> ipAliasTOs = cmd.getIpAliasList(); List<IpAliasTO> ipAliasTOs = cmd.getIpAliasList();
String args = routerIp + " "; String args = "";
for (IpAliasTO ipaliasto : ipAliasTOs) { for (IpAliasTO ipaliasto : ipAliasTOs) {
args = args + ipaliasto.getAlias_count() + ":" + ipaliasto.getRouterip() + ":" + ipaliasto.getNetmask() + "-"; args = args + ipaliasto.getAlias_count() + ":" + ipaliasto.getRouterip() + ":" + ipaliasto.getNetmask() + "-";
} }
String result = callHostPlugin(conn, "vmops", "createipAlias", "args", args); String result = routerProxy("createipAlias.sh", routerIp, args);
if (result == null || result.isEmpty()) { if (result == null || result.isEmpty()) {
return new Answer(cmd, false, "CreateIPAliasCommand failed\n"); return new Answer(cmd, false, "CreateIPAliasCommand failed\n");
} }
@ -2210,10 +2209,9 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
} }
protected Answer execute(final DeleteIpAliasCommand cmd) { protected Answer execute(final DeleteIpAliasCommand cmd) {
Connection conn = getConnection();
String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
List<IpAliasTO> revokedIpAliasTOs = cmd.getDeleteIpAliasTos(); List<IpAliasTO> revokedIpAliasTOs = cmd.getDeleteIpAliasTos();
String args = routerIp + " "; String args = "";
for (IpAliasTO ipAliasTO : revokedIpAliasTOs) { for (IpAliasTO ipAliasTO : revokedIpAliasTOs) {
args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-"; args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-";
} }
@ -2223,7 +2221,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
for (IpAliasTO ipAliasTO : activeIpAliasTOs) { for (IpAliasTO ipAliasTO : activeIpAliasTOs) {
args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-"; args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-";
} }
String result = callHostPlugin(conn, "vmops", "deleteipAlias", "args", args); String result = routerProxy("deleteipAlias", routerIp, args);
if (result == null || result.isEmpty()) { if (result == null || result.isEmpty()) {
return new Answer(cmd, false, "DeleteipAliasCommand failed\n"); return new Answer(cmd, false, "DeleteipAliasCommand failed\n");
} }

View File

@ -1,26 +0,0 @@
#!/usr/bin/env bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
usage() {
printf " %s routerip <alias_count:ip:netmask;alias_count2:ip2:netmask2;....> \n" $(basename $0) >&2
}
set -x
cert="/root/.ssh/id_rsa.cloud"
ssh -p 3922 -q -o StrictHostKeyChecking=no -i $cert root@$1 "/root/createIpAlias.sh $2"

View File

@ -1,25 +0,0 @@
#!/usr/bin/env bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
usage() {
printf " %s routerip <alias_count:ip:netmask;alias_count2:ip2:netmask2;....> \n" $(basename $0) >&2
}
set -x
cert="/root/.ssh/id_rsa.cloud"
ssh -p 3922 -q -o StrictHostKeyChecking=no -i $cert root@$1 "/root/deleteIpAlias.sh $2 $3"

View File

@ -1,29 +0,0 @@
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# @VERSION@
cert="/root/.ssh/id_rsa.cloud"
domr=$1
shift
ssh -p 3922 -o StrictHostKeyChecking=no -i $cert root@$domr "/opt/cloud/bin/ipsectunnel.sh $*" >/dev/null
exit $?

View File

@ -255,8 +255,6 @@ def routerProxy(session, args):
return txt return txt
@echo @echo
def setLoadBalancerRule(session, args): def setLoadBalancerRule(session, args):
sargs = args['args'] sargs = args['args']
@ -272,34 +270,6 @@ def setLoadBalancerRule(session, args):
return txt return txt
@echo
def createipAlias(session, args):
args = args['args']
cmd = args.split(' ')
cmd.insert(0, "/opt/cloud/bin/createipAlias.sh")
cmd.insert(0, "bin/bash")
try:
txt=util.pread2(cmd)
txt='success'
except:
logging.debug("failed to create ip alias on router vm")
txt=''
return txt
@echo
def deleteipAlias(session, args):
args = args['args']
cmd = args.split(' ')
cmd.insert(0, "/opt/cloud/bin/deleteipAlias.sh")
cmd.insert(0, "bin/bash")
try:
txt=util.pread2(cmd)
txt='success'
except:
logging.debug("failed to create ip alias on router vm")
txt=''
return txt
@echo @echo
def createFile(session, args): def createFile(session, args):
file_path = args['filepath'] file_path = args['filepath']
@ -1593,8 +1563,6 @@ if __name__ == "__main__":
"destroy_network_rules_for_vm":destroy_network_rules_for_vm, "destroy_network_rules_for_vm":destroy_network_rules_for_vm,
"default_network_rules_systemvm":default_network_rules_systemvm, "default_network_rules_systemvm":default_network_rules_systemvm,
"network_rules_vmSecondaryIp":network_rules_vmSecondaryIp, "network_rules_vmSecondaryIp":network_rules_vmSecondaryIp,
"createipAlias":createipAlias,
"deleteipAlias":deleteipAlias,
"get_rule_logs_for_vms":get_rule_logs_for_vms, "get_rule_logs_for_vms":get_rule_logs_for_vms,
"add_to_VCPUs_params_live":add_to_VCPUs_params_live, "add_to_VCPUs_params_live":add_to_VCPUs_params_live,
"setLinkLocalIP":setLinkLocalIP, "setLinkLocalIP":setLinkLocalIP,