def get_all(self, marker=None, limit=None, sort_key='id', sort_dir='asc', fields=None, detail=None): """Retrieve a list of conductors. :param marker: pagination marker for large data sets. :param limit: maximum number of resources to return in a single result. This value cannot be larger than the value of max_limit in the [api] section of the ironic configuration, or only max_limit resources will be returned. :param sort_key: column to sort results by. Default: id. :param sort_dir: direction to sort. "asc" or "desc". Default: asc. :param fields: Optional, a list with a specified set of fields of the resource to be returned. :param detail: Optional, boolean to indicate whether retrieve a list of conductors with detail. """ cdict = api.request.context.to_policy_values() policy.authorize('baremetal:conductor:get', cdict, cdict) if not api_utils.allow_expose_conductors(): raise exception.NotFound() api_utils.check_allow_specify_fields(fields) api_utils.check_allowed_fields(fields) api_utils.check_allowed_fields([sort_key]) fields = api_utils.get_request_return_fields(fields, detail, _DEFAULT_RETURN_FIELDS) return self._get_conductors_collection(marker, limit, sort_key, sort_dir, fields=fields, detail=detail)
def get_one(self, hostname, fields=None): """Retrieve information about the given conductor. :param hostname: hostname of a conductor. :param fields: Optional, a list with a specified set of fields of the resource to be returned. """ api_utils.check_policy('baremetal:conductor:get') if not api_utils.allow_expose_conductors(): raise exception.NotFound() api_utils.check_allow_specify_fields(fields) api_utils.check_allowed_fields(fields) conductor = objects.Conductor.get_by_hostname(api.request.context, hostname, online=None) return convert_with_links(conductor, fields=fields)
def convert(): v1 = V1() v1.id = "v1" v1.links = [link.Link.make_link('self', pecan.request.public_url, 'v1', '', bookmark=True), link.Link.make_link('describedby', 'https://docs.openstack.org', '/ironic/latest/contributor/', 'webapi.html', bookmark=True, type='text/html') ] v1.media_types = [MediaType('application/json', 'application/vnd.openstack.ironic.v1+json')] v1.chassis = [link.Link.make_link('self', pecan.request.public_url, 'chassis', ''), link.Link.make_link('bookmark', pecan.request.public_url, 'chassis', '', bookmark=True) ] v1.nodes = [link.Link.make_link('self', pecan.request.public_url, 'nodes', ''), link.Link.make_link('bookmark', pecan.request.public_url, 'nodes', '', bookmark=True) ] v1.ports = [link.Link.make_link('self', pecan.request.public_url, 'ports', ''), link.Link.make_link('bookmark', pecan.request.public_url, 'ports', '', bookmark=True) ] if utils.allow_portgroups(): v1.portgroups = [ link.Link.make_link('self', pecan.request.public_url, 'portgroups', ''), link.Link.make_link('bookmark', pecan.request.public_url, 'portgroups', '', bookmark=True) ] v1.drivers = [link.Link.make_link('self', pecan.request.public_url, 'drivers', ''), link.Link.make_link('bookmark', pecan.request.public_url, 'drivers', '', bookmark=True) ] if utils.allow_volume(): v1.volume = [ link.Link.make_link('self', pecan.request.public_url, 'volume', ''), link.Link.make_link('bookmark', pecan.request.public_url, 'volume', '', bookmark=True) ] if utils.allow_ramdisk_endpoints(): v1.lookup = [link.Link.make_link('self', pecan.request.public_url, 'lookup', ''), link.Link.make_link('bookmark', pecan.request.public_url, 'lookup', '', bookmark=True) ] v1.heartbeat = [link.Link.make_link('self', pecan.request.public_url, 'heartbeat', ''), link.Link.make_link('bookmark', pecan.request.public_url, 'heartbeat', '', bookmark=True) ] if utils.allow_expose_conductors(): v1.conductors = [link.Link.make_link('self', pecan.request.public_url, 'conductors', ''), link.Link.make_link('bookmark', pecan.request.public_url, 'conductors', '', bookmark=True) ] if utils.allow_allocations(): v1.allocations = [link.Link.make_link('self', pecan.request.public_url, 'allocations', ''), link.Link.make_link('bookmark', pecan.request.public_url, 'allocations', '', bookmark=True) ] if utils.allow_expose_events(): v1.events = [link.Link.make_link('self', pecan.request.public_url, 'events', ''), link.Link.make_link('bookmark', pecan.request.public_url, 'events', '', bookmark=True) ] if utils.allow_deploy_templates(): v1.deploy_templates = [ link.Link.make_link('self', pecan.request.public_url, 'deploy_templates', ''), link.Link.make_link('bookmark', pecan.request.public_url, 'deploy_templates', '', bookmark=True) ] v1.version = version.default_version() return v1
def v1(): v1 = { 'id': "v1", 'links': [ link.make_link('self', api.request.public_url, 'v1', '', bookmark=True), link.make_link('describedby', 'https://docs.openstack.org', '/ironic/latest/contributor/', 'webapi.html', bookmark=True, type='text/html') ], 'media_types': { 'base': 'application/json', 'type': 'application/vnd.openstack.ironic.v1+json' }, 'chassis': [ link.make_link('self', api.request.public_url, 'chassis', ''), link.make_link('bookmark', api.request.public_url, 'chassis', '', bookmark=True) ], 'nodes': [ link.make_link('self', api.request.public_url, 'nodes', ''), link.make_link('bookmark', api.request.public_url, 'nodes', '', bookmark=True) ], 'ports': [ link.make_link('self', api.request.public_url, 'ports', ''), link.make_link('bookmark', api.request.public_url, 'ports', '', bookmark=True) ], 'drivers': [ link.make_link('self', api.request.public_url, 'drivers', ''), link.make_link('bookmark', api.request.public_url, 'drivers', '', bookmark=True) ], 'version': version.default_version() } if utils.allow_portgroups(): v1['portgroups'] = [ link.make_link('self', api.request.public_url, 'portgroups', ''), link.make_link('bookmark', api.request.public_url, 'portgroups', '', bookmark=True) ] if utils.allow_volume(): v1['volume'] = [ link.make_link('self', api.request.public_url, 'volume', ''), link.make_link('bookmark', api.request.public_url, 'volume', '', bookmark=True) ] if utils.allow_ramdisk_endpoints(): v1['lookup'] = [ link.make_link('self', api.request.public_url, 'lookup', ''), link.make_link('bookmark', api.request.public_url, 'lookup', '', bookmark=True) ] v1['heartbeat'] = [ link.make_link('self', api.request.public_url, 'heartbeat', ''), link.make_link('bookmark', api.request.public_url, 'heartbeat', '', bookmark=True) ] if utils.allow_expose_conductors(): v1['conductors'] = [ link.make_link('self', api.request.public_url, 'conductors', ''), link.make_link('bookmark', api.request.public_url, 'conductors', '', bookmark=True) ] if utils.allow_allocations(): v1['allocations'] = [ link.make_link('self', api.request.public_url, 'allocations', ''), link.make_link('bookmark', api.request.public_url, 'allocations', '', bookmark=True) ] if utils.allow_expose_events(): v1['events'] = [ link.make_link('self', api.request.public_url, 'events', ''), link.make_link('bookmark', api.request.public_url, 'events', '', bookmark=True) ] if utils.allow_deploy_templates(): v1['deploy_templates'] = [ link.make_link('self', api.request.public_url, 'deploy_templates', ''), link.make_link('bookmark', api.request.public_url, 'deploy_templates', '', bookmark=True) ] return v1