コード例 #1
0
 def get_ip(self, log, options):
     """Implement AddressPlugin.get_ip()."""
     opts = dict_of_opts(options)
     if 'if' not in opts:
         raise AddressError('Required option if= missing, giving up.')
     if_ = opts['if']
     address = IpAddr()
     output = subprocess.getoutput('ip address show dev ' + if_)
     address.parse_ifconfig_output(output)
     return address
コード例 #2
0
ファイル: default_if.py プロジェクト: m-jung/ddupdate
 def get_ip(self, log, options):
     """
     Get default interface using ip route and address using ifconfig.
     """
     if_ = None
     for line in subprocess.getoutput('ip route').split('\n'):
         words = line.split()
         if words[0] == 'default':
             if_ = self.find_device(words)
             break
     if if_ is None:
         raise AddressError("Cannot find default interface, giving up")
     address = IpAddr()
     output = subprocess.getoutput('ip address show dev ' + if_)
     address.parse_ifconfig_output(output)
     return address