Пример #1
0
    def __init__(self, registry=None):

        if registry is None:
            self.registry = NonePersistentRegistry()
        elif isinstance(registry, Registry):
            self.registry = registry
        else:
            raise AttributeError('Registry needs to derive from abstract' \
                                 ' class \'Registry\'')

        self.registry.set_renderer('text/occi',
                                   TextOcciRendering(self.registry))
        self.registry.set_renderer('text/plain',
                                   TextPlainRendering(self.registry))
        self.registry.set_renderer('text/uri-list',
                                   TextUriListRendering(self.registry))
        self.registry.set_renderer('text/html', HTMLRendering(self.registry))

        application = tornado.web.Application([
            (r"/-/", QueryHandler, dict(registry=self.registry)),
            (r"/.well-known/org/ogf/occi/-/", QueryHandler,
             dict(registry=self.registry)),
            (r"(.*)/", CollectionHandler, dict(registry=self.registry)),
            (r"(.*)", ResourceHandler, dict(registry=self.registry)),
        ])

        self.http_server = tornado.httpserver.HTTPServer(application)
Пример #2
0
    def setUp(self):
        self.registry.set_hostname('http://127.0.0.1')
        self.app = Application([(r"(.*)/", CollectionWrapper)])

        self.registry.set_renderer('text/plain',
                                   TextPlainRendering(self.registry))
        self.registry.set_renderer('text/occi',
                                   TextOcciRendering(self.registry))
        self.registry.set_renderer('text/uri-list',
                                   TextUriListRendering(self.registry))

        self.mixin = Mixin('foo', 'mystuff')

        self.compute = Resource('/compute/1', COMPUTE, [])
        self.compute.attributes = {'foo2': 'bar2'}
        self.network = Resource('/network/1', NETWORK, [IPNETWORK])
        self.network_interface = Link('/network/interface/1', NETWORKINTERFACE,
                                      [IPNETWORKINTERFACE], self.compute,
                                      self.network)

        self.registry.set_backend(COMPUTE, SimpleComputeBackend())
        self.registry.set_backend(NETWORK, KindBackend())
        self.registry.set_backend(self.mixin, MixinBackend())
        self.registry.set_backend(START, SimpleComputeBackend())

        self.registry.add_resource(self.compute.identifier, self.compute)
        self.registry.add_resource(self.network.identifier, self.network)
        self.registry.add_resource(self.network_interface.identifier,
                                   self.network_interface)
Пример #3
0
    def setUp(self):
        self.app = Application([(r"(.*)", ResourceWrapper)])
        self.registry.set_renderer('text/plain',
                                   TextPlainRendering(self.registry))
        self.registry.set_renderer('text/occi',
                                   TextOcciRendering(self.registry))

        self.registry.set_backend(COMPUTE, SimpleComputeBackend())
        self.registry.set_backend(NETWORK, KindBackend())
        self.registry.set_backend(NETWORKINTERFACE, KindBackend())
        self.registry.set_backend(START, SimpleComputeBackend())

        self.compute = Resource('/compute/1', COMPUTE, [])
        self.network = Resource('/network/1', NETWORK, [IPNETWORK])

        self.registry.add_resource('/compute/1', self.compute)
        self.registry.add_resource('/network/1', self.network)
Пример #4
0
 def setUp(self):
     self.rendering = TextPlainRendering(self.registry)