Skip to content

Commit

Permalink
Endpoint override from octavia-proxy (#102)
Browse files Browse the repository at this point in the history
Endpoint override from octavia-proxy

Closes #101
Added [elbv2_driver_settings] and [elbv3_driver_settings] sections in config.
Now additional driver settings added in context right before creation of connection.
Closes #103

Reviewed-by: Artem Goncharov <Artem.goncharov@gmail.com>
Reviewed-by: Irina Pereiaslavskaia <irina.pereyaslavskaya@gmail.com>
  • Loading branch information
anton-sidelnikov authored Feb 24, 2022
1 parent d0b482f commit 8da9354
Show file tree
Hide file tree
Showing 18 changed files with 165 additions and 87 deletions.
12 changes: 9 additions & 3 deletions etc/octavia_proxy.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[DEFAULT]
# Print debugging output (set logging level to DEBUG instead of default WARNING level).
# debug = True
#debug = True
log_level = INFO

# Plugin options are hot_plug_plugin (Hot-pluggable controller plugin)
Expand All @@ -27,6 +27,7 @@ log_name='validatetoken'
[api_settings]
bind_host = 0.0.0.0
bind_port = 9876
#region = eu-nl

# How should authentication be handled (keystone, noauth, validatetoken)
auth_strategy = validatetoken
Expand All @@ -50,10 +51,15 @@ auth_strategy = validatetoken
# A comma separated list of dictionaries of the enabled provider driver names
# and descriptions.
enabled_provider_drivers = elbv2:The Open Telekom Cloud Enhanced LB driver.,elbv3:The Open Telekom Cloud AZ aware LD driver.
#

# Default provider driver
default_provider_driver = elbv3
default_provider_driver = elbv2

[elbv2_driver_settings]
#endpoint_override = https://elb.eu-de.otc.t-systems.com/v2.0

[elbv3_driver_settings]
#endpoint_override = https://elb.eu-nl.otc.t-systems.com/v3/%(project_id)s

# The minimum health monitor delay interval for UDP-CONNECT Health Monitor type
# udp_connect_min_interval_health_monitor = 3
Expand Down
37 changes: 25 additions & 12 deletions octavia_proxy/api/drivers/elbv2/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ def loadbalancer_create(self, session, loadbalancer):
tags = []
if 'tags' in lb_attrs:
tags = self._resource_tags(lb_attrs.pop('tags'))

lb = session.elb.create_load_balancer(**lb_attrs)

for tag in tags:
Expand All @@ -136,8 +135,7 @@ def loadbalancer_create(self, session, loadbalancer):
LOG.debug('Created LB according to API is %s' % lb_data)
return lb_data

def loadbalancer_update(self, session, original_load_balancer,
new_attrs):
def loadbalancer_update(self, session, original_load_balancer, new_attrs):
LOG.debug('Updating loadbalancer')

lb = session.elb.update_load_balancer(
Expand Down Expand Up @@ -191,7 +189,6 @@ def listener_create(self, session, listener):
LOG.debug('Creating listener %s' % listener.to_dict())

attrs = listener.to_dict()
# TODO: do this differently
attrs.pop('l7policies', None)

tags = []
Expand Down Expand Up @@ -232,7 +229,9 @@ def listener_delete(self, session, listener):

def health_monitors(self, session, project_id, query_filter=None):
LOG.debug('Fetching health monitor')

result = []

if not query_filter:
query_filter = {}
query_filter.pop('project_id', None)
Expand All @@ -255,6 +254,7 @@ def health_monitors(self, session, project_id, query_filter=None):

def health_monitor_get(self, session, project_id, healthmonitor_id):
LOG.debug('Searching health monitor')

healthmonitor = session.elb.find_health_monitor(
name_or_id=healthmonitor_id, ignore_missing=True)
if healthmonitor:
Expand Down Expand Up @@ -291,6 +291,7 @@ def health_monitor_update(self, session, original, new_attrs):

def health_monitor_delete(self, session, healthmonitor):
LOG.debug('Deleting health monitor %s' % healthmonitor.to_dict())

session.elb.delete_health_monitor(healthmonitor.id)

def pools(self, session, project_id, query_filter=None):
Expand Down Expand Up @@ -328,11 +329,9 @@ def pool_create(self, session, pool):
LOG.debug('Creating pool %s' % pool.to_dict())

attrs = pool.to_dict()

if 'tls_enabled' in attrs:
attrs.pop('tls_enabled')

# TODO: do this differently
res = session.elb.create_pool(**attrs)
result_data = _pool.PoolResponse.from_sdk_object(
res)
Expand All @@ -352,15 +351,18 @@ def pool_update(self, session, original, new_attrs):

def pool_delete(self, session, pool):
LOG.debug('Deleting pool %s' % pool.to_dict())

session.elb.delete_pool(pool.id)

def members(self, session, project_id, pool_id, query_filter=None):
LOG.debug('Fetching pools')
result = []

if not query_filter:
query_filter = {}
query_filter.pop('project_id', None)

result = []

if 'id' in query_filter:
member_data = self.member_get(
project_id=project_id, session=session,
Expand Down Expand Up @@ -389,8 +391,8 @@ def member_get(self, session, project_id, pool_id, member_id):

def member_create(self, session, pool_id, member):
LOG.debug('Creating member %s' % member.to_dict())
attrs = member.to_dict()

attrs = member.to_dict()
if 'subnet_id' not in attrs:
lb_id = session.elb.get_pool(pool_id)['loadbalancers'][0]['id']
attrs['subnet_id'] = session.elb.get_load_balancer(
Expand All @@ -400,6 +402,7 @@ def member_create(self, session, pool_id, member):
attrs.pop('backup', None)
attrs.pop('monitor_port', None)
attrs.pop('monitor_address', None)

res = session.elb.create_member(pool_id, **attrs)
result_data = _member.MemberResponse.from_sdk_object(res)
setattr(result_data, 'provider', PROVIDER)
Expand All @@ -419,10 +422,12 @@ def member_update(self, session, pool_id, original, new_attrs):

def member_delete(self, session, pool_id, member):
LOG.debug('Deleting pool %s' % member.to_dict())

session.elb.delete_member(member.id, pool_id)

def l7policies(self, session, project_id, query_filter=None):
LOG.debug('Fetching L7 policies')

if not query_filter:
query_filter = {}

Expand Down Expand Up @@ -491,15 +496,17 @@ def l7policy_delete(self, session, l7policy, ignore_missing=True):

def l7rules(self, session, project_id, l7policy_id, query_filter=None):
LOG.debug('Fetching l7 rules')

result = []

if not query_filter:
query_filter = {}

if 'id' in query_filter:
l7rule_data = self.l7rule_get(
project_id=project_id, session=session,
l7policy_id=l7policy_id,
l7rule_id=query_filter['id']
l7rule_id=query_filter['id'],
)
if l7rule_data:
result.append(l7rule_data)
Expand All @@ -523,6 +530,7 @@ def l7rule_get(self, session, project_id, l7policy_id, l7rule_id):

def l7rule_create(self, session, l7policy_id, l7rule):
LOG.debug('Creating l7 rule %s' % l7rule.to_dict())

attrs = l7rule.to_dict()

res = session.elb.create_l7_rule(l7_policy=l7policy_id, **attrs)
Expand All @@ -544,10 +552,12 @@ def l7rule_update(self, session, l7policy_id, original, new_attrs):

def l7rule_delete(self, session, l7policy_id, l7rule):
LOG.debug('Deleting l7 rule %s' % l7rule.to_dict())

session.elb.delete_l7_rule(l7rule.id, l7policy_id)

def flavors(self, session, project_id, query_filter=None):
LOG.debug('Fetching flavors')

result = []
return result

Expand All @@ -556,10 +566,12 @@ def flavor_get(self, session, project_id, fl_id):

def availability_zones(self, session, project_id, query_filter=None):
LOG.debug('Fetching availability zones')

if not query_filter:
query_filter = {}

result = []

for az in session.elb.availability_zones(**query_filter):
az.enabled = az.is_enabled
az_data = _az.AvailabilityZoneResponse.from_sdk_object(
Expand All @@ -571,11 +583,12 @@ def availability_zones(self, session, project_id, query_filter=None):

def quotas(self, session, project_id, query_filter=None):
LOG.debug('Fetching quotas')

if not query_filter:
query_filter = {}

result = []
quota = session.elb.get_quotas()
quota = session.elb.quotas(**query_filter)
if quota:
quota_data = _quotas.QuotaResponse.from_sdk_object(
quota
Expand All @@ -584,10 +597,10 @@ def quotas(self, session, project_id, query_filter=None):
result.append(quota_data)
return result

def quota_get(self, session, project_id, param):
def quota_get(self, session, project_id, quota_id):
LOG.debug('Searching for quotas')

quota = session.elb.get_quotas()
quota = session.elb.get_quota(quota_id)
LOG.debug('quotas is %s' % quota)

if quota:
Expand Down
Loading

0 comments on commit 8da9354

Please sign in to comment.