Пример #1
0
def get_host_meta():
    """
    This function services the well-known host-meta XRD data for RESTCONF
    API root discovery.
    """
    if args.verbose > 0:
        print 'get_host_meta: entry'

    xrd_obj = XRD()

    # Add a few extra elements and links before RESTCONF to help make sure
    # the parsing/XPATH is correct

    xrd_obj.elements.append(Element('hm:Host', 'testDevice'))
    xrd_obj.links.append(
        Link(rel='license', href='http://www.apache.org/licenses/LICENSE-2.0'))
    xrd_obj.links.append(Link(rel='author', href='http://bcsw.net'))

    # Add the link for RESTCONF

    xrd_obj.links.append(Link(rel='restconf', href=args.root_resource))

    # Add some extra links here as well

    xrd_obj.links.append(Link(rel='testPath', href='this/does/not/exist'))
    xrd_obj.links.append(
        Link(rel='http://oexchange.org/spec/0.8/rel/resident-target',
             type_='application/xrd+xml',
             href='http://twitter.com/oexchange.xrd'))

    # Convert to XML, pretty-print it to aid in debugging

    xrd_doc = xrd_obj.to_xml()

    return Response(xrd_doc.toprettyxml(indent=' '),
                    mimetype='application/xrd+xml')
Пример #2
0
 def __init__(self, subject=None, **kwargs):
     content_type = 'application/xrd+xml'
     super(XRDResponse, self).__init__(content_type=content_type, **kwargs)
     self._xrd = XRD()
Пример #3
0
 def __init__(self, *args, **kwargs):
     self.xrd = XRD()