Returns device driver for hosting device template with <id>.
161101
def get_hosting_device_driver(self, context, id):
        """"""
        if id is None:
            return
        try:
            return self._hosting_device_drivers[id]
        except KeyError:
            try:
                template = self._get_hosting_device_template(context, id)
                self._hosting_device_drivers[id] = importutils.import_object(
                    template['device_driver'])
            except (ImportError, TypeError, n_exc.NeutronException):
                LOG.exception("Error loading hosting device driver for "
                              "hosting device template %s", id)
            return self._hosting_device_drivers.get(id)
755554
def hostname(self):
        """"""
        try:
            return self.data.get('identity').get('host_name')
        except (KeyError, AttributeError):
            return self.device_status_simple('')
657326
def _get_device_by_key(devices, key):
    '''
    
    '''
    device_keys = [d for d in devices if d.key == key]
    if device_keys:
        return device_keys[0]
    else:
        raise salt.exceptions.VMwareObjectNotFoundError(
            'Virtual machine device with unique key '
            '{0} does not exist'.format(key))
986941
def _delete_dead_service_vm_hosting_device(self, context, hosting_device):
        
        if hosting_device is None:
            return
        plugging_drv = self.get_hosting_device_plugging_driver(
            context, hosting_device['template_id'])
        hosting_device_drv = self.get_hosting_device_driver(
            context, hosting_device['template_id'])
        if plugging_drv is None or hosting_device_drv is None:
            return
        res = plugging_drv.get_hosting_device_resources(
            context, hosting_device['id'], hosting_device['complementary_id'],
            self.l3_tenant_id(), self.mgmt_nw_id())
        if not self.svc_vm_mgr.delete_service_vm(context,
                                                 hosting_device['id']):
            LOG.error('Failed to delete hosting device %s service VM. '
                      'Will un-register it anyway.',
                      hosting_device['id'])
        plugging_drv.delete_hosting_device_resources(
            context, self.l3_tenant_id(), **res)
        with context.session.begin(subtransactions=True):
            # remove all allocations in this hosting device
            context.session.query(hd_models.SlotAllocation).filter_by(
                hosting_device_id=hosting_device['id']).delete()
            context.session.delete(hosting_device)
457779
def _delete_idle_service_vm_hosting_devices(self, context, num, template):
        
        # Delete the "youngest" hosting devices since they are more likely
        # not to have finished booting
        num_deleted = 0
        plugging_drv = self.get_hosting_device_plugging_driver(context,
                                                               template['id'])
        hosting_device_drv = self.get_hosting_device_driver(context,
                                                            template['id'])
        if plugging_drv is None or hosting_device_drv is None or num <= 0:
            return num_deleted
        query = context.session.query(hd_models.HostingDevice)
        query = query.outerjoin(
            hd_models.SlotAllocation,
            hd_models.HostingDevice.id ==
            hd_models.SlotAllocation.hosting_device_id)
        query = query.filter(hd_models.HostingDevice.template_id ==
                             template['id'],
                             hd_models.HostingDevice.admin_state_up ==
                             expr.true(),
                             hd_models.HostingDevice.tenant_bound ==
                             expr.null(),
                             hd_models.HostingDevice.auto_delete ==
                             expr.true())
        query = query.group_by(hd_models.HostingDevice.id).having(
            func.count(hd_models.SlotAllocation.logical_resource_id) == 0)
        query = query.order_by(
            hd_models.HostingDevice.created_at.desc(),
            func.count(hd_models.SlotAllocation.logical_resource_id))
        hd_candidates = query.all()
        num_possible_to_delete = min(len(hd_candidates), num)
        for i in range(num_possible_to_delete):
            res = plugging_drv.get_hosting_device_resources(
                context, hd_candidates[i]['id'],
                hd_candidates[i]['complementary_id'], self.l3_tenant_id(),
                self.mgmt_nw_id())
            if self.svc_vm_mgr.delete_service_vm(context,
                                                 hd_candidates[i]['id']):
                with context.session.begin(subtransactions=True):
                    context.session.delete(hd_candidates[i])
                plugging_drv.delete_hosting_device_resources(
                    context, self.l3_tenant_id(), **res)
                num_deleted += 1
        LOG.info('Deleted %(num)d hosting devices based on template '
                 '%(t_id)s', {'num': num_deleted, 't_id': template['id']})
        return num_deleted
965868
def add_device():
    
    req = request.get_json()
    success = False
    if 'device_id' in req and 'host' in req:
        success = add(req['device_id'], req['host'], req.get('adbkey', ''), req.get('adb_server_ip', ''), req.get('adb_server_port', 5037))
    return jsonify(success=success)
1185542
def device_id_from_name(device_name, nodes):
        
        device_id = None
        for node in nodes:
            if device_name == node['properties']['name']:
                device_id = node['id']
                break
        return device_id
378477
def get_cfg_router_ids(self, context, host, router_ids=None,
                       hosting_device_ids=None):
        """"""
        return self._l3plugin.cfg_list_router_ids_on_host(context, host,
                                                      router_ids,
                                                      hosting_device_ids)
379049
function (containerId) {
			for (var property in winble.deviceManager.deviceList) {
				if (winble.deviceManager.deviceList[property] && winble.deviceManager.deviceList[property].containerId == containerId)
					return (winble.deviceManager.deviceList[property]);
			}
			return (null);
		}
501943
def device(self, device_id, *args, **kwargs):
        
        return Device(device_id, self.corsair_sdk, self._corsair_sdk_path, *args, **kwargs)
648152
def _create_hosting_device_templates_from_config(self):
        
        hdt_dict = config.get_specific_config('cisco_hosting_device_template')
        attr_info = ciscohostingdevicemanager.RESOURCE_ATTRIBUTE_MAP[
            ciscohostingdevicemanager.DEVICE_TEMPLATES]
        adm_context = bc.context.get_admin_context()

        for hdt_uuid, kv_dict in hdt_dict.items():
            # ensure hdt_uuid is properly formatted
            hdt_uuid = config.uuidify(hdt_uuid)
            try:
                self.get_hosting_device_template(adm_context, hdt_uuid)
                is_create = False
            except ciscohostingdevicemanager.HostingDeviceTemplateNotFound:
                is_create = True
            kv_dict['id'] = hdt_uuid
            kv_dict['tenant_id'] = self.l3_tenant_id()
            config.verify_resource_dict(kv_dict, True, attr_info)
            hdt = {ciscohostingdevicemanager.DEVICE_TEMPLATE: kv_dict}
            try:
                if is_create:
                    self.create_hosting_device_template(adm_context, hdt)
                else:
                    self.update_hosting_device_template(adm_context,
                                                        kv_dict['id'], hdt)
            except n_exc.NeutronException:
                with excutils.save_and_reraise_exception():
                    LOG.error('Invalid hosting device template definition '
                              'in configuration file for template = %s',
                              hdt_uuid)
965508
def device_info(self, device_id=None):
        
        if device_id is None:
            device_id = self.device_id
        return get_device_info(self.corsair_sdk, device_id)
413165
def _get_device_template(disk, disk_info, template=None):
    '''
    

    '''
    def _require_disk_opts(*args):
        for arg in args:
            if arg not in disk_info:
                raise SaltCloudSystemExit(
                    'The disk {0} requires a {1}\
                    argument'.format(disk, arg)
                )

    _require_disk_opts('disk_type', 'size')

    size = disk_info['size']
    disk_type = disk_info['disk_type']

    if disk_type == 'clone':
        if 'image' in disk_info:
            clone_image = disk_info['image']
        else:
            clone_image = get_template_image(kwargs={'name':
                                                    template})

        clone_image_id = get_image_id(kwargs={'name': clone_image})
        temp = 'DISK=[IMAGE={0}, IMAGE_ID={1}, CLONE=YES,\
                        SIZE={2}]'.format(clone_image, clone_image_id,
                                          size)
        return temp

    if disk_type == 'volatile':
        _require_disk_opts('type')
        v_type = disk_info['type']
        temp = 'DISK=[TYPE={0}, SIZE={1}]'.format(v_type, size)

        if v_type == 'fs':
            _require_disk_opts('format')
            format = disk_info['format']
            temp = 'DISK=[TYPE={0}, SIZE={1}, FORMAT={2}]'.format(v_type,
                                                                  size, format)
        return temp
293700
def get_dead_hosting_devices_info(self):
        
        res = []
        for hd_id in self.hosting_devices_backlog:
            hd = self.hosting_devices_backlog[hd_id]['hd']
            if hd['hd_state'] == cc.HD_DEAD:
                res.append(hd['id'])
        return res
1201849
def associate_hosting_device_with_config_agent(
            self, client, config_agent_id, body):
        """"""
        return client.post((ConfigAgentHandlingHostingDevice.resource_path +
                            CFG_AGENT_HOSTING_DEVICES) % config_agent_id,
                           body=body)
1217511
def pretty_print_device(device):
    """"""
    logging.info('Device Instance ID: %s' % device['id'])
    if 'nickname' in device:
        logging.info('    Nickname: %s' % device['nickname'])
    if 'modelId' in device:
        logging.info('    Model: %s' % device['modelId'])
    logging.info('')
475766
def device(self, idx):
        

        class GpuDevice(Structure):
            pass

        c_nvmlDevice_t = POINTER(GpuDevice)

        c_index = c_uint(idx)
        device = c_nvmlDevice_t()
        _check_return(_NVML.get_function(
            "nvmlDeviceGetHandleByIndex_v2")(c_index, byref(device)))
        return NvidiaDevice(device)