diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java index 876e3fe4a2c..54ae0f6471d 100755 --- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java +++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java @@ -82,7 +82,6 @@ import com.cloud.utils.script.Script; public class VirtualRoutingResource implements Manager { private static final Logger s_logger = Logger.getLogger(VirtualRoutingResource.class); private String _savepasswordPath; // This script saves a random password to the DomR file system - private String _ipassocPath; private String _publicIpAddress; private String _firewallPath; private String _loadbPath; @@ -90,11 +89,8 @@ public class VirtualRoutingResource implements Manager { private String _vmDataPath; private String _publicEthIf; private String _privateEthIf; - private String _getRouterStatusPath; private String _bumpUpPriorityPath; - private String _l2tpVpnPath; - private String _getDomRVersionPath; - + private String _routerProxyPath; private int _timeout; private int _startTimeout; @@ -146,37 +142,41 @@ public class VirtualRoutingResource implements Manager { } private Answer execute(VpnUsersCfgCommand cmd) { - for (VpnUsersCfgCommand.UsernamePassword userpwd: cmd.getUserpwds()) { - Script command = new Script(_l2tpVpnPath, _timeout, s_logger); - command.add(cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP)); + for (VpnUsersCfgCommand.UsernamePassword userpwd: cmd.getUserpwds()) { + String args = ""; if (!userpwd.isAdd()) { - command.add("-U ", userpwd.getUsername()); + args +="-U "; + args +=userpwd.getUsername(); } else { - command.add("-u ", userpwd.getUsernamePassword()); + args +="-u "; + args += userpwd.getUsernamePassword(); } - String result = command.execute(); + String result = routerProxy("vpn_l2tp.sh", cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP), args); if (result != null) { return new Answer(cmd, false, "Configure VPN user failed for user " + userpwd.getUsername()); } - } - + } return new Answer(cmd); } private Answer execute(RemoteAccessVpnCfgCommand cmd) { - Script command = new Script(_l2tpVpnPath, _timeout, s_logger); - command.add(cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP)); + String args = ""; if (cmd.isCreate()) { - command.add("-r ", cmd.getIpRange()); - command.add("-p ", cmd.getPresharedKey()); - command.add("-s ", cmd.getVpnServerIp()); - command.add("-l ", cmd.getLocalIp()); - command.add("-c "); + args += "-r "; + args += cmd.getIpRange(); + args += " -p "; + args += cmd.getPresharedKey(); + args += " -s "; + args += cmd.getVpnServerIp(); + args += " -l "; + args += cmd.getLocalIp(); + args += " -c "; } else { - command.add("-d "); - command.add("-s ", cmd.getVpnServerIp()); + args +="-d "; + args += " -s "; + args += cmd.getVpnServerIp(); } - String result = command.execute(); + String result = routerProxy("vpn_l2tp.sh", cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP), args); if (result != null) { return new Answer(cmd, false, "Configure VPN failed"); } @@ -474,9 +474,18 @@ public class VirtualRoutingResource implements Manager { } public String getRouterStatus(String routerIP) { - final Script command = new Script(_getRouterStatusPath, _timeout, s_logger); + return routerProxy("checkrouter.sh", routerIP, null); + } + + + public String routerProxy(String script, String routerIP, String args) { + final Script command = new Script(_routerProxyPath, _timeout, s_logger); final OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser(); + command.add(script); command.add(routerIP); + if ( args != null ) { + command.add(args); + } String result = command.execute(parser); if (result == null) { return parser.getLine(); @@ -507,14 +516,7 @@ public class VirtualRoutingResource implements Manager { } protected String getDomRVersion(String routerIP) { - final Script command = new Script(_getDomRVersionPath, _timeout, s_logger); - final OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser(); - command.add(routerIP); - String result = command.execute(parser); - if (result == null) { - return parser.getLine(); - } - return null; + return routerProxy("netusage.sh", routerIP, null); } protected Answer execute(GetDomRVersionCmd cmd) { @@ -592,16 +594,17 @@ public class VirtualRoutingResource implements Manager { public String assignPublicIpAddress(final String vmName, final long id, final String vnet, final String privateIpAddress, final String macAddress, final String publicIpAddress) { - - final Script command = new Script(_ipassocPath, _timeout, s_logger); - command.add("-A"); - command.add("-f"); //first ip is source nat ip - command.add("-r", vmName); - command.add("-i", privateIpAddress); - command.add("-a", macAddress); - command.add("-l", publicIpAddress); - - return command.execute(); + String args ="-A"; + args += " -f"; //first ip is source nat ip + args += " -r "; + args += vmName; + args += " -i "; + args += privateIpAddress; + args += " -a "; + args += macAddress; + args += " -l "; + args += publicIpAddress; + return routerProxy("ipassoc.sh", privateIpAddress, args); } public String assignPublicIpAddress(final String vmName, @@ -610,30 +613,29 @@ public class VirtualRoutingResource implements Manager { final String vlanId, final String vlanGateway, final String vlanNetmask, final String vifMacAddress, String guestIp, int nicNum){ - final Script command = new Script(_ipassocPath, _timeout, s_logger); - command.add( privateIpAddress); + String args = ""; if (add) { - command.add("-A"); + args += "-A"; } else { - command.add("-D"); - } - - if (sourceNat) { - command.add("-s"); - } - if (firstIP) { - command.add( "-f"); - + args += "-D"; } String cidrSize = Long.toString(NetUtils.getCidrSize(vlanNetmask)); - command.add( "-l", publicIpAddress + "/" + cidrSize); - String publicNic = "eth" + nicNum; - command.add("-c", publicNic); - - command.add("-g", vlanGateway); - + if (sourceNat) { + args +=" -s"; + } + if (firstIP) { + args += " -f"; + } + args += " -l "; + args += publicIpAddress + "/" + cidrSize; - return command.execute(); + String publicNic = "eth" + nicNum; + args += " -c "; + args += publicNic; + + args +=" -g "; + args += vlanGateway; + return routerProxy("ipassoc.sh", privateIpAddress, args); } private void deletExitingLinkLocalRoutTable(String linkLocalBr) { @@ -801,12 +803,6 @@ public class VirtualRoutingResource implements Manager { value = (String)params.get("ssh.port"); _port = NumbersUtil.parseInt(value, 3922); - _ipassocPath = findScript("ipassoc.sh"); - if (_ipassocPath == null) { - throw new ConfigurationException("Unable to find the ipassoc.sh"); - } - s_logger.info("ipassoc.sh found in " + _ipassocPath); - _publicIpAddress = (String)params.get("public.ip.address"); if (_publicIpAddress != null) { s_logger.warn("Incoming public ip address is overriden. Will always be using the same ip address: " + _publicIpAddress); @@ -837,11 +833,6 @@ public class VirtualRoutingResource implements Manager { throw new ConfigurationException("Unable to find user_data.sh"); } - _getRouterStatusPath = findScript("getRouterStatus.sh"); - if(_getRouterStatusPath == null) { - throw new ConfigurationException("Unable to find getRouterStatus.sh"); - } - _publicEthIf = (String)params.get("public.network.device"); if (_publicEthIf == null) { _publicEthIf = "xenbr1"; @@ -859,14 +850,9 @@ public class VirtualRoutingResource implements Manager { throw new ConfigurationException("Unable to find bumpUpPriority.sh"); } - _l2tpVpnPath = findScript("l2tp_vpn.sh"); - if (_l2tpVpnPath == null) { - throw new ConfigurationException("Unable to find l2tp_vpn.sh"); - } - - _getDomRVersionPath = findScript("getDomRVersion.sh"); - if(_getDomRVersionPath == null) { - throw new ConfigurationException("Unable to find getDomRVersion.sh"); + _routerProxyPath = findScript("routerProxy.sh"); + if (_routerProxyPath == null) { + throw new ConfigurationException("Unable to find routerProxy.sh"); } return true; diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index 79582a4d7c9..edb1881db78 100644 --- a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -1588,7 +1588,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe protected synchronized Answer execute(final RemoteAccessVpnCfgCommand cmd) { Connection conn = getConnection(); - String args = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); + String args = "vpn_l2tp.sh " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); if (cmd.isCreate()) { args += " -r " + cmd.getIpRange(); args += " -p " + cmd.getPresharedKey(); @@ -1600,7 +1600,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe args += " -d "; args += " -s " + cmd.getVpnServerIp(); } - String result = callHostPlugin(conn, "vmops", "lt2p_vpn", "args", args); + String result = callHostPlugin(conn, "vmops", "routerProxy", "args", args); if (result == null || result.isEmpty()) { return new Answer(cmd, false, "Configure VPN failed"); } diff --git a/scripts/network/domr/l2tp_vpn.sh b/scripts/network/domr/l2tp_vpn.sh deleted file mode 100755 index 87d9a033c0e..00000000000 --- a/scripts/network/domr/l2tp_vpn.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -# Copyright 2012 Citrix Systems, Inc. Licensed under the -# Apache License, Version 2.0 (the "License"); you may not use this -# file except in compliance with the License. Citrix Systems, Inc. -# reserves all rights not expressly granted by 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. -# -# Automatically generated by addcopyright.py at 04/03/2012 - - - - - -# @VERSION@ - -cert="/root/.ssh/id_rsa.cloud" -domr=$1 -shift -ssh -p 3922 -o StrictHostKeyChecking=no -i $cert root@$domr "/opt/cloud/bin/vpn_l2tp.sh $*" >/dev/null - -exit $? diff --git a/scripts/vm/hypervisor/xenserver/vmops b/scripts/vm/hypervisor/xenserver/vmops index 2718f1e0a9f..51627a84e28 100755 --- a/scripts/vm/hypervisor/xenserver/vmops +++ b/scripts/vm/hypervisor/xenserver/vmops @@ -232,21 +232,6 @@ def saveDhcpEntry(session, args): return txt -@echo -def lt2p_vpn(session, args): - sargs = args['args'] - cmd = sargs.split(' ') - cmd.insert(0, "/opt/xensource/bin/l2tp_vpn.sh") - cmd.insert(0, "/bin/bash") - try: - txt = util.pread2(cmd) - txt = 'success' - except: - util.SMlog("l2tp vpn failed " ) - txt = '' - - return txt - @echo def setLinkLocalIP(session, args): brName = args['brName'] @@ -1434,7 +1419,7 @@ if __name__ == "__main__": "destroy_network_rules_for_vm":destroy_network_rules_for_vm, "default_network_rules_systemvm":default_network_rules_systemvm, "get_rule_logs_for_vms":get_rule_logs_for_vms, - "setLinkLocalIP":setLinkLocalIP, "lt2p_vpn":lt2p_vpn, + "setLinkLocalIP":setLinkLocalIP, "cleanup_rules":cleanup_rules, "bumpUpPriority":bumpUpPriority, "kill_copy_process":kill_copy_process}) diff --git a/scripts/vm/hypervisor/xenserver/xcpserver/patch b/scripts/vm/hypervisor/xenserver/xcpserver/patch index b26bd31d633..7171635be16 100644 --- a/scripts/vm/hypervisor/xenserver/xcpserver/patch +++ b/scripts/vm/hypervisor/xenserver/xcpserver/patch @@ -28,7 +28,6 @@ vm_data.sh=../../../../network/domr/,0755,/opt/xensource/bin save_password_to_domr.sh=../../../../network/domr/,0755,/opt/xensource/bin call_firewall.sh=../../../../network/domr/,0755,/opt/xensource/bin call_loadbalancer.sh=../../../../network/domr/,0755,/opt/xensource/bin -l2tp_vpn.sh=../../../../network/domr/,0755,/opt/xensource/bin cloud-setup-bonding.sh=..,0755,/opt/xensource/bin copy_vhd_to_secondarystorage.sh=..,0755,/opt/xensource/bin copy_vhd_from_secondarystorage.sh=..,0755,/opt/xensource/bin diff --git a/scripts/vm/hypervisor/xenserver/xenserver56/patch b/scripts/vm/hypervisor/xenserver/xenserver56/patch index 23c87611591..37d4290f1c3 100644 --- a/scripts/vm/hypervisor/xenserver/xenserver56/patch +++ b/scripts/vm/hypervisor/xenserver/xenserver56/patch @@ -27,7 +27,6 @@ save_password_to_domr.sh=../../../../network/domr/,0755,/opt/xensource/bin call_firewall.sh=../../../../network/domr/,0755,/opt/xensource/bin call_loadbalancer.sh=../../../../network/domr/,0755,/opt/xensource/bin router_proxy.sh=../../../../network/domr/,0755,/opt/xensource/bin -l2tp_vpn.sh=../../../../network/domr/,0755,/opt/xensource/bin copy_vhd_to_secondarystorage.sh=..,0755,/opt/xensource/bin copy_vhd_from_secondarystorage.sh=..,0755,/opt/xensource/bin kill_copy_process.sh=..,0755,/opt/xensource/bin diff --git a/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch b/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch index c979c43a136..5e6aac1f697 100644 --- a/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch +++ b/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch @@ -26,7 +26,6 @@ save_password_to_domr.sh=../../../../network/domr/,0755,/opt/xensource/bin call_firewall.sh=../../../../network/domr/,0755,/opt/xensource/bin call_loadbalancer.sh=../../../../network/domr/,0755,/opt/xensource/bin router_proxy.sh=../../../../network/domr/,0755,/opt/xensource/bin -l2tp_vpn.sh=../../../../network/domr/,0755,/opt/xensource/bin cloud-setup-bonding.sh=..,0755,/opt/xensource/bin copy_vhd_to_secondarystorage.sh=..,0755,/opt/xensource/bin copy_vhd_from_secondarystorage.sh=..,0755,/opt/xensource/bin diff --git a/scripts/vm/hypervisor/xenserver/xenserver60/patch b/scripts/vm/hypervisor/xenserver/xenserver60/patch index a7212e8ec1a..fdbfbbef050 100644 --- a/scripts/vm/hypervisor/xenserver/xenserver60/patch +++ b/scripts/vm/hypervisor/xenserver/xenserver60/patch @@ -31,7 +31,6 @@ save_password_to_domr.sh=../../../../network/domr/,0755,/opt/xensource/bin call_firewall.sh=../../../../network/domr/,0755,/opt/xensource/bin call_loadbalancer.sh=../../../../network/domr/,0755,/opt/xensource/bin router_proxy.sh=../../../../network/domr/,0755,/opt/xensource/bin -l2tp_vpn.sh=../../../../network/domr/,0755,/opt/xensource/bin cloud-setup-bonding.sh=..,0755,/opt/xensource/bin copy_vhd_to_secondarystorage.sh=..,0755,/opt/xensource/bin copy_vhd_from_secondarystorage.sh=..,0755,/opt/xensource/bin diff --git a/wscript b/wscript index 4ef4e365f14..26a82f5de80 100644 --- a/wscript +++ b/wscript @@ -4,7 +4,7 @@ # the following two variables are used by the target "waf dist" # if you change 'em here, you need to change it also in cloud.spec, add a %changelog entry there, and add an entry in debian/changelog -VERSION = '3.0.3.2012-06-06T23:43:59Z' +VERSION = '3.0.3.2012-06-07T00:17:43Z' APPNAME = 'cloud' import shutil,os