Statistics
| Branch: | Tag: | Revision:

root / docs / examplesdir / network.rst @ a54bd720

History | View | Annotate | Download (7.6 kB)

1
Networks
2
========
3

    
4
Users can create private networks to connect Virtual Machines, and can also
5
manage network-related objects and properties e.i., connection to public
6
networks, IPs and subnets.
7

    
8
In the following we assume that there are two active virtual servers (ids 141
9
and 142) connected to one public network with id 1 (default set up).
10

    
11
.. code-block:: console
12

    
13
    $ kamaki server list
14
     141 Server 1
15
     142 Server 1
16

    
17
A look at the current network state:
18

    
19
.. code-block:: console
20

    
21
    $ kamaki network list
22
    1 public_network
23

    
24
Create a private network
25
------------------------
26

    
27
The new network will be named 'My Private Net'
28

    
29
.. code-block:: console
30

    
31
    $ kamaki network create --name='My Private Net'
32
     id: 2
33
     status:      ACTIVE
34
     router:external: True
35
     user_id:     s0m3-u53r-1d
36
     updated:     2013-06-19T13:54:57.672744+00:00
37
     created:     2013-06-19T13:52:02.268886+00:00
38
     links: ...
39
     public:      False
40
     tenant_id:   s0m3-u53r-1d
41
     admin_state_up: True
42
     SNF:floating_ip_pool: False
43
     subnets:
44
     type:        MAC_FILTERED
45

    
46
Connect and disconnect
47
----------------------
48

    
49
Connect the network to the virtual servers:
50

    
51
.. code-block:: console
52

    
53
    $ kamaki network connect 2 --device-id=141 --device-id=142
54
     Creating a port to connect network 2 with device 141
55
     11
56
        status: BUILD
57
        network_id: 29729
58
        mac_address: None
59
        fixed_ips:
60
        device_id: 141
61
        ...
62
     Creating a port to connect network 2 with device 142
63
     12
64
        status: BUILD
65
        network_id: 2
66
        mac_address: None
67
        fixed_ips:
68
        device_id: 142
69
        ...
70

    
71
.. warning:: A port between a network and a server takes some time to be
72
    created. Use --wait to make "connect" wait for all ports to be created
73

    
74
.. note:: **network connect** is a shortcut for **port create**:
75

    
76
    .. code-block:: console
77

    
78
        $ kamaki port create --network-id=1 --device-id=141 --wait
79
        $ kamaki port create --network-id=1 --device-id=142 --wait
80

    
81
Check the current network state:
82

    
83
.. code-block:: console
84

    
85
    $ kamaki network list -l
86
    1 Public network
87
     status: ACTIVE
88
     router:external: True
89
     user_id: None
90
     updated: 2013-06-19T13:36:51.932214+00:00
91
     created: 2013-05-29T17:30:03.040929+00:00
92
     links: ...
93
     tenant_id: None
94
     admin_state_up: True
95
     SNF:floating_ip_pool: False
96
     public: True
97
     subnets:
98
        53
99
     type: IP_LESS_ROUTED
100
    2 My Private Net
101
     status:      ACTIVE
102
     router:external: True
103
     user_id:     s0m3-u53r-1d
104
     updated:     2013-06-19T13:54:57.672744+00:00
105
     created:     2013-06-19T13:52:02.268886+00:00
106
     links: ...
107
     public:      False
108
     tenant_id:   s0m3-u53r-1d
109
     admin_state_up: True
110
     SNF:floating_ip_pool: False
111
     subnets:
112
     type:        MAC_FILTERED
113

    
114
Now the servers can communicate with each other through their shared private
115
network.
116

    
117
Manage floating IPs
118
-------------------
119

    
120
A floating IP can be created (reserved from a pool) and attached to a device.
121

    
122
.. code-block:: console
123

    
124
    $ kamaki ip create --network-id=1
125
     instance_id: None
126
     deleted: False
127
     floating_network_id: 1
128
     fixed_ip_address: None
129
     floating_ip_address: 192.168.3.5
130
     port_id: None
131
     id: 8
132
    $ kamaki ip attach 8 --server-id=141 --wait
133
     13
134
        status: ACTIVE
135
        network_id: 1
136
        mac_address: None
137
        fixed_ips:
138
            subnet: 21
139
            ip_address: 192.168.3.5
140
        device_id: 141
141
        ...
142

    
143
.. note:: **ip attach** is also a shortcut for **port create** !!!
144

    
145
    .. code-block:: console
146

    
147
        ...
148
        $ kamaki port create \
149
          --network-id=1 --device-id=141 --ip-address=192.168.3.5 --wait
150

    
151
An attempt to attach a used IP to another virtual server, should fail:
152

    
153
.. code-block:: console
154

    
155
    $ kamaki ip attach 8 --server-id=142 --wait
156
     (409) IP address '192.168.3.5' is already in use
157

    
158
More than one IPs can be created and more than one can be attached on the same
159
virtual server.
160

    
161
.. code-block:: console
162

    
163
    $ kamaki ip create --network-id=1
164
     instance_id: None
165
     deleted: False
166
     floating_network_id: 1
167
     fixed_ip_address: None
168
     floating_ip_address: 192.168.3.5
169
     port_id: None
170
     id: 9
171
    $ kamaki ip attach 9 --server-id=141 --wait
172
     14
173
        status: ACTIVE
174
        network_id: 1
175
        mac_address: None
176
        fixed_ips:
177
            subnet: 22
178
            ip_address: 192.168.3.6
179
        device_id: 141
180
        ...
181

    
182
Since all connections exist as ports, we can monitor everything with "port"
183
commands:
184

    
185
.. code-block:: console
186

    
187
    $ kamaki port list -l
188
     11
189
        status: ACTIVE
190
        network_id: 2
191
        mac_address: None
192
        fixed_ips:
193
        device_id: 141
194
        ...
195
     12
196
        status: ACTIVE
197
        network_id: 2
198
        mac_address: None
199
        fixed_ips:
200
        device_id: 142
201
     13
202
        status: ACTIVE
203
        network_id: 1
204
        mac_address: None
205
        fixed_ips:
206
            subnet: 21
207
            ip_address: 192.168.3.5
208
        device_id: 141
209
        ...
210
     14
211
        status: ACTIVE
212
        network_id: 1
213
        mac_address: None
214
        fixed_ips:
215
            subnet: 22
216
            ip_address: 192.168.3.6
217
        device_id: 141
218
        ...
219

    
220
Virtual server 141 has two IPs while 142 has none. Detach 192.168.3.6 (id: 9)
221
and attach it to server 142:
222

    
223
.. code-block:: console
224

    
225
    $ detach 9 --wait
226
    $ attach 9 --server-id=142 --wait
227
     14
228
        status: ACTIVE
229
        network_id: 1
230
        mac_address: None
231
        fixed_ips:
232
            subnet: 22
233
            ip_address: 192.168.3.6
234
        device_id: 142
235
        ...
236

    
237
IP quota limits
238
---------------
239

    
240
It is always a good idea to check the resource quotas:
241

    
242
.. code-block:: console
243

    
244
    $ kamaki quota list
245
     cyclades.disk:
246
        usage: 80GiB
247
        limit: 500GiB
248
        pending: 0B
249
     cyclades.vm:
250
        usage: 2
251
        limit: 2
252
        pending: 0
253
     pithos.diskspace:
254
        usage: 1.43GiB
255
        limit: 20GiB
256
        pending: 0B
257
     cyclades.ram:
258
        usage: 9GiB
259
        limit: 40GiB
260
        pending: 0B
261
     cyclades.floating_ip:
262
        usage: 2
263
        limit: 3
264
        pending: 0
265
     cyclades.cpu:
266
        usage: 4
267
        limit: 8
268
        pending: 0
269
     cyclades.network.private:
270
        usage: 2
271
        limit: 5
272
        pending: 0
273

    
274
According to these results, there is only one IP left. We will attempt to
275
reserve two, and when we fail in the second, and then we will release the first
276

    
277
.. code-block:: console
278

    
279
    $ kamaki ip create --network-id=1
280
     instance_id: None
281
     deleted: False
282
     floating_network_id: 1
283
     fixed_ip_address: None
284
     floating_ip_address: 192.168.3.7
285
     port_id: None
286
     id: 10
287
    $ kamaki ip create --network-id=1
288
     (413) REQUEST ENTITY TOO LARGE
289
     |  Limit for resource 'Floating IP address' exceeded for your account.
290
     |  Available: 0, Requested: 1
291
    $ kamaki ip delete 10
292

    
293
Destroy a private network
294
-------------------------
295

    
296
Attempt to destroy the public network
297

    
298
.. code-block:: console
299

    
300
    $ kamaki network delete 1
301
    (403) Network with id 1 is in use
302
    |  FORBIDDEN forbidden (Can not delete the public network.)
303

    
304
.. warning:: Public networks cannot be destroyed with API calls
305

    
306
Attempt to destroy the private network
307

    
308
.. code-block:: console
309

    
310
    $ kamaki network delete 2
311
    (403) Network with id 2 is in use
312

    
313
The attached virtual servers should be disconnected first
314

    
315
.. code-block:: console
316

    
317
    $ kamaki network disconnect 2 --device-id=141 --device-id=142 --wait
318
    $ kamaki network delete 2
319

    
320
.. note:: **network disconnect** is a shortcut for **port delete**
321

    
322
    .. code-block:: console
323

    
324
        $ kamaki port delete 11 --wait
325
        $ kamaki port delete 12 --wait
326
        $ kamaki network delete 2