Revision 5ba43517
b/snf-cyclades-app/synnefo/logic/management/commands/pool-create.py | ||
---|---|---|
33 | 33 |
|
34 | 34 |
from django.core.management.base import BaseCommand, CommandError |
35 | 35 |
from optparse import make_option |
36 |
from synnefo.db.utils import validate_mac |
|
36 | 37 |
|
37 | 38 |
from util import pool_table_from_type |
38 | 39 |
|
... | ... | |
45 | 46 |
option_list = BaseCommand.option_list + ( |
46 | 47 |
make_option("--type", dest="type", |
47 | 48 |
choices=POOL_CHOICES, |
48 |
help="Type of pool" |
|
49 |
help="Type of pool. Choices:" |
|
50 |
" %s" % ",".join(POOL_CHOICES) |
|
49 | 51 |
), |
50 | 52 |
make_option("--size", dest="size", |
51 | 53 |
help="Size of the pool"), |
... | ... | |
69 | 71 |
except ValueError: |
70 | 72 |
raise CommandError("Invalid size") |
71 | 73 |
|
74 |
if type_ == "mac-prefix": |
|
75 |
if base is None: |
|
76 |
base = "aa:00:0" |
|
77 |
try: |
|
78 |
validate_mac(base + "0:00:00:00") |
|
79 |
except: |
|
80 |
raise CommandError("Invalid base. %s is not a" |
|
81 |
" valid MAC prefix." % base) |
|
82 |
|
|
72 | 83 |
pool_table = pool_table_from_type(type_) |
73 | 84 |
|
74 | 85 |
if pool_table.objects.exists(): |
Also available in: Unified diff