ListImages() public method

public ListImages ( ) : List
return List
Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            ///
            /// To run this sample you must have a
            /// LINODE-KEY.txt file with your Linode API
            /// key in it.  See the getting started guide for
            /// info on how to get a key.
            ///
            /// Note that this sample will create a new node
            /// on your account and you will be billed at least
            /// 1 day for that node.  You can manually destroy the
            /// node when you are done at linode.com or you can
            /// make a call to node.Destroy.
            ///

            if (!File.Exists ("LINODE-KEY.txt"))
                throw new Exception ("You must have a LINODE-KEY.txt file to run this sample.");

            var key = File.ReadAllText ("LINODE-KEY.txt").Trim ();
            if (key.Length < 40)
                throw new Exception ("Your LINODE-KEY.txt file must contain a Linode API key.");

            var driver = new LinodeDriver (key);

            // Find a location in the USA
            var location = driver.ListLocations ().FirstOrDefault (l => l.Country == "US");

            // Pick the cheapest plan possible
            var size = driver.ListSizes ().OrderBy (s => s.Price).FirstOrDefault ();

            // Grab any OpenSuse image.
            var image = driver.ListImages ().FirstOrDefault (i => i.Name.Contains ("OpenSUSE"));

            Console.WriteLine ("location: {0}  size:  {1}  image:  {2}", location, size, image);

            // Create the new with a random password
            string password = System.Web.Security.Membership.GeneratePassword (10, 3);
            NodeAuth auth = new NodeAuth (NodeAuthType.Password, password);
            Node n = driver.CreateNode ("my new node", size, image, location, auth);

            Console.WriteLine ("created new node located at {0} with password {1}", n.PublicIPs [0], password);

            var deployment = new MultiStepDeployment () {
                // Create a file on the node
                new RunCommand ("touch /root/test"),
                // Upload a file to the node
                new PutFile ("CreateLinode.exe"),
            };
            n.Deploy (deployment, auth);

            Console.WriteLine ("Your node has been deployed.");
        }
Exemplo n.º 2
0
    public static void Main(string [] args)
    {
        if (args.Length < 1) {
            Console.WriteLine ("You need to supply your Linode API key.");
            return;
        }

        LinodeDriver driver = new LinodeDriver (args [0], null);

        Console.WriteLine (" -- available locations -- ");
        List<NodeLocation> locations = driver.ListLocations ();
        foreach (NodeLocation location in locations) {
            Console.WriteLine (location);
        }

        Console.WriteLine (" -- available images -- ");
        List<NodeImage> images = driver.ListImages ();
        foreach (NodeImage image in images) {
            Console.WriteLine (image);
        }

        Console.WriteLine (" -- available sizes -- ");
        List<NodeSize> sizes = driver.ListSizes ();
        foreach (NodeSize size in sizes) {
            Console.WriteLine (size);
        }

        Console.WriteLine (" -- your nodes -- ");
        List<Node> nodes = driver.ListNodes ();
        foreach (Node node in nodes) {
            Console.WriteLine (node);
        }

        Node new_node = driver.CreateNode ("test node", sizes [0], images [0], locations [0]);

        Console.WriteLine ("just created the node:  {0}", new_node);

        new_node.Destroy ();
        Console.WriteLine ("destroyed the new node");
    }