~koolhead17/openstackbook/cssbook

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?xml version="1.0" encoding="UTF-8"?><chapter xmlns:db="http://docbook.org/ns/docbook" xmlns="http://docbook.org/ns/docbook" xml:id="Instance_Management-d1e1646" version="5.0" xml:base="Instance.xml">
    <title>Instance Management</title>
<section xml:id="Introduction-d1e1651">
<title>Introduction</title>
<para>An instance is a virtual machine provisioned by OpenStack on one of the nova-compute servers. 
When you launch an instance, a series of steps are triggered on various components of the OpenStack. 
During the life cycles of an instance, it moves through various stages as shown in the diagram below:
</para>
<para>
<mediaobject>
    <imageobject role="fo">
        <imagedata fileref="images/lifecycle.png"
            format="PNG" scale="60"/>
    </imageobject>
    <imageobject role="html">
        <imagedata fileref="images/lifecyclehtml.png"
            format="PNG" />
    </imageobject>
</mediaobject></para>
<para>The following interfaces can be used for managing instances in nova.</para>
<itemizedlist>
<listitem><para>Command line tools like euca2ools</para></listitem>
<listitem><para>Custom applications developed using EC2 APIs</para></listitem>
</itemizedlist>
</section>
<section xml:id="Euca2ools-Command_Line_Tools-d1e1828">
<title>Euca2ools-Command Line Tools</title>
<para>Euca2ools from Eucalyptus provide a bunch of command line tools to manage the eucalyptus setup. These commands help you manage images, instances, storage, networking etc. A few commands related to managing the instances are given below.</para>
<para>For a complete list of commands, see Appendix.</para>
<section xml:id="Installation-d1e1839">

<title>Installation</title>

<programlisting>
sudo apt-get install euca2ools
</programlisting>
</section>

<section xml:id="Creation_of_Key_Pairs-d1e1848">
<title>Creation of Key Pairs</title>
<para>OpenStack expects the client tools to use 2 kinds of credentials. One set of credentials are called Access Key and Secret Key that all clients would need to use to make any requests to the Cloud Controller. Each user registered on the web interface has this set created for him. You can download it from the web interface as mentioned in the chapter on "Web Interface".</para>

<para>You will also need to generate a keypair consisting of private key/public key to be able to launch instances on Eucalyptus. These keys are injected into the instances to make password-less SSH access to the instance possible. This depends on the way the necessary tools are bundled into the images. Please refer to the chapter on Image Management for more details. </para>

<para>Keypairs can also be generated using the following commands.</para>
<programlisting>
cd ~/creds
euca-add-keypair mykey &gt; mykey.priv
chmod 600 mykey.priv
</programlisting>
<para>This creates a new keypair called mykey. The private key mykey.priv is saved locally which can be used to connect to an instance launched with mykey as the keypair. euca-describe-keypairs command to list the available keypairs.</para><para>The output should like this:
</para>
<programlisting>
uecadmin@client1:~$ euca-describe-keypairs
KEYPAIR mykey   f7:ac:8e:f5:05:19:2b:31:28:8c:9b:d7:b8:07:0c:3c:b6:34:8f:79
KEYPAIR helloworld      12:96:b3:21:34:8d:6a:3f:92:2e:2b:70:23:ff:7f:51:b5:b7:ad:37
KEYPAIR ubuntu f6:af:9a:59:65:35:32:c4:3a:c4:62:0e:e1:44:0f:71:29:03:2d:91
KEYPAIR lucid  74:04:70:33:ed:57:7a:30:36:1f:ca:c6:ec:d5:4f:10:34:1a:52:51
KEYPAIR karmic   01:f9:aa:5f:4d:20:e2:53:d1:29:d0:0f:e2:f3:8c:21:91:70:7e:c8
</programlisting>
<para>To delete an existing keypair:</para>
<programlisting>
euca-delete-keypair helloworld
</programlisting>
<para>The above tasks can be achieved using Hybridfox from the "Keypairs" tab.</para>
</section>
<section xml:id="Launch_and_manage_instances-d1e1885">
<title>Launch and manage instances</title>
<para>There are several commands that help in managing the instances. Here are a few examples:</para>
<programlisting>
$ euca-run-instances ami-00000003 -k mykey -t m1.tiny

RESERVATION	r-f1ek1ojb	proj	default
INSTANCE	i-00000005	ami-00000003			pending	mykey (proj, None)	0		m1.tiny	2011-10-19T12:48:04Z	unknown zone	ami-00000000	ami-00000000
</programlisting>
<programlisting>
$ euca-describe-instances

RESERVATION	r-f1ek1ojb	proj	default
INSTANCE	i-00000005	ami-00000003	192.168.4.3	192.168.4.3	running	mykey (proj, Openstackvalidationserver1)	0		m1.tiny	2011-10-19T12:48:04Z	nova	ami-00000000	ami-00000000
</programlisting>
<programlisting>
$ euca-reboot-instances i-00000005
</programlisting>
<programlisting>
$ euca-terminate-instances i-00000005
</programlisting>
<programlisting>
$ euca-run-instances ami-XXXXXXXX -k mykey
</programlisting>
<programlisting>
$ euca-get-console-output i-00000005

i-00000005
2011-10-07T07:22:40.795Z
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Linux version 2.6.32-21-server (buildd@yellow) (gcc version 4.
4.3 (Ubuntu 4.4.3-4ubuntu5) ) #32-Ubuntu SMP Fri Oct 07 09:17:34 UTC 2011 (Ub
untu 2.6.32-21.32-server 2.6.32.11+drm33.2)
.............
</programlisting>
<para>You can make password less ssh access to the instance as follows:</para>
<programlisting>
ssh -i mykey.priv user@192.168.4.3
</programlisting>
<para>VM type has implications for harddisk size, amount of RAM and number of CPUs allocated to the instance. Check the VM types available.</para>
<programlisting>sudo nova-manage instance_type list</programlisting>
</section>
</section>
</chapter>