Ejemplo n.º 1
0
    def get_options(self):
        blocking_hlp = "If it is set Scalr Agent will wait for your Script to finish \
        executing before firing and processing further events."

        blocking = click.Option(('--blocking', 'blocking'),
                                is_flag=True,
                                default=False,
                                help=blocking_hlp)

        server_id_hlp = "Identifier of the Server"
        server_id = click.Option(('--serverId', 'serverId'),
                                 required=True,
                                 help=server_id_hlp)

        timeout_hlp = "How many secconds should Scalr Agent wait before aborting the execution of this Script."
        timeout = click.Option(('--timeout', 'timeout'),
                               required=False,
                               help=timeout_hlp)

        nowait_hlp = "Do not wait for script execution to finish"
        nowait = click.Option(('--nowait', 'nowait'),
                              required=False,
                              help=nowait_hlp)

        options = [blocking, server_id, timeout, nowait]
        options.extend(super(ExecuteScript, self).get_options())
        return options
Ejemplo n.º 2
0
 def get_options(self):
     hlp = "The suggested replacement RoleID for the current Role."
     replacement = click.Option(('--replacement', 'replacement'), required=False, help=hlp)
     state_hlp = "The deprecation state to set on the Role."
     state = click.Option(
         ('--state', 'state'), type=click.Choice(['DEPRECATED', 'ACTIVE']), required=True,help=state_hlp)
     options = [replacement, state]
     options.extend(super(RoleDeprecate, self).get_options())
     return options
Ejemplo n.º 3
0
 def get_options(self):
     nowait_hlp = "Do not wait for server to resume"
     nowait = click.Option(('--nowait', 'nowait'),
                           is_flag=True,
                           required=False,
                           help=nowait_hlp)
     hlp = "Launch a new Server for the specified Farm Role."
     farm_role_id = click.Option(('--farmRoleId', 'farm_role_id'),
                                 required=True,
                                 help=hlp)
     options = [farm_role_id, nowait]
     options.extend(super(LaunchServerAlias, self).get_options())
     return options
Ejemplo n.º 4
0
    def get_options(self):
        hlp = "The ID of a new image"
        newimageid = click.Option(('--newImageId', 'newimageid'),
                                  required=True,
                                  help=hlp)
        deprecation_help = "If the value is true Scalr will mark source Image as deprecated."
        deprecate = click.Option(('--deprecateOldImage', 'deprecate'),
                                 help=deprecation_help,
                                 is_flag=True,
                                 default=False)

        options = [newimageid, deprecate]
        options.extend(super(ReplaceImageUser, self).get_options())
        return options
Ejemplo n.º 5
0
 def get_options(self):
     nowait_hlp = "Do not wait for server to reach 'terminated' state"
     nowait = click.Option(('--nowait', 'nowait'),
                           is_flag=True,
                           required=False,
                           help=nowait_hlp)
     hlp = "It is used to terminate the Server immediately ignoring scalr.system.server_terminate_timeout."
     force_terminate = click.Option(('--force', 'force'),
                                    is_flag=True,
                                    default=False,
                                    help=hlp)
     options = [force_terminate, nowait]
     options.extend(super(TerminateServer, self).get_options())
     return options
Ejemplo n.º 6
0
    def get_options(self):
        alias_hlp = "New alias name for the FarmRole being cloned."
        alias = click.Option(('--alias', 'alias'),
                             required=True,
                             help=alias_hlp)

        farm_hlp = "Identifier of the Farm to clone into. If omitted, current Farm is a target to clone the FarmRole."
        farm_id = click.Option(('--farmId', 'farm_id'),
                               required=False,
                               help=farm_hlp)

        options = [alias, farm_id]
        options.extend(super(FarmRoleClone, self).get_options())
        return options
Ejemplo n.º 7
0
    def get_options(self):
        comment = click.Option(('--lockComment', 'comment'),
                               default="",
                               help="Comment to lock a Farm.")
        hlp = "If you would like to prevent other users unlocking the Farm you should set 'owner' options.\
                  With 'team' options only members of the Farm's Teams can unlock this Farm.\
                  Default value 'anyone' means that anyone with access can unlock this Farm."

        unlock_permission = click.Option(
            ('--unlockPermission', 'unlock_permission'),
            default="anyone",
            show_default=True,
            help=hlp)
        options = [comment, unlock_permission]
        options.extend(super(FarmLock, self).get_options())
        return options
Ejemplo n.º 8
0
    def _get_default_options(self):
        default_options = super(Fire, self)._get_default_options()

        server_id = click.Option(('--serverId', 'serverId'),
                                 required=True,
                                 help="Identifier of the Server")
        default_options.append(server_id)
        return default_options
Ejemplo n.º 9
0
 def get_options(self):
     profile_arg = click.Argument(('profile', ), required=False)  # [ST-30]
     hlp = 'Add API credentials for Global scope'
     admin_opt = click.Option(('--with-global-scope', 'admin'),
                              required=False,
                              is_flag=True,
                              help=hlp)
     return [profile_arg, admin_opt]
Ejemplo n.º 10
0
    def get_options(self):
        nowait_hlp = "Do not wait for server to resume after soft reboot"
        nowait = click.Option(('--nowait', 'nowait'),
                              is_flag=True,
                              required=False,
                              help=nowait_hlp)
        hlp = "Reboot type. By default the command requests soft reboot unless this \
        option is present. Beware that some types of the instances do \
        not support soft reboot."

        hard_reboot = click.Option(('--hard', 'hard'),
                                   is_flag=True,
                                   default=False,
                                   help=hlp)
        options = [hard_reboot, nowait]
        options.extend(super(RebootServer, self).get_options())
        return options
Ejemplo n.º 11
0
 def get_options(self):
     hlp = "The name of a new Farm."
     name = click.Option(('--name', 'name'), required=True, help=hlp)
     options = [
         name,
     ]
     options.extend(super(FarmClone, self).get_options())
     return options
Ejemplo n.º 12
0
 def _get_custom_options(self):
     # Disable output modifiers
     options = []
     debug = click.Option(('--debug', 'debug'),
                          is_flag=True,
                          default=False,
                          help="Print debug messages")
     options.append(debug)
     return options
Ejemplo n.º 13
0
 def get_options(self):
     hlp = "The ID of a new image"
     newimageid = click.Option(('--newImageId', 'newimageid'),
                               required=True,
                               help=hlp)
     deprecation_help = "If the value is true Scalr will mark source Image as deprecated."
     deprecate = click.Option(('--deprecateOldImage', 'deprecate'),
                              help=deprecation_help,
                              is_flag=True,
                              default=False)
     scope_help = "Make a replacement for all Roles from the selected scopes. "
     scope_help += "If you choose to make a replacement including lower scope higher scope values will be chosen too"
     scope = click.Option(('--scope', 'scope'),
                          default=self._default_scope,
                          help=scope_help)
     options = [newimageid, deprecate, scope]
     options.extend(super(ReplaceImageAccount, self).get_options())
     return options
Ejemplo n.º 14
0
 def get_options(self):
     debug = click.Option(('--debug', 'debug'),
                          is_flag=True,
                          default=False,
                          help="Print debug messages")
     envid = click.Option(('--envId', 'env_id'), help="Environment ID")
     upd_helpmsg = "Update existing object instead of creating new."
     update = click.Option(('--update', 'update'),
                           is_flag=True,
                           default=False,
                           help=upd_helpmsg,
                           hidden=True)
     dry_run = click.Option(('--dryrun', 'dryrun'),
                            is_flag=True,
                            default=False,
                            help=upd_helpmsg,
                            hidden=True)
     return [debug, update, envid, dry_run]
Ejemplo n.º 15
0
 def _get_default_options(self):
     options = []
     for param in self._get_raw_params():
         option = click.Option(
             ('--{}'.format(param['name']), param['name']),
             required=param['required'],
             help=param['description'])
         options.append(option)
     return options
Ejemplo n.º 16
0
 def get_options(self):
     hlp = "The ID of a new image"
     imageid = click.Option(('--imageId', 'imageId'),
                            required=True,
                            help=hlp)
     options = [
         imageid,
     ]
     options.extend(super(CreateRoleImage, self).get_options())
     return options
Ejemplo n.º 17
0
 def get_options(self):
     hlp = "Launch a new Server for the specified Farm Role."
     farm_role_id = click.Option(('--farmRoleId', 'farm_role_id'),
                                 required=True,
                                 help=hlp)
     options = [
         farm_role_id,
     ]
     options.extend(super(LaunchServerAlias, self).get_options())
     return options
Ejemplo n.º 18
0
 def get_options(self):
     hlp = "The ID of a new image"
     newimageid = click.Option(('--newImageId', 'newimageid'),
                               required=True,
                               help=hlp)
     options = [
         newimageid,
     ]
     options.extend(super(ReplaceRoleImage, self).get_options())
     return options
Ejemplo n.º 19
0
 def get_options(self):
     hlp = "It is used to terminate the Server immediately ignoring scalr.system.server_terminate_timeout."
     force_terminate = click.Option(('--force', 'force'),
                                    is_flag=True,
                                    default=False,
                                    help=hlp)
     options = [
         force_terminate,
     ]
     options.extend(super(FarmTerminate, self).get_options())
     return options
Ejemplo n.º 20
0
 def get_options(self):
     nowait_hlp = "Do not wait for server to resume"
     nowait = click.Option(('--nowait', 'nowait'),
                           is_flag=True,
                           required=False,
                           help=nowait_hlp)
     options = [
         nowait,
     ]
     options.extend(super(ResumeServer, self).get_options())
     return options
Ejemplo n.º 21
0
 def get_options(self):
     hlp = """Modify the Instance type of the Server. Server status before this
     action depends on CloudPlatform: - For EC2 and OpenStack instance type change
     requires server status "suspended". - For VMware instance type change requires
     server status "running" or "suspended"."""
     instance_type = click.Option(('--instanceType', 'instance_type'),
                                  required=True,
                                  help=hlp)
     options = [
         instance_type,
     ]
     options.extend(super(ServerChangeInstanceType, self).get_options())
     return options
Ejemplo n.º 22
0
    def get_options(self):
        hlp = "Reboot type. By default it does soft reboot unless this \
        option is set to true. Beware that some types of the instances do \
        not support soft reboot."

        hard_reboot = click.Option(('--hard', 'hard'),
                                   is_flag=True,
                                   default=False,
                                   help=hlp)
        options = [
            hard_reboot,
        ]
        options.extend(super(RebootServer, self).get_options())
        return options
Ejemplo n.º 23
0
 def get_options(self):
     profile_arg = click.Argument(('profile', ), required=False)  # [ST-30]
     admin_opt = click.Option(('--with-global-scope', 'admin'),
                              required=False,
                              is_flag=True)
     return [profile_arg, admin_opt]
Ejemplo n.º 24
0
    def _get_custom_options(self):
        options = []

        if self.http_method.upper() in ('POST', 'PATCH'):
            stdin = click.Option(('--stdin', 'stdin'),
                                 is_flag=True,
                                 required=False,
                                 help="Read JSON data from standart console "
                                 "input instead of editing it in the "
                                 "default console text editor.")
            options.append(stdin)
            """
            interactive = click.Option(('--interactive', 'interactive'),
                                       is_flag=True, required=False,
                                       help="Edit JSON data in the default "
                                            "console text editor before "
                                            "sending POST request to server.")
            options.append(interactive)
            """

        if self.http_method.upper() == 'GET':
            if self._returns_iterable():
                maxres = click.Option(('--max-results', 'maxResults'),
                                      type=int,
                                      required=False,
                                      help="Maximum number of records. "
                                      "Example: --max-results=2")
                options.append(maxres)

                pagenum = click.Option(('--page-number', 'pageNum'),
                                       type=int,
                                       required=False,
                                       help="Current page "
                                       "number. Example: --page-number=3")
                options.append(pagenum)

                filters = self._get_available_filters()
                if filters:
                    filters = sorted(filters)
                    filter_help = ("Apply filters. Example: type=ebs,size=8."
                                   "Available filters: {}.").format(
                                       ', '.join(filters))
                    filters = click.Option(('--filters', 'filters'),
                                           required=False,
                                           help=filter_help)
                    options.append(filters)

                columns_help = ("Filter columns in table view "
                                "[--table required]. Example: NAME,SIZE,"
                                "SCOPE. Available columns: {}.").format(
                                    ', '.join(self._get_column_names()))
                columns = click.Option(('--columns', 'columns'),
                                       required=False,
                                       help=columns_help)
                options.append(columns)

            raw = click.Option(('--raw', 'transformation'),
                               is_flag=True,
                               flag_value='raw',
                               default=False,
                               hidden=True,
                               help="Print raw response")
            json_ = click.Option(('--json', 'transformation'),
                                 is_flag=True,
                                 flag_value='raw',
                                 default=False,
                                 help="Print raw response")
            xml = click.Option(('--xml', 'transformation'),
                               is_flag=True,
                               flag_value='xml',
                               default=False,
                               help="Print response as a XML")
            tree = click.Option(('--tree', 'transformation'),
                                is_flag=True,
                                flag_value='tree',
                                default=False,
                                help="Print response as a colored tree")
            nocolor = click.Option(('--nocolor', 'nocolor'),
                                   is_flag=True,
                                   default=False,
                                   help="Use colors")
            options += [raw, tree, nocolor, json_, xml]

            if self.name not in ('get', 'retrieve'):  # [ST-54] [ST-102]
                table = click.Option(('--table', 'transformation'),
                                     is_flag=True,
                                     flag_value='table',
                                     default=False,
                                     help="Print response as a colored table")
                options.append(table)

        debug = click.Option(('--debug', 'debug'),
                             is_flag=True,
                             default=False,
                             help="Print debug messages")
        options.append(debug)

        return options
Ejemplo n.º 25
0
 def get_options(self):
     hlp = "The name of a new Role."
     new_name = click.Option(('--name', 'name'), required=True, help=hlp)
     options = [new_name, ]
     options.extend(super(RolePromote, self).get_options())
     return options