def process_extra(self, bundle, request, **kwargs):
        patch_dict = json.loads(request.POST.items()[0][0])

        if patch_dict.has_key('delete_interface') and patch_dict.has_key('interface'):
            patch_dict.pop('delete_interface')
            sys = bundle.obj
            interface = patch_dict.pop('interface', None)
            if sys and interface:
                sys.delete_adapter(interface)

        if patch_dict.has_key('update_interface') and patch_dict.has_key('interface'):
            patch_dict.pop('update_interface')
            sys = bundle.obj
            if patch_dict in 'interface':
                sys.update_adapter(**patch_dict)

        ## Entry point for adding a new adapter by mac address via the rest API
        if patch_dict.has_key('mac'):

            enable_dns = True
            enable_private = True
            enable_public = False
            sys = bundle.obj
            range = patch_dict.pop('range', None)
            fqdn = patch_dict.pop('fqdn', None)
            ip_str = patch_dict.pop('ip_address', None)
            interface = patch_dict.pop('interface', None)
            domain = patch_dict.pop('domain', 'mozilla.com')
            from core.lib.utils import create_ipv4_intr_from_range
            mac = patch_dict['mac']
            if interface:
                interface_type, primary, alias = SystemResource.extract_nic_attrs(interface)
            else:
                interface_type, primary, alias = sys.get_next_adapter()

            if not fqdn:
                domain_parsed = ".".join(sys.hostname.split('.')[1:]) + '.' + domain
                domain_name = domain_parsed.lower()
                label = sys.hostname.split('.')[0]
            else:
                domain_parsed = ".".join(fqdn.split('.')[1:])
                domain_name = domain_parsed.lower()
                label = fqdn.split('.')[0]


            if range:
                range_start_str = range.split(',')[0]
                range_end_str = range.split(',')[1]
                s, errors = create_ipv4_intr_from_range(label, domain_name, sys, mac, range_start_str, range_end_str)
            if ip_str:
                domain = Domain.objects.filter(name=domain_parsed)[0]
                s = StaticInterface(label=label, mac=mac, domain=domain, ip_str=ip_str, ip_type='4', system=sys)
            try:
                if s:
                    s.save()
                    s.update_attrs()
                    if enable_dns and enable_public:
                        private = View.objects.get(name='private')
                        s.views.add(private)
                        s.save()

                    elif enable_dns and enable_private and not enable_public:
                        private = View.objects.get(name='private')
                        s.views.add(private)
                        s.save()

                    if interface:
                        interface_type, primary, alias = SystemResource.extract_nic_attrs(interface)
                    else:
                        interface_type, primary, alias = sys.get_next_adapter()

                    s.attrs.primary = primary
                    s.attrs.interface_type = interface_type
                    s.attrs.alias = alias
                else:
                    print 'We failed'
                    bundle.errors['error_message'] = "Unable to create adapter for unknown reason"
                    raise ValidationError(join(e.messages))
            except ValidationError, e:
                bundle.errors['error_message'] = " ".join(e.messages)
                raise ValidationError(join(e.messages))
            except Exception, e:
                print e
dataset/ETHPy150Open rtucker-mozilla/mozilla_inventory/api_v3/system_api.py/SystemResource.process_extra/swapped operands of `in`