X-Git-Url: https://code.grnet.gr/git/kamaki/blobdiff_plain/62c6652ff43441f355e4d2b2ff25762e16795811..447365fed9f963177ccbe40f6b96e2a70a4d861b:/kamaki/cli/commands/network.py diff --git a/kamaki/cli/commands/network.py b/kamaki/cli/commands/network.py index 2e943c0..459f453 100644 --- a/kamaki/cli/commands/network.py +++ b/kamaki/cli/commands/network.py @@ -362,3 +362,80 @@ class subnet_set(_init_network, _optional_json): def main(self, subnet_id): super(self.__class__, self)._run() self._run(subnet_id=subnet_id) + + +@command(port_cmds) +class port_info(_init_network, _optional_json): + """Get details about a port""" + + @errors.generic.all + @errors.cyclades.connection + def _run(self, port_id): + net = self.client.get_port_details(port_id) + self._print(net, self.print_dict) + + def main(self, port_id): + super(self.__class__, self)._run() + self._run(port_id=port_id) + + +@command(port_cmds) +class port_info(_init_network, _optional_json): + """Get details about a port""" + + @errors.generic.all + @errors.cyclades.connection + def _run(self, port_id): + net = self.client.get_port_details(port_id) + self._print(net, self.print_dict) + + def main(self, port_id): + super(self.__class__, self)._run() + self._run(port_id=port_id) + + +@command(port_cmds) +class port_delete(_init_network, _optional_output_cmd): + """Delete a port""" + + @errors.generic.all + @errors.cyclades.connection + def _run(self, port_id): + r = self.client.delete_port(port_id) + self._optional_output(r) + + def main(self, port_id): + super(self.__class__, self)._run() + self._run(port_id=port_id) + + +@command(port_cmds) +class port_set(_init_network, _optional_json): + """Set an attribute of a port, leave the rest untouched (update) + Only "--name" is supported for now + """ + + arguments = dict(name=ValueArgument('New name of the port', '--name')) + + @errors.generic.all + @errors.cyclades.connection + def _run(self, port_id): + if self['name'] in (None, ): + raise CLISyntaxError( + 'Missing port attributes to update', + details=[ + 'At least one if the following is expected:', + ' --name=']) + r = self.client.get_port_details(port_id) + r = self.client.update_port( + port_id, r['network_id'], name=self['name']) + self._print(r, self.print_dict) + + def main(self, port_id): + super(self.__class__, self)._run() + self._run(port_id=port_id) + + +#@command(port_cmds) +#class port_create(_init_network, _optional_json): +#