octavia 12.0.0.0rc2__py3-none-any.whl → 13.0.0.0rc1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- octavia/amphorae/backends/agent/api_server/osutils.py +1 -0
- octavia/amphorae/backends/agent/api_server/plug.py +21 -7
- octavia/amphorae/backends/agent/api_server/templates/amphora-netns.systemd.j2 +2 -2
- octavia/amphorae/backends/agent/api_server/util.py +21 -0
- octavia/amphorae/backends/health_daemon/health_daemon.py +9 -3
- octavia/amphorae/backends/health_daemon/health_sender.py +2 -0
- octavia/amphorae/backends/utils/interface.py +14 -6
- octavia/amphorae/backends/utils/interface_file.py +6 -3
- octavia/amphorae/backends/utils/keepalivedlvs_query.py +8 -9
- octavia/amphorae/drivers/driver_base.py +1 -2
- octavia/amphorae/drivers/haproxy/rest_api_driver.py +11 -25
- octavia/amphorae/drivers/health/heartbeat_udp.py +34 -24
- octavia/amphorae/drivers/keepalived/jinja/jinja_cfg.py +3 -12
- octavia/amphorae/drivers/noop_driver/driver.py +3 -5
- octavia/api/common/pagination.py +4 -4
- octavia/api/drivers/amphora_driver/v2/driver.py +11 -5
- octavia/api/drivers/driver_agent/driver_get.py +22 -14
- octavia/api/drivers/driver_agent/driver_updater.py +8 -4
- octavia/api/drivers/utils.py +4 -2
- octavia/api/healthcheck/healthcheck_plugins.py +4 -2
- octavia/api/root_controller.py +4 -1
- octavia/api/v2/controllers/amphora.py +35 -38
- octavia/api/v2/controllers/availability_zone_profiles.py +43 -33
- octavia/api/v2/controllers/availability_zones.py +22 -18
- octavia/api/v2/controllers/flavor_profiles.py +37 -28
- octavia/api/v2/controllers/flavors.py +19 -15
- octavia/api/v2/controllers/health_monitor.py +44 -33
- octavia/api/v2/controllers/l7policy.py +52 -40
- octavia/api/v2/controllers/l7rule.py +68 -55
- octavia/api/v2/controllers/listener.py +88 -61
- octavia/api/v2/controllers/load_balancer.py +52 -34
- octavia/api/v2/controllers/member.py +63 -52
- octavia/api/v2/controllers/pool.py +55 -42
- octavia/api/v2/controllers/quotas.py +5 -3
- octavia/api/v2/types/listener.py +15 -0
- octavia/cmd/octavia_worker.py +0 -3
- octavia/cmd/status.py +1 -4
- octavia/common/clients.py +25 -45
- octavia/common/config.py +64 -22
- octavia/common/constants.py +3 -2
- octavia/common/data_models.py +7 -1
- octavia/common/jinja/haproxy/combined_listeners/jinja_cfg.py +12 -1
- octavia/common/jinja/haproxy/combined_listeners/templates/macros.j2 +5 -2
- octavia/common/jinja/lvs/jinja_cfg.py +4 -2
- octavia/common/keystone.py +58 -5
- octavia/common/validate.py +35 -0
- octavia/compute/drivers/noop_driver/driver.py +6 -0
- octavia/controller/healthmanager/health_manager.py +3 -6
- octavia/controller/housekeeping/house_keeping.py +36 -37
- octavia/controller/worker/amphora_rate_limit.py +5 -4
- octavia/controller/worker/task_utils.py +57 -41
- octavia/controller/worker/v2/controller_worker.py +160 -103
- octavia/controller/worker/v2/flows/listener_flows.py +3 -0
- octavia/controller/worker/v2/flows/load_balancer_flows.py +9 -14
- octavia/controller/worker/v2/tasks/amphora_driver_tasks.py +152 -91
- octavia/controller/worker/v2/tasks/compute_tasks.py +4 -2
- octavia/controller/worker/v2/tasks/database_tasks.py +542 -400
- octavia/controller/worker/v2/tasks/network_tasks.py +119 -79
- octavia/db/api.py +26 -23
- octavia/db/base_models.py +2 -2
- octavia/db/healthcheck.py +2 -1
- octavia/db/migration/alembic_migrations/versions/632152d2d32e_add_http_strict_transport_security_.py +42 -0
- octavia/db/models.py +12 -2
- octavia/db/prepare.py +2 -0
- octavia/db/repositories.py +462 -482
- octavia/hacking/checks.py +1 -1
- octavia/network/base.py +0 -14
- octavia/network/drivers/neutron/allowed_address_pairs.py +92 -135
- octavia/network/drivers/neutron/base.py +65 -77
- octavia/network/drivers/neutron/utils.py +69 -85
- octavia/network/drivers/noop_driver/driver.py +0 -7
- octavia/statistics/drivers/update_db.py +10 -10
- octavia/tests/common/constants.py +91 -84
- octavia/tests/common/sample_data_models.py +13 -1
- octavia/tests/fixtures.py +32 -0
- octavia/tests/functional/amphorae/backend/agent/api_server/test_server.py +9 -10
- octavia/tests/functional/api/drivers/driver_agent/test_driver_agent.py +260 -15
- octavia/tests/functional/api/test_root_controller.py +3 -28
- octavia/tests/functional/api/v2/base.py +5 -3
- octavia/tests/functional/api/v2/test_amphora.py +18 -5
- octavia/tests/functional/api/v2/test_availability_zone_profiles.py +1 -0
- octavia/tests/functional/api/v2/test_listener.py +51 -19
- octavia/tests/functional/api/v2/test_load_balancer.py +10 -1
- octavia/tests/functional/db/base.py +31 -16
- octavia/tests/functional/db/test_models.py +27 -28
- octavia/tests/functional/db/test_repositories.py +407 -50
- octavia/tests/unit/amphorae/backends/agent/api_server/test_amphora_info.py +2 -0
- octavia/tests/unit/amphorae/backends/agent/api_server/test_osutils.py +1 -1
- octavia/tests/unit/amphorae/backends/agent/api_server/test_plug.py +54 -6
- octavia/tests/unit/amphorae/backends/agent/api_server/test_util.py +35 -0
- octavia/tests/unit/amphorae/backends/health_daemon/test_health_daemon.py +8 -0
- octavia/tests/unit/amphorae/backends/health_daemon/test_health_sender.py +18 -0
- octavia/tests/unit/amphorae/backends/utils/test_interface.py +81 -0
- octavia/tests/unit/amphorae/backends/utils/test_interface_file.py +2 -0
- octavia/tests/unit/amphorae/backends/utils/test_keepalivedlvs_query.py +129 -5
- octavia/tests/unit/amphorae/drivers/haproxy/test_rest_api_driver_1_0.py +42 -20
- octavia/tests/unit/amphorae/drivers/health/test_heartbeat_udp.py +18 -20
- octavia/tests/unit/amphorae/drivers/keepalived/jinja/test_jinja_cfg.py +4 -4
- octavia/tests/unit/amphorae/drivers/noop_driver/test_driver.py +4 -1
- octavia/tests/unit/api/drivers/driver_agent/test_driver_get.py +3 -3
- octavia/tests/unit/api/drivers/driver_agent/test_driver_updater.py +11 -13
- octavia/tests/unit/base.py +6 -0
- octavia/tests/unit/cmd/test_interface.py +2 -2
- octavia/tests/unit/cmd/test_status.py +2 -2
- octavia/tests/unit/common/jinja/haproxy/combined_listeners/test_jinja_cfg.py +152 -1
- octavia/tests/unit/common/sample_configs/sample_configs_combined.py +10 -3
- octavia/tests/unit/common/test_clients.py +0 -39
- octavia/tests/unit/common/test_keystone.py +54 -0
- octavia/tests/unit/common/test_validate.py +67 -0
- octavia/tests/unit/controller/healthmanager/test_health_manager.py +8 -22
- octavia/tests/unit/controller/housekeeping/test_house_keeping.py +3 -64
- octavia/tests/unit/controller/worker/test_amphora_rate_limit.py +1 -1
- octavia/tests/unit/controller/worker/test_task_utils.py +44 -24
- octavia/tests/unit/controller/worker/v2/flows/test_load_balancer_flows.py +0 -1
- octavia/tests/unit/controller/worker/v2/tasks/test_amphora_driver_tasks.py +49 -26
- octavia/tests/unit/controller/worker/v2/tasks/test_database_tasks.py +399 -196
- octavia/tests/unit/controller/worker/v2/tasks/test_database_tasks_quota.py +37 -64
- octavia/tests/unit/controller/worker/v2/tasks/test_network_tasks.py +3 -14
- octavia/tests/unit/controller/worker/v2/test_controller_worker.py +2 -2
- octavia/tests/unit/network/drivers/neutron/test_allowed_address_pairs.py +456 -561
- octavia/tests/unit/network/drivers/neutron/test_base.py +181 -194
- octavia/tests/unit/network/drivers/neutron/test_utils.py +14 -30
- octavia/tests/unit/statistics/drivers/test_update_db.py +7 -5
- {octavia-12.0.0.0rc2.data → octavia-13.0.0.0rc1.data}/data/share/octavia/README.rst +1 -1
- {octavia-12.0.0.0rc2.dist-info → octavia-13.0.0.0rc1.dist-info}/AUTHORS +4 -0
- {octavia-12.0.0.0rc2.dist-info → octavia-13.0.0.0rc1.dist-info}/METADATA +4 -4
- {octavia-12.0.0.0rc2.dist-info → octavia-13.0.0.0rc1.dist-info}/RECORD +141 -189
- {octavia-12.0.0.0rc2.dist-info → octavia-13.0.0.0rc1.dist-info}/entry_points.txt +1 -2
- octavia-13.0.0.0rc1.dist-info/pbr.json +1 -0
- octavia/api/drivers/amphora_driver/v1/__init__.py +0 -11
- octavia/api/drivers/amphora_driver/v1/driver.py +0 -547
- octavia/controller/queue/v1/__init__.py +0 -11
- octavia/controller/queue/v1/consumer.py +0 -64
- octavia/controller/queue/v1/endpoints.py +0 -160
- octavia/controller/worker/v1/__init__.py +0 -11
- octavia/controller/worker/v1/controller_worker.py +0 -1157
- octavia/controller/worker/v1/flows/__init__.py +0 -11
- octavia/controller/worker/v1/flows/amphora_flows.py +0 -610
- octavia/controller/worker/v1/flows/health_monitor_flows.py +0 -105
- octavia/controller/worker/v1/flows/l7policy_flows.py +0 -94
- octavia/controller/worker/v1/flows/l7rule_flows.py +0 -100
- octavia/controller/worker/v1/flows/listener_flows.py +0 -128
- octavia/controller/worker/v1/flows/load_balancer_flows.py +0 -692
- octavia/controller/worker/v1/flows/member_flows.py +0 -230
- octavia/controller/worker/v1/flows/pool_flows.py +0 -127
- octavia/controller/worker/v1/tasks/__init__.py +0 -11
- octavia/controller/worker/v1/tasks/amphora_driver_tasks.py +0 -453
- octavia/controller/worker/v1/tasks/cert_task.py +0 -51
- octavia/controller/worker/v1/tasks/compute_tasks.py +0 -335
- octavia/controller/worker/v1/tasks/database_tasks.py +0 -2756
- octavia/controller/worker/v1/tasks/lifecycle_tasks.py +0 -173
- octavia/controller/worker/v1/tasks/model_tasks.py +0 -41
- octavia/controller/worker/v1/tasks/network_tasks.py +0 -970
- octavia/controller/worker/v1/tasks/retry_tasks.py +0 -74
- octavia/tests/unit/api/drivers/amphora_driver/v1/__init__.py +0 -11
- octavia/tests/unit/api/drivers/amphora_driver/v1/test_driver.py +0 -824
- octavia/tests/unit/controller/queue/v1/__init__.py +0 -11
- octavia/tests/unit/controller/queue/v1/test_consumer.py +0 -61
- octavia/tests/unit/controller/queue/v1/test_endpoints.py +0 -189
- octavia/tests/unit/controller/worker/v1/__init__.py +0 -11
- octavia/tests/unit/controller/worker/v1/flows/__init__.py +0 -11
- octavia/tests/unit/controller/worker/v1/flows/test_amphora_flows.py +0 -474
- octavia/tests/unit/controller/worker/v1/flows/test_health_monitor_flows.py +0 -72
- octavia/tests/unit/controller/worker/v1/flows/test_l7policy_flows.py +0 -67
- octavia/tests/unit/controller/worker/v1/flows/test_l7rule_flows.py +0 -67
- octavia/tests/unit/controller/worker/v1/flows/test_listener_flows.py +0 -91
- octavia/tests/unit/controller/worker/v1/flows/test_load_balancer_flows.py +0 -431
- octavia/tests/unit/controller/worker/v1/flows/test_member_flows.py +0 -106
- octavia/tests/unit/controller/worker/v1/flows/test_pool_flows.py +0 -77
- octavia/tests/unit/controller/worker/v1/tasks/__init__.py +0 -11
- octavia/tests/unit/controller/worker/v1/tasks/test_amphora_driver_tasks.py +0 -792
- octavia/tests/unit/controller/worker/v1/tasks/test_cert_task.py +0 -46
- octavia/tests/unit/controller/worker/v1/tasks/test_compute_tasks.py +0 -634
- octavia/tests/unit/controller/worker/v1/tasks/test_database_tasks.py +0 -2615
- octavia/tests/unit/controller/worker/v1/tasks/test_database_tasks_quota.py +0 -415
- octavia/tests/unit/controller/worker/v1/tasks/test_lifecycle_tasks.py +0 -401
- octavia/tests/unit/controller/worker/v1/tasks/test_model_tasks.py +0 -44
- octavia/tests/unit/controller/worker/v1/tasks/test_network_tasks.py +0 -1788
- octavia/tests/unit/controller/worker/v1/tasks/test_retry_tasks.py +0 -47
- octavia/tests/unit/controller/worker/v1/test_controller_worker.py +0 -2096
- octavia-12.0.0.0rc2.dist-info/pbr.json +0 -1
- {octavia-12.0.0.0rc2.data → octavia-13.0.0.0rc1.data}/data/share/octavia/LICENSE +0 -0
- {octavia-12.0.0.0rc2.data → octavia-13.0.0.0rc1.data}/data/share/octavia/diskimage-create/README.rst +0 -0
- {octavia-12.0.0.0rc2.data → octavia-13.0.0.0rc1.data}/data/share/octavia/diskimage-create/diskimage-create.sh +0 -0
- {octavia-12.0.0.0rc2.data → octavia-13.0.0.0rc1.data}/data/share/octavia/diskimage-create/image-tests.sh +0 -0
- {octavia-12.0.0.0rc2.data → octavia-13.0.0.0rc1.data}/data/share/octavia/diskimage-create/requirements.txt +0 -0
- {octavia-12.0.0.0rc2.data → octavia-13.0.0.0rc1.data}/data/share/octavia/diskimage-create/test-requirements.txt +0 -0
- {octavia-12.0.0.0rc2.data → octavia-13.0.0.0rc1.data}/data/share/octavia/diskimage-create/tox.ini +0 -0
- {octavia-12.0.0.0rc2.data → octavia-13.0.0.0rc1.data}/data/share/octavia/diskimage-create/version.txt +0 -0
- {octavia-12.0.0.0rc2.data → octavia-13.0.0.0rc1.data}/scripts/octavia-wsgi +0 -0
- {octavia-12.0.0.0rc2.dist-info → octavia-13.0.0.0rc1.dist-info}/LICENSE +0 -0
- {octavia-12.0.0.0rc2.dist-info → octavia-13.0.0.0rc1.dist-info}/WHEEL +0 -0
- {octavia-12.0.0.0rc2.dist-info → octavia-13.0.0.0rc1.dist-info}/top_level.txt +0 -0
@@ -1,453 +0,0 @@
|
|
1
|
-
# Copyright 2015 Hewlett-Packard Development Company, L.P.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
4
|
-
# not use this file except in compliance with the License. You may obtain
|
5
|
-
# a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
11
|
-
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
12
|
-
# License for the specific language governing permissions and limitations
|
13
|
-
# under the License.
|
14
|
-
#
|
15
|
-
|
16
|
-
from cryptography import fernet
|
17
|
-
from oslo_config import cfg
|
18
|
-
from oslo_log import log as logging
|
19
|
-
from stevedore import driver as stevedore_driver
|
20
|
-
from taskflow import task
|
21
|
-
from taskflow.types import failure
|
22
|
-
|
23
|
-
from octavia.amphorae.backends.agent import agent_jinja_cfg
|
24
|
-
from octavia.amphorae.driver_exceptions import exceptions as driver_except
|
25
|
-
from octavia.common import constants
|
26
|
-
from octavia.common import utils
|
27
|
-
from octavia.controller.worker import task_utils as task_utilities
|
28
|
-
from octavia.db import api as db_apis
|
29
|
-
from octavia.db import repositories as repo
|
30
|
-
|
31
|
-
CONF = cfg.CONF
|
32
|
-
LOG = logging.getLogger(__name__)
|
33
|
-
|
34
|
-
|
35
|
-
class BaseAmphoraTask(task.Task):
|
36
|
-
"""Base task to load drivers common to the tasks."""
|
37
|
-
|
38
|
-
def __init__(self, **kwargs):
|
39
|
-
super().__init__(**kwargs)
|
40
|
-
self.amphora_driver = stevedore_driver.DriverManager(
|
41
|
-
namespace='octavia.amphora.drivers',
|
42
|
-
name=CONF.controller_worker.amphora_driver,
|
43
|
-
invoke_on_load=True
|
44
|
-
).driver
|
45
|
-
self.amphora_repo = repo.AmphoraRepository()
|
46
|
-
self.listener_repo = repo.ListenerRepository()
|
47
|
-
self.loadbalancer_repo = repo.LoadBalancerRepository()
|
48
|
-
self.task_utils = task_utilities.TaskUtils()
|
49
|
-
|
50
|
-
|
51
|
-
class AmpListenersUpdate(BaseAmphoraTask):
|
52
|
-
"""Task to update the listeners on one amphora."""
|
53
|
-
|
54
|
-
def execute(self, loadbalancer, amphora, timeout_dict=None):
|
55
|
-
# Note, we don't want this to cause a revert as it may be used
|
56
|
-
# in a failover flow with both amps failing. Skip it and let
|
57
|
-
# health manager fix it.
|
58
|
-
try:
|
59
|
-
# Make sure we have a fresh load balancer object
|
60
|
-
loadbalancer = self.loadbalancer_repo.get(db_apis.get_session(),
|
61
|
-
id=loadbalancer.id)
|
62
|
-
self.amphora_driver.update_amphora_listeners(
|
63
|
-
loadbalancer, amphora, timeout_dict)
|
64
|
-
except Exception as e:
|
65
|
-
LOG.error('Failed to update listeners on amphora %s. Skipping '
|
66
|
-
'this amphora as it is failing to update due to: %s',
|
67
|
-
amphora.id, str(e))
|
68
|
-
self.amphora_repo.update(db_apis.get_session(), amphora.id,
|
69
|
-
status=constants.ERROR)
|
70
|
-
|
71
|
-
|
72
|
-
class AmphoraIndexListenerUpdate(BaseAmphoraTask):
|
73
|
-
"""Task to update the listeners on one amphora."""
|
74
|
-
|
75
|
-
def execute(self, loadbalancer, amphora_index, amphorae,
|
76
|
-
timeout_dict=None):
|
77
|
-
# Note, we don't want this to cause a revert as it may be used
|
78
|
-
# in a failover flow with both amps failing. Skip it and let
|
79
|
-
# health manager fix it.
|
80
|
-
try:
|
81
|
-
# Make sure we have a fresh load balancer object
|
82
|
-
loadbalancer = self.loadbalancer_repo.get(db_apis.get_session(),
|
83
|
-
id=loadbalancer.id)
|
84
|
-
self.amphora_driver.update_amphora_listeners(
|
85
|
-
loadbalancer, amphorae[amphora_index], timeout_dict)
|
86
|
-
except Exception as e:
|
87
|
-
amphora_id = amphorae[amphora_index].id
|
88
|
-
LOG.error('Failed to update listeners on amphora %s. Skipping '
|
89
|
-
'this amphora as it is failing to update due to: %s',
|
90
|
-
amphora_id, str(e))
|
91
|
-
self.amphora_repo.update(db_apis.get_session(), amphora_id,
|
92
|
-
status=constants.ERROR)
|
93
|
-
|
94
|
-
|
95
|
-
class ListenersUpdate(BaseAmphoraTask):
|
96
|
-
"""Task to update amphora with all specified listeners' configurations."""
|
97
|
-
|
98
|
-
def execute(self, loadbalancer):
|
99
|
-
"""Execute updates per listener for an amphora."""
|
100
|
-
self.amphora_driver.update(loadbalancer)
|
101
|
-
|
102
|
-
def revert(self, loadbalancer, *args, **kwargs):
|
103
|
-
"""Handle failed listeners updates."""
|
104
|
-
|
105
|
-
LOG.warning("Reverting listeners updates.")
|
106
|
-
|
107
|
-
for listener in loadbalancer.listeners:
|
108
|
-
self.task_utils.mark_listener_prov_status_error(listener.id)
|
109
|
-
|
110
|
-
|
111
|
-
class ListenersStart(BaseAmphoraTask):
|
112
|
-
"""Task to start all listeners on the vip."""
|
113
|
-
|
114
|
-
def execute(self, loadbalancer, amphora=None):
|
115
|
-
"""Execute listener start routines for listeners on an amphora."""
|
116
|
-
if loadbalancer.listeners:
|
117
|
-
self.amphora_driver.start(loadbalancer, amphora)
|
118
|
-
LOG.debug("Started the listeners on the vip")
|
119
|
-
|
120
|
-
def revert(self, loadbalancer, *args, **kwargs):
|
121
|
-
"""Handle failed listeners starts."""
|
122
|
-
|
123
|
-
LOG.warning("Reverting listeners starts.")
|
124
|
-
for listener in loadbalancer.listeners:
|
125
|
-
self.task_utils.mark_listener_prov_status_error(listener.id)
|
126
|
-
|
127
|
-
|
128
|
-
class AmphoraIndexListenersReload(BaseAmphoraTask):
|
129
|
-
"""Task to reload all listeners on an amphora."""
|
130
|
-
|
131
|
-
def execute(self, loadbalancer, amphora_index, amphorae,
|
132
|
-
timeout_dict=None):
|
133
|
-
"""Execute listener reload routines for listeners on an amphora."""
|
134
|
-
if loadbalancer.listeners:
|
135
|
-
try:
|
136
|
-
self.amphora_driver.reload(
|
137
|
-
loadbalancer, amphorae[amphora_index], timeout_dict)
|
138
|
-
except Exception as e:
|
139
|
-
amphora_id = amphorae[amphora_index].id
|
140
|
-
LOG.warning('Failed to reload listeners on amphora %s. '
|
141
|
-
'Skipping this amphora as it is failing to '
|
142
|
-
'reload due to: %s', amphora_id, str(e))
|
143
|
-
self.amphora_repo.update(db_apis.get_session(), amphora_id,
|
144
|
-
status=constants.ERROR)
|
145
|
-
|
146
|
-
|
147
|
-
class ListenerDelete(BaseAmphoraTask):
|
148
|
-
"""Task to delete the listener on the vip."""
|
149
|
-
|
150
|
-
def execute(self, listener):
|
151
|
-
"""Execute listener delete routines for an amphora."""
|
152
|
-
# TODO(rm_work): This is only relevant because of UDP listeners now.
|
153
|
-
self.amphora_driver.delete(listener)
|
154
|
-
LOG.debug("Deleted the listener on the vip")
|
155
|
-
|
156
|
-
def revert(self, listener, *args, **kwargs):
|
157
|
-
"""Handle a failed listener delete."""
|
158
|
-
|
159
|
-
LOG.warning("Reverting listener delete.")
|
160
|
-
|
161
|
-
self.task_utils.mark_listener_prov_status_error(listener.id)
|
162
|
-
|
163
|
-
|
164
|
-
class AmphoraGetInfo(BaseAmphoraTask):
|
165
|
-
"""Task to get information on an amphora."""
|
166
|
-
|
167
|
-
def execute(self, amphora):
|
168
|
-
"""Execute get_info routine for an amphora."""
|
169
|
-
self.amphora_driver.get_info(amphora)
|
170
|
-
|
171
|
-
|
172
|
-
class AmphoraGetDiagnostics(BaseAmphoraTask):
|
173
|
-
"""Task to get diagnostics on the amphora and the loadbalancers."""
|
174
|
-
|
175
|
-
def execute(self, amphora):
|
176
|
-
"""Execute get_diagnostic routine for an amphora."""
|
177
|
-
self.amphora_driver.get_diagnostics(amphora)
|
178
|
-
|
179
|
-
|
180
|
-
class AmphoraFinalize(BaseAmphoraTask):
|
181
|
-
"""Task to finalize the amphora before any listeners are configured."""
|
182
|
-
|
183
|
-
def execute(self, amphora):
|
184
|
-
"""Execute finalize_amphora routine."""
|
185
|
-
self.amphora_driver.finalize_amphora(amphora)
|
186
|
-
LOG.debug("Finalized the amphora.")
|
187
|
-
|
188
|
-
def revert(self, result, amphora, *args, **kwargs):
|
189
|
-
"""Handle a failed amphora finalize."""
|
190
|
-
if isinstance(result, failure.Failure):
|
191
|
-
return
|
192
|
-
LOG.warning("Reverting amphora finalize.")
|
193
|
-
self.task_utils.mark_amphora_status_error(amphora.id)
|
194
|
-
|
195
|
-
|
196
|
-
class AmphoraPostNetworkPlug(BaseAmphoraTask):
|
197
|
-
"""Task to notify the amphora post network plug."""
|
198
|
-
|
199
|
-
def execute(self, amphora, ports, amphora_network_config):
|
200
|
-
"""Execute post_network_plug routine."""
|
201
|
-
for port in ports:
|
202
|
-
self.amphora_driver.post_network_plug(
|
203
|
-
amphora, port, amphora_network_config)
|
204
|
-
LOG.debug("post_network_plug called on compute instance "
|
205
|
-
"%(compute_id)s for port %(port_id)s",
|
206
|
-
{"compute_id": amphora.compute_id, "port_id": port.id})
|
207
|
-
|
208
|
-
def revert(self, result, amphora, *args, **kwargs):
|
209
|
-
"""Handle a failed post network plug."""
|
210
|
-
if isinstance(result, failure.Failure):
|
211
|
-
return
|
212
|
-
LOG.warning("Reverting post network plug.")
|
213
|
-
self.task_utils.mark_amphora_status_error(amphora.id)
|
214
|
-
|
215
|
-
|
216
|
-
class AmphoraePostNetworkPlug(BaseAmphoraTask):
|
217
|
-
"""Task to notify the amphorae post network plug."""
|
218
|
-
|
219
|
-
def execute(self, loadbalancer, updated_ports, amphorae_network_config):
|
220
|
-
"""Execute post_network_plug routine."""
|
221
|
-
amp_post_plug = AmphoraPostNetworkPlug()
|
222
|
-
# We need to make sure we have the fresh list of amphora
|
223
|
-
amphorae = self.amphora_repo.get_all(
|
224
|
-
db_apis.get_session(), load_balancer_id=loadbalancer.id,
|
225
|
-
status=constants.AMPHORA_ALLOCATED)[0]
|
226
|
-
for amphora in amphorae:
|
227
|
-
if amphora.id in updated_ports:
|
228
|
-
amp_post_plug.execute(amphora, updated_ports[amphora.id],
|
229
|
-
amphorae_network_config[amphora.id])
|
230
|
-
|
231
|
-
def revert(self, result, loadbalancer, updated_ports, *args, **kwargs):
|
232
|
-
"""Handle a failed post network plug."""
|
233
|
-
if isinstance(result, failure.Failure):
|
234
|
-
return
|
235
|
-
LOG.warning("Reverting post network plug.")
|
236
|
-
|
237
|
-
amphorae = self.amphora_repo.get_all(
|
238
|
-
db_apis.get_session(), load_balancer_id=loadbalancer.id,
|
239
|
-
status=constants.AMPHORA_ALLOCATED)[0]
|
240
|
-
for amphora in amphorae:
|
241
|
-
self.task_utils.mark_amphora_status_error(amphora.id)
|
242
|
-
|
243
|
-
|
244
|
-
class AmphoraPostVIPPlug(BaseAmphoraTask):
|
245
|
-
"""Task to notify the amphora post VIP plug."""
|
246
|
-
|
247
|
-
def execute(self, amphora, loadbalancer, amphorae_network_config):
|
248
|
-
"""Execute post_vip_routine."""
|
249
|
-
self.amphora_driver.post_vip_plug(
|
250
|
-
amphora, loadbalancer, amphorae_network_config)
|
251
|
-
LOG.debug("Notified amphora of vip plug")
|
252
|
-
|
253
|
-
def revert(self, result, amphora, loadbalancer, *args, **kwargs):
|
254
|
-
"""Handle a failed amphora vip plug notification."""
|
255
|
-
if isinstance(result, failure.Failure):
|
256
|
-
return
|
257
|
-
LOG.warning("Reverting post vip plug.")
|
258
|
-
self.task_utils.mark_amphora_status_error(amphora.id)
|
259
|
-
|
260
|
-
|
261
|
-
class AmphoraePostVIPPlug(BaseAmphoraTask):
|
262
|
-
"""Task to notify the amphorae post VIP plug."""
|
263
|
-
|
264
|
-
def execute(self, loadbalancer, amphorae_network_config):
|
265
|
-
"""Execute post_vip_plug across the amphorae."""
|
266
|
-
amp_post_vip_plug = AmphoraPostVIPPlug()
|
267
|
-
for amphora in loadbalancer.amphorae:
|
268
|
-
amp_post_vip_plug.execute(amphora,
|
269
|
-
loadbalancer,
|
270
|
-
amphorae_network_config)
|
271
|
-
|
272
|
-
|
273
|
-
class AmphoraCertUpload(BaseAmphoraTask):
|
274
|
-
"""Upload a certificate to the amphora."""
|
275
|
-
|
276
|
-
def execute(self, amphora, server_pem):
|
277
|
-
"""Execute cert_update_amphora routine."""
|
278
|
-
LOG.debug("Upload cert in amphora REST driver")
|
279
|
-
key = utils.get_compatible_server_certs_key_passphrase()
|
280
|
-
fer = fernet.Fernet(key)
|
281
|
-
self.amphora_driver.upload_cert_amp(amphora, fer.decrypt(server_pem))
|
282
|
-
|
283
|
-
|
284
|
-
class AmphoraUpdateVRRPInterface(BaseAmphoraTask):
|
285
|
-
"""Task to get and update the VRRP interface device name from amphora."""
|
286
|
-
|
287
|
-
def execute(self, amphora, timeout_dict=None):
|
288
|
-
try:
|
289
|
-
interface = self.amphora_driver.get_interface_from_ip(
|
290
|
-
amphora, amphora.vrrp_ip, timeout_dict=timeout_dict)
|
291
|
-
except Exception as e:
|
292
|
-
# This can occur when an active/standby LB has no listener
|
293
|
-
LOG.error('Failed to get amphora VRRP interface on amphora '
|
294
|
-
'%s. Skipping this amphora as it is failing due to: '
|
295
|
-
'%s', amphora.id, str(e))
|
296
|
-
self.amphora_repo.update(db_apis.get_session(), amphora.id,
|
297
|
-
status=constants.ERROR)
|
298
|
-
return None
|
299
|
-
|
300
|
-
self.amphora_repo.update(db_apis.get_session(), amphora.id,
|
301
|
-
vrrp_interface=interface)
|
302
|
-
return interface
|
303
|
-
|
304
|
-
|
305
|
-
class AmphoraIndexUpdateVRRPInterface(BaseAmphoraTask):
|
306
|
-
"""Task to get and update the VRRP interface device name from amphora."""
|
307
|
-
|
308
|
-
def execute(self, amphora_index, amphorae, timeout_dict=None):
|
309
|
-
amphora_id = amphorae[amphora_index].id
|
310
|
-
try:
|
311
|
-
interface = self.amphora_driver.get_interface_from_ip(
|
312
|
-
amphorae[amphora_index], amphorae[amphora_index].vrrp_ip,
|
313
|
-
timeout_dict=timeout_dict)
|
314
|
-
except Exception as e:
|
315
|
-
# This can occur when an active/standby LB has no listener
|
316
|
-
LOG.error('Failed to get amphora VRRP interface on amphora '
|
317
|
-
'%s. Skipping this amphora as it is failing due to: '
|
318
|
-
'%s', amphora_id, str(e))
|
319
|
-
self.amphora_repo.update(db_apis.get_session(), amphora_id,
|
320
|
-
status=constants.ERROR)
|
321
|
-
return None
|
322
|
-
|
323
|
-
self.amphora_repo.update(db_apis.get_session(), amphora_id,
|
324
|
-
vrrp_interface=interface)
|
325
|
-
return interface
|
326
|
-
|
327
|
-
|
328
|
-
class AmphoraVRRPUpdate(BaseAmphoraTask):
|
329
|
-
"""Task to update the VRRP configuration of an amphora."""
|
330
|
-
|
331
|
-
def execute(self, loadbalancer_id, amphorae_network_config, amphora,
|
332
|
-
amp_vrrp_int, timeout_dict=None):
|
333
|
-
"""Execute update_vrrp_conf."""
|
334
|
-
loadbalancer = self.loadbalancer_repo.get(db_apis.get_session(),
|
335
|
-
id=loadbalancer_id)
|
336
|
-
# Note, we don't want this to cause a revert as it may be used
|
337
|
-
# in a failover flow with both amps failing. Skip it and let
|
338
|
-
# health manager fix it.
|
339
|
-
amphora.vrrp_interface = amp_vrrp_int
|
340
|
-
try:
|
341
|
-
self.amphora_driver.update_vrrp_conf(
|
342
|
-
loadbalancer, amphorae_network_config, amphora, timeout_dict)
|
343
|
-
except Exception as e:
|
344
|
-
LOG.error('Failed to update VRRP configuration amphora %s. '
|
345
|
-
'Skipping this amphora as it is failing to update due '
|
346
|
-
'to: %s', amphora.id, str(e))
|
347
|
-
self.amphora_repo.update(db_apis.get_session(), amphora.id,
|
348
|
-
status=constants.ERROR)
|
349
|
-
|
350
|
-
LOG.debug("Uploaded VRRP configuration of amphora %s.", amphora.id)
|
351
|
-
|
352
|
-
|
353
|
-
class AmphoraIndexVRRPUpdate(BaseAmphoraTask):
|
354
|
-
"""Task to update the VRRP configuration of an amphora."""
|
355
|
-
|
356
|
-
def execute(self, loadbalancer_id, amphorae_network_config, amphora_index,
|
357
|
-
amphorae, amp_vrrp_int, timeout_dict=None):
|
358
|
-
"""Execute update_vrrp_conf."""
|
359
|
-
loadbalancer = self.loadbalancer_repo.get(db_apis.get_session(),
|
360
|
-
id=loadbalancer_id)
|
361
|
-
# Note, we don't want this to cause a revert as it may be used
|
362
|
-
# in a failover flow with both amps failing. Skip it and let
|
363
|
-
# health manager fix it.
|
364
|
-
amphora_id = amphorae[amphora_index].id
|
365
|
-
amphorae[amphora_index].vrrp_interface = amp_vrrp_int
|
366
|
-
try:
|
367
|
-
self.amphora_driver.update_vrrp_conf(
|
368
|
-
loadbalancer, amphorae_network_config, amphorae[amphora_index],
|
369
|
-
timeout_dict)
|
370
|
-
except Exception as e:
|
371
|
-
LOG.error('Failed to update VRRP configuration amphora %s. '
|
372
|
-
'Skipping this amphora as it is failing to update due '
|
373
|
-
'to: %s', amphora_id, str(e))
|
374
|
-
self.amphora_repo.update(db_apis.get_session(), amphora_id,
|
375
|
-
status=constants.ERROR)
|
376
|
-
return
|
377
|
-
LOG.debug("Uploaded VRRP configuration of amphora %s.", amphora_id)
|
378
|
-
|
379
|
-
|
380
|
-
class AmphoraVRRPStart(BaseAmphoraTask):
|
381
|
-
"""Task to start keepalived on an amphora.
|
382
|
-
|
383
|
-
This will reload keepalived if it is already running.
|
384
|
-
"""
|
385
|
-
|
386
|
-
def execute(self, amphora, timeout_dict=None):
|
387
|
-
self.amphora_driver.start_vrrp_service(amphora, timeout_dict)
|
388
|
-
LOG.debug("Started VRRP on amphora %s.", amphora.id)
|
389
|
-
|
390
|
-
|
391
|
-
class AmphoraIndexVRRPStart(BaseAmphoraTask):
|
392
|
-
"""Task to start keepalived on an amphora.
|
393
|
-
|
394
|
-
This will reload keepalived if it is already running.
|
395
|
-
"""
|
396
|
-
|
397
|
-
def execute(self, amphora_index, amphorae, timeout_dict=None):
|
398
|
-
amphora_id = amphorae[amphora_index].id
|
399
|
-
try:
|
400
|
-
self.amphora_driver.start_vrrp_service(amphorae[amphora_index],
|
401
|
-
timeout_dict)
|
402
|
-
except Exception as e:
|
403
|
-
LOG.error('Failed to start VRRP on amphora %s. '
|
404
|
-
'Skipping this amphora as it is failing to start due '
|
405
|
-
'to: %s', amphora_id, str(e))
|
406
|
-
self.amphora_repo.update(db_apis.get_session(), amphora_id,
|
407
|
-
status=constants.ERROR)
|
408
|
-
return
|
409
|
-
LOG.debug("Started VRRP on amphora %s.", amphorae[amphora_index].id)
|
410
|
-
|
411
|
-
|
412
|
-
class AmphoraComputeConnectivityWait(BaseAmphoraTask):
|
413
|
-
"""Task to wait for the compute instance to be up."""
|
414
|
-
|
415
|
-
def execute(self, amphora):
|
416
|
-
"""Execute get_info routine for an amphora until it responds."""
|
417
|
-
try:
|
418
|
-
amp_info = self.amphora_driver.get_info(amphora)
|
419
|
-
LOG.debug('Successfuly connected to amphora %s: %s',
|
420
|
-
amphora.id, amp_info)
|
421
|
-
except driver_except.TimeOutException:
|
422
|
-
LOG.error("Amphora compute instance failed to become reachable. "
|
423
|
-
"This either means the compute driver failed to fully "
|
424
|
-
"boot the instance inside the timeout interval or the "
|
425
|
-
"instance is not reachable via the lb-mgmt-net.")
|
426
|
-
self.amphora_repo.update(db_apis.get_session(), amphora.id,
|
427
|
-
status=constants.ERROR)
|
428
|
-
raise
|
429
|
-
|
430
|
-
|
431
|
-
class AmphoraConfigUpdate(BaseAmphoraTask):
|
432
|
-
"""Task to push a new amphora agent configuration to the amphora."""
|
433
|
-
|
434
|
-
def execute(self, amphora, flavor):
|
435
|
-
# Extract any flavor based settings
|
436
|
-
if flavor:
|
437
|
-
topology = flavor.get(constants.LOADBALANCER_TOPOLOGY,
|
438
|
-
CONF.controller_worker.loadbalancer_topology)
|
439
|
-
else:
|
440
|
-
topology = CONF.controller_worker.loadbalancer_topology
|
441
|
-
|
442
|
-
# Build the amphora agent config
|
443
|
-
agent_cfg_tmpl = agent_jinja_cfg.AgentJinjaTemplater()
|
444
|
-
agent_config = agent_cfg_tmpl.build_agent_config(amphora.id, topology)
|
445
|
-
|
446
|
-
# Push the new configuration to the amphora
|
447
|
-
try:
|
448
|
-
self.amphora_driver.update_amphora_agent_config(amphora,
|
449
|
-
agent_config)
|
450
|
-
except driver_except.AmpDriverNotImplementedError:
|
451
|
-
LOG.error('Amphora %s does not support agent configuration '
|
452
|
-
'update. Please update the amphora image for this '
|
453
|
-
'amphora. Skipping.', amphora.id)
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# Copyright 2015 Hewlett-Packard Development Company, L.P.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
4
|
-
# not use this file except in compliance with the License. You may obtain
|
5
|
-
# a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
11
|
-
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
12
|
-
# License for the specific language governing permissions and limitations
|
13
|
-
# under the License.
|
14
|
-
#
|
15
|
-
|
16
|
-
from cryptography import fernet
|
17
|
-
from oslo_config import cfg
|
18
|
-
from stevedore import driver as stevedore_driver
|
19
|
-
from taskflow import task
|
20
|
-
|
21
|
-
from octavia.common import utils
|
22
|
-
|
23
|
-
CONF = cfg.CONF
|
24
|
-
|
25
|
-
|
26
|
-
class BaseCertTask(task.Task):
|
27
|
-
"""Base task to load drivers common to the tasks."""
|
28
|
-
|
29
|
-
def __init__(self, **kwargs):
|
30
|
-
super().__init__(**kwargs)
|
31
|
-
self.cert_generator = stevedore_driver.DriverManager(
|
32
|
-
namespace='octavia.cert_generator',
|
33
|
-
name=CONF.certificates.cert_generator,
|
34
|
-
invoke_on_load=True,
|
35
|
-
).driver
|
36
|
-
|
37
|
-
|
38
|
-
class GenerateServerPEMTask(BaseCertTask):
|
39
|
-
"""Create the server certs for the agent comm
|
40
|
-
|
41
|
-
Use the amphora_id for the CN
|
42
|
-
"""
|
43
|
-
|
44
|
-
def execute(self, amphora_id):
|
45
|
-
cert = self.cert_generator.generate_cert_key_pair(
|
46
|
-
cn=amphora_id,
|
47
|
-
validity=CONF.certificates.cert_validity_time)
|
48
|
-
key = utils.get_compatible_server_certs_key_passphrase()
|
49
|
-
fer = fernet.Fernet(key)
|
50
|
-
|
51
|
-
return fer.encrypt(cert.certificate + cert.private_key)
|