Beispiel #1
0
 def post(self, server_id):
     """
     Add user access to a server
     :param server_id: The server id supplied in the URL
     """
     server = server_api.get_server(server_id)
     args = server_user_parser.parse_args()
     server_api.add_user_to_server(self.user, server, args.get('user_id'))
     return marshal(server.get_all_users(), user_fields), HTTP_STATUS.CREATED
Beispiel #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)
Beispiel #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)