From ce67e24d0aeada261aa6b44b2c37abfc6f0973af Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 17 Jan 2014 11:51:41 -0800 Subject: [PATCH] CLOUDSTACK-5779: Move ipAlias to use routerProxy --- .../VirtualRoutingResource.java | 27 ++-------------- .../vmware/resource/VmwareResource.java | 8 ++--- .../xen/resource/CitrixResourceBase.java | 10 +++--- scripts/network/domr/createipAlias.sh | 26 --------------- scripts/network/domr/deleteipAlias.sh | 25 --------------- scripts/network/domr/s2s_vpn.sh | 29 ----------------- scripts/vm/hypervisor/xenserver/vmops | 32 ------------------- .../{root => opt/cloud/bin}/createIpAlias.sh | 0 .../{root => opt/cloud/bin}/deleteIpAlias.sh | 0 9 files changed, 10 insertions(+), 147 deletions(-) delete mode 100755 scripts/network/domr/createipAlias.sh delete mode 100755 scripts/network/domr/deleteipAlias.sh delete mode 100755 scripts/network/domr/s2s_vpn.sh rename systemvm/patches/debian/config/{root => opt/cloud/bin}/createIpAlias.sh (100%) rename systemvm/patches/debian/config/{root => opt/cloud/bin}/deleteIpAlias.sh (100%) diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java index f469d8af952..20cc0ccdc4b 100755 --- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java +++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java @@ -106,10 +106,7 @@ public class VirtualRoutingResource implements Manager { private String _loadbPath; private String _publicEthIf; private String _privateEthIf; - private String _bumpUpPriorityPath; private String _routerProxyPath; - private String _createIpAliasPath; - private String _deleteIpAliasPath; private int _timeout; private int _startTimeout; @@ -587,23 +584,18 @@ public class VirtualRoutingResource implements Manager { protected Answer execute(final CreateIpAliasCommand cmd) { String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); - final Script command = new Script(_createIpAliasPath, _timeout, s_logger); List ipAliasTOs = cmd.getIpAliasList(); String args = ""; - command.add(routerIp); for (IpAliasTO ipaliasto : ipAliasTOs) { args = args + ipaliasto.getAlias_count() + ":" + ipaliasto.getRouterip() + ":" + ipaliasto.getNetmask() + "-"; } - command.add(args); - final String result = command.execute(); + final String result = routerProxy("createipAlias.sh", routerIp, args); return new Answer(cmd, result == null, result); } protected Answer execute(final DeleteIpAliasCommand cmd) { - final Script command = new Script(_deleteIpAliasPath, _timeout, s_logger); String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); String args = ""; - command.add(routerIp); List revokedIpAliasTOs = cmd.getDeleteIpAliasTos(); for (IpAliasTO ipAliasTO : revokedIpAliasTOs) { args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-"; @@ -613,8 +605,7 @@ public class VirtualRoutingResource implements Manager { for (IpAliasTO ipAliasTO : activeIpAliasTOs) { args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-"; } - command.add(args); - final String result = command.execute(); + final String result = routerProxy("deleteipAlias.sh", routerIp, args); return new Answer(cmd, result == null, result); } @@ -1136,24 +1127,10 @@ public class VirtualRoutingResource implements Manager { } _privateEthIf = _privateEthIf.toLowerCase(); - _bumpUpPriorityPath = findScript("bumpUpPriority.sh"); - if (_bumpUpPriorityPath == null) { - throw new ConfigurationException("Unable to find bumpUpPriority.sh"); - } - _routerProxyPath = findScript("router_proxy.sh"); if (_routerProxyPath == null) { 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; } diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java index 5d7cf17204f..817fdec2a2f 100755 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java @@ -2181,14 +2181,14 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa args = args + ipaliasto.getAlias_count() + ":" + ipaliasto.getRouterip() + ":" + ipaliasto.getNetmask() + "-"; } 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 { VmwareManager mgr = getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME); String controlIp = getRouterSshControlIp(cmd); Pair 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()) { 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() + "-"; } 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 { VmwareManager mgr = getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME); String controlIp = getRouterSshControlIp(cmd); Pair 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()) { s_logger.error("deleteIpAlias command on domr " + controlIp + " failed, message: " + result.second()); diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index ea812e3fd76..ddb7912d2b4 100644 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -2194,14 +2194,13 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe } protected Answer execute(final CreateIpAliasCommand cmd) { - Connection conn = getConnection(); String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); List ipAliasTOs = cmd.getIpAliasList(); - String args = routerIp + " "; + String args = ""; for (IpAliasTO ipaliasto : ipAliasTOs) { 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()) { 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) { - Connection conn = getConnection(); String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); List revokedIpAliasTOs = cmd.getDeleteIpAliasTos(); - String args = routerIp + " "; + String args = ""; for (IpAliasTO ipAliasTO : revokedIpAliasTOs) { args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-"; } @@ -2223,7 +2221,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe for (IpAliasTO ipAliasTO : activeIpAliasTOs) { 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()) { return new Answer(cmd, false, "DeleteipAliasCommand failed\n"); } diff --git a/scripts/network/domr/createipAlias.sh b/scripts/network/domr/createipAlias.sh deleted file mode 100755 index c35658e6679..00000000000 --- a/scripts/network/domr/createipAlias.sh +++ /dev/null @@ -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 \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" diff --git a/scripts/network/domr/deleteipAlias.sh b/scripts/network/domr/deleteipAlias.sh deleted file mode 100755 index 6816edd524c..00000000000 --- a/scripts/network/domr/deleteipAlias.sh +++ /dev/null @@ -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 \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" diff --git a/scripts/network/domr/s2s_vpn.sh b/scripts/network/domr/s2s_vpn.sh deleted file mode 100755 index 3ec3e260636..00000000000 --- a/scripts/network/domr/s2s_vpn.sh +++ /dev/null @@ -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 $? diff --git a/scripts/vm/hypervisor/xenserver/vmops b/scripts/vm/hypervisor/xenserver/vmops index 1b045333472..53a00027be6 100755 --- a/scripts/vm/hypervisor/xenserver/vmops +++ b/scripts/vm/hypervisor/xenserver/vmops @@ -255,8 +255,6 @@ def routerProxy(session, args): return txt - - @echo def setLoadBalancerRule(session, args): sargs = args['args'] @@ -272,34 +270,6 @@ def setLoadBalancerRule(session, args): 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 def createFile(session, args): file_path = args['filepath'] @@ -1593,8 +1563,6 @@ if __name__ == "__main__": "destroy_network_rules_for_vm":destroy_network_rules_for_vm, "default_network_rules_systemvm":default_network_rules_systemvm, "network_rules_vmSecondaryIp":network_rules_vmSecondaryIp, - "createipAlias":createipAlias, - "deleteipAlias":deleteipAlias, "get_rule_logs_for_vms":get_rule_logs_for_vms, "add_to_VCPUs_params_live":add_to_VCPUs_params_live, "setLinkLocalIP":setLinkLocalIP, diff --git a/systemvm/patches/debian/config/root/createIpAlias.sh b/systemvm/patches/debian/config/opt/cloud/bin/createIpAlias.sh similarity index 100% rename from systemvm/patches/debian/config/root/createIpAlias.sh rename to systemvm/patches/debian/config/opt/cloud/bin/createIpAlias.sh diff --git a/systemvm/patches/debian/config/root/deleteIpAlias.sh b/systemvm/patches/debian/config/opt/cloud/bin/deleteIpAlias.sh similarity index 100% rename from systemvm/patches/debian/config/root/deleteIpAlias.sh rename to systemvm/patches/debian/config/opt/cloud/bin/deleteIpAlias.sh