Skip to content

Commit b7b54f1

Browse files
Ian Southamwilderrodrigues
authored andcommitted
Fixes to enable test to succeed. Small change to Marvin to be able to override retries
Signed-off-by: wilderrodrigues <wrodrigues@schubergphilis.com>
1 parent 1a93d70 commit b7b54f1

4 files changed

Lines changed: 52 additions & 30 deletions

File tree

‎systemvm/patches/debian/config/opt/cloud/bin/configure.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
from cs.CsApp import CsApache, CsDnsmasq
4040
from cs.CsMonitor import CsMonitor
4141
from cs.CsLoadBalancer import CsLoadBalancer
42+
from cs.CsConfig import CsConfig
4243

4344

4445
class CsPassword(CsDataBag):

‎systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,14 @@ def get_ips(self):
4848

4949
def get_guest_if(self):
5050
"""
51-
Return CsInterface object for the first guest interface
51+
Return CsInterface object for the lowest guest interface
5252
"""
53+
ipr = []
5354
for ip in self.get_ips():
5455
if ip.is_guest():
55-
return ip
56+
ipr.append(ip)
57+
if len(ipr) > 0:
58+
return sorted(ipr)[-1]
5659
return None
5760

5861
def get_guest_ip(self):
@@ -407,10 +410,10 @@ def fw_vpcrouter(self):
407410
])
408411

409412
if self.get_type() in ["public"]:
410-
self.fw.append(["nat", "front",
411-
"-A POSTROUTING -o %s -j SNAT --to-source %s" %
412-
(self.dev, self.address['public_ip'])
413-
])
413+
# self.fw.append(["nat", "front",
414+
# "-A POSTROUTING -o %s -j SNAT --to-source %s" %
415+
# (self.dev, self.address['public_ip'])
416+
# ])
414417
self.fw.append(["", "front",
415418
"-A FORWARD -o %s -d %s -j ACL_INBOUND_%s" % (self.dev, self.address['network'], self.dev)
416419
])

‎systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py‎

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,13 @@
3030
# eth1 public ip
3131
# eth2+ Guest networks
3232
# -------------------------------------------------------------------- #
33-
import sys
3433
import os
35-
from pprint import pprint
36-
from CsDatabag import CsDataBag, CsCmdLine
3734
import logging
3835
import CsHelper
3936
from CsFile import CsFile
40-
from CsConfig import CsConfig
4137
from CsProcess import CsProcess
4238
from CsApp import CsPasswdSvc
39+
from CsAddress import CsDevice
4340
import socket
4441
from time import sleep
4542

@@ -64,6 +61,7 @@ class CsRedundant(object):
6461
def __init__(self, config):
6562
self.cl = config.cmdline()
6663
self.address = config.address()
64+
self.config = config
6765

6866
def set(self):
6967
logging.debug("Router redundancy status is %s", self.cl.is_redundant())
@@ -83,13 +81,11 @@ def _redundant_off(self):
8381
def _redundant_on(self):
8482
guest = self.address.get_guest_if()
8583
# No redundancy if there is no guest network
84+
if self.cl.is_master() or guest is None:
85+
for obj in [o for o in self.address.get_ips() if o.is_public()]:
86+
self.check_is_up(obj.get_device())
8687
if guest is None:
8788
self._redundant_off()
88-
# Bring up the public Interface(s)
89-
if self.cl.is_master():
90-
for obj in [o for o in self.address.get_ips() if o.is_public()]:
91-
print obj.get_device()
92-
self.check_is_up(obj.get_device())
9389
return
9490
CsHelper.mkdir(self.CS_RAMDISK_DIR, 0755, False)
9591
CsHelper.mount_tmpfs(self.CS_RAMDISK_DIR)
@@ -159,6 +155,12 @@ def _redundant_on(self):
159155
if not proc.find():
160156
CsHelper.service("keepalived", "restart")
161157

158+
def release_lock(self):
159+
try:
160+
os.remove("/tmp/master_lock")
161+
except OSError:
162+
pass
163+
162164
def set_lock(self):
163165
"""
164166
Make sure that master state changes happen sequentially
@@ -169,21 +171,21 @@ def set_lock(self):
169171
for iter in range(0, iterations):
170172
try:
171173
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
172-
s.bind('\0master_lock')
174+
s.bind('/tmp/master_lock')
173175
return s
174176
except socket.error, e:
175177
error_code = e.args[0]
176178
error_string = e.args[1]
177179
print "Process already running (%d:%s). Exiting" % (error_code, error_string)
178180
logging.info("Master is already running, waiting")
179-
sleep(1)
181+
sleep(time_between)
180182

181183
def set_fault(self):
182184
""" Set fault mode on this router """
183185
if not self.cl.is_redundant():
184186
logging.error("Set fault called on non-redundant router")
185187
return
186-
s = self.set_lock()
188+
self.set_lock()
187189
logging.info("Router switched to fault mode")
188190
ads = [o for o in self.address.get_ips() if o.is_public()]
189191
for o in ads:
@@ -195,9 +197,10 @@ def set_fault(self):
195197
CsHelper.service("dnsmasq", "stop")
196198
ads = [o for o in self.address.get_ips() if o.needs_vrrp()]
197199
for o in ads:
198-
pwdsvc = CsPasswdSvc(o.get_gateway()).stop()
200+
CsPasswdSvc(o.get_gateway()).stop()
199201
self.cl.set_fault_state()
200202
self.cl.save()
203+
self.release_lock()
201204
logging.info("Router switched to fault mode")
202205

203206
def set_backup(self):
@@ -210,22 +213,29 @@ def set_backup(self):
210213
logging.error("Set backup called on node that is already backup")
211214
return
212215
"""
213-
s = self.set_lock()
216+
self.set_lock()
214217
logging.debug("Setting router to backup")
215218
ads = [o for o in self.address.get_ips() if o.is_public()]
219+
dev = ''
216220
for o in ads:
217-
CsHelper.execute("ifconfig %s down" % o.get_device())
221+
if dev == o.get_device():
222+
continue
223+
logging.info("Bringing public interface %s down" % o.get_device())
224+
cmd2 = "ip link set %s up" % o.get_device()
225+
CsHelper.execute(cmd2)
226+
dev = o.get_device()
218227
cmd = "%s -C %s" % (self.CONNTRACKD_BIN, self.CONNTRACKD_CONF)
219228
CsHelper.execute("%s -d" % cmd)
220229
CsHelper.service("ipsec", "stop")
221230
CsHelper.service("xl2tpd", "stop")
222231
ads = [o for o in self.address.get_ips() if o.needs_vrrp()]
223232
for o in ads:
224-
pwdsvc = CsPasswdSvc(o.get_gateway()).stop()
233+
CsPasswdSvc(o.get_gateway()).stop()
225234
CsHelper.service("dnsmasq", "stop")
226235
# self._set_priority(self.CS_PRIO_DOWN)
227236
self.cl.set_master_state(False)
228237
self.cl.save()
238+
self.release_lock()
229239
logging.info("Router switched to backup mode")
230240

231241
def set_master(self):
@@ -238,15 +248,20 @@ def set_master(self):
238248
logging.error("Set master called on master node")
239249
return
240250
"""
241-
s = self.set_lock()
251+
self.set_lock()
242252
logging.debug("Setting router to master")
243253
ads = [o for o in self.address.get_ips() if o.is_public()]
254+
dev = ''
244255
for o in ads:
245-
# cmd2 = "ip link set %s up" % self.getDevice()
246-
CsHelper.execute("ifconfig %s down" % o.get_device())
247-
CsHelper.execute("ifconfig %s up" % o.get_device())
248-
CsHelper.execute("arping -I %s -A %s -c 1" % (o.get_device(), o.get_ip()))
249-
# FIXME Need to add in the default routes but I am unsure what the gateway is
256+
if dev == o.get_device():
257+
continue
258+
cmd2 = "ip link set %s up" % o.get_device()
259+
if CsDevice(o.get_device(), self.config).waitfordevice():
260+
CsHelper.execute(cmd2)
261+
dev = o.get_device()
262+
logging.info("Bringing public interface %s up" % o.get_device())
263+
else:
264+
logging.error("Device %s was not ready could not bring it up" % o.get_device())
250265
# ip route add default via $gw table Table_$dev proto static
251266
cmd = "%s -C %s" % (self.CONNTRACKD_BIN, self.CONNTRACKD_CONF)
252267
CsHelper.execute("%s -c" % cmd)
@@ -257,10 +272,11 @@ def set_master(self):
257272
CsHelper.service("xl2tpd", "restart")
258273
ads = [o for o in self.address.get_ips() if o.needs_vrrp()]
259274
for o in ads:
260-
pwdsvc = CsPasswdSvc(o.get_gateway()).restart()
275+
CsPasswdSvc(o.get_gateway()).restart()
261276
CsHelper.service("dnsmasq", "restart")
262277
self.cl.set_master_state(True)
263278
self.cl.save()
279+
self.release_lock()
264280
logging.info("Router switched to master mode")
265281

266282
def _collect_ignore_ips(self):

‎tools/marvin/marvin/lib/base.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ def restore(self, apiclient, templateid=None):
551551

552552
def get_ssh_client(
553553
self, ipaddress=None, reconnect=False, port=None,
554-
keyPairFileLocation=None):
554+
keyPairFileLocation=None, retries=20):
555555
"""Get SSH object of VM"""
556556

557557
# If NAT Rules are not created while VM deployment in Advanced mode
@@ -570,13 +570,15 @@ def get_ssh_client(
570570
self.ssh_port,
571571
self.username,
572572
self.password,
573+
retries=retries,
573574
keyPairFileLocation=keyPairFileLocation
574575
)
575576
self.ssh_client = self.ssh_client or is_server_ssh_ready(
576577
self.ssh_ip,
577578
self.ssh_port,
578579
self.username,
579580
self.password,
581+
retries=retries,
580582
keyPairFileLocation=keyPairFileLocation
581583
)
582584
return self.ssh_client

0 commit comments

Comments
 (0)