~cssoss/openstackbook/oneiric

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
<?xml version="1.0" encoding="UTF-8"?><chapter xmlns:db="http://docbook.org/ns/docbook" xmlns="http://docbook.org/ns/docbook" xml:id="Storage_Management-d1e1995" version="5.0" xml:base="Storage.xml">
 <title>Storage Management</title>
<section xml:id="Nova-volume-d1e2000">
<title>Nova-volume</title>
<para>Nova-volume provides persistent block storage compatible with Amazon's Elastic Block Store. The storage on the instances is non persistent in nature and hence any data that you generate and store on the file system on the first disk of the instance gets lost when the instance is terminated. You will need to use persistent volumes provided by nova-volume if you want any data generated during the life of the instance to persist after the instance is terminated.</para>
<para>Commands from euca2ools package can be used to manage these volumes.</para>
<para>Here are a few examples:</para>
<section xml:id="Interacting_with_Storage_Controller-d1e2014">
<title>Interacting with Storage Controller</title>
<para>Make sure that you have sourced novarc before running any of the following commands. The following commands refer to a zone called 'nova', which we created in the chapter on "Installation and Configuration". The project is 'proj' as referred to in the other chapters.</para>
<para>Create a 10 GB volume</para>
<programlisting>euca-create-volume -s 10 -z nova</programlisting>
<para>You should see an output like:</para>
<programlisting>VOLUME    vol-00000002    1    creating (proj, None, None, None)    2011-04-21T07:19:52Z</programlisting>
<para>List the volumes</para>
<programlisting>euca-describe-volumes</programlisting>
<para>You should see an output like this:</para>
<programlisting>VOLUME    vol-00000001     1        nova    available (proj, server1, None, None)    2011-04-21T05:11:22Z</programlisting>
<programlisting>VOLUME    vol-00000002     1        nova    available (proj, server1, None, None)    2011-04-21T07:19:52Z</programlisting>
<para>Attach a volume to a running instance</para>
<programlisting>euca-attach-volume -i i-00000009 -d /dev/vdb vol-00000002</programlisting>
<para>A volume can only be attached to one instance at a time. When euca-describe-volumes shows the status of a volume as 'available', it means it is not attached to any instance and ready to be used. If you run euca-describe-volumes, you can see that the status changes from "available" to "in-use" if it is attached to an  instance successfully.</para>
<para>When a volume is attached to an instance, it shows up as an additional SCSI disk on the instance. You can login to the instance and mount the disk, format it and use it.</para>
<para>Detach a volume from an instance.</para>
<programlisting>euca-detach-volume vol-00000002</programlisting>
<para>The data on the volume persists even after the volume is detached from an instance. You can see the data on reattaching the volume to another instance.</para>
<para>Even though you have indicated /dev/vdb as the device on the instance, the actual device name created by the OS running inside the instance may differ. You can find the name of the device by looking at the device nodes in /dev or by watching the syslog when the volume is being attached.</para>
</section>
<section>
<title>Swift</title>
<para>Swift is a storage service that can be used for storage and archival of objects. Swift provides a REST interface. You can use 'curl' command to get familiar with the service. All requests to Swift service need an authentication token. This authentication token can be obtained by providing your user credentials on Swift. For more details refer to the Swift section in the "Installation &amp; Configuration" chapter.</para>
<para>Execute the following command and make a note of X-Auth-Token. You will need this token to use in all subsequent commands.</para>
<programlisting>
curl -v -H 'X-Storage-User: admin:admin' -H 'X-Storage-Pass: admin' http://10.10.10.2:8080/auth/v1.0
</programlisting>
<para>In the following command examples we are using 'AUTH_tk3bb59eda987446c79160202d4dfbdc8c' as the X-Auth-Token. Replace this with the appropriate token you obtained in the above step.</para>
<para>To create a container:</para>
<programlisting>
curl -X PUT -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/mycontainer
</programlisting>
<para>To list all containers in current account:</para>
<programlisting>
curl -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/
</programlisting>
<para>Uploading a file "file1" to container "mycontainer"</para>
<programlisting>
curl -X PUT -T file1 -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/mycontainer/
</programlisting>
<para>To list all objects in a container:</para>
<programlisting>
curl -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/mycontainer
</programlisting>
<para>To list all objects in a container that starts with a particular prefix "fi":</para>
<programlisting>
curl -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/mycontainer/?prefix=fi 
</programlisting>
<para>To download a particular file "file1" from the container "mycontainer":</para>
<programlisting>
curl -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/mycontainer/file1
</programlisting>
<para>To download file1 and save it locally as localfile1:</para>
<programlisting>
curl -o localfile1 -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/mycontainer/file1
</programlisting>
<para>To delete a container "mycontainer"</para>
<programlisting>
curl -X DELETE -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/mycontainer
</programlisting>
<para>To delete a specific file "file1" from the container:</para>
<programlisting>
curl -X DELETE -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/mycontainer/file1
</programlisting>
<para>To get metadata associated with a Swift account:</para>
<programlisting>
curl -v -X HEAD -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/
</programlisting>
<para>To get metadata associated with a container:</para>
<programlisting>
curl -v -X HEAD -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/mycontainer
</programlisting>
<para>You can request the data from Swift in XML or JSON format by specifying the "format" paramater. This parameter can be applied to any of the above requests. Here are a few examples:</para>
<programlisting>
curl -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/?format=json
</programlisting>
<programlisting>
curl -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/?format=xml
</programlisting>
<para>The above operations can also be done using 'swift' command. For instructions on using 'swift' command, please refer to "swift --help".</para>
</section>
</section>
</chapter>