def audit_lb_pools(self):
     for hm_id, config_data, driver_data in self._object_db.health_monitor_list():
         if HealthMonitorSM.get(hm_id):
             continue
         hm = config_data
         if not hasattr(hm, 'provider'):
             continue
         driver = self._get_driver_for_provider(hm['provider'])
         pools = set()
         for i in hm['pools'] or []:
             pools.add(i['pool_id'])
         try:
             for pool in pools:
                 driver.delete_health_monitor(hm, pool)
         except Exception:
             pass
         self._object_db.healthmonitor_remove(hm_id)
     for lb_id, config_data, driver_data in self._object_db.loadbalancer_list():
         if LoadbalancerSM.get(lb_id):
             continue
         # Delete the lb from the driver
         driver = self._get_driver_for_provider(config_data['provider'])
         driver.delete_loadbalancer(config_data)
         self._object_db.loadbalancer_remove(lb_id)
         self._delete_driver_for_loadbalancer(lb_id)
     for pool_id, config_data, driver_data in self._object_db.pool_list():
         if LoadbalancerPoolSM.get(pool_id):
             continue
         # Delete the pool from the driver
         driver = self._get_driver_for_provider(config_data['provider'])
         driver.delete_pool(config_data)
         self._object_db.pool_remove(pool_id)
         self._delete_driver_for_pool(pool_id)
 def audit_lb_pools(self):
     for hm_id, config_data, driver_data in self._object_db.health_monitor_list(
     ):
         if HealthMonitorSM.get(hm_id):
             continue
         hm = config_data
         driver = self._get_driver_for_provider(hm['provider'])
         pools = set()
         for i in hm['pools'] or []:
             pools.add(i['pool_id'])
         try:
             for pool in pools:
                 driver.delete_health_monitor(hm, pool)
         except Exception:
             pass
         self._object_db.healthmonitor_remove(hm_id)
     for lb_id, config_data, driver_data in self._object_db.loadbalancer_list(
     ):
         if LoadbalancerSM.get(lb_id):
             continue
         # Delete the lb from the driver
         driver = self._get_driver_for_provider(config_data['provider'])
         driver.delete_loadbalancer(config_data)
         self._object_db.loadbalancer_remove(lb_id)
         self._delete_driver_for_loadbalancer(lb_id)
     for pool_id, config_data, driver_data in self._object_db.pool_list():
         if LoadbalancerPoolSM.get(pool_id):
             continue
         # Delete the pool from the driver
         driver = self._get_driver_for_provider(config_data['provider'])
         driver.delete_pool(config_data)
         self._object_db.pool_remove(pool_id)
         self._delete_driver_for_pool(pool_id)
 def _get_driver_for_loadbalancer(self, lb_id, provider=None):
     if lb_id in self._loadbalancer_driver:
         return self._loadbalancer_driver[lb_id]
     if not provider:
         lb = LoadbalancerSM.get(lb_id)
         provider = lb.provider
     if provider:
         driver = self._get_driver_for_provider(provider)
         self._loadbalancer_driver[lb_id] = driver
         return driver
     return self._loadbalancer_driver[self._default_provider]
 def _get_driver_for_loadbalancer(self, lb_id, provider=None):
     if lb_id in self._loadbalancer_driver:
         return self._loadbalancer_driver[lb_id]
     if not provider:
         lb = LoadbalancerSM.get(lb_id)
         provider = lb.provider
     if provider:
         driver = self._get_driver_for_provider(provider)
         self._loadbalancer_driver[lb_id] = driver
         return driver
     return self._loadbalancer_driver[self._default_provider]
 def _send_lb_config_uve(self, lb_id, deleted):
     lb = LoadbalancerSM.get(lb_id)
     if not lb:
         return
     sandesh = self._svc_mon.logger._sandesh
     if deleted == True:
         uve_lb = UveLoadbalancerConfig(name=lb.uuid, deleted=True)
         uve_lb.listener = {}
         uve_lb.pool = {}
         uve_trace = UveLoadbalancerConfigTrace(data=uve_lb,
                                                sandesh=sandesh)
         uve_trace.send(sandesh=sandesh)
         return
     uve_lb = UveLoadbalancerConfig()
     uve_lb.name = lb.uuid
     uve_lb.listener = {}
     uve_lb.pool = {}
     pool_found = False
     for ll_id in lb.loadbalancer_listeners:
         ll = LoadbalancerListenerSM.get(ll_id)
         if not ll:
             continue
         if not ll.params['admin_state']:
             continue
         ll_uuid = ll.uuid
         pools = []
         pool = LoadbalancerPoolSM.get(ll.loadbalancer_pool)
         if pool and pool.params['admin_state']:
             pools.append(pool.uuid)
             uve_lb_listener = LoadbalancerConfig()
             uve_lb_listener.pool_uuid = pools
             uve_lb.listener[ll_uuid] = uve_lb_listener
             pool_uuid = pool.uuid
             pool_found = True
             members = []
             uve_lb_pool = LoadbalancerConfig()
             for member_id in pool.members:
                 member = LoadbalancerMemberSM.get(member_id)
                 members.append(member.uuid)
             uve_lb_pool.member_uuid = members
             uve_lb.pool[pool_uuid] = uve_lb_pool
     if pool_found == True:
         uve_trace = UveLoadbalancerConfigTrace(data=uve_lb,
                                                sandesh=sandesh)
         uve_trace.send(sandesh=sandesh)
     else:
         uve_lb = UveLoadbalancerConfig(name=lb.uuid, deleted=True)
         uve_lb.listener = {}
         uve_lb.pool = {}
         uve_trace = UveLoadbalancerConfigTrace(data=uve_lb,
                                                sandesh=sandesh)
         uve_trace.send(sandesh=sandesh)
     return
 def _send_lb_config_uve(self, lb_id, deleted):
     lb = LoadbalancerSM.get(lb_id)
     if not lb:
         return
     sandesh = self._svc_mon.logger._sandesh
     if deleted == True:
         uve_lb = UveLoadbalancerConfig(name=lb.uuid, deleted=True)
         uve_lb.listener = {}
         uve_lb.pool = {}
         uve_trace = UveLoadbalancerConfigTrace(data=uve_lb, sandesh=sandesh)
         uve_trace.send(sandesh=sandesh)
         return
     uve_lb = UveLoadbalancerConfig()
     uve_lb.name = lb.uuid
     uve_lb.listener = {}
     uve_lb.pool = {}
     pool_found = False
     for ll_id in lb.loadbalancer_listeners:
         ll = LoadbalancerListenerSM.get(ll_id)
         if not ll:
             continue
         if not ll.params['admin_state']:
             continue
         ll_uuid = ll.uuid
         pools = []
         pool =  LoadbalancerPoolSM.get(ll.loadbalancer_pool)
         if pool and pool.params['admin_state']:
             pools.append(pool.uuid)
             uve_lb_listener = LoadbalancerConfig()
             uve_lb_listener.pool_uuid = pools
             uve_lb.listener[ll_uuid] = uve_lb_listener
             pool_uuid = pool.uuid
             pool_found = True
             members = []
             uve_lb_pool = LoadbalancerConfig()
             for member_id in pool.members:
                 member = LoadbalancerMemberSM.get(member_id)
                 members.append(member.uuid)
             uve_lb_pool.member_uuid = members
             uve_lb.pool[pool_uuid] = uve_lb_pool
     if pool_found == True:
         uve_trace = UveLoadbalancerConfigTrace(data=uve_lb, sandesh=sandesh)
         uve_trace.send(sandesh=sandesh)
     else:
         uve_lb = UveLoadbalancerConfig(name=lb.uuid, deleted=True)
         uve_lb.listener = {}
         uve_lb.pool = {}
         uve_trace = UveLoadbalancerConfigTrace(data=uve_lb, sandesh=sandesh)
         uve_trace.send(sandesh=sandesh)
     return
    def _get_vip_vmi(self, si):
        lb = LoadbalancerSM.get(si.loadbalancer)
        if lb:
            vmi_id = lb.virtual_machine_interface
            vmi = VirtualMachineInterfaceSM.get(vmi_id)
            return vmi

        pool = LoadbalancerPoolSM.get(si.loadbalancer_pool)
        if pool:
            vip = VirtualIpSM.get(pool.virtual_ip)
            if vip:
                vmi_id = vip.virtual_machine_interface
                vmi = VirtualMachineInterfaceSM.get(vmi_id)
                return vmi

        return None
    def _get_vip_vmi(self, si):
        lb = LoadbalancerSM.get(si.loadbalancer)
        if lb:
            vmi_id = lb.virtual_machine_interface
            vmi = VirtualMachineInterfaceSM.get(vmi_id)
            return vmi

        pool = LoadbalancerPoolSM.get(si.loadbalancer_pool)
        if pool:
            vip = VirtualIpSM.get(pool.virtual_ip)
            if vip:
                vmi_id = vip.virtual_machine_interface
                vmi = VirtualMachineInterfaceSM.get(vmi_id)
                return vmi

        return None
 def audit_lb_pools(self):
     for lb_id, config_data, driver_data in self._object_db.loadbalancer_list():
         if LoadbalancerSM.get(lb_id):
             continue
         # Delete the lb from the driver
         driver = self._get_driver_for_provider(config_data['provider'])
         driver.delete_loadbalancer(config_data)
         self._object_db.loadbalancer_remove(lb_id)
         self._delete_driver_for_loadbalancer(lb_id)
     for pool_id, config_data, driver_data in self._object_db.pool_list():
         if LoadbalancerPoolSM.get(pool_id):
             continue
         # Delete the pool from the driver
         driver = self._get_driver_for_provider(config_data['provider'])
         driver.delete_pool(config_data)
         self._object_db.pool_remove(pool_id)
         self._delete_driver_for_pool(pool_id)
示例#10
0
 def audit_lb_pools(self):
     for lb_id, config_data, driver_data in self._cassandra.loadbalancer_list():
         if LoadbalancerSM.get(lb_id):
             continue
         # Delete the lb from the driver
         driver = self._get_driver_for_provider(config_data['provider'])
         driver.delete_loadbalancer(config_data)
         self._cassandra.loadbalancer_remove(lb_id)
         self._delete_driver_for_loadbalancer(lb_id)
     for pool_id, config_data, driver_data in self._cassandra.pool_list():
         if LoadbalancerPoolSM.get(pool_id):
             continue
         # Delete the pool from the driver
         driver = self._get_driver_for_provider(config_data['provider'])
         driver.delete_pool(config_data)
         self._cassandra.pool_remove(pool_id)
         self._delete_driver_for_pool(pool_id)
    def _get_vip_vmi(self, si):
        pool = LoadbalancerPoolSM.get(si.loadbalancer_pool)
        if not pool:
            return None

        listener = LoadbalancerListenerSM.get(pool.loadbalancer_listener)
        if listener:
            lb = LoadbalancerSM.get(listener.loadbalancer)
            vmi_id = lb.virtual_machine_interface
            vmi = VirtualMachineInterfaceSM.get(vmi_id)
            return vmi

        vip = VirtualIpSM.get(pool.virtual_ip)
        if vip:
            vmi_id = vip.virtual_machine_interface
            vmi = VirtualMachineInterfaceSM.get(vmi_id)
            return vmi

        return None
    def listener_get_reqdict(self, listener):
        props = listener.params
        lb = LoadbalancerSM.get(listener.loadbalancer)

        res = {'id': listener.uuid,
               'tenant_id': listener.parent_uuid.replace('-', ''),
               'name': listener.display_name,
               'description': self._get_object_description(listener),
               'subnet_id': lb.params.get('subnet_id'),
               'address': lb.params.get('vip_address'),
               'port_id': lb.virtual_machine_interface,
               'protocol_port': props['protocol_port'],
               'protocol': props['protocol'],
               'pool_id': listener.loadbalancer_pool,
               'session_persistence': None,
               'admin_state_up': props['admin_state'],
               'status': self._get_object_status(listener)}

        return res