Esempio n. 1
0
    def create_or_update_relation_view(cls, name, cr_ids):
        if not cr_ids:
            return abort(400, "Node must be selected")

        existed = PreferenceRelationView.get_by(name=name,
                                                to_dict=False,
                                                first=True)
        if existed is None:
            PreferenceRelationView.create(name=name, cr_ids=json.dumps(cr_ids))

        return cls.get_relation_view()
Esempio n. 2
0
    def create_or_update_relation_view(cls, name, cr_ids):
        if not cr_ids:
            return abort(400, "Node must be selected")

        existed = PreferenceRelationView.get_by(name=name, to_dict=False, first=True)
        current_app.logger.debug(existed)
        if existed is None:
            PreferenceRelationView.create(name=name, cr_ids=json.dumps(cr_ids))

            if current_app.config.get("USE_ACL"):
                ACLManager().add_resource(name, ResourceTypeEnum.RELATION_VIEW)
                ACLManager().grant_resource_to_role(name,
                                                    RoleEnum.CMDB_READ_ALL,
                                                    ResourceTypeEnum.RELATION_VIEW,
                                                    permissions=[PermEnum.READ])

        return cls.get_relation_view()