Statistics
| Branch: | Tag: | Revision:

root / docs / collection_of_examples / network.rst @ 404eb288

History | View | Annotate | Download (7.2 kB)

1 d0f431bb Stavros Sachtouris
Networks
2 d0f431bb Stavros Sachtouris
========
3 d0f431bb Stavros Sachtouris
4 d0f431bb Stavros Sachtouris
Users can create private networks between Virtual Machines.
5 d0f431bb Stavros Sachtouris
6 d0f431bb Stavros Sachtouris
In the following we assume that there are two active VMs (ids 141 and 142)
7 d0f431bb Stavros Sachtouris
connected to one public network with id 1 (default set up).
8 d0f431bb Stavros Sachtouris
9 d0f431bb Stavros Sachtouris
.. code-block:: console
10 d0f431bb Stavros Sachtouris
11 d0f431bb Stavros Sachtouris
    $ kamaki server addr 141
12 d0f431bb Stavros Sachtouris
    nic-141-0
13 d0f431bb Stavros Sachtouris
        firewallProfile: DISABLED
14 d0f431bb Stavros Sachtouris
        ipv4:            10.0.0.1
15 d0f431bb Stavros Sachtouris
        ipv6:            None
16 d0f431bb Stavros Sachtouris
        mac_address:     aa:00:00:23:0d:59
17 d0f431bb Stavros Sachtouris
        network_id:      1
18 d0f431bb Stavros Sachtouris
    $ kamaki server addr 142
19 d0f431bb Stavros Sachtouris
    nic-142-0
20 d0f431bb Stavros Sachtouris
        firewallProfile: DISABLED
21 d0f431bb Stavros Sachtouris
        ipv4:            10.0.0.3
22 d0f431bb Stavros Sachtouris
        ipv6:            None
23 d0f431bb Stavros Sachtouris
        mac_address:     aa:00:00:70:21:65
24 d0f431bb Stavros Sachtouris
        network_id:      1
25 d0f431bb Stavros Sachtouris
    $
26 d0f431bb Stavros Sachtouris
27 d0f431bb Stavros Sachtouris
.. note:: In Synnefo, each VM connects to a network through a NIC. The id of a
28 d0f431bb Stavros Sachtouris
    nic is nic-<server id>-<increment> by convention.
29 d0f431bb Stavros Sachtouris
30 d0f431bb Stavros Sachtouris
Let's load kamaki for networks and have a look at the current network state. We
31 d0f431bb Stavros Sachtouris
expect to find at least one public network (id: 1)
32 d0f431bb Stavros Sachtouris
33 d0f431bb Stavros Sachtouris
.. code-block:: console
34 d0f431bb Stavros Sachtouris
35 d0f431bb Stavros Sachtouris
    $ kamaki
36 d0f431bb Stavros Sachtouris
    kamaki v0.9 - Interactive Shell
37 d0f431bb Stavros Sachtouris
38 d0f431bb Stavros Sachtouris
    /exit       terminate kamaki
39 d0f431bb Stavros Sachtouris
    exit or ^D  exit context
40 d0f431bb Stavros Sachtouris
    ? or help   available commands
41 d0f431bb Stavros Sachtouris
    ?command    help on command
42 d0f431bb Stavros Sachtouris
    !<command>  execute OS shell command
43 d0f431bb Stavros Sachtouris
44 d0f431bb Stavros Sachtouris
    [kamaki]: network
45 d0f431bb Stavros Sachtouris
    [network]: list
46 d0f431bb Stavros Sachtouris
    1 public_network
47 d0f431bb Stavros Sachtouris
    [network]:
48 d0f431bb Stavros Sachtouris
49 d0f431bb Stavros Sachtouris
Create a private network
50 d0f431bb Stavros Sachtouris
------------------------
51 d0f431bb Stavros Sachtouris
52 d0f431bb Stavros Sachtouris
The new network will be named 'My Private Net'
53 d0f431bb Stavros Sachtouris
54 d0f431bb Stavros Sachtouris
.. code-block:: console
55 d0f431bb Stavros Sachtouris
56 d0f431bb Stavros Sachtouris
    [network]: create 'My Private Net'
57 d0f431bb Stavros Sachtouris
    attachments:
58 d0f431bb Stavros Sachtouris
    cidr:        192.168.1.0/24
59 d0f431bb Stavros Sachtouris
    cidr6:       None
60 d0f431bb Stavros Sachtouris
    created:     2013-06-19T13:52:02.268886+00:00
61 d0f431bb Stavros Sachtouris
    dhcp:        False
62 d0f431bb Stavros Sachtouris
    gateway:     None
63 d0f431bb Stavros Sachtouris
    gateway6:    None
64 d0f431bb Stavros Sachtouris
    id:          3
65 d0f431bb Stavros Sachtouris
    name:        My Private Net
66 d0f431bb Stavros Sachtouris
    public:      False
67 d0f431bb Stavros Sachtouris
    status:      ACTIVE
68 d0f431bb Stavros Sachtouris
    tenant_id:   s0m3-u53r-1d
69 d0f431bb Stavros Sachtouris
    type:        MAC_FILTERED
70 d0f431bb Stavros Sachtouris
    updated:     2013-06-19T13:52:02.388779+00:00
71 d0f431bb Stavros Sachtouris
    user_id:     s0m3-u53r-1d
72 d0f431bb Stavros Sachtouris
    [network]:
73 d0f431bb Stavros Sachtouris
74 d0f431bb Stavros Sachtouris
Let's create two more networks, one for VM 141 and one for Vm 142
75 d0f431bb Stavros Sachtouris
76 d0f431bb Stavros Sachtouris
.. code-block:: console
77 d0f431bb Stavros Sachtouris
78 d0f431bb Stavros Sachtouris
    [network]: create 'For VM 141'
79 d0f431bb Stavros Sachtouris
    ...
80 d0f431bb Stavros Sachtouris
    id:         4
81 d0f431bb Stavros Sachtouris
    ...
82 d0f431bb Stavros Sachtouris
    [network]: create 'For VM 142'
83 d0f431bb Stavros Sachtouris
    ...
84 d0f431bb Stavros Sachtouris
    id:         5
85 d0f431bb Stavros Sachtouris
    ...
86 d0f431bb Stavros Sachtouris
    [network]:
87 d0f431bb Stavros Sachtouris
88 d0f431bb Stavros Sachtouris
Connect and disconnect
89 d0f431bb Stavros Sachtouris
----------------------
90 d0f431bb Stavros Sachtouris
91 d0f431bb Stavros Sachtouris
To make a points, the networks should be connected to their respecting VMs
92 d0f431bb Stavros Sachtouris
93 d0f431bb Stavros Sachtouris
.. code-block:: console
94 d0f431bb Stavros Sachtouris
95 d0f431bb Stavros Sachtouris
    [network]: connect 141 4
96 d0f431bb Stavros Sachtouris
    [network]: connect 142 5
97 d0f431bb Stavros Sachtouris
    [network]:
98 d0f431bb Stavros Sachtouris
99 d0f431bb Stavros Sachtouris
Now, let's check the current network state. We expect to see the servers
100 d0f431bb Stavros Sachtouris
connected to netowkrd with ids 4 and 5, but not 3.
101 d0f431bb Stavros Sachtouris
102 d0f431bb Stavros Sachtouris
.. code-block:: console
103 d0f431bb Stavros Sachtouris
104 d0f431bb Stavros Sachtouris
    [network]: list -l
105 d0f431bb Stavros Sachtouris
    1 public_network
106 d0f431bb Stavros Sachtouris
     attachments:
107 d0f431bb Stavros Sachtouris
                nic-141-0
108 d0f431bb Stavros Sachtouris
                . . . . . . .
109 d0f431bb Stavros Sachtouris
                nic-142-0
110 d0f431bb Stavros Sachtouris
     cidr:        10.0.0.0/24
111 d0f431bb Stavros Sachtouris
     cidr6:       None
112 d0f431bb Stavros Sachtouris
     created:     2013-05-29T17:30:03.040929+00:00
113 d0f431bb Stavros Sachtouris
     dhcp:        True
114 d0f431bb Stavros Sachtouris
     gateway:     10.0.0.254
115 d0f431bb Stavros Sachtouris
     gateway6:    None
116 d0f431bb Stavros Sachtouris
     public:      True
117 d0f431bb Stavros Sachtouris
     status:      ACTIVE
118 d0f431bb Stavros Sachtouris
     tenant_id:   None
119 d0f431bb Stavros Sachtouris
     type:        CUSTOM
120 d0f431bb Stavros Sachtouris
     updated:     2013-06-19T13:36:51.932214+00:00
121 d0f431bb Stavros Sachtouris
     user_id:     None
122 d0f431bb Stavros Sachtouris
    3 My Private Net
123 d0f431bb Stavros Sachtouris
     attachments:
124 d0f431bb Stavros Sachtouris
     cidr:        192.168.1.0/24
125 d0f431bb Stavros Sachtouris
     cidr6:       None
126 d0f431bb Stavros Sachtouris
     created:     2013-06-19T13:52:02.268886+00:00
127 d0f431bb Stavros Sachtouris
     dhcp:        False
128 d0f431bb Stavros Sachtouris
     gateway:     None
129 d0f431bb Stavros Sachtouris
     gateway6:    None
130 d0f431bb Stavros Sachtouris
     public:      False
131 d0f431bb Stavros Sachtouris
     status:      ACTIVE
132 d0f431bb Stavros Sachtouris
     tenant_id:   s0m3-u53r-1d
133 d0f431bb Stavros Sachtouris
     type:        MAC_FILTERED
134 d0f431bb Stavros Sachtouris
     updated:     2013-06-19T13:54:57.672744+00:00
135 d0f431bb Stavros Sachtouris
     user_id:     s0m3-u53r-1d
136 d0f431bb Stavros Sachtouris
    4 For VM 141
137 d0f431bb Stavros Sachtouris
     attachments:
138 d0f431bb Stavros Sachtouris
                nic-141-1
139 d0f431bb Stavros Sachtouris
     cidr:        192.168.2.0/24
140 d0f431bb Stavros Sachtouris
     cidr6:       None
141 d0f431bb Stavros Sachtouris
     created:     2013-06-19T13:53:02.268886+00:00
142 d0f431bb Stavros Sachtouris
     dhcp:        False
143 d0f431bb Stavros Sachtouris
     gateway:     None
144 d0f431bb Stavros Sachtouris
     gateway6:    None
145 d0f431bb Stavros Sachtouris
     public:      False
146 d0f431bb Stavros Sachtouris
     status:      ACTIVE
147 d0f431bb Stavros Sachtouris
     tenant_id:   s0m3-u53r-1d
148 d0f431bb Stavros Sachtouris
     type:        MAC_FILTERED
149 d0f431bb Stavros Sachtouris
     updated:     2013-06-19T13:54:57.672744+00:00
150 d0f431bb Stavros Sachtouris
     user_id:     s0m3-u53r-1d
151 d0f431bb Stavros Sachtouris
    5 For VM 142
152 d0f431bb Stavros Sachtouris
     attachments:
153 d0f431bb Stavros Sachtouris
                nic-141-2
154 d0f431bb Stavros Sachtouris
     cidr:        192.168.3.0/24
155 d0f431bb Stavros Sachtouris
     cidr6:       None
156 d0f431bb Stavros Sachtouris
     created:     2013-06-19T13:54:02.268886+00:00
157 d0f431bb Stavros Sachtouris
     dhcp:        False
158 d0f431bb Stavros Sachtouris
     gateway:     None
159 d0f431bb Stavros Sachtouris
     gateway6:    None
160 d0f431bb Stavros Sachtouris
     public:      False
161 d0f431bb Stavros Sachtouris
     status:      ACTIVE
162 d0f431bb Stavros Sachtouris
     tenant_id:   s0m3-u53r-1d
163 d0f431bb Stavros Sachtouris
     type:        MAC_FILTERED
164 d0f431bb Stavros Sachtouris
     updated:     2013-06-19T13:54:57.672744+00:00
165 d0f431bb Stavros Sachtouris
     user_id:     s0m3-u53r-1d
166 d0f431bb Stavros Sachtouris
    [network]:
167 d0f431bb Stavros Sachtouris
168 d0f431bb Stavros Sachtouris
It is time to make meaningful connections: connect two servers to a private
169 d0f431bb Stavros Sachtouris
network
170 d0f431bb Stavros Sachtouris
171 d0f431bb Stavros Sachtouris
.. code-block:: console
172 d0f431bb Stavros Sachtouris
173 d0f431bb Stavros Sachtouris
    [network]: connect 141 3
174 d0f431bb Stavros Sachtouris
    [network]: connect 142 3
175 d0f431bb Stavros Sachtouris
    [network]:
176 d0f431bb Stavros Sachtouris
177 d0f431bb Stavros Sachtouris
Now the servers can communicate with eachother through their shared private
178 d0f431bb Stavros Sachtouris
network. Let's see the network details to confirm that
179 d0f431bb Stavros Sachtouris
180 d0f431bb Stavros Sachtouris
.. code-block:: console
181 d0f431bb Stavros Sachtouris
182 d0f431bb Stavros Sachtouris
    [network]: info 3
183 d0f431bb Stavros Sachtouris
    attachments:
184 d0f431bb Stavros Sachtouris
                nic-141-2
185 d0f431bb Stavros Sachtouris
                . . . . . . .
186 d0f431bb Stavros Sachtouris
                nic-142-2
187 d0f431bb Stavros Sachtouris
    cidr:        192.168.1.0/24
188 d0f431bb Stavros Sachtouris
    cidr6:       None
189 d0f431bb Stavros Sachtouris
    created:     2013-06-19T13:52:02.268886+00:00
190 d0f431bb Stavros Sachtouris
    dhcp:        False
191 d0f431bb Stavros Sachtouris
    gateway:     None
192 d0f431bb Stavros Sachtouris
    gateway6:    None
193 d0f431bb Stavros Sachtouris
    name:        My Private Net
194 d0f431bb Stavros Sachtouris
    public:      False
195 d0f431bb Stavros Sachtouris
    status:      ACTIVE
196 d0f431bb Stavros Sachtouris
    tenant_id:   s0m3-u53r-1d
197 d0f431bb Stavros Sachtouris
    type:        MAC_FILTERED
198 d0f431bb Stavros Sachtouris
    updated:     2013-06-19T13:54:57.672744+00:00
199 d0f431bb Stavros Sachtouris
    user_id:     s0m3-u53r-1d
200 d0f431bb Stavros Sachtouris
    [network]:
201 d0f431bb Stavros Sachtouris
202 d0f431bb Stavros Sachtouris
Destroy a private network
203 d0f431bb Stavros Sachtouris
-------------------------
204 d0f431bb Stavros Sachtouris
205 d0f431bb Stavros Sachtouris
Attempt to destroy the public network
206 d0f431bb Stavros Sachtouris
207 d0f431bb Stavros Sachtouris
.. code-block:: console
208 d0f431bb Stavros Sachtouris
209 d0f431bb Stavros Sachtouris
    [network]: delete 1
210 d0f431bb Stavros Sachtouris
    (403) Network with id 1 is in use
211 d0f431bb Stavros Sachtouris
    |  FORBIDDEN forbidden (Can not delete the public network.)
212 d0f431bb Stavros Sachtouris
    [kamaki]:
213 d0f431bb Stavros Sachtouris
214 d0f431bb Stavros Sachtouris
.. warning:: Public networks cannot be destroyed in Synnefo
215 d0f431bb Stavros Sachtouris
216 d0f431bb Stavros Sachtouris
Attempt to destroy the useless `For VM 141` network
217 d0f431bb Stavros Sachtouris
218 d0f431bb Stavros Sachtouris
.. code-block:: console
219 d0f431bb Stavros Sachtouris
220 d0f431bb Stavros Sachtouris
    [network]: delete 4
221 d0f431bb Stavros Sachtouris
    (403) Network with id 4 is in use
222 d0f431bb Stavros Sachtouris
    [network]:
223 d0f431bb Stavros Sachtouris
224 d0f431bb Stavros Sachtouris
The attached VMs should be disconnected first (recall that the nic-141-1
225 d0f431bb Stavros Sachtouris
connects network with id 4 to VM with id 141)
226 d0f431bb Stavros Sachtouris
227 d0f431bb Stavros Sachtouris
.. code-block:: console
228 d0f431bb Stavros Sachtouris
229 d0f431bb Stavros Sachtouris
    [network]: disconnect nic-141-1
230 d0f431bb Stavros Sachtouris
    [network]: delete 4
231 d0f431bb Stavros Sachtouris
    [network]:
232 d0f431bb Stavros Sachtouris
233 d0f431bb Stavros Sachtouris
Attempt to delete the common network. Now we know that we should disconnect the
234 d0f431bb Stavros Sachtouris
respective nics (nic-141-2, nic-142-2) first
235 d0f431bb Stavros Sachtouris
236 d0f431bb Stavros Sachtouris
.. code-block:: console
237 d0f431bb Stavros Sachtouris
238 d0f431bb Stavros Sachtouris
    [network]: disconnect nic-142-2
239 d0f431bb Stavros Sachtouris
    [network]: disconnect nic-141-2
240 d0f431bb Stavros Sachtouris
    (404) No nic nic-141-2 on server(VM) with id 141
241 d0f431bb Stavros Sachtouris
    |  * check server(VM) with id 142: /server info 141
242 d0f431bb Stavros Sachtouris
    |  * list nics for server(VM) with id 141:
243 d0f431bb Stavros Sachtouris
    |        /server addr 141
244 d0f431bb Stavros Sachtouris
    |  Network Interface nic-141-2 not found on server 141
245 d0f431bb Stavros Sachtouris
    [network]:
246 d0f431bb Stavros Sachtouris
247 d0f431bb Stavros Sachtouris
Strangely, kamaki did not find any nic-141-2 nics. Why?
248 d0f431bb Stavros Sachtouris
249 d0f431bb Stavros Sachtouris
Answer: A listing of the 141 nics shows that the network connection to network
250 d0f431bb Stavros Sachtouris
with id 3 is now renamed as nic-141-1
251 d0f431bb Stavros Sachtouris
252 d0f431bb Stavros Sachtouris
.. code-block:: console
253 d0f431bb Stavros Sachtouris
254 d0f431bb Stavros Sachtouris
    [network]: /server addr 141
255 d0f431bb Stavros Sachtouris
    nic-142-0
256 d0f431bb Stavros Sachtouris
     firewallProfile: DISABLED
257 d0f431bb Stavros Sachtouris
     ipv4:            10.0.0.1
258 d0f431bb Stavros Sachtouris
     ipv6:            None
259 d0f431bb Stavros Sachtouris
     mac_address:     aa:00:00:23:0d:59
260 d0f431bb Stavros Sachtouris
     network_id:      1
261 d0f431bb Stavros Sachtouris
    nic-142-1
262 d0f431bb Stavros Sachtouris
     firewallProfile: DISABLED
263 d0f431bb Stavros Sachtouris
     ipv4:            192.168.1.0/24
264 d0f431bb Stavros Sachtouris
     ipv6:            None
265 d0f431bb Stavros Sachtouris
     mac_address:     aa:00:00:23:0d:60
266 d0f431bb Stavros Sachtouris
     network_id:      1
267 d0f431bb Stavros Sachtouris
     [network]:
268 d0f431bb Stavros Sachtouris
269 d0f431bb Stavros Sachtouris
.. warning:: Synnefo network server renames the nics of a VM whenever another
270 d0f431bb Stavros Sachtouris
    nic is of the same server is deleted
271 d0f431bb Stavros Sachtouris
272 d0f431bb Stavros Sachtouris
Let's remove the correct nic, then, and check if any other nics are related to
273 d0f431bb Stavros Sachtouris
the network with id 3.
274 d0f431bb Stavros Sachtouris
275 d0f431bb Stavros Sachtouris
.. code-block:: console
276 d0f431bb Stavros Sachtouris
277 d0f431bb Stavros Sachtouris
    [network]: delete nic-141-1
278 d0f431bb Stavros Sachtouris
    [network]: info 3
279 d0f431bb Stavros Sachtouris
    attachments:
280 d0f431bb Stavros Sachtouris
    cidr:        192.168.1.0/24
281 d0f431bb Stavros Sachtouris
    cidr6:       None
282 d0f431bb Stavros Sachtouris
    ...
283 d0f431bb Stavros Sachtouris
    [network]:
284 d0f431bb Stavros Sachtouris
285 d0f431bb Stavros Sachtouris
So, we are ready to destroy the network
286 d0f431bb Stavros Sachtouris
287 d0f431bb Stavros Sachtouris
.. code-block:: console
288 d0f431bb Stavros Sachtouris
289 d0f431bb Stavros Sachtouris
    [network]: delete 3
290 d0f431bb Stavros Sachtouris
    [network]: