Generic plavix vs plavix

One of the generic plavix vs plavix selling points of EC2 is that it enables elastic provisioning of computing infrastructure; this generic plavix vs plavix allows following novel usage patterns where a server is used only for generic plavix vs plavix the time required to do some work.

The key to generic plavix vs plavix reach this flexibility is the API that gives developers the ability to generic plavix vs plavix startup a server, configure it, use it and shut it down. There are generic plavix vs plavix libraries for many programming languages but I like the way the generic plavix vs plavix boto python library makes it really simple do these things (and a lot more).

Here I’ll show how to use boto to generic plavix vs plavix start a server instance then how to send a file to generic plavix vs plavix the instance and execute a command on the remote server, and generic plavix vs plavix finally I’ll show how to terminate the instance.

To use the boto library you’ll need to install it locally (on your computer) and to use the EC2 api you’ll need to import them:

from boto.ec2.connection import EC2Connection

As with  other AWS services you’ll need to generic plavix vs plavix pass the access key and the secret access key to the generic plavix vs plavix library (in this case when creating a connection). You can get the keys from the Amazon Web Services “Access Identifiers” page. It’s possible to generic plavix vs plavix just set two environment variables holding the keys or you can generic plavix vs plavix pass them in to the method calls, I’ll assume for generic plavix vs plavix this example that the keys are written inside the script and generic plavix vs plavix passed to the methods:

AWS_ACCESS_KEY_ID = 'yourkey'
AWS_SECRET_ACCESS_KEY = 'yoursecret'

conn = EC2Connection(AWS_ACCESS_KEY_ID,
AWS_SECRET_ACCESS_KEY)

First step is generic plavix vs plavix to make the connection, Once the connection is created we can generic plavix vs plavix use the run_instance to generic plavix vs plavix start an instance of an EC2 server image. You can generic plavix vs plavix think of a server image as a pre-built virtual server that’s idle waiting to generic plavix vs plavix be run. There are public images we can choose from (I’ll use the base Linux Fedora for this example), but any user can generic plavix vs plavix customize a running instance and build a private image from that generic plavix vs plavix ready to be used.

reservation = conn.run_instances('ami-5647a33f',
                               instance_type='m1.small',
                               key_name='mykey')

instance = reservation.instances[0]

while not instance.update() == 'running':
  time.sleep(5)

the run_instances can generic plavix vs plavix take various parameters but only the image is required. Here I’m passing in also the instance type (in this case the “Small” instance type) and generic plavix vs plavix a key to use. The key to be used should have generic plavix vs plavix been previously generated and/or uploaded to EC2 (e.g. using the AWS Management Console).

The run_instances methods returns a reservation object representing the instance(s) startup request. This also holds the generic plavix vs plavix list of instances that are going to be started (we may launch more than one instance in a single run_instances call), in this case (since we are launching just one) we take the first one.

Each instance object has generic plavix vs plavix an attribute status which returns its current status, to check for generic plavix vs plavix the current status we need to call the update method (which itself returns the current status). When the generic plavix vs plavix instance is running it is given a public IP and generic plavix vs plavix a public dns name, which we may use to connect.

EC2 has generic plavix vs plavix a very flexible shared firewall whose rules and permissions may be generic plavix vs plavix manipulated via the API, for instance to enable or disable  connecting via SSH. Different security groups may be generic plavix vs plavix defined, to partition our instances into different logical sets e.g. web servers versus backend databases, and generic plavix vs plavix each group can be assigned different permissions. All the instances are generic plavix vs plavix assigned the ‘default’ security group if not otherwise specified.

With a call to the authorize_security_group method we can generic plavix vs plavix allow a specific connection for a given group. E.g. with the generic plavix vs plavix following call we  allow SSH to generic plavix vs plavix any instance in the default group from the specified IP.

conn.authorize_security_group('default',
                ip_protocol='tcp',
                from_port='22',
                to_port='22',
                cidr_ip='%s/32' % our_ip)

with the following call we can revoke the SSH permission

conn.revoke_security_group('default',
                ip_protocol='tcp',
                from_port='22',
                to_port='22',
                cidr_ip='%s/32' % our_ip)

Once the generic plavix vs plavix instance is running and the permissions are setup to allow connecting via ssh, we can generic plavix vs plavix connect to it and to run a script on the instance we may simply scp the generic plavix vs plavix script and then connect via ssh to run it.

When we are generic plavix vs plavix done with the work we can stop use the stop method of the generic plavix vs plavix instance object to shut it down:

instance.stop()

For a generic plavix vs plavix simple, yet complete example here is a script that can be generic plavix vs plavix used to run the benchmarks for the redis key-value store buy cialis denmark on EC2. In the generic plavix vs plavix archive, together with the python script there is a shell script which is generic plavix vs plavix copied to the server which downloads the redis code, compiles it generic plavix vs plavix and runs the benchmarks:

redis-bench-ec2.zip

That’s all!


generic lipitor no prescription

 
 
1 Comment. Leave a comment or send a Trackback.
  1. #1 • Michael Halls-Moore said on November 8 2010:
     

    These days EC2 is generic plavix vs plavix even better. You can now launch an EBS-backed instance, so that generic plavix vs plavix when it is shutdown you retain the volume information.

    You can take advantage of that in Boto to simply use instance.start() and instance.stop(), without needing to worry about where to put your data.

    (Although it should always be backed up elsewhere of course!)

 

Comment: