"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "octavia/api/drivers/driver_agent/driver_updater.py" between
octavia-7.1.1.tar.gz and octavia-8.0.0.tar.gz

About: OpenStack Octavia is an operator-grade reference implementation for Load Balancing as a Service (LBaaS).
The "Wallaby" series (latest release).

driver_updater.py  (octavia-7.1.1):driver_updater.py  (octavia-8.0.0)
skipping to change at line 19 skipping to change at line 19
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import time import time
from octavia_lib.api.drivers import exceptions as driver_exceptions from octavia_lib.api.drivers import exceptions as driver_exceptions
from octavia_lib.common import constants as lib_consts from octavia_lib.common import constants as lib_consts
from oslo_log import log as logging
from oslo_utils import excutils
from octavia.common import constants as consts from octavia.common import constants as consts
from octavia.common import data_models from octavia.common import data_models
from octavia.common import utils from octavia.common import utils
from octavia.db import api as db_apis from octavia.db import api as db_apis
from octavia.db import repositories as repo from octavia.db import repositories as repo
from octavia.statistics import stats_base from octavia.statistics import stats_base
LOG = logging.getLogger(__name__)
class DriverUpdater(object): class DriverUpdater(object):
def __init__(self, **kwargs): def __init__(self, **kwargs):
self.repos = repo.Repositories()
self.loadbalancer_repo = repo.LoadBalancerRepository() self.loadbalancer_repo = repo.LoadBalancerRepository()
self.listener_repo = repo.ListenerRepository() self.listener_repo = repo.ListenerRepository()
self.pool_repo = repo.PoolRepository() self.pool_repo = repo.PoolRepository()
self.health_mon_repo = repo.HealthMonitorRepository() self.health_mon_repo = repo.HealthMonitorRepository()
self.member_repo = repo.MemberRepository() self.member_repo = repo.MemberRepository()
self.l7policy_repo = repo.L7PolicyRepository() self.l7policy_repo = repo.L7PolicyRepository()
self.l7rule_repo = repo.L7RuleRepository() self.l7rule_repo = repo.L7RuleRepository()
self.listener_stats_repo = repo.ListenerStatisticsRepository() self.listener_stats_repo = repo.ListenerStatisticsRepository()
self.db_session = db_apis.get_session() self.db_session = db_apis.get_session()
skipping to change at line 52 skipping to change at line 57
def _check_for_lb_vip_deallocate(self, repo, lb_id): def _check_for_lb_vip_deallocate(self, repo, lb_id):
lb = repo.get(self.db_session, id=lb_id) lb = repo.get(self.db_session, id=lb_id)
if lb.vip.octavia_owned: if lb.vip.octavia_owned:
vip = lb.vip vip = lb.vip
# We need a backreference # We need a backreference
vip.load_balancer = lb vip.load_balancer = lb
# Only lookup the network driver if we have a VIP to deallocate # Only lookup the network driver if we have a VIP to deallocate
network_driver = utils.get_network_driver() network_driver = utils.get_network_driver()
network_driver.deallocate_vip(vip) network_driver.deallocate_vip(vip)
def _decrement_quota(self, repo, object_name, record_id):
lock_session = db_apis.get_session(autocommit=False)
db_object = repo.get(lock_session, id=record_id)
try:
if db_object.provisioning_status == consts.DELETED:
LOG.info('%(name)s with ID of %(id)s is already in the '
'DELETED state. Skipping quota update.',
{'name': object_name, 'id': record_id})
lock_session.rollback()
return
self.repos.decrement_quota(lock_session,
repo.model_class.__data_model__,
db_object.project_id)
lock_session.commit()
except Exception:
with excutils.save_and_reraise_exception():
LOG.error('Failed to decrement %(name)s quota for '
'project: %(proj)s the project may have excess '
'quota in use.', {'proj': db_object.project_id,
'name': object_name})
lock_session.rollback()
def _process_status_update(self, repo, object_name, record, def _process_status_update(self, repo, object_name, record,
delete_record=False): delete_record=False):
# Zero it out so that if the ID is missing from a record we do not # Zero it out so that if the ID is missing from a record we do not
# report the last LB as the failed record in the exception # report the last LB as the failed record in the exception
record_id = None record_id = None
try: try:
record_id = record['id'] record_id = record['id']
record_kwargs = {} record_kwargs = {}
prov_status = record.get(consts.PROVISIONING_STATUS, None) prov_status = record.get(consts.PROVISIONING_STATUS, None)
if prov_status: if prov_status:
if (prov_status == consts.DELETED and if prov_status == consts.DELETED:
object_name == consts.LOADBALANCERS): if object_name == consts.LOADBALANCERS:
self._check_for_lb_vip_deallocate(repo, record_id) self._check_for_lb_vip_deallocate(repo, record_id)
elif prov_status == consts.DELETED and delete_record:
repo.delete(self.db_session, id=record_id) self._decrement_quota(repo, object_name, record_id)
return
if delete_record and object_name != consts.LOADBALANCERS:
repo.delete(self.db_session, id=record_id)
return
record_kwargs[consts.PROVISIONING_STATUS] = prov_status record_kwargs[consts.PROVISIONING_STATUS] = prov_status
op_status = record.get(consts.OPERATING_STATUS, None) op_status = record.get(consts.OPERATING_STATUS, None)
if op_status: if op_status:
record_kwargs[consts.OPERATING_STATUS] = op_status record_kwargs[consts.OPERATING_STATUS] = op_status
if prov_status or op_status: if prov_status or op_status:
repo.update(self.db_session, record_id, **record_kwargs) repo.update(self.db_session, record_id, **record_kwargs)
except Exception as e: except Exception as e:
# We need to raise a failure here to notify the driver it is # We need to raise a failure here to notify the driver it is
# sending bad status data. # sending bad status data.
raise driver_exceptions.UpdateStatusError( raise driver_exceptions.UpdateStatusError(
 End of changes. 5 change blocks. 
6 lines changed or deleted 37 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)