Example #1
0
 def testListDevicesDetails(self):
     add_image('img1', id=23)
     add_device('device2', last_image_id=23, server='server1')
     self.assertEquals(data.list_devices(detail=True), {'devices': [
         udict(id=1, name='device1', fqdn='device1', inventory_id=1,
               mac_address='000000000000', imaging_server='server1',
               relay_info='relay-1:bank1:relay1', state='offline',
               comments=None, last_image=None, boot_config=u'{}',
               environment=None),
         udict(id=2, name='device2', fqdn='device2', inventory_id=2,
               mac_address='000000000000', imaging_server='server1',
               relay_info='', state='offline', comments=None,
               last_image='img1', boot_config=u'{}', environment=None),
         ]})
Example #2
0
    def _populate(self):
        fqdn = config.get('server', 'fqdn')
        for dev_dict in data.list_devices(detail=True)['devices']:
            # only emulate devices managed by this imaging sever
            if dev_dict['imaging_server'] != fqdn:
                continue

            # only emulate devices with relay info starting with 'localhost' 
            hostname, bank, relay = dev_dict['relay_info'].rsplit(":", 2)
            if not hostname.startswith('localhost:'):
                continue

            if hostname not in self.chassis:
                self.chassis[hostname] = Chassis(self, hostname)
            chassis = self.chassis[hostname]

            device = Device(self, dev_dict['name'], dev_dict)
            self.devices[dev_dict['name']] = device
            self.devices_by_fqdn[dev_dict['fqdn']] = device
            chassis.add_device(int(bank[4:]), int(relay[5:]), device)
Example #3
0
 def GET(self):
     args, _ = templeton.handlers.get_request_parms()
     return data.list_devices(detail='details' in args)
Example #4
0
 def testListDevices(self):
     self.assertEquals(data.list_devices(), { 'devices' : [ 'device1' ] })
Example #5
0
 def GET(self):
     args, _ = templeton.handlers.get_request_parms()
     if 'details' in args:
         return dict(devices=data.dump_devices())
     else:
         return data.list_devices()
Example #6
0
 def GET(self):
     args, _ = templeton.handlers.get_request_parms()
     if 'details' in args:
         return dict(devices=data.dump_devices())
     else:
         return data.list_devices()