Skip to content

Commit

Permalink
Support more console types in "server console" cmd
Browse files Browse the repository at this point in the history
Fixes grnet#36
  • Loading branch information
saxtouri committed Jul 25, 2014
1 parent 06ace38 commit 639df36
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion kamaki/cli/cmds/cyclades.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,16 +829,45 @@ def main(self, server_id):
self._run(server_id=server_id)


class ConsoleTypeArgument(ValueArgument):

@property
def value(self):
return getattr(self, '_value', None)

@value.setter
def value(self, new_value):
if new_value:
v = new_value.lower()
if v in CycladesComputeClient.CONSOLE_TYPES:
self._value = v
else:
raise CLIInvalidArgument(
'Invalid console type %s' % new_value, details=[
'Valid console types: %s' % (
', '.join(CycladesComputeClient.CONSOLE_TYPES)), ])


@command(server_cmds)
class server_console(_CycladesInit, OptionalOutput):
"""Create a VMC console and show connection information"""

arguments = dict(
console_type=ConsoleTypeArgument(
'Valid values: %s Default: %s' % (
', '.join(CycladesComputeClient.CONSOLE_TYPES),
CycladesComputeClient.CONSOLE_TYPES[0]),
'--type'),
)

@errors.Generic.all
@errors.Cyclades.connection
@errors.Cyclades.server_id
def _run(self, server_id):
self.error('The following credentials will be invalidated shortly')
self.print_(self.client.get_server_console(server_id), self.print_dict)
ctype = self['console_type'] or CycladesComputeClient.CONSOLE_TYPES[0]
self.print_(
self.client.get_server_console(server_id, ctype), self.print_dict)

def main(self, server_id):
super(self.__class__, self)._run()
Expand Down

0 comments on commit 639df36

Please sign in to comment.