96 |
96 |
dest='backend_id',
|
97 |
97 |
default=None,
|
98 |
98 |
help='ID of the backend that the network will be created. Only for'
|
99 |
|
' public networks')
|
|
99 |
' public networks'),
|
|
100 |
make_option('--link',
|
|
101 |
dest='link',
|
|
102 |
default=None,
|
|
103 |
help="Connectivity link of the Network. None for default."),
|
|
104 |
make_option('--mac-prefix',
|
|
105 |
dest='mac_prefix',
|
|
106 |
default=None,
|
|
107 |
help="MAC prefix of the network. None for default")
|
100 |
108 |
)
|
101 |
109 |
|
102 |
110 |
def handle(self, *args, **options):
|
... | ... | |
108 |
116 |
net_type = options['type']
|
109 |
117 |
backend_id = options['backend_id']
|
110 |
118 |
public = options['public']
|
|
119 |
link = options['link']
|
|
120 |
mac_prefix = options['mac_prefix']
|
111 |
121 |
|
112 |
122 |
if not name:
|
113 |
123 |
raise CommandError("Name is required")
|
... | ... | |
115 |
125 |
raise CommandError("Subnet is required")
|
116 |
126 |
if public and not backend_id:
|
117 |
127 |
raise CommandError("backend-id is required")
|
118 |
|
if public and not net_type == 'PUBLIC_ROUTED':
|
119 |
|
raise CommandError("Invalid type for public network")
|
120 |
128 |
if backend_id and not public:
|
121 |
129 |
raise CommandError("Private networks must be created to"
|
122 |
130 |
" all backends")
|
123 |
131 |
|
|
132 |
if mac_prefix and net_type == "PRIVATE_MAC_FILTERED":
|
|
133 |
raise CommandError("Can not override MAC_FILTERED mac-prefix")
|
|
134 |
if link and net_type == "PRIVATE_PHYSICAL_VLAN":
|
|
135 |
raise CommandError("Can not override PHYSICAL_VLAN link")
|
|
136 |
|
124 |
137 |
if backend_id:
|
125 |
138 |
try:
|
126 |
139 |
backend_id = int(backend_id)
|
... | ... | |
130 |
143 |
except Backend.DoesNotExist:
|
131 |
144 |
raise CommandError("Backend not found in DB")
|
132 |
145 |
|
133 |
|
link, mac_prefix = net_resources(net_type)
|
|
146 |
default_link, default_mac_prefix = net_resources(net_type)
|
|
147 |
if not link:
|
|
148 |
link = default_link
|
|
149 |
if not mac_prefix:
|
|
150 |
mac_prefix = default_mac_prefix
|
134 |
151 |
|
135 |
152 |
subnet, gateway, subnet6, gateway6 = validate_network_info(options)
|
136 |
153 |
|