|
39 | 39 | [out] transactions |
40 | 40 | list of string tuples as source and destination names for "ip link set |
41 | 41 | name" |
| 42 | +
|
| 43 | +Terms and abbreviations used in this file: |
| 44 | +**kname**: The kernel name of the network interface (the original name assigned by the kernel). |
| 45 | +**tname**: The temporary name of the network interface, |
| 46 | + used as an intermediate step during the renaming process to avoid name conflicts. |
42 | 47 | """ |
43 | 48 |
|
44 | 49 | from __future__ import unicode_literals |
@@ -122,24 +127,32 @@ def __rename_nic(nic, name, transactions, cur_state): |
122 | 127 | transactions.append((nic.kname, name)) |
123 | 128 |
|
124 | 129 |
|
125 | | -def rename_logic( static_rules, |
126 | | - cur_state, |
127 | | - last_state, |
128 | | - old_state ): |
| 130 | +def rename_logic(static_rules, cur_state, last_state, old_state): |
129 | 131 | """ |
130 | 132 | Core logic of renaming the current state based on the rules and past state. |
| 133 | +
|
131 | 134 | This function assumes all inputs have been suitably sanitised. |
132 | | - @param static_rules |
| 135 | +
|
| 136 | + Parameters |
| 137 | + ---------- |
| 138 | + static_rules : list |
133 | 139 | List of MACPCI objects representing rules |
134 | | - @param cur_state |
| 140 | + cur_state : list |
135 | 141 | List of MACPCI objects representing the current state |
136 | | - @param last_state |
| 142 | + last_state : list |
137 | 143 | List of MACPCI objects representing the last boot state |
138 | | - @param old_state |
| 144 | + old_state : list |
139 | 145 | List of MACPCI objects representing the old state |
140 | | - @returns List of tuples... |
141 | | - @throws AssertionError (Should not be thrown, but better to know about logic |
142 | | - errors if they occur) |
| 146 | +
|
| 147 | + Returns |
| 148 | + ------- |
| 149 | + list |
| 150 | + List of tuples representing name transactions. |
| 151 | +
|
| 152 | + Raises |
| 153 | + ------ |
| 154 | + AssertionError |
| 155 | + If the current state contains invalid entries. |
143 | 156 | """ |
144 | 157 |
|
145 | 158 | transactions = [] |
@@ -365,26 +378,38 @@ def rename_logic( static_rules, |
365 | 378 | util.niceformat(cur_state))) |
366 | 379 | return transactions |
367 | 380 |
|
368 | | -def rename( static_rules, |
369 | | - cur_state, |
370 | | - last_state, |
371 | | - old_state ): |
| 381 | +def rename(static_rules, cur_state, last_state, old_state): |
372 | 382 | """ |
373 | 383 | Rename current state based on the rules and past state. |
374 | | - This function sanitises the input and delegates the renaming logic to |
375 | | - __rename. |
376 | | - @param static_rules |
| 384 | +
|
| 385 | + This function sanitises the input and delegates the renaming logic to rename_logic. |
| 386 | +
|
| 387 | + Parameters |
| 388 | + ---------- |
| 389 | + static_rules : list |
377 | 390 | List of MACPCI objects representing rules |
378 | | - @param cur_state |
| 391 | + cur_state : list |
379 | 392 | List of MACPCI objects representing the current state |
380 | | - @param last_state |
| 393 | + last_state : list |
381 | 394 | List of MACPCI objects representing the last boot state |
382 | | - @param old_state |
| 395 | + old_state : list |
383 | 396 | List of MACPCI objects representing the old state |
384 | 397 |
|
385 | | - @throws StaticRuleError, CurrentStateError, LastStateError, TypeError |
386 | | -
|
387 | | - @returns list of tuples of name changes required |
| 398 | + Returns |
| 399 | + ------- |
| 400 | + list |
| 401 | + List of tuples of name changes required |
| 402 | +
|
| 403 | + Raises |
| 404 | + ------ |
| 405 | + StaticRuleError |
| 406 | + If a static rule has a kernel name, a tname not starting with 'eth', duplicate eth names, or duplicate MACs. |
| 407 | + CurrentStateError |
| 408 | + If the current state contains invalid entries. |
| 409 | + LastStateError |
| 410 | + If the last state contains invalid entries. |
| 411 | + TypeError |
| 412 | + If any of the input lists contain objects that are not MACPCI instances. |
388 | 413 | """ |
389 | 414 |
|
390 | 415 | if len(static_rules): |
|
0 commit comments