def create_pool(self, context, pool):
     agent = self.pool_scheduler.schedule(self.plugin, context, pool,
                                          self.device_driver)
     if not agent:
         raise lbaas_agentscheduler.NoEligibleLbaasAgent(pool_id=pool['id'])
     self.agent_rpc.create_pool(context, pool, agent['host'],
                                self.device_driver)
    def reschedule_loadbalancer_instance(self, plugin, context, loadbalancer,
                                         device_driver):
        """Reschedule loadbalancer to a new lbaas-agent

        Remove the loadbalancer from the lbaas-agent(s) currently hosting it and
        schedule it again
        """
        cur_agent = plugin.get_lbaas_agent_hosting_loadbalancer(
            context, loadbalancer.id)
        LOG.info(
            _('Reschedule Loadbalancer %(loadbalancer_id)s been hosted'
              ' by lbaas agent %(agent)s'), {
                  'loadbalancer_id': id,
                  'agent': cur_agent
              })
        with context.session.begin(subtransactions=True):
            if cur_agent:
                self._unbind_loadbalancer(context, loadbalancer.id,
                                          cur_agent['agent']['id'])
            else:
                LOG.error("Reschedule Loadbalancer %s not found agent", id)
            new_agent = self.schedule(plugin, context, loadbalancer,
                                      device_driver)
            LOG.info(
                _('Reschedule Loadbalancer %(loadbalancer_id)s to '
                  ' agent %(agent)s'), {
                      'loadbalancer_id': id,
                      'agent': new_agent
                  })
            if not new_agent:
                raise lbaas_agentscheduler.NoEligibleLbaasAgent(
                    loadbalancer_id=id)
            return new_agent
Exemple #3
0
 def create_pool(self, context, pool):
     agent = self.pool_scheduler.schedule(self.plugin, context, pool,
                                          self.device_driver)  #首先通过agent scheduler分配agent:从数据库agents表中查询类型为Loadbalancer agent,admin_state_up状态为Active的lbaas-agent
     if not agent:
         raise lbaas_agentscheduler.NoEligibleLbaasAgent(pool_id=pool['id'])
     self.agent_rpc.create_pool(context, pool, agent['host'],
                                self.device_driver)
Exemple #4
0
    def create_pool(self, context, pool):
        LOG.info(_("Pool to be created: %s" % repr(pool)))
        #This is where we pick an agent for this pool (and related resources)
        agent = self.pool_scheduler.schedule(self.plugin, context, pool)

        if not agent:
            raise lbaas_agentscheduler.NoEligibleLbaasAgent(pool_id=pool['id'])

        network_info = self._get_pool_network_info(context, pool)

        #allocate a snat port/ipaddress on the subnet if one doesn't exist
        port = self._create_snatport_for_subnet_if_not_exists(
            context, pool['tenant_id'], pool['subnet_id'], network_info)

        self.agent_rpc.create_pool(context, pool, network_info, agent['host'])
        LOG.info(_('create_pool rpc sent to loadbalancer agent...'))
Exemple #5
0
    def create_loadbalancer_instance(self, context, loadbalancer):
        agent = self.loadbalancer_scheduler.schedule(self.plugin, context,
                                                     loadbalancer,
                                                     self.device_driver)
        if not agent:
            LOG.warning(
                _(" LoadBalancer '%(loadbalancer)s' can not be created"
                  " because no eligible lbaas-agent can be found. ") %
                {'loadbalancer': loadbalancer.id})
            raise lbaas_agentscheduler.NoEligibleLbaasAgent(
                loadbalancer_id=loadbalancer.id)

        #LOG.info("create_loadbalancer_instance deployed_loadbalancer_ids
        #             add %s", loadbalancer.id)
        #self.deployed_loadbalancer_ids.add(loadbalancer.id)
        self.agent_rpc.create_loadbalancer(context, loadbalancer.to_dict(),
                                           agent['agent']['host'],
                                           self.device_driver)
Exemple #6
0
 def create_pool(self, context, pool):
     if not self.pool_scheduler.schedule(self.plugin, context, pool):
         raise lbaas_agentscheduler.NoEligibleLbaasAgent(pool_id=pool['id'])