Ejemplo n.º 1
0
def setup_dev():
    from internal import server
    from internal import user
    from internal.exceptions import ServerAlreadyExistsError
    from internal.exceptions import UserAlreadyExistsError

    for name, url in DEV_SERVERS.iteritems():
        try:
            server.create_server(name, url)
        except ServerAlreadyExistsError:
            pass

    for email, data in DEV_USERS.iteritems():
        try:
            user.create_user(data[0], data[1], email, data[2], data[3])
        except UserAlreadyExistsError:
            pass
Ejemplo n.º 2
0
def setup_dev():
    from internal import server as internal_server
    from internal import user as internal_user
    from internal import public_key as internal_public_key
    from internal.exceptions import ServerAlreadyExistsError
    from internal.exceptions import UserAlreadyExistsError

    system_user = internal_user.create_user(None, "Vinz", "System",
                                            "*****@*****.**", "vinz", "vinz")

    servers = []
    for name, url in DEV_SERVERS.iteritems():
        try:
            server = internal_server.create_server(system_user, name, url)
            servers.append(server)
            print "Created server %s: %s" % (name, url)
        except ServerAlreadyExistsError:
            print "Server %s already exists" % name
            server = internal_server.get_server_by_hostname(url)
            servers.append(server)

    for email, data in DEV_USERS.iteritems():
        user = None
        try:
            user = internal_user.create_user(system_user, data[0], data[1],
                                             email, data[2], data[3])
            print "Created user %s: %s" % (data[2], email)
        except UserAlreadyExistsError:
            user = internal_user.get_user_by_email(email)
            print "User %s already exists" % (data[2])

        if user:
            for server in servers:
                print "Adding %s to %s" % (user.username, server.hostname)
                internal_server.add_user_to_server(system_user, server,
                                                   user.id)

            if not user.key_list:
                print "Adding public key for %s" % user.username
                key = internal_public_key.create_public_key(
                    user, user, 'test key', VINZ_PUBLIC_KEY)
Ejemplo n.º 3
0
def setup_dev():
    from internal import server as internal_server
    from internal import user as internal_user
    from internal import public_key as internal_public_key
    from internal.exceptions import ServerAlreadyExistsError
    from internal.exceptions import UserAlreadyExistsError

    system_user = internal_user.create_user(None, "Vinz", "System", "*****@*****.**",
                                            "vinz", "vinz")

    servers = []
    for name, url in DEV_SERVERS.iteritems():
        try:
            server = internal_server.create_server(system_user, name, url)
            servers.append(server)
            print "Created server %s: %s" % (name, url)
        except ServerAlreadyExistsError:
            print "Server %s already exists" % name
            server = internal_server.get_server_by_hostname(url)
            servers.append(server)

    for email, data in DEV_USERS.iteritems():
        user = None
        try:
            user = internal_user.create_user(system_user, data[0], data[1], email, data[2], data[3])
            print "Created user %s: %s" % (data[2], email)
        except UserAlreadyExistsError:
            user = internal_user.get_user_by_email(email)
            print "User %s already exists" % (data[2])

        if user:
            for server in servers:
                print "Adding %s to %s" % (user.username, server.hostname)
                internal_server.add_user_to_server(system_user, server, user.id)

            if not user.key_list:
                print "Adding public key for %s" % user.username
                key = internal_public_key.create_public_key(user, user, 'test key', VINZ_PUBLIC_KEY)
Ejemplo n.º 4
0
 def post(self):
     args = user_parser.parse_args()
     user = user_api.create_user(self.user, **args)
     return marshal(user, user_fields), HTTP_STATUS.CREATED
Ejemplo n.º 5
0
 def post(self):
     args = user_parser.parse_args()
     user = user_api.create_user(self.user, **args)
     return marshal(user, user_fields), HTTP_STATUS.CREATED