Revision cd0927f7 kamaki/cli/commands/network.py
b/kamaki/cli/commands/network.py | ||
---|---|---|
31 | 31 |
# interpreted as representing official policies, either expressed |
32 | 32 |
# or implied, of GRNET S.A. |
33 | 33 |
|
34 |
from base64 import b64encode |
|
35 |
from os.path import exists, expanduser |
|
36 | 34 |
from io import StringIO |
37 | 35 |
from pydoc import pager |
38 | 36 |
|
39 | 37 |
from kamaki.cli import command |
40 | 38 |
from kamaki.cli.command_tree import CommandTree |
41 |
from kamaki.cli.utils import remove_from_items, filter_dicts_by_dict |
|
42 | 39 |
from kamaki.cli.errors import ( |
43 |
raiseCLIError, CLISyntaxError, CLIBaseUrlError, CLIInvalidArgument) |
|
44 |
from kamaki.clients.network import NetworkClient, ClientError |
|
45 |
from kamaki.cli.argument import FlagArgument, ValueArgument, KeyValueArgument |
|
46 |
from kamaki.cli.argument import ProgressBarArgument, DateArgument, IntArgument |
|
40 |
CLISyntaxError, CLIBaseUrlError, CLIInvalidArgument) |
|
41 |
from kamaki.clients.cyclades import CycladesNetworkClient |
|
42 |
from kamaki.cli.argument import FlagArgument, ValueArgument |
|
47 | 43 |
from kamaki.cli.commands import _command_init, errors, addLogSettings |
48 | 44 |
from kamaki.cli.commands import ( |
49 | 45 |
_optional_output_cmd, _optional_json, _name_filter, _id_filter) |
... | ... | |
70 | 66 |
if base_url: |
71 | 67 |
token = self._custom_token(service) or self._custom_token( |
72 | 68 |
'compute') or self.config.get_cloud('token') |
73 |
self.client = NetworkClient( |
|
69 |
self.client = CycladesNetworkClient(
|
|
74 | 70 |
base_url=base_url, token=token) |
75 | 71 |
return |
76 | 72 |
else: |
... | ... | |
81 | 77 |
self._custom_version('compute') or '') |
82 | 78 |
base_url = cyclades_endpoints['publicURL'] |
83 | 79 |
token = self.auth_base.token |
84 |
self.client = NetworkClient(base_url=base_url, token=token) |
|
80 |
self.client = CycladesNetworkClient(base_url=base_url, token=token)
|
|
85 | 81 |
else: |
86 | 82 |
raise CLIBaseUrlError(service='network') |
87 | 83 |
|
... | ... | |
141 | 137 |
|
142 | 138 |
@command(network_cmds) |
143 | 139 |
class network_create(_init_network, _optional_json): |
144 |
"""Create a new network""" |
|
140 |
"""Create a new network |
|
141 |
Valid network types: CUSTOM, MAC_FILTERED, IP_LESS_ROUTED, PHYSICAL_VLAN |
|
142 |
""" |
|
145 | 143 |
|
146 |
arguments = dict(shared=FlagArgument( |
|
147 |
'Network will be shared (special privileges required)', '--shared') |
|
144 |
arguments = dict( |
|
145 |
name=ValueArgument('Network name', '--name'), |
|
146 |
shared=FlagArgument( |
|
147 |
'Make network shared (special privileges required)', '--shared') |
|
148 | 148 |
) |
149 | 149 |
|
150 | 150 |
@errors.generic.all |
151 | 151 |
@errors.cyclades.connection |
152 |
def _run(self, name):
|
|
153 |
# admin_state_up is not used in Cyclades
|
|
152 |
@errors.cyclades.network_type
|
|
153 |
def _run(self, network_type):
|
|
154 | 154 |
net = self.client.create_network( |
155 |
name, shared=self['shared'])
|
|
155 |
network_type, name=self['name'], shared=self['shared'])
|
|
156 | 156 |
self._print(net, self.print_dict) |
157 | 157 |
|
158 |
def main(self, name):
|
|
158 |
def main(self, network_type):
|
|
159 | 159 |
super(self.__class__, self)._run() |
160 |
self._run(name=name)
|
|
160 |
self._run(network_type=network_type)
|
|
161 | 161 |
|
162 | 162 |
|
163 | 163 |
@command(network_cmds) |
... | ... | |
190 | 190 |
def _run(self, network_id): |
191 | 191 |
if self['name'] in (None, ): |
192 | 192 |
raise CLISyntaxError( |
193 |
'Missing network atrributes to update',
|
|
193 |
'Missing network attributes to update',
|
|
194 | 194 |
details=[ |
195 | 195 |
'At least one if the following is expected:', |
196 | 196 |
' --name=<new name>']) |
Also available in: Unified diff