Skip to content

Commit

Permalink
Merge pull request #481 from a10networks/master
Browse files Browse the repository at this point in the history
Merge master to stable/stein for v1.3.1 release
  • Loading branch information
ytsai-a10 authored Aug 4, 2021
2 parents e0545b8 + 67015e8 commit b24737b
Show file tree
Hide file tree
Showing 14 changed files with 159 additions and 180 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ this provider driver uses a "Thunder per Tenant" architecture. Therefore, each t
| a10-octavia | acos-client | ACOS Version |
| v1.1 | v2.6.1 | 5.2.1, 4.1.4-GR1-P5 |
| v1.2 | v2.7.0 | 5.2.1-p1 |
| v1.3 | v2.8.0 | 5.2.1-p1 |
| v1.3, v1.3.1 | v2.8.0 | 5.2.1-p1 |
```

## Project Resources
Expand Down
4 changes: 0 additions & 4 deletions a10_octavia/common/a10constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@
SSL_TEMPLATE = "ssl_template"

COMPUTE_BUSY = "compute_busy"
FLOW_TYPE = 'flow_type'
CREATE_FLOW = 'create'
DELETE_FLOW = 'delete'
UPDATE_FLOW = 'update'

# ============================
# Taskflow flow and task names
Expand Down
7 changes: 0 additions & 7 deletions a10_octavia/common/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,6 @@ def __init__(self):
super(ProjectDeviceNotFound, self).__init__(msg=msg)


class DeviceIsProjectDevice(acos_errors.ACOSException):
def __init__(self):
msg = ('The device already specify project_id in configuration file, '
'device-name flavor can not use it.')
super(DeviceIsProjectDevice, self).__init__(msg=msg)


class FlavorDeviceNotFound(acos_errors.ACOSException):
def __init__(self, device):
msg = ('[device-name flavor] Device [{0}] not found in the configuration'
Expand Down
7 changes: 0 additions & 7 deletions a10_octavia/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,3 @@ def get_loadbalancer_flavor(loadbalancer):
id=flavor.flavor_profile_id)
flavor_data = json.loads(flavor_profile.flavor_data)
return flavor_data


def get_device_vrid_owner(device_name, partition, hmt):
owner = device_name
if hmt == 'enable':
owner = device_name + '-' + partition
return owner
42 changes: 20 additions & 22 deletions a10_octavia/controller/worker/flows/a10_load_balancer_flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,7 @@ def get_update_rack_load_balancer_flow(self, vthunder_conf, device_dict, topolog
provides=constants.FLAVOR_DATA))
update_LB_flow.add(vthunder_tasks.GetVthunderConfByFlavor(
inject={a10constants.VTHUNDER_CONFIG: vthunder_conf,
a10constants.DEVICE_CONFIG_DICT: device_dict,
a10constants.FLOW_TYPE: a10constants.UPDATE_FLOW},
a10constants.DEVICE_CONFIG_DICT: device_dict},
requires=(constants.LOADBALANCER, a10constants.VTHUNDER_CONFIG,
a10constants.DEVICE_CONFIG_DICT, constants.FLAVOR_DATA),
provides=(a10constants.VTHUNDER_CONFIG, a10constants.USE_DEVICE_FLAVOR)))
Expand Down Expand Up @@ -646,8 +645,7 @@ def get_create_rack_vthunder_load_balancer_flow(
provides=constants.FLAVOR_DATA))
lb_create_flow.add(vthunder_tasks.GetVthunderConfByFlavor(
inject={a10constants.VTHUNDER_CONFIG: vthunder_conf,
a10constants.DEVICE_CONFIG_DICT: device_dict,
a10constants.FLOW_TYPE: a10constants.CREATE_FLOW},
a10constants.DEVICE_CONFIG_DICT: device_dict},
requires=(constants.LOADBALANCER, a10constants.VTHUNDER_CONFIG,
a10constants.DEVICE_CONFIG_DICT, constants.FLAVOR_DATA),
provides=(a10constants.VTHUNDER_CONFIG, a10constants.USE_DEVICE_FLAVOR)))
Expand Down Expand Up @@ -707,8 +705,7 @@ def get_delete_rack_vthunder_load_balancer_flow(self, lb, cascade, vthunder_conf
provides=constants.FLAVOR_DATA))
delete_LB_flow.add(vthunder_tasks.GetVthunderConfByFlavor(
inject={a10constants.VTHUNDER_CONFIG: vthunder_conf,
a10constants.DEVICE_CONFIG_DICT: device_dict,
a10constants.FLOW_TYPE: a10constants.DELETE_FLOW},
a10constants.DEVICE_CONFIG_DICT: device_dict},
requires=(constants.LOADBALANCER, a10constants.VTHUNDER_CONFIG,
a10constants.DEVICE_CONFIG_DICT, constants.FLAVOR_DATA),
provides=(a10constants.VTHUNDER_CONFIG, a10constants.USE_DEVICE_FLAVOR)))
Expand Down Expand Up @@ -825,8 +822,7 @@ def handle_vrid_for_loadbalancer_subflow(self):
a10_database_tasks.GetVRIDForLoadbalancerResource(
requires=[
a10constants.PARTITION_PROJECT_LIST,
a10constants.VTHUNDER,
a10constants.USE_DEVICE_FLAVOR],
a10constants.VTHUNDER],
provides=a10constants.VRID_LIST))
handle_vrid_for_lb_subflow.add(vthunder_tasks.ConfigureVRID(
requires=a10constants.VTHUNDER))
Expand All @@ -845,8 +841,7 @@ def handle_vrid_for_loadbalancer_subflow(self):
a10_database_tasks.UpdateVRIDForLoadbalancerResource(
requires=[
a10constants.VRID_LIST,
a10constants.VTHUNDER_CONFIG,
a10constants.USE_DEVICE_FLAVOR],
a10constants.VTHUNDER],
rebind={
a10constants.LB_RESOURCE: constants.LOADBALANCER}))
return handle_vrid_for_lb_subflow
Expand All @@ -873,8 +868,7 @@ def get_delete_rack_lb_vrid_subflow(self):
a10_database_tasks.GetVRIDForLoadbalancerResource(
requires=[
a10constants.PARTITION_PROJECT_LIST,
a10constants.VTHUNDER,
a10constants.USE_DEVICE_FLAVOR],
a10constants.VTHUNDER],
provides=a10constants.VRID_LIST))
delete_lb_vrid_subflow.add(
a10_network_tasks.DeleteVRIDPort(
Expand Down Expand Up @@ -909,8 +903,7 @@ def get_delete_lb_vrid_subflow(self, deleteCompute):
a10_database_tasks.GetVRIDForLoadbalancerResource(
requires=[
a10constants.PARTITION_PROJECT_LIST,
a10constants.VTHUNDER,
a10constants.USE_DEVICE_FLAVOR],
a10constants.VTHUNDER],
provides=a10constants.VRID_LIST))
delete_lb_vrid_subflow.add(
a10_network_tasks.DeleteVRIDPort(
Expand Down Expand Up @@ -946,7 +939,19 @@ def _get_cascade_delete_pools_listeners_flow(self, lb):
"""
pools_listeners_delete_flow = linear_flow.Flow('pool_listener_delete_flow')
store = {}
# loop fo loadbalancer's pool deletion
# loop for loadbalancer's l7policy deletion
l7policy_delete_flow = None
for listener in lb.listeners:
l7policy_delete_flow = linear_flow.Flow('l7policy_delete_flow')
for l7policy in listener.l7policies:
l7policy_name = 'l7policy_' + l7policy.id
store[l7policy_name] = l7policy
l7policy_delete_flow.add(
self._l7policy_flows.get_cascade_delete_l7policy_internal_flow(l7policy_name))
if l7policy_delete_flow:
pools_listeners_delete_flow.add(l7policy_delete_flow)

# loop for loadbalancer's pool deletion
for pool in lb.pools:
pool_name = 'pool' + pool.id
members = pool.members
Expand All @@ -971,13 +976,6 @@ def _get_cascade_delete_pools_listeners_flow(self, lb):
listeners_delete_flow = unordered_flow.Flow('listener_delete_flow')
compute_flag = lb.amphorae
for listener in lb.listeners:
l7policy_delete_flow = linear_flow.Flow('l7policy_delete_flow')
for l7policy in listener.l7policies:
l7policy_name = 'l7policy_' + l7policy.id
store[l7policy_name] = l7policy
l7policy_delete_flow.add(
self._l7policy_flows.get_cascade_delete_l7policy_internal_flow(l7policy_name))
listeners_delete_flow.add(l7policy_delete_flow)
listener_name = 'listener_' + listener.id
store[listener_name] = listener
listeners_delete_flow.add(
Expand Down
21 changes: 7 additions & 14 deletions a10_octavia/controller/worker/flows/a10_member_flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,7 @@ def get_rack_vthunder_delete_member_flow(self, vthunder_conf, device_dict):
provides=constants.FLAVOR))
delete_member_flow.add(vthunder_tasks.GetVthunderConfByFlavor(
inject={a10constants.VTHUNDER_CONFIG: vthunder_conf,
a10constants.DEVICE_CONFIG_DICT: device_dict,
a10constants.FLOW_TYPE: a10constants.DELETE_FLOW},
a10constants.DEVICE_CONFIG_DICT: device_dict},
requires=(constants.LOADBALANCER, a10constants.VTHUNDER_CONFIG,
a10constants.DEVICE_CONFIG_DICT),
rebind={constants.FLAVOR_DATA: constants.FLAVOR},
Expand Down Expand Up @@ -491,8 +490,7 @@ def get_delete_member_vrid_subflow(self):
a10_database_tasks.GetVRIDForLoadbalancerResource(
requires=[
a10constants.PARTITION_PROJECT_LIST,
a10constants.VTHUNDER,
a10constants.USE_DEVICE_FLAVOR],
a10constants.VTHUNDER],
provides=a10constants.VRID_LIST))
delete_member_vrid_subflow.add(
a10_network_tasks.DeleteVRIDPort(
Expand Down Expand Up @@ -536,8 +534,7 @@ def get_delete_member_vrid_internal_subflow(self, pool, pool_members):
name='get_vrid_for_loadbalancer_resource' + pool,
requires=[
a10constants.PARTITION_PROJECT_LIST,
a10constants.VTHUNDER,
a10constants.USE_DEVICE_FLAVOR],
a10constants.VTHUNDER],
provides=a10constants.VRID_LIST))
delete_member_vrid_subflow.add(
a10_network_tasks.DeleteMultipleVRIDPort(
Expand Down Expand Up @@ -570,8 +567,7 @@ def handle_vrid_for_member_subflow(self):
a10_database_tasks.GetVRIDForLoadbalancerResource(
requires=[
a10constants.PARTITION_PROJECT_LIST,
a10constants.VTHUNDER,
a10constants.USE_DEVICE_FLAVOR],
a10constants.VTHUNDER],
provides=a10constants.VRID_LIST))
handle_vrid_for_member_subflow.add(
a10_network_tasks.HandleVRIDFloatingIP(
Expand All @@ -588,8 +584,7 @@ def handle_vrid_for_member_subflow(self):
a10_database_tasks.UpdateVRIDForLoadbalancerResource(
requires=[
a10constants.VRID_LIST,
a10constants.VTHUNDER_CONFIG,
a10constants.USE_DEVICE_FLAVOR],
a10constants.VTHUNDER],
rebind={
a10constants.LB_RESOURCE: constants.MEMBER}))

Expand Down Expand Up @@ -668,8 +663,7 @@ def get_rack_vthunder_update_member_flow(self, vthunder_conf, device_dict):
provides=constants.FLAVOR))
update_member_flow.add(vthunder_tasks.GetVthunderConfByFlavor(
inject={a10constants.VTHUNDER_CONFIG: vthunder_conf,
a10constants.DEVICE_CONFIG_DICT: device_dict,
a10constants.FLOW_TYPE: a10constants.UPDATE_FLOW},
a10constants.DEVICE_CONFIG_DICT: device_dict},
requires=(constants.LOADBALANCER, a10constants.VTHUNDER_CONFIG,
a10constants.DEVICE_CONFIG_DICT),
rebind={constants.FLAVOR_DATA: constants.FLAVOR},
Expand Down Expand Up @@ -723,8 +717,7 @@ def get_rack_vthunder_create_member_flow(self, vthunder_conf, device_dict):
provides=constants.FLAVOR))
create_member_flow.add(vthunder_tasks.GetVthunderConfByFlavor(
inject={a10constants.VTHUNDER_CONFIG: vthunder_conf,
a10constants.DEVICE_CONFIG_DICT: device_dict,
a10constants.FLOW_TYPE: a10constants.CREATE_FLOW},
a10constants.DEVICE_CONFIG_DICT: device_dict},
requires=(constants.LOADBALANCER, a10constants.VTHUNDER_CONFIG,
a10constants.DEVICE_CONFIG_DICT),
rebind={constants.FLAVOR_DATA: constants.FLAVOR},
Expand Down
103 changes: 31 additions & 72 deletions a10_octavia/controller/worker/tasks/a10_database_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,32 +343,20 @@ def execute(self, amphora):

class GetVRIDForLoadbalancerResource(BaseDatabaseTask):

def execute(self, partition_project_list, vthunder, use_device_flavor):
def execute(self, partition_project_list, vthunder):
vrid_list = []
if partition_project_list and not use_device_flavor:
try:
vrid_list = self.vrid_repo.get_vrid_from_project_ids(
db_apis.get_session(), project_ids=partition_project_list)
return vrid_list
except Exception as e:
LOG.exception(
"Failed to get VRID list for given project list %s due to %s",
partition_project_list,
str(e))
raise e
elif use_device_flavor:
if vthunder is not None:
if vthunder:
owner = vthunder.ip_address + "_" + vthunder.partition_name
if partition_project_list:
try:
owner = utils.get_device_vrid_owner(
vthunder.device_name, vthunder.partition_name,
vthunder.hierarchical_multitenancy)
vrid_list = self.vrid_repo.get_vrid_from_owner(
db_apis.get_session(), owner=owner)
db_apis.get_session(), owner=owner,
project_ids=partition_project_list)
return vrid_list
except Exception as e:
LOG.exception(
"Failed to get VRID list for given device %s due to %s",
vthunder.device_name,
"Failed to get VRID list for given owner %s due to %s",
owner,
str(e))
raise e
return vrid_list
Expand All @@ -380,26 +368,19 @@ def __init__(self, *arg, **kwargs):
self.vrid_created = []
super(UpdateVRIDForLoadbalancerResource, self).__init__(*arg, **kwargs)

def execute(self, lb_resource, vrid_list, vthunder_config, use_device_flavor):
def execute(self, lb_resource, vrid_list, vthunder):
owner = vthunder.ip_address + "_" + vthunder.partition_name
if not vrid_list:
# delete all vrids from DB for the lB resource's project.
try:
if not use_device_flavor:
self.vrid_repo.delete(db_apis.get_session(),
owner=lb_resource.project_id)
LOG.debug("Successfully deleted DB vrid from project %s",
lb_resource.project_id)
elif use_device_flavor:
owner = utils.get_device_vrid_owner(
vthunder_config.device_name, vthunder_config.partition_name,
vthunder_config.hierarchical_multitenancy)
self.vrid_repo.delete(db_apis.get_session(), owner=owner)
LOG.debug("Successfully deleted DB vrid from device %s", owner)
self.vrid_repo.delete(db_apis.get_session(),
owner=owner)
LOG.debug("Successfully deleted DB vrid from owner %s", owner)

except Exception as e:
LOG.error(
"Failed to delete VRID data for project %s due to %s",
lb_resource.project_id,
"Failed to delete VRID data for owner %s due to %s",
owner,
str(e))
raise e
return
Expand All @@ -425,44 +406,22 @@ def execute(self, lb_resource, vrid_list, vthunder_config, use_device_flavor):
raise e

else:
if use_device_flavor:
try:
owner = utils.get_device_vrid_owner(
vthunder_config.device_name,
vthunder_config.partition_name,
vthunder_config.hierarchical_multitenancy)
new_vrid = self.vrid_repo.create(
db_apis.get_session(),
id=vrid.id,
owner=owner,
vrid_floating_ip=vrid.vrid_floating_ip,
vrid_port_id=vrid.vrid_port_id,
vrid=vrid.vrid,
subnet_id=vrid.subnet_id)
self.vrid_created.append(new_vrid)
except Exception as e:
LOG.error(
"Failed to create VRID data for VRID FIP %s due to %s",
vrid.vrid_floating_ip,
str(e))
raise e
else:
try:
new_vrid = self.vrid_repo.create(
db_apis.get_session(),
id=vrid.id,
owner=vrid.owner,
vrid_floating_ip=vrid.vrid_floating_ip,
vrid_port_id=vrid.vrid_port_id,
vrid=vrid.vrid,
subnet_id=vrid.subnet_id)
self.vrid_created.append(new_vrid)
except Exception as e:
LOG.error(
"Failed to create VRID data for VRID FIP %s due to %s",
vrid.vrid_floating_ip,
str(e))
raise e
try:
new_vrid = self.vrid_repo.create(
db_apis.get_session(),
id=vrid.id,
owner=owner,
vrid_floating_ip=vrid.vrid_floating_ip,
vrid_port_id=vrid.vrid_port_id,
vrid=vrid.vrid,
subnet_id=vrid.subnet_id)
self.vrid_created.append(new_vrid)
except Exception as e:
LOG.error(
"Failed to create VRID data for VRID FIP %s due to %s",
vrid.vrid_floating_ip,
str(e))
raise e

def revert(self, *args, **kwargs):
for vrid in self.vrid_created:
Expand Down
9 changes: 2 additions & 7 deletions a10_octavia/controller/worker/tasks/a10_network_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,13 +778,8 @@ def execute(self, vthunder, lb_resource, vrid_list, subnet,
vrid_floating_ips = []
update_vrid_flag = False
existing_fips = []
if use_device_flavor:
owner = a10_utils.get_device_vrid_owner(
vthunder_config.device_name, vthunder_config.partition_name,
vthunder_config.hierarchical_multitenancy)
self._add_vrid_to_list(updated_vrid_list, subnet, owner)
else:
self._add_vrid_to_list(updated_vrid_list, subnet, lb_resource.project_id)
owner = vthunder.ip_address + "_" + vthunder.partition_name
self._add_vrid_to_list(updated_vrid_list, subnet, owner)
for vrid in updated_vrid_list:
try:
vrid_summary = self.axapi_client.vrrpa.get(vrid.vrid)
Expand Down
Loading

0 comments on commit b24737b

Please sign in to comment.