Browse Source

Merge "Octavia flavors" into stable/victoria

changes/16/779916/1
Zuul 2 months ago
committed by Gerrit Code Review
parent
commit
3aaad8b752
6 changed files with 117 additions and 4 deletions
  1. +26
    -1
      vmware_nsx/services/lbaas/nsx_p/implementation/loadbalancer_mgr.py
  2. +12
    -0
      vmware_nsx/services/lbaas/nsx_v/implementation/loadbalancer_mgr.py
  3. +4
    -1
      vmware_nsx/services/lbaas/nsx_v3/implementation/lb_utils.py
  4. +13
    -1
      vmware_nsx/services/lbaas/nsx_v3/implementation/loadbalancer_mgr.py
  5. +45
    -1
      vmware_nsx/services/lbaas/octavia/octavia_driver.py
  6. +17
    -0
      vmware_nsx/services/lbaas/octavia/octavia_listener.py

+ 26
- 1
vmware_nsx/services/lbaas/nsx_p/implementation/loadbalancer_mgr.py View File

@ -95,7 +95,8 @@ class EdgeLoadBalancerManagerFromDict(base_mgr.NsxpLoadbalancerBaseManager):
tags.append(p_utils.get_service_lb_tag(lb['id']))
lb_size = lb_utils.get_lb_flavor_size(self.flavor_plugin, context,
lb.get('flavor_id'))
lb.get('flavor_id'),
lb.get('flavor'))
try:
if network and network.get('router:external'):
@ -227,6 +228,30 @@ class EdgeLoadBalancerManagerFromDict(base_mgr.NsxpLoadbalancerBaseManager):
context, lb, [])
self.delete(context, lb, completor)
def get_supported_flavor_metadata(self):
return {
'lb_size': 'loadbalancer edge size, one of: %s' % ', '.join(
lb_const.LB_FLAVOR_SIZES)}
def validate_flavor(self, flavor_metadata):
# Validate flavor attributes
valid_flavor_keys = ['lb_size']
for k in flavor_metadata.keys():
if k not in valid_flavor_keys:
return {'valid': False}
# Validate attribute
if (flavor_metadata.get('lb_size') and
flavor_metadata['lb_size'] not in lb_const.LB_FLAVOR_SIZES):
return {'valid': False}
return {'valid': True}
def get_supported_availability_zone_metadata(self):
return {}
def validate_availability_zone(self, availability_zone_metadata):
return False
def _nsx_status_to_lb_status(nsx_status):
if not nsx_status:


+ 12
- 0
vmware_nsx/services/lbaas/nsx_v/implementation/loadbalancer_mgr.py View File

@ -210,3 +210,15 @@ class EdgeLoadBalancerManagerFromDict(base_mgr.EdgeLoadbalancerBaseManager):
if not found:
return False
return True
def get_supported_flavor_metadata(self):
return None
def validate_flavor(self, flavor_metadata):
return None
def get_supported_availability_zone_metadata(self):
return None
def validate_availability_zone(self, availability_zone_metadata):
return None

+ 4
- 1
vmware_nsx/services/lbaas/nsx_v3/implementation/lb_utils.py View File

@ -62,7 +62,10 @@ def get_router_from_network(context, plugin, subnet_id):
@log_helpers.log_method_call
def get_lb_flavor_size(flavor_plugin, context, flavor_id):
def get_lb_flavor_size(flavor_plugin, context, flavor_id, flavor):
# Octavia will have a flavor obj here
if flavor:
return flavor.get('lb_size', lb_const.DEFAULT_LB_SIZE)
if not flavor_id:
return lb_const.DEFAULT_LB_SIZE


+ 13
- 1
vmware_nsx/services/lbaas/nsx_v3/implementation/loadbalancer_mgr.py View File

@ -55,7 +55,7 @@ class EdgeLoadBalancerManagerFromDict(base_mgr.Nsxv3LoadbalancerBaseManager):
lb_service = service_client.get_router_lb_service(nsx_router_id)
if not lb_service:
lb_size = lb_utils.get_lb_flavor_size(
self.flavor_plugin, context, lb.get('flavor_id'))
self.flavor_plugin, context, lb.get('flavor_id'), None)
if router_id:
# Make sure the NSX service router exists
if not self.core_plugin.service_router_has_services(
@ -244,3 +244,15 @@ class EdgeLoadBalancerManagerFromDict(base_mgr.Nsxv3LoadbalancerBaseManager):
def delete_cascade(self, context, lb, completor):
"""Delete all backend and DB resources of this loadbalancer"""
self.delete(context, lb, completor)
def get_supported_flavor_metadata(self):
return None
def validate_flavor(self, flavor_metadata):
return None
def get_supported_availability_zone_metadata(self):
return None
def validate_availability_zone(self, availability_zone_metadata):
return None

+ 45
- 1
vmware_nsx/services/lbaas/octavia/octavia_driver.py View File

@ -557,10 +557,54 @@ class NSXOctaviaDriver(driver_base.ProviderDriver):
# Flavor
@log_helpers.log_method_call
def get_supported_flavor_metadata(self):
raise exceptions.NotImplementedError()
try:
md = self.client.call({}, 'get_supported_flavor_metadata')
except Exception:
raise exceptions.DriverError()
if md is None:
raise exceptions.NotImplementedError()
return md
@log_helpers.log_method_call
def validate_flavor(self, flavor_metadata):
kw = {'flavor_metadata': flavor_metadata}
try:
result = self.client.call({}, 'validate_flavor', **kw)
except Exception:
raise exceptions.DriverError()
if result and result.get('valid', False):
return None
if result:
raise exceptions.UnsupportedOptionError()
raise exceptions.NotImplementedError()
# AZ
@log_helpers.log_method_call
def get_supported_availability_zone_metadata(self):
try:
md = self.client.call(
{}, 'get_supported_availability_zone_metadata')
except Exception:
raise exceptions.DriverError()
if md is None:
raise exceptions.NotImplementedError()
return md
@log_helpers.log_method_call
def validate_availability_zone(self, availability_zone_metadata):
kw = {'availability_zone_metadata': availability_zone_metadata}
try:
result = self.client.call({}, 'validate_availability_zone', **kw)
except Exception:
raise exceptions.DriverError()
if result and result.get('valid', False):
return None
if result:
raise exceptions.UnsupportedOptionError()
raise exceptions.NotImplementedError()


+ 17
- 0
vmware_nsx/services/lbaas/octavia/octavia_listener.py View File

@ -694,6 +694,23 @@ class NSXOctaviaListenerEndpoint(object):
return False
return True
@log_helpers.log_method_call
def get_supported_flavor_metadata(self, ctxt):
return self.loadbalancer.get_supported_flavor_metadata()
@log_helpers.log_method_call
def validate_flavor(self, ctxt, flavor_metadata):
return self.loadbalancer.validate_flavor(flavor_metadata)
@log_helpers.log_method_call
def get_supported_availability_zone_metadata(self, ctxt):
return self.loadbalancer.get_supported_availability_zone_metadata()
@log_helpers.log_method_call
def validate_availability_zone(self, ctxt, availability_zone_metadata):
return self.loadbalancer.validate_availability_zone(
availability_zone_metadata)
class NSXOctaviaStatisticsCollector(object):
def __init__(self, core_plugin, listener_stats_getter,


Loading…
Cancel
Save