Ejemplo n.º 1
0
    def _setup_routes(self, mapper, ext_mgr, init_only):
        if init_only is None or 'versions' in init_only:
            self.resources['versions'] = versions.create_resource()
            mapper.connect("versions", "/",
                        controller=self.resources['versions'],
                        action='show',
                        conditions={"method": ['GET']})

        mapper.redirect("", "/")

        if init_only is None or 'consoles' in init_only:
            self.resources['consoles'] = consoles.create_resource()
            mapper.resource("console", "consoles",
                        controller=self.resources['consoles'],
                        parent_resource=dict(member_name='server',
                        collection_name='servers'))

        if init_only is None or 'consoles' in init_only or \
                'servers' in init_only or 'ips' in init_only:
            self.resources['servers'] = servers.create_resource(ext_mgr)
            mapper.resource("server", "servers",
                            controller=self.resources['servers'],
                            collection={'detail': 'GET'},
                            member={'action': 'POST'})

        if init_only is None or 'ips' in init_only:
            self.resources['ips'] = ips.create_resource()
            mapper.resource("ip", "ips", controller=self.resources['ips'],
                            parent_resource=dict(member_name='server',
                                                 collection_name='servers'))

        if init_only is None or 'images' in init_only:
            self.resources['images'] = images.create_resource()
            mapper.resource("image", "images",
                            controller=self.resources['images'],
                            collection={'detail': 'GET'})

        if init_only is None or 'limits' in init_only:
            self.resources['limits'] = limits.create_resource()
            mapper.resource("limit", "limits",
                            controller=self.resources['limits'])

        if init_only is None or 'flavors' in init_only:
            self.resources['flavors'] = flavors.create_resource()
            mapper.resource("flavor", "flavors",
                            controller=self.resources['flavors'],
                            collection={'detail': 'GET'},
                            member={'action': 'POST'})

        if init_only is None or 'image_metadata' in init_only:
            self.resources['image_metadata'] = image_metadata.create_resource()
            image_metadata_controller = self.resources['image_metadata']

            mapper.resource("image_meta", "metadata",
                            controller=image_metadata_controller,
                            parent_resource=dict(member_name='image',
                            collection_name='images'))

            mapper.connect("metadata",
                           "/{project_id}/images/{image_id}/metadata",
                           controller=image_metadata_controller,
                           action='update_all',
                           conditions={"method": ['PUT']})

        if init_only is None or 'server_metadata' in init_only:
            self.resources['server_metadata'] = \
                server_metadata.create_resource()
            server_metadata_controller = self.resources['server_metadata']

            mapper.resource("server_meta", "metadata",
                            controller=server_metadata_controller,
                            parent_resource=dict(member_name='server',
                            collection_name='servers'))

            mapper.connect("metadata",
                           "/{project_id}/servers/{server_id}/metadata",
                           controller=server_metadata_controller,
                           action='update_all',
                           conditions={"method": ['PUT']})
Ejemplo n.º 2
0
    def _setup_routes(self, mapper, ext_mgr, init_only):
        if init_only is None or 'versions' in init_only:
            self.resources['versions'] = versions.create_resource()
            mapper.connect("versions",
                           "/",
                           controller=self.resources['versions'],
                           action='show',
                           conditions={"method": ['GET']})

        mapper.redirect("", "/")

        if init_only is None or 'consoles' in init_only:
            self.resources['consoles'] = consoles.create_resource()
            mapper.resource("console",
                            "consoles",
                            controller=self.resources['consoles'],
                            parent_resource=dict(member_name='server',
                                                 collection_name='servers'))

        if init_only is None or 'consoles' in init_only or \
                'servers' in init_only or 'ips' in init_only:
            self.resources['servers'] = servers.create_resource(ext_mgr)
            mapper.resource("server",
                            "servers",
                            controller=self.resources['servers'],
                            collection={
                                'detail': 'GET',
                                'stratolist': 'GET'
                            },
                            member={'action': 'POST'})

        if init_only is None or 'ips' in init_only:
            self.resources['ips'] = ips.create_resource()
            mapper.resource("ip",
                            "ips",
                            controller=self.resources['ips'],
                            parent_resource=dict(member_name='server',
                                                 collection_name='servers'))

        if init_only is None or 'images' in init_only:
            self.resources['images'] = images.create_resource()
            mapper.resource("image",
                            "images",
                            controller=self.resources['images'],
                            collection={'detail': 'GET'})

        if init_only is None or 'limits' in init_only:
            self.resources['limits'] = limits.create_resource()
            mapper.resource("limit",
                            "limits",
                            controller=self.resources['limits'])

        if init_only is None or 'flavors' in init_only:
            self.resources['flavors'] = flavors.create_resource()
            mapper.resource("flavor",
                            "flavors",
                            controller=self.resources['flavors'],
                            collection={'detail': 'GET'},
                            member={'action': 'POST'})

        if init_only is None or 'image_metadata' in init_only:
            self.resources['image_metadata'] = image_metadata.create_resource()
            image_metadata_controller = self.resources['image_metadata']

            mapper.resource("image_meta",
                            "metadata",
                            controller=image_metadata_controller,
                            parent_resource=dict(member_name='image',
                                                 collection_name='images'))

            mapper.connect("metadata",
                           "/{project_id}/images/{image_id}/metadata",
                           controller=image_metadata_controller,
                           action='update_all',
                           conditions={"method": ['PUT']})

        if init_only is None or 'server_metadata' in init_only:
            self.resources['server_metadata'] = \
                server_metadata.create_resource()
            server_metadata_controller = self.resources['server_metadata']

            mapper.resource("server_meta",
                            "metadata",
                            controller=server_metadata_controller,
                            parent_resource=dict(member_name='server',
                                                 collection_name='servers'))

            mapper.connect("metadata",
                           "/{project_id}/servers/{server_id}/metadata",
                           controller=server_metadata_controller,
                           action='update_all',
                           conditions={"method": ['PUT']})
Ejemplo n.º 3
0
    def _setup_routes(self, mapper):
        self.resources['versions'] = versions.create_resource()
        mapper.connect("versions", "/",
                    controller=self.resources['versions'],
                    action='show')

        mapper.redirect("", "/")

        self.resources['consoles'] = consoles.create_resource()
        mapper.resource("console", "consoles",
                    controller=self.resources['consoles'],
                    parent_resource=dict(member_name='server',
                    collection_name='servers'))

        self.resources['servers'] = servers.create_resource()
        mapper.resource("server", "servers",
                        controller=self.resources['servers'],
                        collection={'detail': 'GET'},
                        member={'action': 'POST'})

        self.resources['ips'] = ips.create_resource()
        mapper.resource("ip", "ips", controller=self.resources['ips'],
                        parent_resource=dict(member_name='server',
                                             collection_name='servers'))

        self.resources['images'] = images.create_resource()
        mapper.resource("image", "images",
                        controller=self.resources['images'],
                        collection={'detail': 'GET'})

        self.resources['limits'] = limits.create_resource()
        mapper.resource("limit", "limits",
                        controller=self.resources['limits'])

        self.resources['flavors'] = flavors.create_resource()
        mapper.resource("flavor", "flavors",
                        controller=self.resources['flavors'],
                        collection={'detail': 'GET'})

        self.resources['image_metadata'] = image_metadata.create_resource()
        image_metadata_controller = self.resources['image_metadata']

        mapper.resource("image_meta", "metadata",
                        controller=image_metadata_controller,
                        parent_resource=dict(member_name='image',
                        collection_name='images'))

        mapper.connect("metadata", "/{project_id}/images/{image_id}/metadata",
                       controller=image_metadata_controller,
                       action='update_all',
                       conditions={"method": ['PUT']})

        self.resources['server_metadata'] = server_metadata.create_resource()
        server_metadata_controller = self.resources['server_metadata']

        mapper.resource("server_meta", "metadata",
                        controller=server_metadata_controller,
                        parent_resource=dict(member_name='server',
                        collection_name='servers'))

        mapper.connect("metadata",
                       "/{project_id}/servers/{server_id}/metadata",
                       controller=server_metadata_controller,
                       action='update_all',
                       conditions={"method": ['PUT']})

	self.resources['networks'] = networks.create_resource()
	mapper.resource("network", "networks",
                        controller=self.resources['networks'],
                        collection={'detail': 'GET'})
Ejemplo n.º 4
0
    def _setup_routes(self, mapper, ext_mgr, init_only):
        if init_only is None or "versions" in init_only:
            self.resources["versions"] = versions.create_resource()
            mapper.connect(
                "versions", "/", controller=self.resources["versions"], action="show", conditions={"method": ["GET"]}
            )

        mapper.redirect("", "/")

        if init_only is None or "consoles" in init_only:
            self.resources["consoles"] = consoles.create_resource()
            mapper.resource(
                "console",
                "consoles",
                controller=self.resources["consoles"],
                parent_resource=dict(member_name="server", collection_name="servers"),
            )

        if init_only is None or "consoles" in init_only or "servers" in init_only or "ips" in init_only:
            self.resources["servers"] = servers.create_resource(ext_mgr)
            mapper.resource(
                "server",
                "servers",
                controller=self.resources["servers"],
                collection={"detail": "GET"},
                member={"action": "POST"},
            )

        if init_only is None or "ips" in init_only:
            self.resources["ips"] = ips.create_resource()
            mapper.resource(
                "ip",
                "ips",
                controller=self.resources["ips"],
                parent_resource=dict(member_name="server", collection_name="servers"),
            )

        if init_only is None or "images" in init_only:
            self.resources["images"] = images.create_resource()
            mapper.resource("image", "images", controller=self.resources["images"], collection={"detail": "GET"})

        if init_only is None or "limits" in init_only:
            self.resources["limits"] = limits.create_resource()
            mapper.resource("limit", "limits", controller=self.resources["limits"])

        if init_only is None or "flavors" in init_only:
            self.resources["flavors"] = flavors.create_resource()
            mapper.resource(
                "flavor",
                "flavors",
                controller=self.resources["flavors"],
                collection={"detail": "GET"},
                member={"action": "POST"},
            )

        if init_only is None or "image_metadata" in init_only:
            self.resources["image_metadata"] = image_metadata.create_resource()
            image_metadata_controller = self.resources["image_metadata"]

            mapper.resource(
                "image_meta",
                "metadata",
                controller=image_metadata_controller,
                parent_resource=dict(member_name="image", collection_name="images"),
            )

            mapper.connect(
                "metadata",
                "/{project_id}/images/{image_id}/metadata",
                controller=image_metadata_controller,
                action="update_all",
                conditions={"method": ["PUT"]},
            )

        if init_only is None or "server_metadata" in init_only:
            self.resources["server_metadata"] = server_metadata.create_resource()
            server_metadata_controller = self.resources["server_metadata"]

            mapper.resource(
                "server_meta",
                "metadata",
                controller=server_metadata_controller,
                parent_resource=dict(member_name="server", collection_name="servers"),
            )

            mapper.connect(
                "metadata",
                "/{project_id}/servers/{server_id}/metadata",
                controller=server_metadata_controller,
                action="update_all",
                conditions={"method": ["PUT"]},
            )
Ejemplo n.º 5
0
    def _setup_routes(self, mapper, ext_mgr, init_only):

        if init_only is None or 'versions' in init_only:
            self.resources['versions'] = versions.create_resource()
            mapper.connect("versions", "/",
                        controller=self.resources['versions'],
                        action='show',
                        conditions={"method": ['GET']})

        mapper.redirect("", "/")

        if init_only is None or 'consoles' in init_only:
            self.resources['consoles'] = consoles.create_resource()
            mapper.resource("console", "consoles",
                        controller=self.resources['consoles'],
                        parent_resource=dict(member_name='server',
                        collection_name='servers'))

        if init_only is None or 'consoles' in init_only or \
                'servers' in init_only or 'ips' in init_only:
            self.resources['servers'] = servers.create_resource(ext_mgr)
            mapper.resource("server", "servers",
                            controller=self.resources['servers'],
                            collection={'detail': 'GET'},
                            member={'action': 'POST'})

        if init_only is None or 'domains' in init_only:
            self.resources['domains'] = domains.create_resource(ext_mgr)

            domains_controller = self.resources['domains']

            # kwargs['path_prefix'] = 'domains/{domain_id}/%s/:%s_id' \
            #                        % (p_collection, p_member)

            # map.extend(routes, "/domains")

            # mapper.resource("domains", "servers",
            #    controller=self.resources['domains'],
                #collection={'detail': 'GET'},
            #    path_prefix="/domains",
            #    member={'action': 'POST'})

            # mapper.resource("action", "domains",
            #                controller=domains_controller,
            #                parent_resource=dict(member_name='domain',
            #                                      collection_name='domains'),
            #               /servers/:server_id",
                            #member={'action': 'POST'})
            # mapper.resource("domain", "servers",
            #    controller=domains_controller,
            #    parent_resource=dict(member_name='domain',
            #    collection_name='domains'))

            #===========================================================
            # mapper.connect("domains",
            #    "/domains/{domain_id}/servers/{server_id}/action",
            #    controller=domains_controller,
            #    action='default',
            #    conditions={"method": ['POST']})
            #===========================================================

            mapper.connect("domains",
               "/domains/{domain_id}/servers/{server_id}",
               controller=domains_controller,
               action='delete',
               conditions={"method": ['DELETE']})

            mapper.connect("domains",
                           "/domains/{domain_id}/servers",
                           controller=domains_controller,
                           action='index',
                           conditions={"method": ['GET']})

            mapper.connect("domains",
               "/domains/{domain_id}/servers/{server_id}",
               controller=domains_controller,
               action='show',
               conditions={"method": ['GET']})

            mapper.connect("domains",
               "/domains/{domain_id}/servers/{id}/action",
               controller=domains_controller,
               action='action',
               conditions={"method": ['POST']})

            # mapper.resource("server", "servers",
            #                # controller=domains_controller,
            #                path_prefix='/domains/{domain_id}',
            #                member={'action': 'POST'})

        if init_only is None or 'ips' in init_only:
            self.resources['ips'] = ips.create_resource()
            mapper.resource("ip", "ips", controller=self.resources['ips'],
                            parent_resource=dict(member_name='server',
                                                 collection_name='servers'))

        if init_only is None or 'images' in init_only:
            self.resources['images'] = images.create_resource()
            mapper.resource("image", "images",
                            controller=self.resources['images'],
                            collection={'detail': 'GET'})

        if init_only is None or 'limits' in init_only:
            self.resources['limits'] = limits.create_resource()
            mapper.resource("limit", "limits",
                            controller=self.resources['limits'])

        if init_only is None or 'flavors' in init_only:
            self.resources['flavors'] = flavors.create_resource()
            mapper.resource("flavor", "flavors",
                            controller=self.resources['flavors'],
                            collection={'detail': 'GET'},
                            member={'action': 'POST'})

        if init_only is None or 'image_metadata' in init_only:
            self.resources['image_metadata'] = image_metadata.create_resource()
            image_metadata_controller = self.resources['image_metadata']

            mapper.resource("image_meta", "metadata",
                            controller=image_metadata_controller,
                            parent_resource=dict(member_name='image',
                            collection_name='images'))

            mapper.connect("metadata",
                           "/{project_id}/images/{image_id}/metadata",
                           controller=image_metadata_controller,
                           action='update_all',
                           conditions={"method": ['PUT']})

        if init_only is None or 'server_metadata' in init_only:
            self.resources['server_metadata'] = \
                server_metadata.create_resource()
            server_metadata_controller = self.resources['server_metadata']

            mapper.resource("server_meta", "metadata",
                            controller=server_metadata_controller,
                            parent_resource=dict(member_name='server',
                            collection_name='servers'))

            mapper.connect("metadata",
                           "/{project_id}/servers/{server_id}/metadata",
                           controller=server_metadata_controller,
                           action='update_all',
                           conditions={"method": ['PUT']})