Package org.opennebula.client.user

Examples of org.opennebula.client.user.UserPool


        }

        // We will create a user pool and query some information.
        // The info method retrieves and saves internally the information
        // from OpenNebula.
        UserPool    userpool = new UserPool(oneClient);
        OneResponse rc       = userpool.info();

        // The response can be an error, in which case we have access to a
        // human-readable error message.
        if (rc.isError())
        {
            System.out.println(rc.getErrorMessage());
            return;
        }

        // Let's find out the current state of the users pool
        printUserPool(userpool);

        // Now we will try to allocate a new user
        System.out.println("Allocating new user (javaUser,javaPassword)...");
        rc = User.allocate(oneClient, "javaUser", "javaPassword");

        if (rc.isError())
        {
            System.out.println(rc.getErrorMessage());
            return;
        }

        // If the allocation was successful, then the response message contains
        // the new user's ID.
        int userID = Integer.parseInt( rc.getMessage() );
        System.out.println("The allocation request returned this ID: " + userID);

        // We can create a representation for the new user, using the returned
        // user-ID
        User javaUser = new User(userID, oneClient);

        // And request its information
        rc = javaUser.info();

        // Alternatively we could have requested the user's info with the
        // static info method:
        // rc = User.info(oneClient, userID);
        // and processed the xml returned in the message of the OneResponse.

        if (rc.isError())
        {
            System.out.println(rc.getErrorMessage());
            return;
        }

        // This is how the info returned looks like...
        System.out.println("Info for " + javaUser.xpath("name") + "...");
        System.out.println(rc.getMessage());

        // Wait a second... what was that xpath method for?
        // Now that we have the user's info loaded, we can use xpath expressions
        // without parsing and initializing any xml, as simple as
        // String name = javaUser.xpath("name");

        // The user pool information is now outdated, so we need to call the
        // info method again
        userpool.info();
        printUserPool(userpool);

        // Let's delete this new user, using its ID
        System.out.println("Deleting " + javaUser.getName() + "...");
        rc = javaUser.delete();

        if (rc.isError())
        {
            System.out.println(rc.getErrorMessage());
            return;
        }

        // Now the pool information is outdated again, it is time to reload it.
        userpool.info();
        printUserPool(userpool);
    }
View Full Code Here


     */
    @BeforeClass
    public static void setUpBeforeClass() throws Exception
    {
        client      = new Client();
        userPool    = new UserPool(client);
    }
View Full Code Here

TOP

Related Classes of org.opennebula.client.user.UserPool

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.