def new_wired_connection(self): '''return the newly added wired remote connection object''' s_connection = NMSettingConnection() s_wired = NMSettingWired() s_ip4config = NMSettingIP4Config() s_ip6config = NMSettingIP6Config() s_connection.type = "802-3-ethernet" # s_connection.id = "有线连接" s_connection.id = self.generate_connection_id("wired") s_connection.autoconnect = True s_connection.uuid = uuid.uuid4() s_connection.timestamp = time.time() s_wired.duplex = "full" s_wired.clear_s390_options() s_ip4config.method = "auto" s_ip4config.clear_addresses() s_ip4config.clear_routes() s_ip4config.clear_dns() s_ip6config.method = "auto" s_ip6config.routes = [] s_ip6config.dns = [] s_ip6config.addresses = [] settings_dict = { "802-3-ethernet": s_wired.prop_dict, "connection": s_connection.prop_dict, "ipv4": s_ip4config.prop_dict, "ipv6": s_ip6config.prop_dict } from nmutils.nmconnection import NMConnection new_connection = NMConnection() for item in settings_dict.iterkeys(): new_connection.get_setting(item).prop_dict = settings_dict[item] new_connection.settings_dict = settings_dict return new_connection
def new_wired_connection(self): '''return the newly added wired remote connection object''' s_connection = NMSettingConnection() s_wired = NMSettingWired() s_ip4config = NMSettingIP4Config() s_ip6config = NMSettingIP6Config() s_connection.type = "802-3-ethernet" # s_connection.id = "有线连接" s_connection.id = self.generate_connection_id("wired") s_connection.autoconnect = True s_connection.uuid = uuid.uuid4() s_connection.timestamp = time.time() s_wired.duplex = "full" s_wired.clear_s390_options() s_ip4config.method = "auto" s_ip4config.clear_addresses() s_ip4config.clear_routes() s_ip4config.clear_dns() s_ip6config.method = "auto" s_ip6config.routes = [] s_ip6config.dns = [] s_ip6config.addresses = [] settings_dict = {"802-3-ethernet":s_wired.prop_dict, "connection":s_connection.prop_dict, "ipv4":s_ip4config.prop_dict ,"ipv6":s_ip6config.prop_dict } from nmutils.nmconnection import NMConnection new_connection = NMConnection() for item in settings_dict.iterkeys(): new_connection.get_setting(item).prop_dict = settings_dict[item] new_connection.settings_dict = settings_dict return new_connection
def new_pppoe_connection(self): s_connection = NMSettingConnection() s_wired = NMSettingWired() s_ip4config = NMSettingIP4Config() s_pppoe = NMSettingPPPOE() s_ppp = NMSettingPPP() s_connection.type = "pppoe" # s_connection.id = "DSL连接1" s_connection.id = self.generate_connection_id("dsl") s_connection.autoconnect = True s_connection.uuid = uuid.uuid4() s_connection.timestamp = time.time() s_wired.duplex = "full" s_wired.clear_s390_options() s_ip4config.method = "auto" s_ip4config.clear_addresses() s_ip4config.clear_routes() s_ip4config.clear_dns() s_pppoe.username = "" s_pppoe.password = "" settings_dict = { "802-3-ethernet": s_wired.prop_dict, "connection": s_connection.prop_dict, "ipv4": s_ip4config.prop_dict, "pppoe": s_pppoe.prop_dict, "ppp": s_ppp.prop_dict } from nmutils.nmconnection import NMConnection new_connection = NMConnection() for item in settings_dict.iterkeys(): new_connection.get_setting(item).prop_dict = settings_dict[item] new_connection.settings_dict = settings_dict return new_connection
def new_pppoe_connection(self): s_connection = NMSettingConnection() s_wired = NMSettingWired() s_ip4config = NMSettingIP4Config() s_pppoe = NMSettingPPPOE() s_ppp = NMSettingPPP() s_connection.type = "pppoe" # s_connection.id = "DSL连接1" s_connection.id = self.generate_connection_id("dsl") s_connection.autoconnect = True s_connection.uuid = uuid.uuid4() s_connection.timestamp = time.time() s_wired.duplex = "full" s_wired.clear_s390_options() s_ip4config.method = "auto" s_ip4config.clear_addresses() s_ip4config.clear_routes() s_ip4config.clear_dns() s_pppoe.username = "" s_pppoe.password = "" settings_dict = {"802-3-ethernet":s_wired.prop_dict, "connection":s_connection.prop_dict, "ipv4":s_ip4config.prop_dict, "pppoe":s_pppoe.prop_dict, "ppp":s_ppp.prop_dict } from nmutils.nmconnection import NMConnection new_connection = NMConnection() for item in settings_dict.iterkeys(): new_connection.get_setting(item).prop_dict = settings_dict[item] new_connection.settings_dict = settings_dict return new_connection