Revision 83192241

/dev/null
1

  
2
virtual machines
3
----------------
4

  
5
Create a server
6
^^^^^^^^^^^^^^^
7

  
8
Inject ssh keys
9
^^^^^^^^^^^^^^^
10

  
11
Inject user profiles
12
^^^^^^^^^^^^^^^^^^^^
13

  
14
Connect and disconnect to a network
15
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
16

  
17
Networks
18
--------
19

  
20
Create a private network
21
^^^^^^^^^^^^^^^^^^^^^^^^
22

  
23
Connect VMs on it
24
^^^^^^^^^^^^^^^^^
25

  
26
Destroy a private network
27
^^^^^^^^^^^^^^^^^^^^^^^^^
b/docs/collection_of_examples/network.rst
1
Networks
2
========
3

  
4
Users can create private networks between Virtual Machines.
5

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

  
9
.. code-block:: console
10

  
11
    $ kamaki server addr 141
12
    nic-141-0
13
        firewallProfile: DISABLED
14
        ipv4:            10.0.0.1
15
        ipv6:            None
16
        mac_address:     aa:00:00:23:0d:59
17
        network_id:      1
18
    $ kamaki server addr 142
19
    nic-142-0
20
        firewallProfile: DISABLED
21
        ipv4:            10.0.0.3
22
        ipv6:            None
23
        mac_address:     aa:00:00:70:21:65
24
        network_id:      1
25
    $
26

  
27
.. note:: In Synnefo, each VM connects to a network through a NIC. The id of a
28
    nic is nic-<server id>-<increment> by convention.
29

  
30
Let's load kamaki for networks and have a look at the current network state. We
31
expect to find at least one public network (id: 1)
32

  
33
.. code-block:: console
34

  
35
    $ kamaki
36
    kamaki v0.9 - Interactive Shell
37

  
38
    /exit       terminate kamaki
39
    exit or ^D  exit context
40
    ? or help   available commands
41
    ?command    help on command
42
    !<command>  execute OS shell command
43

  
44
    [kamaki]: network
45
    [network]: list
46
    1 public_network
47
    [network]:
48

  
49
Create a private network
50
------------------------
51

  
52
The new network will be named 'My Private Net'
53

  
54
.. code-block:: console
55

  
56
    [network]: create 'My Private Net'
57
    attachments:
58
    cidr:        192.168.1.0/24
59
    cidr6:       None
60
    created:     2013-06-19T13:52:02.268886+00:00
61
    dhcp:        False
62
    gateway:     None
63
    gateway6:    None
64
    id:          3
65
    name:        My Private Net
66
    public:      False
67
    status:      ACTIVE
68
    tenant_id:   s0m3-u53r-1d
69
    type:        MAC_FILTERED
70
    updated:     2013-06-19T13:52:02.388779+00:00
71
    user_id:     s0m3-u53r-1d
72
    [network]:
73

  
74
Let's create two more networks, one for VM 141 and one for Vm 142
75

  
76
.. code-block:: console
77

  
78
    [network]: create 'For VM 141'
79
    ...
80
    id:         4
81
    ...
82
    [network]: create 'For VM 142'
83
    ...
84
    id:         5
85
    ...
86
    [network]:
87

  
88
Connect and disconnect
89
----------------------
90

  
91
To make a points, the networks should be connected to their respecting VMs
92

  
93
.. code-block:: console
94

  
95
    [network]: connect 141 4
96
    [network]: connect 142 5
97
    [network]:
98

  
99
Now, let's check the current network state. We expect to see the servers
100
connected to netowkrd with ids 4 and 5, but not 3.
101

  
102
.. code-block:: console
103

  
104
    [network]: list -l
105
    1 public_network
106
     attachments:
107
                nic-141-0
108
                . . . . . . .
109
                nic-142-0
110
     cidr:        10.0.0.0/24
111
     cidr6:       None
112
     created:     2013-05-29T17:30:03.040929+00:00
113
     dhcp:        True
114
     gateway:     10.0.0.254
115
     gateway6:    None
116
     public:      True
117
     status:      ACTIVE
118
     tenant_id:   None
119
     type:        CUSTOM
120
     updated:     2013-06-19T13:36:51.932214+00:00
121
     user_id:     None
122
    3 My Private Net
123
     attachments:
124
     cidr:        192.168.1.0/24
125
     cidr6:       None
126
     created:     2013-06-19T13:52:02.268886+00:00
127
     dhcp:        False
128
     gateway:     None
129
     gateway6:    None
130
     public:      False
131
     status:      ACTIVE
132
     tenant_id:   s0m3-u53r-1d
133
     type:        MAC_FILTERED
134
     updated:     2013-06-19T13:54:57.672744+00:00
135
     user_id:     s0m3-u53r-1d
136
    4 For VM 141
137
     attachments:
138
                nic-141-1
139
     cidr:        192.168.2.0/24
140
     cidr6:       None
141
     created:     2013-06-19T13:53:02.268886+00:00
142
     dhcp:        False
143
     gateway:     None
144
     gateway6:    None
145
     public:      False
146
     status:      ACTIVE
147
     tenant_id:   s0m3-u53r-1d
148
     type:        MAC_FILTERED
149
     updated:     2013-06-19T13:54:57.672744+00:00
150
     user_id:     s0m3-u53r-1d
151
    5 For VM 142
152
     attachments:
153
                nic-141-2
154
     cidr:        192.168.3.0/24
155
     cidr6:       None
156
     created:     2013-06-19T13:54:02.268886+00:00
157
     dhcp:        False
158
     gateway:     None
159
     gateway6:    None
160
     public:      False
161
     status:      ACTIVE
162
     tenant_id:   s0m3-u53r-1d
163
     type:        MAC_FILTERED
164
     updated:     2013-06-19T13:54:57.672744+00:00
165
     user_id:     s0m3-u53r-1d
166
    [network]:
167

  
168
It is time to make meaningful connections: connect two servers to a private
169
network
170

  
171
.. code-block:: console
172

  
173
    [network]: connect 141 3
174
    [network]: connect 142 3
175
    [network]:
176

  
177
Now the servers can communicate with eachother through their shared private
178
network. Let's see the network details to confirm that
179

  
180
.. code-block:: console
181

  
182
    [network]: info 3
183
    attachments:
184
                nic-141-2
185
                . . . . . . .
186
                nic-142-2
187
    cidr:        192.168.1.0/24
188
    cidr6:       None
189
    created:     2013-06-19T13:52:02.268886+00:00
190
    dhcp:        False
191
    gateway:     None
192
    gateway6:    None
193
    name:        My Private Net
194
    public:      False
195
    status:      ACTIVE
196
    tenant_id:   s0m3-u53r-1d
197
    type:        MAC_FILTERED
198
    updated:     2013-06-19T13:54:57.672744+00:00
199
    user_id:     s0m3-u53r-1d
200
    [network]:
201

  
202
Destroy a private network
203
-------------------------
204

  
205
Attempt to destroy the public network
206

  
207
.. code-block:: console
208

  
209
    [network]: delete 1
210
    (403) Network with id 1 is in use
211
    |  FORBIDDEN forbidden (Can not delete the public network.)
212
    [kamaki]:
213

  
214
.. warning:: Public networks cannot be destroyed in Synnefo
215

  
216
Attempt to destroy the useless `For VM 141` network
217

  
218
.. code-block:: console
219

  
220
    [network]: delete 4
221
    (403) Network with id 4 is in use
222
    [network]:
223

  
224
The attached VMs should be disconnected first (recall that the nic-141-1
225
connects network with id 4 to VM with id 141)
226

  
227
.. code-block:: console
228

  
229
    [network]: disconnect nic-141-1
230
    [network]: delete 4
231
    [network]:
232

  
233
Attempt to delete the common network. Now we know that we should disconnect the
234
respective nics (nic-141-2, nic-142-2) first
235

  
236
.. code-block:: console
237

  
238
    [network]: disconnect nic-142-2
239
    [network]: disconnect nic-141-2
240
    (404) No nic nic-141-2 on server(VM) with id 141
241
    |  * check server(VM) with id 142: /server info 141
242
    |  * list nics for server(VM) with id 141:
243
    |        /server addr 141
244
    |  Network Interface nic-141-2 not found on server 141
245
    [network]:
246

  
247
Strangely, kamaki did not find any nic-141-2 nics. Why?
248

  
249
Answer: A listing of the 141 nics shows that the network connection to network
250
with id 3 is now renamed as nic-141-1
251

  
252
.. code-block:: console
253

  
254
    [network]: /server addr 141
255
    nic-142-0
256
     firewallProfile: DISABLED
257
     ipv4:            10.0.0.1
258
     ipv6:            None
259
     mac_address:     aa:00:00:23:0d:59
260
     network_id:      1
261
    nic-142-1
262
     firewallProfile: DISABLED
263
     ipv4:            192.168.1.0/24
264
     ipv6:            None
265
     mac_address:     aa:00:00:23:0d:60
266
     network_id:      1
267
     [network]:
268

  
269
.. warning:: Synnefo network server renames the nics of a VM whenever another
270
    nic is of the same server is deleted
271

  
272
Let's remove the correct nic, then, and check if any other nics are related to
273
the network with id 3.
274

  
275
.. code-block:: console
276

  
277
    [network]: delete nic-141-1
278
    [network]: info 3
279
    attachments:
280
    cidr:        192.168.1.0/24
281
    cidr6:       None
282
    ...
283
    [network]:
284

  
285
So, we are ready to destroy the network
286

  
287
.. code-block:: console
288

  
289
    [network]: delete 3
290
    [network]:
b/docs/examples.rst
11 11
    collection_of_examples/sharing
12 12
    collection_of_examples/imageregister
13 13
    collection_of_examples/server
14
    collection_of_examples/network
b/kamaki/cli/utils.py
211 211
    prefix = ''
212 212
    item_sep = False
213 213
    for item in sorted(l):
214
        if item in exclude:
214
        if ('%s' % item) in exclude:
215 215
            continue
216 216
        elif with_enumeration:
217 217
            prefix = '%s. ' % counter

Also available in: Unified diff