예제 #1
0
def convert_with_links(rpc_portgroup, fields=None, sanitize=True):
    """Add links to the portgroup."""
    portgroup = api_utils.object_to_dict(
        rpc_portgroup,
        link_resource='portgroups',
        fields=('address', 'extra', 'internal_info', 'mode', 'name',
                'properties', 'standalone_ports_supported'))
    api_utils.populate_node_uuid(rpc_portgroup, portgroup)
    url = api.request.public_url
    portgroup['ports'] = [
        link.make_link('self', url, 'portgroups',
                       rpc_portgroup.uuid + "/ports"),
        link.make_link('bookmark',
                       url,
                       'portgroups',
                       rpc_portgroup.uuid + "/ports",
                       bookmark=True)
    ]

    if fields is not None:
        api_utils.check_for_invalid_fields(fields, portgroup)

    if not sanitize:
        return portgroup

    api_utils.sanitize_dict(portgroup, fields)

    return portgroup
예제 #2
0
파일: port.py 프로젝트: namnx228/ironic
def port_sanitize(port, fields=None):
    """Removes sensitive and unrequested data.

    Will only keep the fields specified in the ``fields`` parameter.

    :param fields:
        list of fields to preserve, or ``None`` to preserve them all
    :type fields: list of str
    """
    hide_fields_in_newer_versions(port)
    api_utils.sanitize_dict(port, fields)
예제 #3
0
def template_sanitize(template, fields):
    """Removes sensitive and unrequested data.

    Will only keep the fields specified in the ``fields`` parameter.

    :param fields:
        list of fields to preserve, or ``None`` to preserve them all
    :type fields: list of str
    """
    api_utils.sanitize_dict(template, fields)
    if template.get('steps'):
        for step in template['steps']:
            step_sanitize(step)
예제 #4
0
def convert_with_links(rpc_conductor, fields=None, sanitize=True):
    conductor = api_utils.object_to_dict(
        rpc_conductor,
        include_uuid=False,
        fields=('hostname', 'conductor_group', 'drivers'),
        link_resource='conductors',
        link_resource_args=rpc_conductor.hostname)
    conductor['alive'] = not timeutils.is_older_than(
        rpc_conductor.updated_at, CONF.conductor.heartbeat_timeout)
    if fields is not None:
        api_utils.check_for_invalid_fields(fields, conductor)

    if sanitize:
        api_utils.sanitize_dict(conductor, fields)
    return conductor
예제 #5
0
def convert_with_links(rpc_connector, fields=None, sanitize=True):
    connector = api_utils.object_to_dict(rpc_connector,
                                         link_resource='volume/connectors',
                                         fields=('connector_id', 'extra',
                                                 'type'))
    api_utils.populate_node_uuid(rpc_connector, connector)

    if fields is not None:
        api_utils.check_for_invalid_fields(fields, connector)

    if not sanitize:
        return connector

    api_utils.sanitize_dict(connector, fields)

    return connector
예제 #6
0
def convert_with_links(rpc_target, fields=None, sanitize=True):
    target = api_utils.object_to_dict(rpc_target,
                                      link_resource='volume/targets',
                                      fields=('boot_index', 'extra',
                                              'properties', 'volume_id',
                                              'volume_type'))
    api_utils.populate_node_uuid(rpc_target, target)

    if fields is not None:
        api_utils.check_for_invalid_fields(fields, target)

    if not sanitize:
        return target

    api_utils.sanitize_dict(target, fields)

    return target
예제 #7
0
파일: chassis.py 프로젝트: namnx228/ironic
def convert_with_links(rpc_chassis, fields=None, sanitize=True):
    chassis = api_utils.object_to_dict(rpc_chassis,
                                       fields=('description', 'extra'),
                                       link_resource='chassis')

    url = api.request.public_url
    chassis['nodes'] = [
        link.make_link('self', url, 'chassis', rpc_chassis.uuid + "/nodes"),
        link.make_link('bookmark',
                       url,
                       'chassis',
                       rpc_chassis.uuid + "/nodes",
                       bookmark=True)
    ],

    if fields is not None:
        api_utils.check_for_invalid_fields(fields, chassis)

    if sanitize:
        api_utils.sanitize_dict(chassis, fields)
    return chassis
예제 #8
0
def allocation_sanitize(allocation, fields):
    hide_fields_in_newer_versions(allocation)
    api_utils.sanitize_dict(allocation, fields)