-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Add load balancer support. #218
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,11 +163,11 @@ def lrouter_nat_add(self, lrouter, nat_type, external_ip, logical_ip): | |
params = [lrouter, nat_type, external_ip, logical_ip] | ||
self.run("lr-nat-add", args=params) | ||
|
||
def lswitch_add(self, name, other_cfg={}): | ||
params = [name] | ||
|
||
def lswitch_add(self, name, other_cfg={}, lbs=[]): | ||
self.run("ls-add", args=[name]) | ||
|
||
self.run("ls-add", args=params) | ||
for lb in lbs: | ||
self.run("ls-lb-add", args=[name, lb]) | ||
|
||
for cfg, val in other_cfg.items(): | ||
param_cfg = 'other_config:{c}="{v}"'.format(c=cfg, v=val) | ||
|
@@ -282,6 +282,26 @@ def port_group_del(self, port_group): | |
params = [port_group] | ||
self.run("pg-del", [], params) | ||
|
||
def lb_add(self, lb_name, lb_vip, lb_proto): | ||
params = [lb_name, lb_vip, '\'\'', lb_proto] | ||
self.run("lb-add", [], params) | ||
|
||
def lb_set_vip_backends(self, lb_name, lb_vip, lb_backends): | ||
vips_set='vips=\'\"{}\"=\"{}\"\''.format(lb_vip, lb_backends) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit, you can get rid of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ack, thanks. |
||
params = ['Load_Balancer', lb_name, vips_set] | ||
self.run('set', args=params) | ||
|
||
def lb_list(self, lb_name=None): | ||
opts = ['--bare', '--columns', 'name,vips'] | ||
params = ['Load_Balancer'] | ||
if lb_name: | ||
params.append(lb_name) | ||
stdout = StringIO() | ||
self.run('list', opts=opts, args=params, stdout=stdout) | ||
output = stdout.getvalue() | ||
|
||
return get_lb_info(output) | ||
|
||
def show(self, lswitch=None): | ||
params = [lswitch] if lswitch else [] | ||
stdout = StringIO() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -418,6 +418,11 @@ def setup_switch_per_node(self, fake_multinode_args = {}, | |
lport_create_args = {}, | ||
port_bind_args = {}, | ||
create_mgmt_port = True): | ||
# TODO: figure out how to not reload the context? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @putnopvut This is the hack I was talking about. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you go into a bit more detail about what's going on here? I've been away from this for long enough that I don't even know what it means to reload the context. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The rally runner doesn't allow that because iterations might be run in parallel, I presume. To work around it I explicitly updated self.context["ovn-nb-lbs"] with the results of |
||
ovn_nbctl = self._get_ovn_controller(self.install_method) | ||
lswitches = ovn_nbctl.show() | ||
self.context["ovn-nb-lbs"] = ovn_nbctl.lb_list() | ||
|
||
self.connect_chassis_nodes(fake_multinode_args) | ||
self.wait_chassis_nodes(fake_multinode_args) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the
=
token is not found, thensplit()
will return a list containing the whole string as the first item. Therefore,len(tokens)
wont' ever be 0.You can just replace this whole block with
This will ensure that
lbs[lb_name]
is set to a tuple of 2 items. If the=
is not present, then the second item of the tuple will be an empty string.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Way better, will do, thanks!