Revision b34864e8
b/lib/client/gnt_network.py | ||
---|---|---|
28 | 28 |
from ganeti import constants |
29 | 29 |
from ganeti import opcodes |
30 | 30 |
from ganeti import utils |
31 |
from ganeti import errors |
|
31 | 32 |
from textwrap import wrap |
32 | 33 |
|
33 | 34 |
|
... | ... | |
37 | 38 |
|
38 | 39 |
|
39 | 40 |
def _HandleReservedIPs(ips): |
40 |
if ips is not None:
|
|
41 |
if ips == "":
|
|
42 |
return []
|
|
43 |
else:
|
|
44 |
return utils.UnescapeAndSplit(ips, sep=",")
|
|
45 |
return None
|
|
41 |
if ips is None: |
|
42 |
return None
|
|
43 |
elif not ips:
|
|
44 |
return []
|
|
45 |
else:
|
|
46 |
return utils.UnescapeAndSplit(ips, sep=",")
|
|
46 | 47 |
|
47 | 48 |
|
48 | 49 |
def AddNetwork(opts, args): |
... | ... | |
57 | 58 |
""" |
58 | 59 |
(network_name, ) = args |
59 | 60 |
|
61 |
if opts.network is None: |
|
62 |
raise errors.OpPrereqError("The --network option must be given", |
|
63 |
errors.ECODE_INVAL) |
|
64 |
|
|
60 | 65 |
if opts.tags is not None: |
61 | 66 |
tags = opts.tags.split(",") |
62 | 67 |
else: |
63 | 68 |
tags = [] |
64 | 69 |
|
65 |
op = opcodes.OpNetworkAdd( |
|
66 |
network_name=network_name, |
|
67 |
gateway=opts.gateway, |
|
68 |
network=opts.network, |
|
69 |
gateway6=opts.gateway6, |
|
70 |
network6=opts.network6, |
|
71 |
mac_prefix=opts.mac_prefix, |
|
72 |
network_type=opts.network_type, |
|
73 |
add_reserved_ips=_HandleReservedIPs(opts.add_reserved_ips), |
|
74 |
conflicts_check=opts.conflicts_check, |
|
75 |
tags=tags) |
|
70 |
reserved_ips = _HandleReservedIPs(opts.add_reserved_ips) |
|
71 |
|
|
72 |
op = opcodes.OpNetworkAdd(network_name=network_name, |
|
73 |
gateway=opts.gateway, |
|
74 |
network=opts.network, |
|
75 |
gateway6=opts.gateway6, |
|
76 |
network6=opts.network6, |
|
77 |
mac_prefix=opts.mac_prefix, |
|
78 |
network_type=opts.network_type, |
|
79 |
add_reserved_ips=reserved_ips, |
|
80 |
conflicts_check=opts.conflicts_check, |
|
81 |
tags=tags) |
|
76 | 82 |
SubmitOpCode(op, opts=opts) |
77 | 83 |
|
78 | 84 |
|
Also available in: Unified diff