<commit_before>MCloud Getting Started Guide
=============================
To get started with MCloud you can download the compiled binary and
all its dependencies here: http://github.com/jacksonh/MCloud/downloads
once you have MCloud downloaded you can reference MCloud.dll in your
.net project.

A sample application is available in the samples directory.


Creating accounts
=================
MCloud is a managed interface to various cloud providers.  To do
anything useful with MCloud you will need to have accounts with at
least one of these cloud providers.

Currently the two supported cloud providers are Linode and EC2:

### EC2

EC2 users should sign up at http://aws.amazon.com. Once you are signed
up you can get your access key and your secret access key by clicking Account and
then SecurityCredentials. In this guide we will refer to the Access
Key ID as your user ID and the Secret Access Key as your user key.

### Linode

Linode users should sign up at http://linode.com. Once you are signed
up you can get your key by clicking the My Profile link and scrolling
down to the API key.  The API key is a unique ID that acts as a
username AND password. Since the API key refers to both your username
and password, it as used as a NodeAuth.Username in MCloud.




Logging in to your cloud provider 
=================================
MCloud uses an abstract Driver type for interacting with your cloud
provider. To create a Driver you just instantiate one of the Driver
types:

> NodeDriver driver = new MCloud.Linode.LinodeDriver (api_key);
OR:
> NodeDriver driver = new MCloud.EC2.EC2Driver (access_id, secret_access_id);



Listing your cloud providers available packages
===============================================
Once you have created an instance of a Driver you can query your cloud
provider to see what sort of node you can create. Here are the things
you can query for with MCloud:

 Returns a list of images such as "Open Suse 11.2" or "Red Hat".

 	 driver.ListImages ();
 	 { NodeImage id="54" name="Slackware 12.2" driver="Linode", NodeImage id="41" name="Ubuntu 8.04 LTS" driver="Linode" }

Returns a list of the geographical data center locations.

	driver.ListLocations ();
	{ NodeLocation id="2" name="Dallas, TX, USA" driver="Linode" Country="US", NodeLocation id="3" name="Fremont, CA, USA" driver="Linode" Country="US", }

Returns a list of the available sizes (packages of ram, gb, transfer for set prices).

	driver.ListSizes ()
	{ NodeSize id="1" name="Linode 512" driver="Linode" ram="512" disk="16384" bandwidth="200" price="1995", NodeSize id="2" name="Linode 768" driver="Linode" ram="768" disk="24576" bandwidth="300" price="2995"}


Interacting with Nodes
======================
You can get a list of your nodes with the Driver.ListNodes method. 
Once you have an instance of your nodes, you can check the state of
the node, check its IP addresses, reboot and terminate your nodes.

     
    List<Node> nodes = driver.ListNodes ();
    // print the state of all of the nodes
    nodes.ForEach (n => Console.WriteLine ("node state:  {0}", n.State));

    // reboot all the nodes
    nodes.ForEach (n => n.Reboot ());

    // destroy all the nodes
    nodes.ForEach (n => n.Destroy ());

Properties of the node can change between the time you got a reference
to the node and now.  To get the update properties of the node use the
Update () method.

       node.Reboot ();
       while (node.State == NodeState.ShuttingDown) {
       	   node.Update ();
       }


Creating new Nodes
==================
Once you have found an image, size and location that meet your needs
you can create a new node with the CreateNode method. This is a
synchronous method that will create a new node on the cloud provider
and return once the node has been created. Nodes will not be
immediately available after being created as they still have to wait
for their boot proccess to finish.

    NodeAuth auth = new NodeAuth (NodeAuthType.Password, "root", "<PASSWORD>");
    Node node = driver.CreateNode ("My Node", size, image, location, auth);

The NodeAuth object passed to CreateNode is used to create a login to
the machine once it is booted. So if you use a NodeAuthType.Password
the root user password will be set to that value.  If you use a
NodeAuthType.SSHKey the supplied keypath will be used for login. If
your image is preconfigured with a authorization method, you can use
the NodeAuthType.None.


Deploying your node
===================

Once a node is create you can use Deployment objects from the
MCloud.Deploy namespace to setup your node.  The best way to do this
is to create a MultistepDeployment and adding each of your steps to it
in the collection initializer.

       MultiStepDeployment md = new MultiStepDeployment () {
           new ScriptDeployment ("setup_db.sh"),
           new ScriptDeployment ("setup_webserver.sh"),
           new PutDirectoryDeployment ("/src/thesite", "/srv/www/thesite"),
           new SSHDeployment ("service apache2 restart")
       }

The following deployment steps are available:

 * **MultiStepDeployment**: Used to run a series of deployments.
 * **PutFileDeployment**: Put a single file on the node.
 * **PutFilesDeployment**: Put a list of files on the node.
 * **PutDirectoryDeployment**: Recursively copy a directory to the node.
 * **ScriptDeployment**: Copy a local script to the node and run it.
 * **SSHDeployment**: Run a single unix command on the node.
 * **SSHKeyDeployment**: Copy the current users ssh key to the node.
<commit_msg>Make the example code a little nicer.<commit_after>MCloud Getting Started Guide
=============================
To get started with MCloud you can download the compiled binary and
all its dependencies here: http://github.com/jacksonh/MCloud/downloads
once you have MCloud downloaded you can reference MCloud.dll in your
.net project.

A sample application is available in the samples directory.


Creating accounts
=================
MCloud is a managed interface to various cloud providers.  To do
anything useful with MCloud you will need to have accounts with at
least one of these cloud providers.

Currently the two supported cloud providers are Linode and EC2:

### EC2

EC2 users should sign up at http://aws.amazon.com. Once you are signed
up you can get your access key and your secret access key by clicking Account and
then SecurityCredentials. In this guide we will refer to the Access
Key ID as your user ID and the Secret Access Key as your user key.

### Linode

Linode users should sign up at http://linode.com. Once you are signed
up you can get your key by clicking the My Profile link and scrolling
down to the API key.  The API key is a unique ID that acts as a
username AND password. Since the API key refers to both your username
and password, it as used as a NodeAuth.Username in MCloud.




Logging in to your cloud provider 
=================================
MCloud uses an abstract Driver type for interacting with your cloud
provider. To create a Driver you just instantiate one of the Driver
types:

> NodeDriver driver = new MCloud.Linode.LinodeDriver (api_key);
OR:
> NodeDriver driver = new MCloud.EC2.EC2Driver (access_id, secret_access_id);



Listing your cloud providers available packages
===============================================
Once you have created an instance of a Driver you can query your cloud
provider to see what sort of node you can create. Here are the things
you can query for with MCloud:

 Returns a list of images such as "Open Suse 11.2" or "Red Hat".

 	 driver.ListImages ();
 	 { NodeImage id="54" name="Slackware 12.2" driver="Linode", NodeImage id="41" name="Ubuntu 8.04 LTS" driver="Linode" }

Returns a list of the geographical data center locations.

	driver.ListLocations ();
	{ NodeLocation id="2" name="Dallas, TX, USA" driver="Linode" Country="US", NodeLocation id="3" name="Fremont, CA, USA" driver="Linode" Country="US", }

Returns a list of the available sizes (packages of ram, gb, transfer for set prices).

	driver.ListSizes ()
	{ NodeSize id="1" name="Linode 512" driver="Linode" ram="512" disk="16384" bandwidth="200" price="1995", NodeSize id="2" name="Linode 768" driver="Linode" ram="768" disk="24576" bandwidth="300" price="2995"}


Interacting with Nodes
======================
You can get a list of your nodes with the Driver.ListNodes method. 
Once you have an instance of your nodes, you can check the state of
the node, check its IP addresses, reboot and terminate your nodes.

     
    List<Node> nodes = driver.ListNodes ();
    // print the state of all of the nodes
    nodes.ForEach (n => Console.WriteLine ("node state:  {0}", n.State));

    // reboot all the nodes
    nodes.ForEach (n => n.Reboot ());

    // destroy all the nodes
    nodes.ForEach (n => n.Destroy ());

Properties of the node can change between the time you got a reference
to the node and now.  To get the update properties of the node use the
Update () method.

       node.Reboot ();
       while (node.State == NodeState.ShuttingDown) {
       	   node.Update ();
       }


Creating new Nodes
==================
Once you have found an image, size and location that meet your needs
you can create a new node with the CreateNode method. This is a
synchronous method that will create a new node on the cloud provider
and return once the node has been created. Nodes will not be
immediately available after being created as they still have to wait
for their boot proccess to finish.

    NodeAuth auth = new NodeAuth (NodeAuthType.Password, "root", "<PASSWORD>");
    Node node = driver.CreateNode ("My Node", size, image, location, auth);

The NodeAuth object passed to CreateNode is used to create a login to
the machine once it is booted. So if you use a NodeAuthType.Password
the root user password will be set to that value.  If you use a
NodeAuthType.SSHKey the supplied keypath will be used for login. If
your image is preconfigured with a authorization method, you can use
the NodeAuthType.None.


Deploying your node
===================

Once a node is create you can use Deployment objects from the
MCloud.Deploy namespace to setup your node.  The best way to do this
is to create a MultistepDeployment and adding each of your steps to it
in the collection initializer.

       MultiStepDeployment md = new MultiStepDeployment () {
           new ScriptDeployment ("setup_db.sh"),
           new ScriptDeployment ("setup_webserver.sh"),
           new PutDirectoryDeployment ("/src/thesite", "/srv/www/thesite"),
           new SSHDeployment ("service apache2 restart")
       }
       nodes.ForEach (n => n.Deploy (md, auth));
       
The following deployment steps are available:

 * **MultiStepDeployment**: Used to run a series of deployments.
 * **PutFileDeployment**: Put a single file on the node.
 * **PutFilesDeployment**: Put a list of files on the node.
 * **PutDirectoryDeployment**: Recursively copy a directory to the node.
 * **ScriptDeployment**: Copy a local script to the node and run it.
 * **SSHDeployment**: Run a single unix command on the node.
 * **SSHKeyDeployment**: Copy the current users ssh key to the node.

{'fraction_non_alphanumeric': 0.10256640344580042, 'fraction_numerical': 0.010768126346015794, 'mean_word_length': 4.02027027027027, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1171257', 'n_tokens_mistral': 3081, 'n_tokens_neox': 2897, 'n_words': 1519}