Skip to content
  • P
    Projects
  • G
    Groups
  • S
    Snippets
  • Help

CIRCLE / cloud

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 94
  • Merge Requests 10
  • Pipelines
  • Wiki
  • Snippets
  • Members
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Merged
Merge request !170 opened Aug 25, 2014 by Guba Sándor@gubasandor 
  • Report abuse
Report abuse

Custom Connect Command

  • Discussion 6
  • Commits 24
  • Changes
{{ resolvedDiscussionCount }}/{{ discussionCount }} {{ resolvedCountText }} resolved
  • Őry Máté
    @orymate started a discussion on an old version of the diff Sep 01, 2014
    circle/dashboard/forms.py
    1057 1059 return super(UserKeyForm, self).clean()
    1058 1060  
    1059 1061  
    1062 class ConnectCommandForm(forms.ModelForm):
    1063 class Meta:
    1064 fields = ('name', 'access_method', 'template')
    1065 model = ConnectCommand
    1066
    1067 @property
    1068 def helper(self):
    1069 helper = FormHelper()
    1070 helper.add_input(Submit("submit", _("Save")))
    1071 return helper
    1072
    1073 def __init__(self, *args, **kwargs):
    1074 self.user = kwargs.pop("user", None)
    • Őry Máté @orymate commented Sep 01, 2014
      Owner

      what's the semantics for None user?

      Edited Sep 02, 2014
      ~~what's the semantics for None user?~~
    Please register or sign in to reply
  • Őry Máté
    @orymate started a discussion on an old version of the diff Sep 01, 2014
    circle/dashboard/models.py
    104 class ConnectCommand(Model):
    105 user = ForeignKey(User, related_name='command_set')
    106 access_method = CharField(max_length=10, choices=ACCESS_METHODS,
    107 verbose_name=_('access method'),
    108 help_text=_('Type of the remote access method.'))
    109 name = CharField(max_length="128", verbose_name=_('name'), blank=False,
    110 help_text=_("Name of your custom command."))
    111 template = CharField(blank=True, null=True, max_length=256,
    112 verbose_name=_('command template'),
    113 help_text=_('Template for connection command string. '
    114 'Available parameters are: '
    115 'username, password, '
    116 'host, port, app. Example: sshpass '
    117 '-p %(password)s ssh -o '
    118 'StrictHostKeyChecking=no %(username)s@'
    119 '%(host)s -p %(port)s'))
    • Őry Máté @orymate commented Sep 01, 2014
      Owner

      You could add a validator to check if expanding an example dict raises any exceptions.

      Edited Sep 02, 2014
      ~~You could add a validator to check if expanding an example dict raises any exceptions.~~
    Please register or sign in to reply
  • Őry Máté
    @orymate started a discussion on the diff Sep 01, 2014
    circle/dashboard/models.py
    154 def get_connect_commands(self, instance, use_ipv6=False):
    155 """ Generate connection command based on template."""
    156 single_command = instance.get_connect_command(use_ipv6)
    157 if single_command: # can we even connect to that VM
    158 commands = self.user.command_set.filter(
    159 access_method=instance.access_method)
    160 if commands.count() < 1:
    161 return [single_command]
    162 else:
    163 return [
    164 command.template % {
    165 'port': instance.get_connect_port(use_ipv6=use_ipv6),
    166 'host': instance.get_connect_host(use_ipv6=use_ipv6),
    167 'password': instance.pw,
    168 'username': 'cloud',
    169 } for command in commands]
    • Őry Máté @orymate commented Sep 01, 2014
      Owner

      What happens if template is wrong?

      Edited Sep 02, 2014
      ~~What happens if template is wrong?~~
    Please register or sign in to reply
  • Őry Máté
    @orymate started a discussion on an old version of the diff Sep 01, 2014
    circle/dashboard/tables.py
    272 )
    273 actions = TemplateColumn(
    274 verbose_name=_("Actions"),
    275 template_name=("dashboard/connect-command-list/column-command"
    276 "-actions.html"),
    277 orderable=False,
    278 )
    279
    280 class Meta:
    281 model = ConnectCommand
    282 attrs = {'class': ('table table-bordered table-striped table-hover'),
    283 'id': "profile-command-list-table"}
    284 fields = ('name', 'access_method', 'template', 'actions')
    285 prefix = "cmd-"
    286 empty_text = _("You don't have any custom connection string, the "
    287 "default ones will be used.")
    • Őry Máté @orymate commented Sep 01, 2014
      Owner

      There should be some description about what is a connection command.

      Edited Sep 03, 2014
      ~~There should be some description about what is a connection command.~~
    Please register or sign in to reply
  • Őry Máté
    @orymate started a discussion on an old version of the diff Sep 01, 2014
    Last updated by Kálmán Viktor Sep 01, 2014
    circle/dashboard/templates/dashboard/connect-command-edit.html
    1 {% extends "dashboard/base.html" %}
    2 {% load i18n %}
    3 {% load sizefieldtags %}
    • Őry Máté @orymate commented Sep 01, 2014
      Owner

      ?

      Edited Sep 02, 2014
      ~~?~~
    • Kálmán Viktor @kviktor commented Sep 01, 2014
      Owner

      🐕

      :dog2:
    Please register or sign in to reply
  • Write
  • Preview
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment
Kálmán Viktor
Assignee
Kálmán Viktor @kviktor
Assign to
None
Milestone
None
Assign milestone
Time tracking
0
Labels
None
Assign labels
  • View labels
3
3 participants
Reference: circle/cloud!170