Exemplo n.º 1
0
def delete_rack(rack_id):

    rack_obj = Rack()
    rack = rack_obj.get_rack(idt=rack_id)

    error_vlans = list()
    error_envs = list()

    envs_ids = models_env.Ambiente.objects.filter(
        dcroom=rack.dcroom.id,
        grupo_l3__nome=str(rack.nome)).values_list('id', flat=True)

    log.debug("rack envs. Qtd: %s - Envs: %s" %
              (str(len(envs_ids)), str(envs_ids)))

    vlans_ids = models_vlan.Vlan.objects.filter(
        nome__icontains=rack.nome).values_list('id', flat=True)

    log.debug("rack vlan. Qtd: %s - VLans: %s" %
              (str(len(vlans_ids)), str(vlans_ids)))

    for idt in vlans_ids:
        try:
            facade_vlan_v3.delete_vlan(idt)
        except (models_vlan.VlanError, models_vlan.VlanErrorV3,
                ValidationAPIException, ObjectDoesNotExistException, Exception,
                NetworkAPIException), e:
            error_vlans.append({'vlan_id': idt, 'error': e})
Exemplo n.º 2
0
def delete_rack(rack_id):

    rack_obj = Rack()
    rack = rack_obj.get_rack(idt=rack_id)

    error_vlans = list()
    error_envs = list()

    envs_ids = models_env.Ambiente.objects.filter(dcroom=rack.dcroom.id,
                                                  grupo_l3__nome=str(rack.nome)
                                                  ).values_list('id', flat=True)

    log.debug("rack envs. Qtd: %s - Envs: %s" % (str(len(envs_ids)), str(envs_ids)))

    vlans_ids = models_vlan.Vlan.objects.filter(nome__icontains=rack.nome
                                                ).values_list('id', flat=True)

    log.debug("rack vlan. Qtd: %s - VLans: %s" % (str(len(vlans_ids)), str(vlans_ids)))

    for idt in vlans_ids:
        try:
            facade_vlan_v3.delete_vlan(idt)
        except (models_vlan.VlanError,
                models_vlan.VlanErrorV3,
                ValidationAPIException,
                ObjectDoesNotExistException,
                Exception,
                NetworkAPIException), e:
            error_vlans.append({'vlan_id': idt, 'error': e})
Exemplo n.º 3
0
    def delete(self, request, *args, **kwargs):
        """Deletes list of vlans."""

        obj_ids = kwargs['obj_ids'].split(';')
        for obj_id in obj_ids:
            facade.delete_vlan(obj_id)

        return Response({}, status=status.HTTP_200_OK)
Exemplo n.º 4
0
    def delete(self, request, *args, **kwargs):
        """Deletes list of vlans."""

        obj_ids = kwargs['obj_ids'].split(';')
        for obj_id in obj_ids:
            facade.delete_vlan(
                obj_id
            )

        return Response({}, status=status.HTTP_200_OK)
Exemplo n.º 5
0
    def delete(self, request, *args, **kwargs):
        """
        Deletes list of vlans
        """

        obj_ids = kwargs['obj_ids'].split(';')
        locks_list = create_lock(obj_ids, LOCK_VLAN)
        try:
            facade.delete_vlan(obj_ids)
        except Exception, exception:
            log.error(exception)
            raise api_exceptions.NetworkAPIException(exception)
Exemplo n.º 6
0
def delete_vlan(self, vlan_id, user_id):

    msg = {'object_type': 'vlan', 'action': 'deallocate', 'object_id': vlan_id}
    self.update_state(state='PROGRESS', meta=msg)

    vlan_obj = facade.get_vlan_by_id(vlan_id)

    try:
        facade.delete_vlan(vlan_id)

    except Exception, exception:
        msg['message'] = 'Vlan was not deallocated.'.format(vlan_obj)
        msg['reason'] = str(exception)

        raise Exception(msg)
Exemplo n.º 7
0
def delete_vlan(self, vlan_id, user_id):

    msg = {
        'object_type': 'vlan',
        'action': 'deallocate',
        'object_id': vlan_id
    }
    self.update_state(
        state='PROGRESS',
        meta=msg
    )

    vlan_obj = facade.get_vlan_by_id(vlan_id)

    try:
        facade.delete_vlan(vlan_id)

    except Exception, exception:
        msg['message'] = 'Vlan was not deallocated.'.format(vlan_obj)
        msg['reason'] = str(exception)

        raise Exception(msg)