コード例 #1
0
ファイル: cluster.py プロジェクト: sebrandon1/fuel-web
 def get_options(cls):
     data = web.input(graph_type=None, dry_run="0", noop_run="0")
     return {
         'graph_type': data.graph_type or None,
         'force': True,
         'dry_run': utils.parse_bool(data.dry_run),
         'noop_run': utils.parse_bool(data.noop_run),
     }
コード例 #2
0
ファイル: cluster.py プロジェクト: zhanghui9700/fuel-web
 def get_options(cls):
     data = web.input(graph_type=None, dry_run="0", noop_run="0")
     return {
         'graph_type': data.graph_type or None,
         'force': True,
         'dry_run': utils.parse_bool(data.dry_run),
         'noop_run': utils.parse_bool(data.noop_run),
     }
コード例 #3
0
ファイル: test_utils.py プロジェクト: pod2metra/fuel-web
    def test_parse_bool(self):
        true_values = ['1', 't', 'T', 'TRUE', 'True', 'true']
        false_values = ['0', 'f', 'F', 'FALSE', 'False', 'false']

        for value in true_values:
            self.assertTrue(parse_bool(value))
        for value in false_values:
            self.assertFalse(parse_bool(value))

        self.assertRaises(ValueError, parse_bool, 'tru')
        self.assertRaises(ValueError, parse_bool, 'fals')
コード例 #4
0
ファイル: test_utils.py プロジェクト: sebrandon1/fuel-web
    def test_parse_bool(self):
        true_values = ['1', 't', 'T', 'TRUE', 'True', 'true']
        false_values = ['0', 'f', 'F', 'FALSE', 'False', 'false']

        for value in true_values:
            self.assertTrue(parse_bool(value))
        for value in false_values:
            self.assertFalse(parse_bool(value))

        self.assertRaises(ValueError, parse_bool, 'tru')
        self.assertRaises(ValueError, parse_bool, 'fals')
コード例 #5
0
    def GET(self, transaction_id):
        """:returns: Collection of DeploymentHistory records.

        :http: * 200 (OK)
               * 400 (Bad tasks in given transaction)
               * 404 (transaction not found in db, task not found in snapshot)
        """
        # get transaction data
        transaction = self.get_object_or_404(
            objects.Transaction, transaction_id)

        # process input parameters
        nodes_ids = self.get_param_as_set('nodes_ids')
        statuses = self.get_param_as_set('statuses')
        tasks_names = self.get_param_as_set('tasks_names')
        include_summary = utils.parse_bool(
            web.input(include_summary="0").include_summary)
        try:
            self.validator.validate_query(nodes_ids=nodes_ids,
                                          statuses=statuses,
                                          tasks_names=tasks_names)
        except errors.ValidationException as exc:
            raise self.http(400, exc.message)

        # fetch and serialize history
        data = self.collection.get_history(transaction=transaction,
                                           nodes_ids=nodes_ids,
                                           statuses=statuses,
                                           tasks_names=tasks_names,
                                           include_summary=include_summary)

        if self.get_requested_mime() == 'text/csv':
            return self.get_csv(data)
        else:
            return self.get_default(data)
コード例 #6
0
ファイル: cluster.py プロジェクト: sebrandon1/fuel-web
    def PATCH(self, cluster_id):
        """:returns: JSONized Cluster attributes.

        :http: * 200 (OK)
               * 400 (wrong attributes data specified)
               * 403 (attribute changing is not allowed)
               * 404 (cluster not found in db)
               * 500 (cluster has no attributes)
        """
        cluster = self.get_object_or_404(objects.Cluster, cluster_id)

        if not cluster.attributes:
            raise self.http(500, "No attributes found!")

        force = utils.parse_bool(web.input(force='0').force)

        data = self.checked_data(cluster=cluster, force=force)
        try:
            objects.Cluster.patch_attributes(cluster, data)
        except errors.NailgunException as exc:
            raise self.http(400, exc.message)

        return {
            'editable': objects.Cluster.get_editable_attributes(
                cluster, all_plugins_versions=True)
        }
コード例 #7
0
ファイル: cluster.py プロジェクト: zhanghui9700/fuel-web
    def PATCH(self, cluster_id):
        """:returns: JSONized Cluster attributes.

        :http: * 200 (OK)
               * 400 (wrong attributes data specified)
               * 403 (attribute changing is not allowed)
               * 404 (cluster not found in db)
               * 500 (cluster has no attributes)
        """
        cluster = self.get_object_or_404(objects.Cluster, cluster_id)

        if not cluster.attributes:
            raise self.http(500, "No attributes found!")

        force = utils.parse_bool(web.input(force='0').force)

        data = self.checked_data(cluster=cluster, force=force)
        try:
            objects.Cluster.patch_attributes(cluster, data)
        except errors.NailgunException as exc:
            raise self.http(400, exc.message)

        return {
            'editable':
            objects.Cluster.get_editable_attributes(cluster,
                                                    all_plugins_versions=True)
        }
コード例 #8
0
ファイル: openstack_config.py プロジェクト: ogelbukh/fuel-web
    def _convert_query_fields(cls, data):
        """Converts parameters from URL query to appropriate types

        Parameters in URL query don't care any information about data types.
        Schema validation doesn't perform any type conversion, so
        it is required to convert them before schema validation.
        """
        for field in ['cluster_id', 'node_id']:
            value = data.get(field, None)
            if value is not None:
                try:
                    data[field] = int(value)
                except ValueError:
                    raise errors.InvalidData("Invalid '{0}' value: '{1}'"
                                             .format(field, value))

        node_ids = data.get('node_ids', None)
        if node_ids is not None:
            try:
                data['node_ids'] = [int(n) for n in node_ids.split(',')]
            except ValueError:
                raise errors.InvalidData("Invalid 'node_ids' value: '{0}'"
                                         .format(node_ids))

        if 'is_active' in data:
            try:
                data['is_active'] = utils.parse_bool(data['is_active'])
            except ValueError:
                raise errors.InvalidData("Invalid 'is_active' value: '{0}'"
                                         .format(data['is_active']))
コード例 #9
0
    def GET(self, transaction_id):
        """:returns: Collection of DeploymentHistory records.

        :http: * 200 (OK)
               * 400 (Bad tasks in given transaction)
               * 404 (transaction not found in db, task not found in snapshot)
        """
        # get transaction data
        transaction = self.get_object_or_404(
            objects.Transaction, transaction_id)

        # process input parameters
        nodes_ids = self.get_param_as_set('nodes')
        statuses = self.get_param_as_set('statuses')
        tasks_names = self.get_param_as_set('tasks_names')
        include_summary = utils.parse_bool(
            web.input(include_summary="0").include_summary)
        try:
            self.validator.validate_query(nodes_ids=nodes_ids,
                                          statuses=statuses,
                                          tasks_names=tasks_names)
        except errors.ValidationException as exc:
            raise self.http(400, exc.message)

        # fetch and serialize history
        data = self.collection.get_history(transaction=transaction,
                                           nodes_ids=nodes_ids,
                                           statuses=statuses,
                                           tasks_names=tasks_names,
                                           include_summary=include_summary)

        if self.get_requested_mime() == 'text/csv':
            return self.get_csv(data)
        else:
            return self.get_default(data)
コード例 #10
0
    def GET(self):
        """Get deployment graphs list with filtering.

        :returns: JSONized object.

        :http: * 200 (OK)
               * 400 (invalid object data specified)
               * 404 (object not found in db)
        :http GET params:
               * clusters_ids = comma separated list of clusters IDs
               * plugins_ids = comma separated list of plugins IDs
               * releases_ids = comma separated list of releases IDs
               * graph_types = comma separated list of deployment graph types
               * fetch_related = bool value (default false). When you are
                 specifying clusters list this flag allow to fetch not
                 only clusters own graphs but all graphs for given clusters
                 releases and enabled plugins to view the full picture.

        """
        # process args
        clusters_ids = self.get_param_as_set("clusters_ids")
        if clusters_ids:
            clusters_ids = self.checked_data(validate_method=self.validator.validate_ids_list, data=clusters_ids)

        plugins_ids = self.get_param_as_set("plugins_ids")
        if plugins_ids:
            plugins_ids = self.checked_data(
                validate_method=self.validator.validate_ids_list, data=self.get_param_as_set("plugins_ids")
            )

        releases_ids = self.get_param_as_set("releases_ids")
        if releases_ids:
            releases_ids = self.checked_data(
                validate_method=self.validator.validate_ids_list, data=self.get_param_as_set("releases_ids")
            )

        graph_types = self.get_param_as_set("graph_types")
        fetch_related = utils.parse_bool(web.input(fetch_related="0").fetch_related)

        # apply filtering
        if clusters_ids or plugins_ids or releases_ids:
            entities = []  # all objects for which related graphs is fetched
            if clusters_ids:
                entities.extend(objects.ClusterCollection.filter_by_id_list(None, clusters_ids).all())
            if plugins_ids:
                entities.extend(objects.PluginCollection.filter_by_id_list(None, plugins_ids).all())
            if releases_ids:
                entities.extend(objects.ReleaseCollection.filter_by_id_list(None, releases_ids).all())
            result = self.collection.get_related_graphs(entities, graph_types, fetch_related)
        else:
            if graph_types:  # and no other filters
                result = self.collection.filter_by_graph_types(graph_types)
            else:
                result = self.collection.all()
        return self.collection.to_list(result)
コード例 #11
0
ファイル: orchestrator.py プロジェクト: zhanghui9700/fuel-web
    def _serialize(self, cluster, nodes):
        if objects.Release.is_lcm_supported(cluster.release):
            serialized = deployment_serializers.serialize_for_lcm(
                cluster, nodes, ignore_customized=True)
        else:
            graph = orchestrator_graph.AstuteGraph(cluster)
            serialized = deployment_serializers.serialize(
                graph, cluster, nodes, ignore_customized=True)

        return _deployment_info_in_compatible_format(
            serialized, utils.parse_bool(web.input(split='0').split))
コード例 #12
0
ファイル: orchestrator.py プロジェクト: openstack/fuel-web
    def _serialize(self, cluster, nodes):
        if objects.Release.is_lcm_supported(cluster.release):
            serialized = deployment_serializers.serialize_for_lcm(
                cluster, nodes, ignore_customized=True
            )
        else:
            graph = orchestrator_graph.AstuteGraph(cluster)
            serialized = deployment_serializers.serialize(
                graph, cluster, nodes, ignore_customized=True)

        return _deployment_info_in_compatible_format(
            serialized, utils.parse_bool(web.input(split='0').split)
        )
コード例 #13
0
ファイル: orchestrator.py プロジェクト: ekorekin/fuel-web
    def PUT(self, cluster_id):
        """:returns: JSONized Task object.

        :http: * 200 (task successfully executed)
               * 202 (task scheduled for execution)
               * 400 (data validation failed)
               * 404 (cluster or nodes not found in db)
        """
        cluster = self.get_object_or_404(objects.Cluster, cluster_id)
        force = utils.parse_bool(web.input(force='0').force)

        data = self.checked_data(self.validator.validate_deployment,
                                 cluster=cluster,
                                 graph_type=self.get_graph_type())
        return self.handle_task(cluster,
                                deployment_tasks=data,
                                graph_type=self.get_graph_type(),
                                force=force)
コード例 #14
0
ファイル: cluster.py プロジェクト: zhanghui9700/fuel-web
    def DELETE(self, obj_id):
        """:returns: {}

        :http: * 202 (cluster deletion process launched)
               * 400 (failed to execute cluster deletion process)
               * 404 (cluster not found in db)
        """
        cluster = self.get_object_or_404(self.single, obj_id)
        task_manager = ClusterDeletionManager(cluster_id=cluster.id)
        try:
            logger.debug('Trying to execute cluster deletion task')
            task = task_manager.execute(
                force=utils.parse_bool(web.input(force='0').force))
        except Exception as e:
            logger.warn('Error while execution '
                        'cluster deletion task: %s' % str(e))
            logger.warn(traceback.format_exc())
            raise self.http(400, str(e))

        raise self.http(202, objects.Task.to_json(task))
コード例 #15
0
ファイル: orchestrator.py プロジェクト: zbx/fuel-web
    def PUT(self, cluster_id):
        """:returns: JSONized Task object.

        :http: * 200 (task successfully executed)
               * 202 (task scheduled for execution)
               * 400 (data validation failed)
               * 404 (cluster or nodes not found in db)
        """
        cluster = self.get_object_or_404(objects.Cluster, cluster_id)
        force = utils.parse_bool(web.input(force='0').force)

        data = self.checked_data(
            self.validator.validate_deployment,
            cluster=cluster,
            graph_type=self.get_graph_type())
        return self.handle_task(
            cluster,
            deployment_tasks=data,
            graph_type=self.get_graph_type(),
            force=force)
コード例 #16
0
    def DELETE(self, obj_id):
        """:returns: Empty string

        :http: * 204 (object successfully marked as deleted)
               * 400 (object could not deleted)
               * 404 (object not found in db)
        """
        obj = self.get_object_or_404(
            self.single,
            obj_id
        )

        force = utils.parse_bool(web.input(force='0').force)

        try:
            self.validator.validate_delete(None, obj, force=force)
        except errors.CannotDelete as exc:
            raise self.http(400, exc.message)

        self.single.delete(obj)
        raise self.http(204)
コード例 #17
0
ファイル: cluster.py プロジェクト: sebrandon1/fuel-web
    def DELETE(self, obj_id):
        """:returns: {}

        :http: * 202 (cluster deletion process launched)
               * 400 (failed to execute cluster deletion process)
               * 404 (cluster not found in db)
        """
        cluster = self.get_object_or_404(self.single, obj_id)
        task_manager = ClusterDeletionManager(cluster_id=cluster.id)
        try:
            logger.debug('Trying to execute cluster deletion task')
            task = task_manager.execute(
                force=utils.parse_bool(web.input(force='0').force)
            )
        except Exception as e:
            logger.warn('Error while execution '
                        'cluster deletion task: %s' % str(e))
            logger.warn(traceback.format_exc())
            raise self.http(400, str(e))

        raise self.http(202, objects.Task.to_json(task))
コード例 #18
0
ファイル: orchestrator.py プロジェクト: openstack/fuel-web
 def get_force(self):
     return utils.parse_bool(web.input(force='0').force)
コード例 #19
0
ファイル: orchestrator.py プロジェクト: zhanghui9700/fuel-web
 def get_force(self):
     return utils.parse_bool(web.input(force='0').force)
コード例 #20
0
ファイル: orchestrator.py プロジェクト: zhanghui9700/fuel-web
 def get_noop_run(self):
     return utils.parse_bool(web.input(noop_run='0').noop_run)
コード例 #21
0
ファイル: orchestrator.py プロジェクト: zhanghui9700/fuel-web
 def get_dry_run(self):
     return utils.parse_bool(web.input(dry_run='0').dry_run)
コード例 #22
0
ファイル: orchestrator.py プロジェクト: zhanghui9700/fuel-web
 def get_orchestrator_info(self, cluster):
     return _deployment_info_in_compatible_format(
         objects.Cluster.get_deployment_info(cluster),
         utils.parse_bool(web.input(split='0').split))
コード例 #23
0
 def get_noop_run(self):
     return utils.parse_bool(web.input(noop_run='0').noop_run)
コード例 #24
0
 def get_dry_run(self):
     return utils.parse_bool(web.input(dry_run='0').dry_run)
コード例 #25
0
ファイル: deployment_graph.py プロジェクト: warpc/fuel-web
    def GET(self):
        """Get deployment graphs list with filtering.

        :returns: JSONized object.

        :http: * 200 (OK)
               * 400 (invalid object data specified)
               * 404 (object not found in db)
        :http GET params:
               * clusters_ids = comma separated list of clusters IDs
               * plugins_ids = comma separated list of plugins IDs
               * releases_ids = comma separated list of releases IDs
               * graph_types = comma separated list of deployment graph types
               * fetch_related = bool value (default false). When you are
                 specifying clusters list this flag allow to fetch not
                 only clusters own graphs but all graphs for given clusters
                 releases and enabled plugins to view the full picture.

        """
        # process args
        clusters_ids = self.get_param_as_set('clusters_ids')
        if clusters_ids:
            clusters_ids = self.checked_data(
                validate_method=self.validator.validate_ids_list,
                data=clusters_ids)

        plugins_ids = self.get_param_as_set('plugins_ids')
        if plugins_ids:
            plugins_ids = self.checked_data(
                validate_method=self.validator.validate_ids_list,
                data=self.get_param_as_set('plugins_ids'))

        releases_ids = self.get_param_as_set('releases_ids')
        if releases_ids:
            releases_ids = self.checked_data(
                validate_method=self.validator.validate_ids_list,
                data=self.get_param_as_set('releases_ids'))

        graph_types = self.get_param_as_set('graph_types')
        fetch_related = utils.parse_bool(
            web.input(fetch_related='0').fetch_related)

        # apply filtering
        if clusters_ids or plugins_ids or releases_ids:
            entities = []  # all objects for which related graphs is fetched
            if clusters_ids:
                entities.extend(
                    objects.ClusterCollection.filter_by_id_list(
                        None, clusters_ids).all())
            if plugins_ids:
                entities.extend(
                    objects.PluginCollection.filter_by_id_list(
                        None, plugins_ids).all())
            if releases_ids:
                entities.extend(
                    objects.ReleaseCollection.filter_by_id_list(
                        None, releases_ids).all())
            result = self.collection.get_related_graphs(
                entities, graph_types, fetch_related)
        else:
            if graph_types:  # and no other filters
                result = self.collection.filter_by_graph_types(graph_types)
            else:
                result = self.collection.all()
        return self.collection.to_list(result)
コード例 #26
0
ファイル: cluster.py プロジェクト: sebrandon1/fuel-web
 def get_options(cls):
     return {
         'force': utils.parse_bool(web.input(force='0').force)
     }
コード例 #27
0
ファイル: cluster.py プロジェクト: zhanghui9700/fuel-web
 def get_options(cls):
     return {'force': utils.parse_bool(web.input(force='0').force)}
コード例 #28
0
ファイル: orchestrator.py プロジェクト: openstack/fuel-web
 def get_orchestrator_info(self, cluster):
     return _deployment_info_in_compatible_format(
         objects.Cluster.get_deployment_info(cluster),
         utils.parse_bool(web.input(split='0').split)
     )