Exemple #1
0
 def ir_init(self):
     """
         check and load ir module and return real ir device.
     """
     dev = self.ir_get_dev()
     if dev == None:
         try:
             sh.modprobe(IR_MODULE)
             dev = self.ir_get_dev()
             return dev
         except Exception, e:
             return None
Exemple #2
0
 def IsConfigured(self):
     if self.IsConnected() and self.IsInstalled():
         dev_path = '/dev/bus/usb/%s/%s' % (self.usb_bus_num, self.usb_dev_num)
         ret = sh.ls(dev_path,'-l')
         with sh.sudo:
             ret = sh.chmod('777',dev_path)
             ret = sh.modprobe('-r', 'ds2490')            
         self._configured = True    
     else:
         self._configured = False
     
     return self._configured
Exemple #3
0
    def IsConfigured(self):
        if self.IsConnected() and self.IsInstalled():
            dev_path = '/dev/bus/usb/%s/%s' % (self.usb_bus_num,
                                               self.usb_dev_num)
            ret = sh.ls(dev_path, '-l')
            with sh.sudo:
                ret = sh.chmod('777', dev_path)
                ret = sh.modprobe('-r', 'ds2490')
            self._configured = True
        else:
            self._configured = False

        return self._configured
def build_network(_server):
    network = _server['meta']['network']
    sort_order = ['physical', 'symlink', 'bond', 'tagged']
    networks = sorted(network.items(),
                      key=lambda x: sort_order.index(x[1]['type']))

    for name, net in networks:
        if net['type'] == 'symlink':
            continue
        elif net['type'] == 'bond':
            sh.modprobe('bonding', 'mode=4', 'miimon=100',
                        'xmit_hash_policy=1')
            sh.ifconfig(name, 'up')
            for iface in net['interfaces']:
                sh.ifenslave(name, iface)
        elif net['type'] == 'tagged':
            iface = net['interfaces'][0]
            sh.vconfig('add', iface, net['vlan'])
            sh.ifconfig(name, 'up')
        # Assign ip if required
        if net.get('ip'):
            ip = netaddr.IPNetwork('/'.join((net['ip'], net['mask'])))
            sh.ip('addr', 'add', str(ip),
                  'brd', str(ip.broadcast), 'dev', name)
def build_network(_server):
    network = _server['meta']['network']
    sort_order = ['physical', 'symlink', 'bond', 'tagged']
    networks = sorted(network.items(),
                      key=lambda x: sort_order.index(x[1]['type']))

    for name, net in networks:
        if net['type'] == 'symlink':
            continue
        elif net['type'] == 'bond':
            sh.modprobe('bonding', 'mode=4', 'miimon=100',
                        'xmit_hash_policy=1')
            sh.ifconfig(name, 'up')
            for iface in net['interfaces']:
                sh.ifenslave(name, iface)
        elif net['type'] == 'tagged':
            iface = net['interfaces'][0]
            sh.vconfig('add', iface, net['vlan'])
            sh.ifconfig(name, 'up')
        # Assign ip if required
        if net.get('ip'):
            ip = netaddr.IPNetwork('/'.join((net['ip'], net['mask'])))
            sh.ip('addr', 'add', str(ip), 'brd', str(ip.broadcast), 'dev',
                  name)