Пример #1
0
 def _run_command(self, ifaceobj, op):
     cmd_list = ifaceobj.get_attr_value(op)
     if cmd_list:
         os.environ['IFACE'] = ifaceobj.name if ifaceobj.name else ''
         os.environ['LOGICAL'] = ifaceobj.name if ifaceobj.name else ''
         os.environ['METHOD'] = ifaceobj.addr_method if ifaceobj.addr_method else ''
         os.environ['ADDRFAM'] = ','.join(ifaceobj.addr_family) if ifaceobj.addr_family else ''
         for cmd in cmd_list:
             try:
                 utils.exec_user_command(cmd)
             except Exception, e:
                 if not self.ignore_error(str(e)):
                     self.logger.warn('%s: %s %s' % (ifaceobj.name, op,
                                                     str(e).strip('\n')))
                 pass
Пример #2
0
 def link_set_alias(self, ifacename, alias):
     if not alias:
         utils.exec_user_command('echo "" > /sys/class/net/%s/ifalias' %
                                 ifacename)
     else:
         self.write_file('/sys/class/net/%s/ifalias' % ifacename, alias)