Revision 11e90588 tools/cfgupgrade
b/tools/cfgupgrade | ||
---|---|---|
34 | 34 |
import logging |
35 | 35 |
import time |
36 | 36 |
from cStringIO import StringIO |
37 |
from bitarray import bitarray |
|
38 |
from base64 import b64encode, b64decode |
|
37 | 39 |
|
38 | 40 |
from ganeti import constants |
39 | 41 |
from ganeti import serializer |
... | ... | |
126 | 128 |
_FillIPolicySpecs(default_ipolicy, ipolicy) |
127 | 129 |
|
128 | 130 |
|
131 |
# pylint: disable=E1101 |
|
129 | 132 |
def UpgradeNetworks(config_data): |
130 |
networks = config_data.get("networks", None)
|
|
133 |
networks = config_data.get("networks", {})
|
|
131 | 134 |
if not networks: |
132 | 135 |
config_data["networks"] = {} |
136 |
for nobj in networks.values(): |
|
137 |
for key in ("reservations", "ext_reservations"): |
|
138 |
r = nobj[key] |
|
139 |
if options.tob64: |
|
140 |
try: |
|
141 |
b = bitarray(r) |
|
142 |
nobj[key] = b64encode(b.tobytes()) |
|
143 |
except ValueError: |
|
144 |
print("No 01 network found! Probably already in base64.") |
|
145 |
if options.to01: |
|
146 |
try: |
|
147 |
b = bitarray(r) |
|
148 |
print("01 network found! Do nothing.") |
|
149 |
except ValueError: |
|
150 |
b = bitarray() |
|
151 |
b.frombytes(b64decode(r)) |
|
152 |
nobj[key] = b.to01() |
|
153 |
print("%s: %s -> %s" % (nobj["name"], r, nobj[key])) |
|
133 | 154 |
|
134 | 155 |
|
135 | 156 |
def UpgradeCluster(config_data): |
... | ... | |
395 | 416 |
parser.add_option("--downgrade", |
396 | 417 |
help="Downgrade to the previous stable version", |
397 | 418 |
action="store_true", dest="downgrade", default=False) |
419 |
parser.add_option("--tob64", |
|
420 |
help="Change to base64 encoded networks", |
|
421 |
action="store_true", dest="tob64", default=False) |
|
422 |
parser.add_option("--to01", |
|
423 |
help="Change to non encoded networks (01 bitarrays)", |
|
424 |
action="store_true", dest="to01", default=False) |
|
398 | 425 |
(options, args) = parser.parse_args() |
399 | 426 |
|
400 | 427 |
# We need to keep filenames locally because they might be renamed between |
Also available in: Unified diff