def set_macvlan_interface(obj): data = obj.get()['data'] nas_if.log_info("data = " + str(data)) vrf = 'default' if if_name not in data: nas_if.log_err("Missing Maclvan interface name") return False name = obj.get_attr_data(if_name) if name is None: nas_if.log_err("Empty Macvlan interface name") if vrf_name in data: vrf = obj.get_attr_data(vrf_name) if physical_addr in data: mac_addr = obj.get_attr_data(physical_addr) if dn_base_ip_tool.set_if_mac(name, mac_addr, vrf) == False: nas_if.log_err("Failed to set MAC address for " + str(name)) return False if if_state in data: state = obj.get_attr_data(if_state) if dn_base_ip_tool.set_if_state(name, state, vrf) == False: nas_if.log_err("Failed to set the interface state for " + str(name)) return False return True
def handle_set_obj(obj): name = _get_name_from_obj(obj) try: mtu = obj.get_attr_data('base-interface/entry/mtu') if dn_base_ip_tool.set_if_mtu(name, mtu) == False: print "Failed to execute request...", res return False except: pass try: state = obj.get_attr_data('base-interface/entry/admin-status') if dn_base_ip_tool.set_if_state(name, state) == False: print('Failed to set the interface state.', name, state) return False except: pass try: mac = obj.get_attr_data('base-interface/entry/mac-address') if dn_base_ip_tool.set_if_mac(name, mac) == False: print('Failed to set the interface mac.', name, mac) return False except: pass return True
def set_loopback_interface(obj): name = None try: name = obj.get_attr_data('if/interfaces/interface/name') except: pass if name is None: nas_if.log_err("Failed to create interface without name") return False try: mtu = obj.get_attr_data('dell-if/if/interfaces/interface/mtu') if dn_base_ip_tool.set_if_mtu(name, mtu) == False: nas_if.log_err("Failed to execute request..." + str(res)) return False except: pass try: state = obj.get_attr_data('if/interfaces/interface/enabled') if dn_base_ip_tool.set_if_state(name, state) == False: nas_if.log_err(('Failed to set the interface state.', name, state)) return False except: pass try: mac_str = obj.get_attr_data( 'dell-if/if/interfaces/interface/phys-address') if dn_base_ip_tool.set_if_mac(name, mac_str) == False: nas_if.log_err(('Failed to set the interface mac.' + str(name) + ' , ' + str(mac_str))) return False except: pass return True