Пример #1
0
 def get_parser(self, prog_name):
     parser = super(EditWorkspace, self).get_parser(prog_name)
     parser.add_argument(
         "--domain-type",
         choices=["LITE_AD", "LOCAL_AD"],
         required=True,
         help=_("LOCAL_AD - your local exists AD; "
                "LITE_AD - cloud lite AD"),
     )
     parser.add_argument(
         "--domain-admin-account",
         metavar="<account>",
         required=False,
         help=_("Optional When domain type is LOCAL_AD, "
                "domain-admin-account should be an exists "
                "admin account of LOCAL AD"),
     )
     parser.add_argument(
         "--old-domain-password",
         metavar="<password>",
         required=False,
         help=_("Current domain password "
                "(Required when domain type is LITE_AD)"),
     )
     parser.add_argument(
         "--domain-password",
         metavar="<password>",
         required=False,
         help=_("New domain password"),
     )
     return parser
 def add_hard_or_soft_arg(parser, required=True):
     force_reboot = parser.add_mutually_exclusive_group(required=required)
     force_reboot.add_argument('--hard',
                               action="store_true",
                               dest='force',
                               help=_("hard reboot"))
     force_reboot.add_argument('--soft',
                               action="store_false",
                               dest='force',
                               help=_("soft reboot"))
 def add_switch_arg(parser, name, required=False):
     group = parser.add_mutually_exclusive_group(required=required)
     group.add_argument('--enable-%s' % name,
                        action="store_true",
                        default=None,
                        dest='enable_%s' % name.replace("-", "_"),
                        help=_("enable %s" % name.replace("-", " ")))
     group.add_argument('--disable-%s' % name,
                        action="store_false",
                        default=None,
                        dest='enable_%s' % name.replace("-", "_"),
                        help=_("disable %s" % name.replace("-", " ")))
Пример #4
0
class ListLoginRecords(command.Lister):
    _description = _("list desktop login records")

    def get_parser(self, prog_name):
        parser = super(ListLoginRecords, self).get_parser(prog_name)
        pb.DesktopUser.add_start_time_option(parser)
        pb.DesktopUser.add_end_time_option(parser)
        pb.DesktopUser.add_user_name_option(parser)
        pb.DesktopUser.add_computer_name_option(parser)
        pb.DesktopUser.add_terminal_type_option(parser)
        bpb.BaseParser.add_offset_option(parser)
        bpb.BaseParser.add_limit_option(parser)
        return parser

    def take_action(self, args):
        client = self.app.client_manager.workspace

        kwargs = dict(start_time=args.start_time,
                      end_time=args.end_time,
                      user_name=args.user_name,
                      computer_name=args.computer_name,
                      terminal_type=args.terminal_type,
                      offset=args.offset,
                      limit=args.limit)
        records = client.desktop_users.list_login_records(**kwargs)
        columns = resource.DesktopLoginRecords.list_column_names
        outputs = [r.get_display_data(columns) for r in records]
        return columns, outputs
class ShowDesktop(command.ShowOne):
    _description = _("Show desktop detail")

    def get_parser(self, prog_name):
        parser = super(ShowDesktop, self).get_parser(prog_name)
        pb.Desktop.add_desktop_id_arg(parser, 'show')
        return parser

    def take_action(self, args):
        compute = self.app.client_manager.compute
        client = self.app.client_manager.workspace
        desktop = client.desktops.find(args.desktop_id)

        # replace security groups
        # sg_list = [utils.find_resource(compute.security_groups,
        #                                sg['id']).name
        #            for sg in desktop.security_groups]
        # desktop.security_groups = sg_list
        desktop.security_groups = [sg['id'] for sg in desktop.security_groups]

        addresses = []
        for address in six.itervalues(desktop.addresses):
            addresses += address
        desktop.addresses = addresses

        columns = resource.Desktop.show_column_names
        formatter = resource.Desktop.formatter
        return columns, desktop.get_display_data(columns, formatter=formatter)
 def add_vpc_option(parser):
     parser.add_argument(
         "--vpc",
         metavar="<vpc>",
         required=True,
         help=_("vpc to assign to workspace (UUID or Name)"),
     )
 def add_active_dns_ip_option(parser):
     parser.add_argument(
         "--active-dns-ip",
         metavar="<IP>",
         required=False,
         help=_("Required when domain type is LOCAL_AD"),
     )
 def add_standby_dns_ip_option(parser):
     parser.add_argument(
         "--standby-dns-ip",
         metavar="<IP>",
         required=False,
         help=_("Optional when domain type is LOCAL_AD"),
     )
 def add_user_mail_option(parser):
     parser.add_argument(
         "--user-email",
         metavar="<email>",
         required=True,
         help=_("User Mail to receive notification when desktop created"),
     )
 def add_display_level_arg(parser):
     parser.add_argument("--display-level",
                         choices=[
                             "SMOOTHNESS_FIRST",
                             "QUALITY_FIRST",
                         ],
                         help=_("display level"))
 def add_product_id_option(parser):
     parser.add_argument(
         "--product-id",
         metavar="<product-id>",
         required=True,
         help=_("desktop product id"),
     )
 def add_image_id_option(parser):
     parser.add_argument(
         "--image-id",
         metavar="<image-id>",
         required=False,
         help=_("desktop customer image id"),
     )
 def add_access_mode_option(parser):
     parser.add_argument(
         "--access-mode",
         required=True,
         choices=["INTERNET", "DEDICATED", "BOTH"],
         help=_("Access mode to connect to workspace"),
     )
 def add_file_redirection_mode_arg(parser):
     parser.add_argument("--file-redirection-mode",
                         choices=[
                             "DISABLED",
                             "READ_ONLY",
                             "READ_AND_WRITE",
                         ],
                         help=_("setup file redirection mode"))
 def add_domain_type_option(parser):
     parser.add_argument(
         "--domain-type",
         choices=["LITE_AD", "LOCAL_AD"],
         required=True,
         help=_("When LOCAL_AD, make sure LOCAL AD network and "
                "VPC network can access each other"),
     )
Пример #16
0
 def get_parser(self, prog_name):
     parser = super(ShowJob, self).get_parser(prog_name)
     parser.add_argument(
         "job_id",
         metavar="<job-id>",
         help=_("Job to show (ID)")
     )
     return parser
 def add_root_volume_option(parser):
     parser.add_argument(
         "--root-volume",
         metavar="<volume-type:volume-size>",
         required=True,
         type=parsetypes.volume_type,
         help=_("Desktop Root Volume, volume type [SSD|SATA], "
                "volume size unit is GB (example: SSD:80)"),
     )
 def add_computer_name_option(parser, required=False, help_text=None):
     default_help_text = _("list desktop with the user name")
     help_text = help_text if help_text else default_help_text
     parser.add_argument(
         "--computer-name",
         metavar="<computer-name>",
         required=required,
         help=help_text,
     )
 def add_clipboard_redirection_arg(parser):
     parser.add_argument("--clipboard-redirection",
                         choices=[
                             "DISABLED",
                             "SERVER_TO_CLIENT_ENABLED",
                             "CLIENT_TO_SERVER_ENABLED",
                             "TWO_WAY_ENABLED",
                         ],
                         help=_("setup clipboard redirection"))
 def add_printer_driver_arg(parser):
     parser.add_argument("--universal-printer-driver",
                         choices=[
                             "Default", "HDP XPSDrv Driver",
                             "Universal Printing PCL 5",
                             "Universal Printing PCL 6",
                             "Universal Printing PS"
                         ],
                         help=_("setup universal printer driver"))
 def add_domain_name_option(parser):
     parser.add_argument(
         "--domain-name",
         metavar="<domain-name>",
         required=True,
         help=_("When domain type is LOCAL_AD, domain-name should be an "
                "exists domain with max 255 length. when domain type is "
                "LITE AD, domain-name can only contains character, digit, "
                "- and ."),
     )
 def add_domain_admin_account_option(parser):
     parser.add_argument(
         "--domain-admin-account",
         metavar="<account>",
         required=True,
         help=_("When domain type is LOCAL_AD, domain-admin-account "
                "should be an exists admin account of LOCAL AD;"
                "when domain type is LITE AD, domain-admin-account "
                "should follow [a-zA-Z0-9-_] and start with character"),
     )
 def get_parser(self, prog_name):
     parser = super(EditDesktop, self).get_parser(prog_name)
     pb.Desktop.add_desktop_id_arg(parser, 'edit')
     computer_name_desc = _("Desktop Computer name (must be unique, "
                            "character [a-zA-Z0-9-_] allowed, start "
                            "with alphabet, length between 1-15)")
     pb.Desktop.add_computer_name_option(
         parser, True, computer_name_desc
     )
     return parser
Пример #24
0
class EditPolicy(command.Command):
    _description = _("edit policy")

    def get_parser(self, prog_name):
        parser = super(EditPolicy, self).get_parser(prog_name)
        # usb related
        pb.Policy.add_switch_arg(parser, 'usb-port-redirection')
        pb.Policy.add_switch_arg(parser, 'usb-image')
        pb.Policy.add_switch_arg(parser, 'usb-video')
        pb.Policy.add_switch_arg(parser, 'usb-printer')
        pb.Policy.add_switch_arg(parser, 'usb-storage')
        pb.Policy.add_switch_arg(parser, 'usb-smart-card')

        # printer related
        pb.Policy.add_switch_arg(parser, 'printer-redirection')
        pb.Policy.add_switch_arg(parser, 'sync-client-default-printer')
        pb.Policy.add_printer_driver_arg(parser)

        # file redirection related
        pb.Policy.add_file_redirection_mode_arg(parser)
        pb.Policy.add_switch_arg(parser, 'fixed-drive')
        pb.Policy.add_switch_arg(parser, 'removable-drive')
        pb.Policy.add_switch_arg(parser, 'cd-rom-drive')
        pb.Policy.add_switch_arg(parser, 'network-drive')

        # clipboard redirection
        pb.Policy.add_clipboard_redirection_arg(parser)

        # hdp plus
        pb.Policy.add_switch_arg(parser, 'hdp-plus')
        pb.Policy.add_display_level_arg(parser)
        pb.Policy.add_bandwidth_arg(parser)
        pb.Policy.add_frame_rate_arg(parser)
        pb.Policy.add_video_frame_rate_arg(parser)
        pb.Policy.add_smoothing_factor_arg(parser)
        pb.Policy.add_lossy_compression_quality_arg(parser)

        return parser

    def take_action(self, args):
        client = self.app.client_manager.workspace
        client.policies.edit(
            args.enable_usb_port_redirection, args.enable_usb_image,
            args.enable_usb_video, args.enable_usb_printer,
            args.enable_usb_storage, args.enable_usb_smart_card,
            args.enable_printer_redirection,
            args.enable_sync_client_default_printer,
            args.universal_printer_driver, args.file_redirection_mode,
            args.enable_fixed_drive, args.enable_removable_drive,
            args.enable_cd_rom_drive, args.enable_network_drive,
            args.clipboard_redirection, args.enable_hdp_plus,
            args.display_level, args.bandwidth, args.frame_rate,
            args.video_frame_rate, args.smoothing_factor,
            args.lossy_compression_quality)
        return 'done'
Пример #25
0
class DisableWorkspace(command.Command):
    _description = _("disable workspace")

    def get_parser(self, prog_name):
        parser = super(DisableWorkspace, self).get_parser(prog_name)
        return parser

    def take_action(self, args):
        client = self.app.client_manager.workspace
        job = client.workspaces.disable()
        return "Request Received, job id: %s" % job["job_id"]
 def add_domain_password_option(parser):
     parser.add_argument(
         "--domain-password",
         metavar="<password>",
         required=True,
         help=_("When domain type is LOCAL_AD, domain-password should be"
                " same with password of domain-admin-account;"
                "when domain type is LITE AD, domain-admin-account "
                "should follow [a-zA-Z0-9-_] and start with character with"
                "a length [8-64]"),
     )
 def add_security_group_option(parser):
     parser.add_argument(
         "--security-group",
         metavar="<security-group>",
         default=[],
         required=False,
         dest="security_groups",
         action='append',
         help=_('Security group to assign to this desktop (name or ID) '
                '(repeat option to set multiple security groups)'),
     )
 def add_subnets_option(parser):
     parser.add_argument(
         "--subnet",
         metavar="<subnet>",
         required=True,
         default=[],
         action='append',
         dest="subnets",
         help=_("Subnets to assign to workspace (UUID or Name). "
                "(Repeat option to set multiple subnet)"),
     )
 def add_nic_option(parser):
     parser.add_argument(
         "--nic",
         metavar="<subnet=subnet-uuid,ip=ip-address>",
         required=False,
         default=[],
         action='append',
         dest="nics",
         type=parsetypes.subnet_type,
         help=_("NIC to assign to this desktop. subnet is required, "
                "ip is optional. (Repeat option to set multiple NIC)"),
     )
 def add_data_volume_option(parser):
     parser.add_argument(
         "--data-volume",
         metavar="<volume-type:volume-size>",
         required=False,
         default=[],
         type=parsetypes.volume_type,
         dest="data_volumes",
         action='append',
         help=_("Desktop data Volume, volume type [SSD|SATA], "
                "volume size unit is GB (example: SSD:80). "
                "(Repeat option to set multiple data volumes.)"),
     )