Skip to content

Commit 8c1700a

Browse files
anthonyxuAlena Prokharchyk
authored andcommitted
VPC : introduce router_proxy.sh, resource should use this as a proxy to call scripts inside domr
already did this for ipassoc and getDomRVersion
1 parent 31b8f07 commit 8c1700a

8 files changed

Lines changed: 56 additions & 108 deletions

File tree

core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,8 +1359,8 @@ private CheckRouterAnswer execute(CheckRouterCommand cmd) {
13591359

13601360
private GetDomRVersionAnswer execute(GetDomRVersionCmd cmd) {
13611361
Connection conn = getConnection();
1362-
String args = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
1363-
String result = callHostPlugin(conn, "vmops", "getDomRVersion", "args", args);
1362+
String args = "get_template_version.sh " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
1363+
String result = callHostPlugin(conn, "vmops", "routerProxy", "args", args);
13641364
if (result == null || result.isEmpty()) {
13651365
return new GetDomRVersionAnswer(cmd, "getDomRVersionCmd failed");
13661366
}
@@ -1732,7 +1732,7 @@ protected void assignPublicIpAddress(Connection conn, String vmName, String priv
17321732
throw new InternalErrorException("Failed to find DomR VIF to associate/disassociate IP with.");
17331733
}
17341734

1735-
String args = privateIpAddress;
1735+
String args = "ipassoc.sh " + privateIpAddress;
17361736

17371737
if (add) {
17381738
args += " -A ";
@@ -1758,7 +1758,7 @@ protected void assignPublicIpAddress(Connection conn, String vmName, String priv
17581758
args += vlanGateway;
17591759

17601760

1761-
String result = callHostPlugin(conn, "vmops", "ipassoc", "args", args);
1761+
String result = callHostPlugin(conn, "vmops", "routerProxy", "args", args);
17621762
if (result == null || result.isEmpty()) {
17631763
throw new InternalErrorException("Xen plugin \"ipassoc\" failed.");
17641764
}

scripts/network/domr/ipassoc.sh

Lines changed: 0 additions & 52 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
# Copyright 2012 Citrix Systems, Inc. Licensed under the
33
# Apache License, Version 2.0 (the "License"); you may not use this
44
# file except in compliance with the License. Citrix Systems, Inc.
@@ -12,14 +12,11 @@
1212
#
1313
# Automatically generated by addcopyright.py at 04/03/2012
1414

15-
usage() {
16-
printf "Usage:\n %s <domR eth1 ip> \n" $(basename $0) >&2
17-
printf " %s <domR eth1 ip> \n" $(basename $0) >&2
18-
}
1915

20-
cert="/root/.ssh/id_rsa.cloud"
21-
domRIp=$1
22-
shift
16+
17+
# used as a proxy to call script inside virtual router
18+
19+
#set -x
2320

2421
check_gw() {
2522
ping -c 1 -n -q $1 > /dev/null
@@ -28,15 +25,30 @@ check_gw() {
2825
sleep 1
2926
ping -c 1 -n -q $1 > /dev/null
3027
fi
31-
return $?;
28+
if [ $? -gt 0 ]
29+
then
30+
exit 1
31+
fi
3232
}
3333

34+
cert="/root/.ssh/id_rsa.cloud"
35+
36+
script=$1
37+
shift
38+
39+
domRIp=$1
40+
shift
3441

3542
check_gw "$domRIp"
36-
if [ $? -gt 0 ]
37-
then
38-
exit 1
39-
fi
4043

41-
ssh -p 3922 -q -o StrictHostKeyChecking=no -i $cert root@$domRIp "/opt/cloud/bin/get_template_version.sh"
44+
ssh -p 3922 -q -o StrictHostKeyChecking=no -i $cert root@$domRIp "/root/$script $*"
4245
exit $?
46+
47+
48+
49+
50+
51+
52+
53+
54+

scripts/vm/hypervisor/xenserver/vmops

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -139,21 +139,6 @@ def pingxenserver(session, args):
139139
txt = 'success'
140140
return txt
141141

142-
@echo
143-
def ipassoc(session, args):
144-
sargs = args['args']
145-
cmd = sargs.split(' ')
146-
cmd.insert(0, "/opt/xensource/bin/ipassoc.sh")
147-
cmd.insert(0, "/bin/bash")
148-
try:
149-
txt = util.pread2(cmd)
150-
txt = 'success'
151-
except:
152-
util.SMlog(" ip associate failed " )
153-
txt = ''
154-
155-
return txt
156-
157142
@echo
158143
def vm_data(session, args):
159144
router_ip = args.pop('routerIP')
@@ -306,6 +291,8 @@ def setLinkLocalIP(session, args):
306291
txt = ''
307292
txt = 'success'
308293
return txt
294+
295+
309296

310297
@echo
311298
def setFirewallRule(session, args):
@@ -321,6 +308,23 @@ def setFirewallRule(session, args):
321308
txt = ''
322309

323310
return txt
311+
312+
@echo
313+
def routerProxy(session, args):
314+
sargs = args['args']
315+
cmd = sargs.split(' ')
316+
cmd.insert(0, "/opt/xensource/bin/router_proxy.sh")
317+
cmd.insert(0, "/bin/bash")
318+
try:
319+
txt = util.pread2(cmd)
320+
txt = 'success'
321+
except:
322+
util.SMlog("routerProxy command " + sargs + " failed " )
323+
txt = ''
324+
325+
return txt
326+
327+
324328

325329
@echo
326330
def setLoadBalancerRule(session, args):
@@ -1444,26 +1448,13 @@ def bumpUpPriority(session, args):
14441448

14451449
return txt
14461450

1447-
@echo
1448-
def getDomRVersion(session, args):
1449-
sargs = args['args']
1450-
cmd = sargs.split(' ')
1451-
cmd.insert(0, "/opt/xensource/bin/getDomRVersion.sh")
1452-
cmd.insert(0, "/bin/bash")
1453-
try:
1454-
txt = util.pread2(cmd)
1455-
except:
1456-
util.SMlog(" get domR version fail! ")
1457-
txt = ''
1458-
1459-
return txt
14601451

14611452
if __name__ == "__main__":
14621453
XenAPIPlugin.dispatch({"pingtest": pingtest, "setup_iscsi":setup_iscsi, "gethostvmstats": gethostvmstats,
14631454
"getvncport": getvncport, "getgateway": getgateway, "preparemigration": preparemigration,
14641455
"setIptables": setIptables, "pingdomr": pingdomr, "pingxenserver": pingxenserver,
1465-
"ipassoc": ipassoc, "vm_data": vm_data, "savePassword": savePassword,
1466-
"saveDhcpEntry": saveDhcpEntry, "setFirewallRule": setFirewallRule,
1456+
"vm_data": vm_data, "savePassword": savePassword,
1457+
"saveDhcpEntry": saveDhcpEntry, "setFirewallRule": setFirewallRule, "routerProxy": routerProxy,
14671458
"setLoadBalancerRule": setLoadBalancerRule, "createFile": createFile, "deleteFile": deleteFile,
14681459
"networkUsage": networkUsage, "network_rules":network_rules,
14691460
"can_bridge_firewall":can_bridge_firewall, "default_network_rules":default_network_rules,
@@ -1472,5 +1463,5 @@ if __name__ == "__main__":
14721463
"get_rule_logs_for_vms":get_rule_logs_for_vms,
14731464
"setLinkLocalIP":setLinkLocalIP, "lt2p_vpn":lt2p_vpn,
14741465
"cleanup_rules":cleanup_rules, "checkRouter":checkRouter,
1475-
"bumpUpPriority":bumpUpPriority, "getDomRVersion":getDomRVersion,
1466+
"bumpUpPriority":bumpUpPriority,
14761467
"kill_copy_process":kill_copy_process})

scripts/vm/hypervisor/xenserver/xenserver56/patch

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ setup_iscsi.sh=..,0755,/opt/xensource/bin
2222
cloud-setup-bonding.sh=..,0755,/opt/xensource/bin
2323
pingtest.sh=../../..,0755,/opt/xensource/bin
2424
dhcp_entry.sh=../../../../network/domr/,0755,/opt/xensource/bin
25-
ipassoc.sh=../../../../network/domr/,0755,/opt/xensource/bin
2625
vm_data.sh=../../../../network/domr/,0755,/opt/xensource/bin
2726
save_password_to_domr.sh=../../../../network/domr/,0755,/opt/xensource/bin
2827
networkUsage.sh=../../../../network/domr/,0755,/opt/xensource/bin
2928
call_firewall.sh=../../../../network/domr/,0755,/opt/xensource/bin
3029
call_loadbalancer.sh=../../../../network/domr/,0755,/opt/xensource/bin
30+
router_proxy.sh=../../../../network/domr/,0755,/opt/xensource/bin
3131
l2tp_vpn.sh=../../../../network/domr/,0755,/opt/xensource/bin
3232
copy_vhd_to_secondarystorage.sh=..,0755,/opt/xensource/bin
3333
copy_vhd_from_secondarystorage.sh=..,0755,/opt/xensource/bin
@@ -46,6 +46,5 @@ cloud-clean-vlan.sh=..,0755,/opt/xensource/bin
4646
cloud-prepare-upgrade.sh=..,0755,/opt/xensource/bin
4747
getRouterStatus.sh=../../../../network/domr/,0755,/opt/xensource/bin
4848
bumpUpPriority.sh=../../../../network/domr/,0755,/opt/xensource/bin
49-
getDomRVersion.sh=../../../../network/domr/,0755,/opt/xensource/bin
5049
swift=..,0755,/opt/xensource/bin
5150
swiftxen=..,0755,/etc/xapi.d/plugins

scripts/vm/hypervisor/xenserver/xenserver56fp1/patch

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ make_migratable.sh=..,0755,/opt/xensource/bin
2121
setup_iscsi.sh=..,0755,/opt/xensource/bin
2222
pingtest.sh=../../..,0755,/opt/xensource/bin
2323
dhcp_entry.sh=../../../../network/domr/,0755,/opt/xensource/bin
24-
ipassoc.sh=../../../../network/domr/,0755,/opt/xensource/bin
2524
vm_data.sh=../../../../network/domr/,0755,/opt/xensource/bin
2625
save_password_to_domr.sh=../../../../network/domr/,0755,/opt/xensource/bin
2726
networkUsage.sh=../../../../network/domr/,0755,/opt/xensource/bin
2827
call_firewall.sh=../../../../network/domr/,0755,/opt/xensource/bin
2928
call_loadbalancer.sh=../../../../network/domr/,0755,/opt/xensource/bin
29+
router_proxy.sh=../../../../network/domr/,0755,/opt/xensource/bin
3030
l2tp_vpn.sh=../../../../network/domr/,0755,/opt/xensource/bin
3131
cloud-setup-bonding.sh=..,0755,/opt/xensource/bin
3232
copy_vhd_to_secondarystorage.sh=..,0755,/opt/xensource/bin
@@ -45,6 +45,5 @@ cloud-clean-vlan.sh=..,0755,/opt/xensource/bin
4545
cloud-prepare-upgrade.sh=..,0755,/opt/xensource/bin
4646
getRouterStatus.sh=../../../../network/domr/,0755,/opt/xensource/bin
4747
bumpUpPriority.sh=../../../../network/domr/,0755,/opt/xensource/bin
48-
getDomRVersion.sh=../../../../network/domr/,0755,/opt/xensource/bin
4948
swift=..,0755,/opt/xensource/bin
5049
swiftxen=..,0755,/etc/xapi.d/plugins

scripts/vm/hypervisor/xenserver/xenserver60/patch

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ make_migratable.sh=..,0755,/opt/xensource/bin
2727
setup_iscsi.sh=..,0755,/opt/xensource/bin
2828
pingtest.sh=../../..,0755,/opt/xensource/bin
2929
dhcp_entry.sh=../../../../network/domr/,0755,/opt/xensource/bin
30-
ipassoc.sh=../../../../network/domr/,0755,/opt/xensource/bin
3130
vm_data.sh=../../../../network/domr/,0755,/opt/xensource/bin
3231
save_password_to_domr.sh=../../../../network/domr/,0755,/opt/xensource/bin
3332
networkUsage.sh=../../../../network/domr/,0755,/opt/xensource/bin
3433
call_firewall.sh=../../../../network/domr/,0755,/opt/xensource/bin
3534
call_loadbalancer.sh=../../../../network/domr/,0755,/opt/xensource/bin
35+
router_proxy=../../../../network/domr/,0755,/opt/xensource/bin
3636
l2tp_vpn.sh=../../../../network/domr/,0755,/opt/xensource/bin
3737
cloud-setup-bonding.sh=..,0755,/opt/xensource/bin
3838
copy_vhd_to_secondarystorage.sh=..,0755,/opt/xensource/bin
@@ -51,6 +51,5 @@ cloud-clean-vlan.sh=..,0755,/opt/xensource/bin
5151
cloud-prepare-upgrade.sh=..,0755,/opt/xensource/bin
5252
getRouterStatus.sh=../../../../network/domr/,0755,/opt/xensource/bin
5353
bumpUpPriority.sh=../../../../network/domr/,0755,/opt/xensource/bin
54-
getDomRVersion.sh=../../../../network/domr/,0755,/opt/xensource/bin
5554
swift=..,0755,/opt/xensource/bin
5655
swiftxen=..,0755,/etc/xapi.d/plugins

wscript

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# the following two variables are used by the target "waf dist"
55
# 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
66

7-
VERSION = '3.0.3.2012-06-05T23:07:27Z'
7+
VERSION = '3.0.3.2012-06-06T00:22:14Z'
88
APPNAME = 'cloud'
99

1010
import shutil,os

0 commit comments

Comments
 (0)