def hm_get_reqdict(self, health_monitor):
        res = {'id': health_monitor.uuid,
               'tenant_id': health_monitor.parent_uuid.replace('-', ''),
               'status': self._get_object_status(health_monitor)}

        props = health_monitor.params
        for key, mapping in self._loadbalancer_health_type_mapping.iteritems():
            value = props[key]
            if value is not None:
                res[mapping] = value

        pool_ids = []
        pool_back_refs = health_monitor.loadbalancer_pools
        for pool_back_ref in pool_back_refs or []:
            pool_id = {}
            pool_id['pool_id'] = pool_back_ref
            pool_ids.append(pool_id)
        res['pools'] = pool_ids

        if pool_ids:
            pool = LoadbalancerPoolSM.get(pool_ids[0]['pool_id'])
            if pool:
                res['provider'] = pool.provider

        return res
 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)
示例#4
0
    def hm_get_reqdict(self, health_monitor):
        res = {
            'id': health_monitor.uuid,
            'tenant_id': health_monitor.parent_uuid.replace('-', ''),
            'status': self._get_object_status(health_monitor)
        }

        props = health_monitor.params
        for key, mapping in self._loadbalancer_health_type_mapping.iteritems():
            if key in props and props[key]:
                res[mapping] = props[key]

        pool_ids = []
        pool_back_refs = health_monitor.loadbalancer_pools
        for pool_back_ref in pool_back_refs or []:
            pool_id = {}
            pool_id['pool_id'] = pool_back_ref
            pool_ids.append(pool_id)
        res['pools'] = pool_ids

        if pool_ids:
            pool = LoadbalancerPoolSM.get(pool_ids[0]['pool_id'])
            if pool:
                res['provider'] = pool.provider

        return res
 def audit_lb_pools(self):
     for pool_id, config_data, driver_data in self.lb_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.lb_db.pool_remove(pool_id)
示例#6
0
 def audit_lb_pools(self):
     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)
 def _get_driver_for_pool(self, pool_id, provider=None):
     if pool_id in self._pool_driver:
         return self._pool_driver[pool_id]
     if not provider:
         pool = LoadbalancerPoolSM.get(pool_id)
         provider = pool.provider
     if provider:
         driver = self._get_driver_for_provider(provider)
         self._pool_driver[pool_id] = driver
         return driver
     return self._loadbalancer_driver[self._default_provider]
 def _get_driver_for_pool(self, pool_id, provider=None):
     if pool_id in self._pool_driver:
         return self._pool_driver[pool_id]
     if not provider:
         pool = LoadbalancerPoolSM.get(pool_id)
         provider = pool.provider
     if provider:
         driver = self._get_driver_for_provider(provider)
         self._pool_driver[pool_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 loadbalancer_member_get_reqdict(self, member):
        res = {"id": member.uuid, "pool_id": member.loadbalancer_pool, "status": self._get_object_status(member)}

        pool = LoadbalancerPoolSM.get(member.loadbalancer_pool)
        res["tenant_id"] = pool.parent_uuid.replace("-", "")

        props = member.params
        for key, mapping in self._loadbalancer_member_type_mapping.iteritems():
            value = props[key]
            if value is not None:
                res[mapping] = value

        return res
示例#11
0
    def _get_vip_vmi(self, si):
        if not si.loadbalancer_pool:
            return None

        pool = LoadbalancerPoolSM.get(si.loadbalancer_pool)
        if not pool.virtual_ip:
            return None

        vip = VirtualIpSM.get(pool.virtual_ip)
        if not vip.virtual_machine_interface:
            return None

        vmi = VirtualMachineInterfaceSM.get(vip.virtual_machine_interface)
        return vmi
    def _get_vip_vmi(self, si):
        if not si.loadbalancer_pool:
            return None

        pool = LoadbalancerPoolSM.get(si.loadbalancer_pool)
        if not pool.virtual_ip:
            return None

        vip = VirtualIpSM.get(pool.virtual_ip)
        if not vip.virtual_machine_interface:
            return None

        vmi = VirtualMachineInterfaceSM.get(vip.virtual_machine_interface)
        return vmi
 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 loadbalancer_member_get_reqdict(self, member):
        res = {'id': member.uuid,
               'vmi': member.vmi,
               'pool_id': member.loadbalancer_pool,
               'status': self._get_object_status(member)}

        pool = LoadbalancerPoolSM.get(member.loadbalancer_pool)
        res['tenant_id'] = pool.parent_uuid.replace('-', '')

        props = member.params
        for key, mapping in self._loadbalancer_member_type_mapping.iteritems():
            if key in props and props[key]:
                res[mapping] = props[key]

        return res
    def loadbalancer_member_get_reqdict(self, member):
        res = {'id': member.uuid,
               'pool_id': member.loadbalancer_pool,
               'status': self._get_object_status(member)}

        pool = LoadbalancerPoolSM.get(member.loadbalancer_pool)
        res['tenant_id'] = pool.parent_uuid.replace('-', '')

        props = member.params
        for key, mapping in self._loadbalancer_member_type_mapping.iteritems():
            value = props[key]
            if value is not None:
                res[mapping] = value

        return res
    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 _get_vip_vmi_iip(self, si):
        if not si.loadbalancer_pool:
            return None, None

        pool = LoadbalancerPoolSM.get(si.loadbalancer_pool)
        if not pool.virtual_ip:
            return None, None

        vip = VirtualIpSM.get(pool.virtual_ip)
        if not vip.virtual_machine_interface:
            return None, None

        vmi = VirtualMachineInterfaceSM.get(vip.virtual_machine_interface)
        if not vmi.instance_ip or not vmi.virtual_network:
            return None, None

        return vmi.instance_ip, vmi.virtual_network
示例#19
0
    def _get_vip_vmi_iip(self, si):
        if not si.loadbalancer_pool:
            return None, None

        pool = LoadbalancerPoolSM.get(si.loadbalancer_pool)
        if not pool.virtual_ip:
            return None, None

        vip = VirtualIpSM.get(pool.virtual_ip)
        if not vip.virtual_machine_interface:
            return None, None

        vmi = VirtualMachineInterfaceSM.get(vip.virtual_machine_interface)
        if not vmi.instance_ip or not vmi.virtual_network:
            return None, None

        return vmi.instance_ip, vmi.virtual_network
示例#20
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 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)
    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