Revision 447365fe kamaki/cli/commands/network.py

b/kamaki/cli/commands/network.py
362 362
    def main(self, subnet_id):
363 363
        super(self.__class__, self)._run()
364 364
        self._run(subnet_id=subnet_id)
365

  
366

  
367
@command(port_cmds)
368
class port_info(_init_network, _optional_json):
369
    """Get details about a port"""
370

  
371
    @errors.generic.all
372
    @errors.cyclades.connection
373
    def _run(self, port_id):
374
        net = self.client.get_port_details(port_id)
375
        self._print(net, self.print_dict)
376

  
377
    def main(self, port_id):
378
        super(self.__class__, self)._run()
379
        self._run(port_id=port_id)
380

  
381

  
382
@command(port_cmds)
383
class port_info(_init_network, _optional_json):
384
    """Get details about a port"""
385

  
386
    @errors.generic.all
387
    @errors.cyclades.connection
388
    def _run(self, port_id):
389
        net = self.client.get_port_details(port_id)
390
        self._print(net, self.print_dict)
391

  
392
    def main(self, port_id):
393
        super(self.__class__, self)._run()
394
        self._run(port_id=port_id)
395

  
396

  
397
@command(port_cmds)
398
class port_delete(_init_network, _optional_output_cmd):
399
    """Delete a port"""
400

  
401
    @errors.generic.all
402
    @errors.cyclades.connection
403
    def _run(self, port_id):
404
        r = self.client.delete_port(port_id)
405
        self._optional_output(r)
406

  
407
    def main(self, port_id):
408
        super(self.__class__, self)._run()
409
        self._run(port_id=port_id)
410

  
411

  
412
@command(port_cmds)
413
class port_set(_init_network, _optional_json):
414
    """Set an attribute of a port, leave the rest untouched (update)
415
    Only "--name" is supported for now
416
    """
417

  
418
    arguments = dict(name=ValueArgument('New name of the port', '--name'))
419

  
420
    @errors.generic.all
421
    @errors.cyclades.connection
422
    def _run(self, port_id):
423
        if self['name'] in (None, ):
424
            raise CLISyntaxError(
425
                'Missing port attributes to update',
426
                details=[
427
                    'At least one if the following is expected:',
428
                    '  --name=<new name>'])
429
        r = self.client.get_port_details(port_id)
430
        r = self.client.update_port(
431
            port_id, r['network_id'], name=self['name'])
432
        self._print(r, self.print_dict)
433

  
434
    def main(self, port_id):
435
        super(self.__class__, self)._run()
436
        self._run(port_id=port_id)
437

  
438

  
439
#@command(port_cmds)
440
#class port_create(_init_network, _optional_json):
441
#

Also available in: Unified diff