Ejemplo n.º 1
0
    def delete_computehost(self, host_id):
        host = db_api.host_get(host_id)
        if not host:
            raise manager_ex.HostNotFound(host=host_id)

        with trusts.create_ctx_from_trust(host['trust_id']):
            # TODO(sbauza):
            #  - Check if no leases having this host scheduled
            inventory = nova_inventory.NovaInventory()
            servers = inventory.get_servers_per_host(
                host['hypervisor_hostname'])
            if servers:
                raise manager_ex.HostHavingServers(
                    host=host['hypervisor_hostname'], servers=servers)

            try:
                pool = rp.ReservationPool()
                pool.remove_computehost(self.freepool_name,
                                        host['service_name'])
                # NOTE(sbauza): Extracapabilities will be destroyed thanks to
                #  the DB FK.
                db_api.host_destroy(host_id)
            except db_ex.ClimateDBException:
                # Nothing so bad, but we need to advert the admin
                # he has to rerun
                raise manager_ex.CantRemoveHost(host=host_id,
                                                pool=self.freepool_name)
Ejemplo n.º 2
0
    def delete_computehost(self, host_id):
        host = db_api.host_get(host_id)
        if not host:
            raise manager_ex.HostNotFound(host=host_id)

        with trusts.create_ctx_from_trust(host['trust_id']):
            # TODO(sbauza):
            #  - Check if no leases having this host scheduled
            inventory = nova_inventory.NovaInventory()
            servers = inventory.get_servers_per_host(
                host['hypervisor_hostname'])
            if servers:
                raise manager_ex.HostHavingServers(
                    host=host['hypervisor_hostname'], servers=servers)

            try:
                pool = rp.ReservationPool()
                pool.remove_computehost(self.freepool_name,
                                        host['service_name'])
                # NOTE(sbauza): Extracapabilities will be destroyed thanks to
                #  the DB FK.
                db_api.host_destroy(host_id)
            except db_ex.ClimateDBException:
                # Nothing so bad, but we need to advert the admin
                # he has to rerun
                raise manager_ex.CantRemoveHost(host=host_id,
                                                pool=self.freepool_name)
Ejemplo n.º 3
0
 def delete_computehost(self, host_id):
     # TODO(sbauza):
     #  - Check if no leases having this host scheduled
     servers = self.inventory.get_servers_per_host(host_id)
     if servers:
         raise manager_exceptions.HostHavingServers(host=host_id,
                                                    servers=servers)
     host = db_api.host_get(host_id)
     if not host:
         raise manager_exceptions.HostNotFound(host=host_id)
     try:
         self.pool.remove_computehost(self.freepool_name,
                                      host['hypervisor_hostname'])
         # NOTE(sbauza): Extracapabilities will be destroyed thanks to
         #  the DB FK.
         db_api.host_destroy(host_id)
     except RuntimeError:
         # Nothing so bad, but we need to advert the admin he has to rerun
         raise manager_exceptions.CantRemoveHost(host=host_id,
                                                 pool=self.freepool_name)