def post(self, *args, **kwargs):
        """ Add a component.

        Args:
            tenant_id: the tenant id
            component_id: the id of a component istance

        Request:
            version: protocol version (1.0)
            argv: the app to be loaded
            params: the apps parameters

        Example URLs:

            POST
                /api/v1/tenants/52313ecb-9d00-4b7d-b873-b55d3d9ada26/components
            {
              "version" : 1.0,
              "argv" : "apps.pollers.linkstatspoller"
            }

        """

        try:

            if len(args) != 1:
                raise ValueError("Invalid url")

            request = tornado.escape.json_decode(self.request.body)

            if "version" not in request:
                raise ValueError("missing version element")

            if "argv" not in request:
                raise ValueError("missing argv element")

            tenant_id = UUID(args[0])

            argv = request['argv'].split(" ")
            argv.append("--tenant_id=%s" % tenant_id)

            components, components_order = _parse_args(argv)

            if not _do_launch(components, components_order):
                raise ValueError("Invalid args")

        except ValueError as ex:
            self.send_error(400, message=ex)
        except KeyError as ex:
            self.send_error(404, message=ex)

        self.set_status(201, None)
Exemple #2
0
    def post(self, *args, **kwargs):
        """ Add a component.

        Args:
            tenant_id: the tenant id
            component_id: the id of a component istance

        Request:
            version: protocol version (1.0)
            argv: the app to be loaded
            params: the apps parameters

        Example URLs:

            POST
                /api/v1/tenants/52313ecb-9d00-4b7d-b873-b55d3d9ada26/components
            {
              "version" : 1.0,
              "argv" : "apps.pollers.linkstatspoller"
            }

        """

        try:

            if len(args) != 1:
                raise ValueError("Invalid url")

            request = tornado.escape.json_decode(self.request.body)

            if "version" not in request:
                raise ValueError("missing version element")

            if "argv" not in request:
                raise ValueError("missing argv element")

            tenant_id = UUID(args[0])

            argv = request['argv'].strip().split(" ")
            argv.append("--tenant_id=%s" % tenant_id)

            components, components_order = _parse_args(argv)

            if not _do_launch(components, components_order):
                raise ValueError("Invalid args")

        except ValueError as ex:
            self.send_error(400, message=ex)
        except KeyError as ex:
            self.send_error(404, message=ex)

        self.set_status(201, None)
    def post(self, *args, **kwargs):
        """ Add a component.

        Args:
            component_id: the id of a component istance

        Request:
            version: protocol version (1.0)
            component: module name
            params: dictionary of parametes supported by the component
                    as reported by the GET request

        Example URLs:

            PUT /api/v1/components
            {
              "version" : 1.0,
              "component" : "<component>"
            }

        """

        try:

            if len(args) != 0:
                raise ValueError("Invalid url")

            request = tornado.escape.json_decode(self.request.body)

            if "version" not in request:
                raise ValueError("missing version element")

            if "argv" not in request:
                raise ValueError("missing argv element")

            argv = request['argv'].split(" ")
            components, components_order = _parse_args(argv)

            if not _do_launch(components, components_order):
                raise ValueError("Invalid args")

        except ValueError as ex:
            self.send_error(400, message=ex)
        #except KeyError as ex:
        #    self.send_error(404, message=ex)

        self.set_status(201, None)
    def post(self, *args, **kwargs):
        """ Add a component.

        Args:
            component_id: the id of a component istance

        Request:
            version: protocol version (1.0)
            component: module name
            params: dictionary of parametes supported by the component
                    as reported by the GET request

        Example URLs:

            PUT /api/v1/components
            {
              "version" : 1.0,
              "component" : "<component>"
            }

        """

        try:

            if len(args) != 0:
                raise ValueError("Invalid url")

            request = tornado.escape.json_decode(self.request.body)

            if "version" not in request:
                raise ValueError("missing version element")

            if "argv" not in request:
                raise ValueError("missing argv element")

            argv = request['argv'].split(" ")
            components, components_order = _parse_args(argv)

            if not _do_launch(components, components_order):
                raise ValueError("Invalid args")

        except ValueError as ex:
            self.send_error(400, message=ex)
        except KeyError as ex:
            self.send_error(404, message=ex)

        self.set_status(201, None)