Revision 61c2c62d

b/kamaki/cli/commands/cyclades.py
109 109
            timeout=timeout if current_status not in ('BUILD', ) else 100)
110 110

  
111 111

  
112
class _network_wait(_service_wait):
113

  
114
    def _wait(self, net_id, current_status, timeout=60):
115
        super(_network_wait, self)._wait(
116
            'Network', net_id, self.client.wait_network, current_status,
117
            timeout=timeout)
118

  
119

  
120
class _firewall_wait(_service_wait):
121

  
122
    def _wait(self, server_id, current_status, timeout=60):
123
        super(_firewall_wait, self)._wait(
124
            'Firewall of server',
125
            server_id, self.client.wait_firewall, current_status,
126
            timeout=timeout)
127

  
128

  
129 112
class _init_cyclades(_command_init):
130 113
    @errors.generic.all
131 114
    @addLogSettings
......
278 261

  
279 262
@command(server_cmds)
280 263
class server_info(_init_cyclades, _optional_json):
281
    """Detailed information on a Virtual Machine
282
    Contains:
283
    - name, id, status, create/update dates
284
    - network interfaces
285
    - metadata (e.g., os, superuser) and diagnostics
286
    - hardware flavor and os image ids
287
    """
264
    """Detailed information on a Virtual Machine"""
265

  
266
    arguments = dict(
267
        addr=FlagArgument(
268
            'Show only the network interfaces of this virtual server',
269
            '--nics'),
270
        vnc=FlagArgument(
271
            'Show VNC connection information (valid for a short period)',
272
            '--vnc-credentials'),
273
        stats=FlagArgument('Get URLs for server statistics', '--stats')
274
    )
288 275

  
289 276
    @errors.generic.all
290 277
    @errors.cyclades.connection
291 278
    @errors.cyclades.server_id
292 279
    def _run(self, server_id):
293 280
        vm = self.client.get_server_details(server_id)
294
        uuids = self._uuids2usernames([vm['user_id'], vm['tenant_id']])
295
        vm['user_id'] += ' (%s)' % uuids[vm['user_id']]
296
        vm['tenant_id'] += ' (%s)' % uuids[vm['tenant_id']]
297
        self._print(vm, self.print_dict)
281
        if self['addr']:
282
            self._print(vm.get('attachments', []))
283
        elif self['vnc']:
284
            self.error(
285
                '(!) For security reasons, the following credentials are '
286
                'invalidated\nafter a short time period, depending on the '
287
                'server settings\n')
288
            self._print(
289
                self.client.get_server_console(server_id), self.print_dict)
290
        elif self['stats']:
291
            self._print(
292
                self.client.get_server_stats(server_id), self.print_dict)
293
        else:
294
            uuids = self._uuids2usernames([vm['user_id'], vm['tenant_id']])
295
            vm['user_id'] += ' (%s)' % uuids[vm['user_id']]
296
            vm['tenant_id'] += ' (%s)' % uuids[vm['tenant_id']]
297
            self._print(vm, self.print_dict)
298 298

  
299 299
    def main(self, server_id):
300 300
        super(self.__class__, self)._run()
301
        choose_one = ('addr', 'vnc', 'stats')
302
        count = len([a for a in choose_one if self[a]])
303
        if count > 1:
304
            raise CLIInvalidArgument('Invalid argument compination', details=[
305
                'Arguments %s cannot be used simultaneously' % ', '.join(
306
                    [self.arguments[a].lvalue for a in choose_one])])
301 307
        self._run(server_id=server_id)
302 308

  
303 309

  
......
701 707

  
702 708

  
703 709
@command(server_cmds)
704
class server_console(_init_cyclades, _optional_json):
705
    """Get a VNC console to access an existing virtual server
706
    Console connection information provided (at least):
707
    - host: (url or address) a VNC host
708
    - port: (int) the gateway to enter virtual server on host
709
    - password: for VNC authorization
710
    """
710
class server_addr(_init_cyclades):
711
    """List network interfaces for a server (DEPRECATED, use /server info)"""
711 712

  
712
    @errors.generic.all
713
    @errors.cyclades.connection
714
    @errors.cyclades.server_id
715
    def _run(self, server_id):
716
        self._print(
717
            self.client.get_server_console(int(server_id)), self.print_dict)
718

  
719
    def main(self, server_id):
720
        super(self.__class__, self)._run()
721
        self._run(server_id=server_id)
713
    def main(self, *args):
714
        raiseCLIError('DEPRECATED', importance=3, details=[
715
            'Replaced by',
716
            '  [kamaki] server info <SERVER_ID> --nics'])
722 717

  
723 718

  
724 719
@command(server_cmds)
725
class server_addr(_init_cyclades, _optional_json):
726
    """List the addresses of all network interfaces on a virtual server"""
727

  
728
    arguments = dict(
729
        enum=FlagArgument('Enumerate results', '--enumerate')
730
    )
731

  
732
    @errors.generic.all
733
    @errors.cyclades.connection
734
    @errors.cyclades.server_id
735
    def _run(self, server_id):
736
        reply = self.client.list_server_nics(int(server_id))
737
        self._print(reply, with_enumeration=self['enum'] and (reply) > 1)
720
class server_console(_init_cyclades, _optional_json):
721
    """Get VNC console credentials (DEPRECATED, use /server info)"""
738 722

  
739
    def main(self, server_id):
740
        super(self.__class__, self)._run()
741
        self._run(server_id=server_id)
723
    def main(self, *args):
724
        raiseCLIError('DEPRECATED', importance=3, details=[
725
            'Replaced by',
726
            '  [kamaki] server info <SERVER_ID> --vnc-credentials'])
742 727

  
743 728

  
744 729
@command(server_cmds)
745 730
class server_stats(_init_cyclades, _optional_json):
746
    """Get virtual server statistics"""
731
    """Get URLs for server statistics (DEPRECATED, use /server info)"""
747 732

  
748
    @errors.generic.all
749
    @errors.cyclades.connection
750
    @errors.cyclades.server_id
751
    def _run(self, server_id):
752
        self._print(
753
            self.client.get_server_stats(int(server_id)), self.print_dict)
754

  
755
    def main(self, server_id):
756
        super(self.__class__, self)._run()
757
        self._run(server_id=server_id)
733
    def main(self, *args):
734
        raiseCLIError('DEPRECATED', importance=3, details=[
735
            'Replaced by',
736
            '  [kamaki] server info <SERVER_ID> --stats'])
758 737

  
759 738

  
760 739
@command(server_cmds)

Also available in: Unified diff