mirror of https://github.com/apache/cloudstack.git
VPC : introduce router_proxy.sh, resource should use this as a proxy to call scripts inside domr
already did this for ipassoc and getDomRVersion
This commit is contained in:
parent
d9758045d9
commit
076a876f80
|
|
@ -1340,8 +1340,8 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
|
||||
private GetDomRVersionAnswer execute(GetDomRVersionCmd cmd) {
|
||||
Connection conn = getConnection();
|
||||
String args = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
||||
String result = callHostPlugin(conn, "vmops", "getDomRVersion", "args", args);
|
||||
String args = "get_template_version.sh " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
||||
String result = callHostPlugin(conn, "vmops", "routerProxy", "args", args);
|
||||
if (result == null || result.isEmpty()) {
|
||||
return new GetDomRVersionAnswer(cmd, "getDomRVersionCmd failed");
|
||||
}
|
||||
|
|
@ -1717,7 +1717,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
throw new InternalErrorException("Failed to find DomR VIF to associate/disassociate IP with.");
|
||||
}
|
||||
|
||||
String args = privateIpAddress;
|
||||
String args = "ipassoc.sh " + privateIpAddress;
|
||||
|
||||
if (add) {
|
||||
args += " -A ";
|
||||
|
|
@ -1744,7 +1744,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
args += vlanGateway;
|
||||
|
||||
|
||||
String result = callHostPlugin(conn, "vmops", "ipassoc", "args", args);
|
||||
String result = callHostPlugin(conn, "vmops", "routerProxy", "args", args);
|
||||
if (result == null || result.isEmpty()) {
|
||||
throw new InternalErrorException("Xen plugin \"ipassoc\" failed.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,52 +0,0 @@
|
|||
#!/usr/bin/env 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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# $Id: ipassoc.sh 9804 2010-06-22 18:36:49Z alex $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/network/domr/ipassoc.sh $
|
||||
# ipassoc.sh -- associate/disassociate a public ip with an instance
|
||||
# 2.1.4
|
||||
usage() {
|
||||
printf "Usage:\n %s -A -i <domR eth1 ip> -l <public-ip-address> -r <domr name> [-f] \n" $(basename $0) >&2
|
||||
printf " %s -D -i <domR eth1 ip> -l <public-ip-address> -r <domr name> [-f] \n" $(basename $0) >&2
|
||||
}
|
||||
|
||||
cert="/root/.ssh/id_rsa.cloud"
|
||||
domRIp=$1
|
||||
shift
|
||||
|
||||
|
||||
check_gw() {
|
||||
ping -c 1 -n -q $1 > /dev/null
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
sleep 1
|
||||
ping -c 1 -n -q $1 > /dev/null
|
||||
fi
|
||||
return $?;
|
||||
}
|
||||
|
||||
|
||||
check_gw "$domRIp"
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
ssh -p 3922 -q -o StrictHostKeyChecking=no -i $cert root@$domRIp "/root/ipassoc.sh $*"
|
||||
exit $?
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
#!/usr/bin/env 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.
|
||||
|
|
@ -12,14 +12,11 @@
|
|||
#
|
||||
# Automatically generated by addcopyright.py at 04/03/2012
|
||||
|
||||
usage() {
|
||||
printf "Usage:\n %s <domR eth1 ip> \n" $(basename $0) >&2
|
||||
printf " %s <domR eth1 ip> \n" $(basename $0) >&2
|
||||
}
|
||||
|
||||
cert="/root/.ssh/id_rsa.cloud"
|
||||
domRIp=$1
|
||||
shift
|
||||
|
||||
# used as a proxy to call script inside virtual router
|
||||
|
||||
#set -x
|
||||
|
||||
check_gw() {
|
||||
ping -c 1 -n -q $1 > /dev/null
|
||||
|
|
@ -28,15 +25,30 @@ check_gw() {
|
|||
sleep 1
|
||||
ping -c 1 -n -q $1 > /dev/null
|
||||
fi
|
||||
return $?;
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
cert="/root/.ssh/id_rsa.cloud"
|
||||
|
||||
script=$1
|
||||
shift
|
||||
|
||||
domRIp=$1
|
||||
shift
|
||||
|
||||
check_gw "$domRIp"
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ssh -p 3922 -q -o StrictHostKeyChecking=no -i $cert root@$domRIp "/opt/cloud/bin/get_template_version.sh"
|
||||
ssh -p 3922 -q -o StrictHostKeyChecking=no -i $cert root@$domRIp "/root/$script $*"
|
||||
exit $?
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -139,21 +139,6 @@ def pingxenserver(session, args):
|
|||
txt = 'success'
|
||||
return txt
|
||||
|
||||
@echo
|
||||
def ipassoc(session, args):
|
||||
sargs = args['args']
|
||||
cmd = sargs.split(' ')
|
||||
cmd.insert(0, "/opt/xensource/bin/ipassoc.sh")
|
||||
cmd.insert(0, "/bin/bash")
|
||||
try:
|
||||
txt = util.pread2(cmd)
|
||||
txt = 'success'
|
||||
except:
|
||||
util.SMlog(" ip associate failed " )
|
||||
txt = ''
|
||||
|
||||
return txt
|
||||
|
||||
@echo
|
||||
def vm_data(session, args):
|
||||
router_ip = args.pop('routerIP')
|
||||
|
|
@ -298,6 +283,8 @@ def setLinkLocalIP(session, args):
|
|||
txt = ''
|
||||
txt = 'success'
|
||||
return txt
|
||||
|
||||
|
||||
|
||||
@echo
|
||||
def setFirewallRule(session, args):
|
||||
|
|
@ -313,6 +300,23 @@ def setFirewallRule(session, args):
|
|||
txt = ''
|
||||
|
||||
return txt
|
||||
|
||||
@echo
|
||||
def routerProxy(session, args):
|
||||
sargs = args['args']
|
||||
cmd = sargs.split(' ')
|
||||
cmd.insert(0, "/opt/xensource/bin/router_proxy.sh")
|
||||
cmd.insert(0, "/bin/bash")
|
||||
try:
|
||||
txt = util.pread2(cmd)
|
||||
txt = 'success'
|
||||
except:
|
||||
util.SMlog("routerProxy command " + sargs + " failed " )
|
||||
txt = ''
|
||||
|
||||
return txt
|
||||
|
||||
|
||||
|
||||
@echo
|
||||
def setLoadBalancerRule(session, args):
|
||||
|
|
@ -1436,26 +1440,13 @@ def bumpUpPriority(session, args):
|
|||
|
||||
return txt
|
||||
|
||||
@echo
|
||||
def getDomRVersion(session, args):
|
||||
sargs = args['args']
|
||||
cmd = sargs.split(' ')
|
||||
cmd.insert(0, "/opt/xensource/bin/getDomRVersion.sh")
|
||||
cmd.insert(0, "/bin/bash")
|
||||
try:
|
||||
txt = util.pread2(cmd)
|
||||
except:
|
||||
util.SMlog(" get domR version fail! ")
|
||||
txt = ''
|
||||
|
||||
return txt
|
||||
|
||||
if __name__ == "__main__":
|
||||
XenAPIPlugin.dispatch({"pingtest": pingtest, "setup_iscsi":setup_iscsi, "gethostvmstats": gethostvmstats,
|
||||
"getvncport": getvncport, "getgateway": getgateway, "preparemigration": preparemigration,
|
||||
"setIptables": setIptables, "pingdomr": pingdomr, "pingxenserver": pingxenserver,
|
||||
"ipassoc": ipassoc, "vm_data": vm_data, "savePassword": savePassword,
|
||||
"saveDhcpEntry": saveDhcpEntry, "setFirewallRule": setFirewallRule,
|
||||
"vm_data": vm_data, "savePassword": savePassword,
|
||||
"saveDhcpEntry": saveDhcpEntry, "setFirewallRule": setFirewallRule, "routerProxy": routerProxy,
|
||||
"setLoadBalancerRule": setLoadBalancerRule, "createFile": createFile, "deleteFile": deleteFile,
|
||||
"networkUsage": networkUsage, "network_rules":network_rules,
|
||||
"can_bridge_firewall":can_bridge_firewall, "default_network_rules":default_network_rules,
|
||||
|
|
@ -1464,5 +1455,5 @@ if __name__ == "__main__":
|
|||
"get_rule_logs_for_vms":get_rule_logs_for_vms,
|
||||
"setLinkLocalIP":setLinkLocalIP, "lt2p_vpn":lt2p_vpn,
|
||||
"cleanup_rules":cleanup_rules, "checkRouter":checkRouter,
|
||||
"bumpUpPriority":bumpUpPriority, "getDomRVersion":getDomRVersion,
|
||||
"bumpUpPriority":bumpUpPriority,
|
||||
"kill_copy_process":kill_copy_process})
|
||||
|
|
|
|||
|
|
@ -22,12 +22,12 @@ setup_iscsi.sh=..,0755,/opt/xensource/bin
|
|||
cloud-setup-bonding.sh=..,0755,/opt/xensource/bin
|
||||
pingtest.sh=../../..,0755,/opt/xensource/bin
|
||||
dhcp_entry.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
ipassoc.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
vm_data.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
save_password_to_domr.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
networkUsage.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
|
||||
|
|
@ -46,6 +46,5 @@ cloud-clean-vlan.sh=..,0755,/opt/xensource/bin
|
|||
cloud-prepare-upgrade.sh=..,0755,/opt/xensource/bin
|
||||
getRouterStatus.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
bumpUpPriority.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
getDomRVersion.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
swift=..,0755,/opt/xensource/bin
|
||||
swiftxen=..,0755,/etc/xapi.d/plugins
|
||||
|
|
|
|||
|
|
@ -27,12 +27,12 @@ make_migratable.sh=..,0755,/opt/xensource/bin
|
|||
setup_iscsi.sh=..,0755,/opt/xensource/bin
|
||||
pingtest.sh=../../..,0755,/opt/xensource/bin
|
||||
dhcp_entry.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
ipassoc.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
vm_data.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
save_password_to_domr.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
networkUsage.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
|
||||
|
|
@ -51,6 +51,5 @@ cloud-clean-vlan.sh=..,0755,/opt/xensource/bin
|
|||
cloud-prepare-upgrade.sh=..,0755,/opt/xensource/bin
|
||||
getRouterStatus.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
bumpUpPriority.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
getDomRVersion.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
swift=..,0755,/opt/xensource/bin
|
||||
swiftxen=..,0755,/etc/xapi.d/plugins
|
||||
|
|
|
|||
|
|
@ -27,12 +27,12 @@ make_migratable.sh=..,0755,/opt/xensource/bin
|
|||
setup_iscsi.sh=..,0755,/opt/xensource/bin
|
||||
pingtest.sh=../../..,0755,/opt/xensource/bin
|
||||
dhcp_entry.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
ipassoc.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
vm_data.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
save_password_to_domr.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
networkUsage.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=../../../../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
|
||||
|
|
@ -51,6 +51,5 @@ cloud-clean-vlan.sh=..,0755,/opt/xensource/bin
|
|||
cloud-prepare-upgrade.sh=..,0755,/opt/xensource/bin
|
||||
getRouterStatus.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
bumpUpPriority.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
getDomRVersion.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
swift=..,0755,/opt/xensource/bin
|
||||
swiftxen=..,0755,/etc/xapi.d/plugins
|
||||
|
|
|
|||
2
wscript
2
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-05T23:07:27Z'
|
||||
VERSION = '3.0.3.2012-06-06T00:22:14Z'
|
||||
APPNAME = 'cloud'
|
||||
|
||||
import shutil,os
|
||||
|
|
|
|||
Loading…
Reference in New Issue