def from_cps_val(cls, name, val): if cls.is_attr_enum(name): der_val = bytearray_utils.ba_to_value('uint32_t', val) der_val = nas_acl_utils.enum_reverse_get( der_val, cls.attr_enum_prefix(name)) elif cls.is_attr_intf(name): ifidx = bytearray_utils.ba_to_value('uint32_t', val) der_val = if_utl.ifindex_to_name(ifidx) else: der_val = bytearray_utils.ba_to_value(cls.attr_type(name), str(val)) return der_val
def from_cps_val(cls, name, val): if cls.is_attr_enum(name): der_val = bytearray_utils.ba_to_value('uint32_t', val) der_val = nas_acl_utils.enum_reverse_get( der_val, cls.attr_enum_prefix(name)) elif cls.is_attr_intf(name): ifidx = bytearray_utils.ba_to_value('uint32_t', val) der_val = if_utl.ifindex_to_name (ifidx) else: der_val = bytearray_utils.ba_to_value( cls.attr_type(name), str(val)) return der_val
def event_handler(obj): global br_list operation, br_name, untagged_if_name, tagged_if_name = None, None, None, None try: operation = obj['operation'] except: dbg_print("Exception in reading operation") try: br_name = cps_attr_data_get(obj, 'if/interfaces/interface/name') except: dbg_print("Exception in reading name") try: untagged_if_name = obj['data'].get( 'dell-if/if/interfaces/interface/untagged-ports') untagged_if_name = ba.ba_to_value('string', untagged_if_name[0]) except: dbg_print("Exception in reading untagged Port name") try: tagged_if_name = obj['data'].get( 'dell-if/if/interfaces/interface/tagged-ports') tagged_if_name = ba.ba_to_value('string', tagged_if_name[0]) except: dbg_print("Exception in reading tagged port name") if operation is not None and br_name is not None and tagged_if_name is not None: #Bridge tagged member add if operation == 'create': dbg_print("\nAdd Tagged Member") print_attrs(operation, br_name, untagged_if_name, tagged_if_name) if br_name in br_list: br_list[br_name].append(tagged_if_name) #Bridge tagged member delete if operation == 'delete': dbg_print("\nRemove Tagged Member") print_attrs(operation, br_name, untagged_if_name, tagged_if_name) if br_name in br_list: br_list[br_name].remove(tagged_if_name) elif operation is not None and br_name is not None and untagged_if_name is not None: #Bridge untagged member add if operation == 'create': dbg_print("\nAdd Unagged Member") print_attrs(operation, br_name, untagged_if_name, tagged_if_name) if br_name in br_list: br_list[br_name].append(untagged_if_name) #Bridge untagged member delete if operation == 'delete': dbg_print("\nRemove Unagged Member") print_attrs(operation, br_name, untagged_if_name, tagged_if_name) if br_name in br_list: br_list[br_name].remove(untagged_if_name) elif operation is not None or br_name is not None: #Bridge create if operation == 'create': dbg_print("\nCreate Bridge") print_attrs(operation, br_name, untagged_if_name, tagged_if_name) if br_name not in br_list: br_list[br_name] = [] #Bridge delete if operation == 'delete': dbg_print("\nDelete Bridge") print_attrs(operation, br_name, untagged_if_name, tagged_if_name) if br_name in br_list: del br_list[br_name] return
def from_data(self, key, val): t = self.find_type(key, val) return bytearray_utils.ba_to_value(t, val)