Ejemplo n.º 1
0
# Bootstrap the Sentry environment
from sentry.utils.runner import configure

configure()

import os

from sentry import options
options.set('system.url-prefix', 'http://*****:*****@localhost')
options.set('auth.allow-registration', True)
options.set('beacon.anonymous', True)

from django.conf import settings

from sentry.models import (Team, Project, ProjectKey, User, Organization,
                           OrganizationMember, OrganizationMemberTeam)

organization = Organization.objects.first()
if not organization:
    organization = Organization()
    organization.name = 'Sentry'
    organization.save()

team = Team.objects.first()
if not team:
    team = Team()
    team.name = 'Sentry'
    team.organization = organization
    team.save()
Ejemplo n.º 2
0
__author__ = 'Diep Pham'
__maintainer__ = 'Diep Pham'
__email__ = '*****@*****.**'

import logging

import yaml

import pysc

import re
from operator import or_

# Bootstrap the Sentry environment
from sentry.utils.runner import configure
configure()

from sentry.models import (
    ApiKey,
    Organization,
    OrganizationMember,
    Project,
    ProjectKey,
    Team,
    User,
)

logger = logging.getLogger(__name__)


class SentryMonitoring(pysc.Application):
Ejemplo n.º 3
0
import json
import click
import urlparse
import logging

from datetime import datetime
from subprocess import Popen, PIPE
from contextlib import contextmanager

HERE = os.path.abspath(os.path.dirname(__file__))
SENTRY_CONFIG = os.path.join(HERE, 'sentry.conf.py')

# No sentry or django imports before that point
from sentry.utils import runner

runner.configure(config_path=SENTRY_CONFIG, skip_backend_validation=True)
from django.conf import settings

# Fair game from here
from django.core.management import call_command

from sentry.utils.apidocs import Runner, MockUtils, iter_scenarios, \
    iter_endpoints, get_sections

OUTPUT_PATH = os.path.join(HERE, 'cache')
HOST = urlparse.urlparse(settings.SENTRY_URL_PREFIX).netloc

# We don't care about you, go away
_logger = logging.getLogger('sentry.events')
_logger.disabled = True
Ejemplo n.º 4
0
import zlib
import json
import click
import urlparse
import logging

from datetime import datetime
from subprocess import Popen, PIPE
from contextlib import contextmanager

HERE = os.path.abspath(os.path.dirname(__file__))
SENTRY_CONFIG = os.path.join(HERE, 'sentry.conf.py')

# No sentry or django imports before that point
from sentry.utils import runner
runner.configure(config_path=SENTRY_CONFIG, skip_backend_validation=True)
from django.conf import settings

# Fair game from here
from django.core.management import call_command

from sentry.utils.apidocs import Runner, MockUtils, iter_scenarios, \
    iter_endpoints, get_sections


OUTPUT_PATH = os.path.join(HERE, 'cache')
HOST = urlparse.urlparse(settings.SENTRY_URL_PREFIX).netloc


# We don't care about you, go away
_logger = logging.getLogger('sentry.events')
Ejemplo n.º 5
0
def main():
    parser = build_parser()
    options, _args = parser.parse_args()

    os.environ['SENTRY_CONF'] = options.sentry_path

    from sentry.utils.runner import configure
    configure()

    from django.conf import settings
    # Add in the sentry object models
    from sentry.models import Organization, Project, ProjectKey, Team, User

    admin_email = settings.SENTRY_OPTIONS['system.admin-email']

    if not options.project:
        parser.error("Project name required")
    if not options.platform:
        parser.error("Platform is required")

    try:
        o = Organization.objects.get(name=options.org)
    except Organization.DoesNotExist:
        print "Organization not found: %s" % options.org
        sys.exit(1)

    try:
        u = User.objects.get(email=admin_email)
    except User.DoesNotExist:
        print "Admin user not found: %s" % admin_email
        sys.exit(1)

    # try to load the requested team
    try:
        t = Team.objects.get(name=options.team, organization_id=o.id)
    except Team.DoesNotExist:
        # this team does not yet exist.    Create it.
        t = Team()
        t.name = options.team
        t.organization_id = o.id
        t.owner_id = u.id
        t.save()
        # reload the object
        t = Team.objects.get(name=options.team, organization_id=o.id)

    try:
        p = Project.objects.get(name=options.project, team_id=t.id)
    except:
        # the project doesn't exist.    Create it!
        p = Project()
        # ensure all project names are in lowercase
        p.name = options.project.lower()
        p.team_id = t.id
        p.organization_id = o.id
        p.platform = options.platform

        try:
            p.save()
        except:
            print "Project save failed for %s" % (options.project)
            sys.exit(1)

    # create a static file containing this application's DSN
    k = ProjectKey.objects.get(project_id=p.id).get_dsn()
    prefix = quote(o.name.lower() + "-" + t.name.lower() + "-")
    dsn_path = "%s/dsn/%s%s" % (options.sentry_path, prefix, p.name)
    dsn = open(dsn_path, 'w')
    dsn.write(k)
    dsn.close()

    if options.verbose:
        print "Project %s created in team %s." % (options.project, t.name)
Ejemplo n.º 6
0
# Bootstrap the Sentry environment
from sentry.utils.runner import configure
configure("/home/sentry/sentry.conf.py")

# Do something crazy
from sentry.models import Team, Project, ProjectKey, User, Organization

user = User.objects.get(pk=1)

organization = Organization()
organization.name = 'AgoraVoting'
organization.owner = user
organization.save()

team = Team()
team.name = 'AgoraVoting'
team.organization = organization
team.save()

project = Project()
project.team = team
project.name = 'AuthApi'
project.organization = organization
project.save()

key = ProjectKey.objects.filter(project=project)[0]
dsn = key.get_dsn()

# writting the sentry configuration to deploy.conf
authapi_conf = '''
# sentry
Ejemplo n.º 7
0
import sys

# Bootstrap the Sentry environment
from sentry.utils.runner import configure
configure(sys.argv[1])

# Do something crazy
from sentry.models import Team, Project, ProjectKey, User, Organization

user = User()
user.username = '******'
if User.objects.filter(username=user.username).exists():
    print("User admin already exists")
else:
    user.email = 'admin@localhost'
    user.is_superuser = True
    user.set_password('admin')
    user.save()
Ejemplo n.º 8
0
Create organization/team/user for sentry monitoring
"""

__author__ = 'Diep Pham'
__maintainer__ = 'Diep Pham'
__email__ = '*****@*****.**'

import logging

import yaml

import pysc

# Bootstrap the Sentry environment
from sentry.utils.runner import configure
configure('/etc/sentry.conf.py')

from sentry.models import Team, Project, ProjectKey, User, Organization

logger = logging.getLogger(__name__)


class SentryMonitoring(pysc.Application):
    def get_argument_parser(self):
        argp = super(SentryMonitoring, self).get_argument_parser()
        argp.add_argument(
            "--dsn-file", help="path to write monitoring sentry dsn",
            required=True)
        argp.add_argument(
            "--test", help="run in test mode", action="store_true")