def add_openstack_env(arg_parser):
    ''' Add OS_ environment variables to and argparse.ArgumentParser.'''

    arg_parser.add_argument('--os-username', metavar='<auth-user-name>',
        default=novaclient_utils.env('OS_USERNAME', 'NOVA_USERNAME'),
        help='Defaults to env[OS_USERNAME].')
    arg_parser.add_argument('--os_username', help=argparse.SUPPRESS)

    arg_parser.add_argument('--os-password', metavar='<auth-password>',
        default=novaclient_utils.env('OS_PASSWORD', 'NOVA_PASSWORD'),
        help='Defaults to env[OS_PASSWORD].')
    arg_parser.add_argument('--os_password', help=argparse.SUPPRESS)

    arg_parser.add_argument('--os-tenant-name', metavar='<auth-tenant-name>',
        default=novaclient_utils.env('OS_TENANT_NAME', 'NOVA_PROJECT_ID'),
        help='Defaults to env[OS_TENANT_NAME].')
    arg_parser.add_argument('--os_tenant_name', help=argparse.SUPPRESS)

    arg_parser.add_argument('--os-auth-url', metavar='<auth-url>',
        default=novaclient_utils.env('OS_AUTH_URL', 'NOVA_URL'),
        help='Defaults to env[OS_AUTH_URL].')
    arg_parser.add_argument('--os_auth_url', help=argparse.SUPPRESS)

    arg_parser.add_argument('--os-auth-token', metavar='<auth-token>',
        default=novaclient_utils.env('OS_AUTH_TOKEN', 'NOVA_AUTH_TOKEN'),
        help='Defaults to env[OS_AUTH_TOKEN].')
    arg_parser.add_argument('--os_auth_token', help=argparse.SUPPRESS)

    arg_parser.add_argument("--swift-auth-url", type=str)
    arg_parser.add_argument("--swift-username", type=str)
    arg_parser.add_argument("--swift-tenant", type=str)
    arg_parser.add_argument("--swift-password", type=str)
示例#2
0
    def _append_global_identity_args(self, parser, argv):
        # Register the CLI arguments that have moved to the session object.
        loading.register_session_argparse_arguments(parser)
        # Peek into argv to see if os-token was given,
        # in which case, the token auth plugin is what the user wants
        # else, we'll default to password
        default_auth_plugin = 'password'
        if "--os-token" in argv:
            default_auth_plugin = 'token'
        loading.register_auth_argparse_arguments(
            parser, argv, default=default_auth_plugin)

        parser.set_defaults(insecure=strutils.bool_from_string(
            utils.env('NOVACLIENT_INSECURE', default=False)))
        parser.set_defaults(os_auth_url=utils.env('OS_AUTH_URL', 'NOVA_URL'))

        parser.set_defaults(os_username=utils.env('OS_USERNAME',
                                                  'NOVA_USERNAME'))
        parser.set_defaults(os_password=utils.env('OS_PASSWORD',
                                                  'NOVA_PASSWORD'))
        parser.set_defaults(os_project_name=utils.env(
            'OS_PROJECT_NAME', 'OS_TENANT_NAME', 'NOVA_PROJECT_ID'))
        parser.set_defaults(os_project_id=utils.env(
            'OS_PROJECT_ID', 'OS_TENANT_ID'))
        parser.set_defaults(
            os_project_domain_id=utils.env('OS_PROJECT_DOMAIN_ID'))
        parser.set_defaults(
            os_project_domain_name=utils.env('OS_PROJECT_DOMAIN_NAME'))
        parser.set_defaults(
            os_user_domain_id=utils.env('OS_USER_DOMAIN_ID'))
        parser.set_defaults(
            os_user_domain_name=utils.env('OS_USER_DOMAIN_NAME'))
示例#3
0
    def _append_global_identity_args(self, parser, argv):
        # Register the CLI arguments that have moved to the session object.
        loading.register_session_argparse_arguments(parser)
        # Peek into argv to see if os-token was given,
        # in which case, the token auth plugin is what the user wants
        # else, we'll default to password
        default_auth_plugin = 'password'
        if "--os-token" in argv:
            default_auth_plugin = 'token'
        loading.register_auth_argparse_arguments(parser,
                                                 argv,
                                                 default=default_auth_plugin)

        parser.set_defaults(insecure=strutils.bool_from_string(
            utils.env('NOVACLIENT_INSECURE', default=False)))
        parser.set_defaults(os_auth_url=utils.env('OS_AUTH_URL', 'NOVA_URL'))

        parser.set_defaults(
            os_username=utils.env('OS_USERNAME', 'NOVA_USERNAME'))
        parser.set_defaults(
            os_password=utils.env('OS_PASSWORD', 'NOVA_PASSWORD'))
        parser.set_defaults(os_project_name=utils.env(
            'OS_PROJECT_NAME', 'OS_TENANT_NAME', 'NOVA_PROJECT_ID'))
        parser.set_defaults(
            os_project_id=utils.env('OS_PROJECT_ID', 'OS_TENANT_ID'))
        parser.set_defaults(
            os_project_domain_id=utils.env('OS_PROJECT_DOMAIN_ID'))
        parser.set_defaults(
            os_project_domain_name=utils.env('OS_PROJECT_DOMAIN_NAME'))
        parser.set_defaults(os_user_domain_id=utils.env('OS_USER_DOMAIN_ID'))
        parser.set_defaults(
            os_user_domain_name=utils.env('OS_USER_DOMAIN_NAME'))
示例#4
0
    def completion_cache(self, cache_type, obj_class, mode):
        """The completion cache for bash autocompletion.

        The completion cache store items that can be used for bash
        autocompletion, like UUIDs or human-friendly IDs.

        A resource listing will clear and repopulate the cache.

        A resource create will append to the cache.

        Delete is not handled because listings are assumed to be performed
        often enough to keep the cache reasonably up-to-date.
        """
        # NOTE(wryan): This lock protects read and write access to the
        # completion caches
        with self.cache_lock:
            base_dir = utils.env('NOVACLIENT_UUID_CACHE_DIR',
                                 default="~/.novaclient")

            # NOTE(sirp): Keep separate UUID caches for each username +
            # endpoint pair
            username = utils.env('OS_USERNAME', 'NOVA_USERNAME')
            url = utils.env('OS_URL', 'NOVA_URL')
            uniqifier = hashlib.md5(
                username.encode('utf-8') + url.encode('utf-8')).hexdigest()

            cache_dir = os.path.expanduser(os.path.join(base_dir, uniqifier))

            try:
                os.makedirs(cache_dir, 0o755)
            except OSError:
                # NOTE(kiall): This is typically either permission denied while
                #              attempting to create the directory, or the
                #              directory already exists. Either way, don't
                #              fail.
                pass

            resource = obj_class.__name__.lower()
            filename = "%s-%s-cache" % (resource, cache_type.replace('_', '-'))
            path = os.path.join(cache_dir, filename)

            cache_attr = "_%s_cache" % cache_type

            try:
                setattr(self, cache_attr, open(path, mode))
            except IOError:
                # NOTE(kiall): This is typically a permission denied while
                #              attempting to write the cache file.
                pass

            try:
                yield
            finally:
                cache = getattr(self, cache_attr, None)
                if cache:
                    cache.close()
                    delattr(self, cache_attr)
示例#5
0
    def completion_cache(self, cache_type, obj_class, mode):
        """The completion cache for bash autocompletion.

        The completion cache store items that can be used for bash
        autocompletion, like UUIDs or human-friendly IDs.

        A resource listing will clear and repopulate the cache.

        A resource create will append to the cache.

        Delete is not handled because listings are assumed to be performed
        often enough to keep the cache reasonably up-to-date.
        """
        # NOTE(wryan): This lock protects read and write access to the
        # completion caches
        with self.cache_lock:
            base_dir = utils.env('NOVACLIENT_UUID_CACHE_DIR',
                                 default="~/.novaclient")

            # NOTE(sirp): Keep separate UUID caches for each username +
            # endpoint pair
            username = utils.env('OS_USERNAME', 'NOVA_USERNAME')
            url = utils.env('OS_URL', 'NOVA_URL')
            uniqifier = hashlib.md5(username.encode('utf-8') +
                                    url.encode('utf-8')).hexdigest()

            cache_dir = os.path.expanduser(os.path.join(base_dir, uniqifier))

            try:
                os.makedirs(cache_dir, 0o755)
            except OSError:
                # NOTE(kiall): This is typically either permission denied while
                #              attempting to create the directory, or the
                #              directory already exists. Either way, don't
                #              fail.
                pass

            resource = obj_class.__name__.lower()
            filename = "%s-%s-cache" % (resource, cache_type.replace('_', '-'))
            path = os.path.join(cache_dir, filename)

            cache_attr = "_%s_cache" % cache_type

            try:
                setattr(self, cache_attr, open(path, mode))
            except IOError:
                # NOTE(kiall): This is typically a permission denied while
                #              attempting to write the cache file.
                pass

            try:
                yield
            finally:
                cache = getattr(self, cache_attr, None)
                if cache:
                    cache.close()
                    delattr(self, cache_attr)
示例#6
0
    def _append_global_identity_args(self, parser):
        # Register the CLI arguments that have moved to the session object.
        ksession.Session.register_cli_options(parser)

        parser.set_defaults(
            insecure=utils.env('NOVACLIENT_INSECURE', default=False))

        identity.Password.register_argparse_arguments(parser)

        parser.set_defaults(
            os_username=utils.env('OS_USERNAME', 'NOVA_USERNAME'))
        parser.set_defaults(
            os_password=utils.env('OS_PASSWORD', 'NOVA_PASSWORD'))
        parser.set_defaults(os_auth_url=utils.env('OS_AUTH_URL', 'NOVA_URL'))
示例#7
0
 def password(self):
     if self._validate_string(self.args.os_password):
         return self.args.os_password
     if self._validate_string(self.args.apikey):
         return self.args.apikey
     verify_pass = utils.bool_from_str(utils.env("OS_VERIFY_PASSWORD"))
     return self._prompt_password(verify_pass)
示例#8
0
 def password(self):
     if self._validate_string(self.args.os_password):
         return self.args.os_password
     if self._validate_string(self.args.apikey):
         return self.args.apikey
     verify_pass = utils.bool_from_str(utils.env("OS_VERIFY_PASSWORD"))
     return self._prompt_password(verify_pass)
示例#9
0
 def _make_directory_name(self, username, auth_url):
     """Creates a unique directory name based on the auth_url and username
     of the current user.
     """
     uniqifier = hashlib.md5(
         username.encode('utf-8') + auth_url.encode('utf-8')).hexdigest()
     base_dir = utils.env('NOVACLIENT_UUID_CACHE_DIR',
                          default="~/.novaclient")
     return os.path.expanduser(os.path.join(base_dir, uniqifier))
示例#10
0
 def _make_directory_name(self, username, auth_url):
     """Creates a unique directory name based on the auth_url and username
     of the current user.
     """
     uniqifier = hashlib.md5(username.encode('utf-8') +
                             auth_url.encode('utf-8')).hexdigest()
     base_dir = utils.env('NOVACLIENT_UUID_CACHE_DIR',
                          default="~/.novaclient")
     return os.path.expanduser(os.path.join(base_dir, uniqifier))
示例#11
0
def add_openstack_env(arg_parser):
    ''' Add OS_ environment variables to and argparse.ArgumentParser.'''

    arg_parser.add_argument('--os-username',
                            metavar='<auth-user-name>',
                            default=novaclient_utils.env(
                                'OS_USERNAME', 'NOVA_USERNAME'),
                            help='Defaults to env[OS_USERNAME].')
    arg_parser.add_argument('--os_username', help=argparse.SUPPRESS)

    arg_parser.add_argument('--os-password',
                            metavar='<auth-password>',
                            default=novaclient_utils.env(
                                'OS_PASSWORD', 'NOVA_PASSWORD'),
                            help='Defaults to env[OS_PASSWORD].')
    arg_parser.add_argument('--os_password', help=argparse.SUPPRESS)

    arg_parser.add_argument('--os-tenant-name',
                            metavar='<auth-tenant-name>',
                            default=novaclient_utils.env(
                                'OS_TENANT_NAME', 'NOVA_PROJECT_ID'),
                            help='Defaults to env[OS_TENANT_NAME].')
    arg_parser.add_argument('--os_tenant_name', help=argparse.SUPPRESS)

    arg_parser.add_argument('--os-auth-url',
                            metavar='<auth-url>',
                            default=novaclient_utils.env(
                                'OS_AUTH_URL', 'NOVA_URL'),
                            help='Defaults to env[OS_AUTH_URL].')
    arg_parser.add_argument('--os_auth_url', help=argparse.SUPPRESS)

    arg_parser.add_argument('--os-auth-token',
                            metavar='<auth-token>',
                            default=novaclient_utils.env(
                                'OS_AUTH_TOKEN', 'NOVA_AUTH_TOKEN'),
                            help='Defaults to env[OS_AUTH_TOKEN].')
    arg_parser.add_argument('--os_auth_token', help=argparse.SUPPRESS)

    arg_parser.add_argument("--swift-auth-url", type=str)
    arg_parser.add_argument("--swift-username", type=str)
    arg_parser.add_argument("--swift-tenant", type=str)
    arg_parser.add_argument("--swift-password", type=str)
示例#12
0
 def password(self):
     # Cache password so we prompt user at most once
     if self._password:
         pass
     elif self._validate_string(self.args.os_password):
         self._password = self.args.os_password
     else:
         verify_pass = strutils.bool_from_string(utils.env("OS_VERIFY_PASSWORD", default=False), True)
         self._password = self._prompt_password(verify_pass)
     if not self._password:
         raise exc.CommandError(
             "Expecting a password provided via either " "--os-password, env[OS_PASSWORD], or " "prompted response"
         )
     return self._password
示例#13
0
 def password(self):
     # Cache password so we prompt user at most once
     if self._password:
         pass
     elif self._validate_string(self.args.os_password):
         self._password = self.args.os_password
     else:
         verify_pass = strutils.bool_from_string(
             utils.env("OS_VERIFY_PASSWORD", default=False), True)
         self._password = self._prompt_password(verify_pass)
     if not self._password:
         raise exc.CommandError('Expecting a password provided via either '
                                '--os-password, env[OS_PASSWORD], or '
                                'prompted response')
     return self._password
示例#14
0
    def get_base_parser(self):
        parser = NovaClientArgumentParser(
            prog="nova",
            description=__doc__.strip(),
            epilog='See "nova help COMMAND" ' "for help on a specific command.",
            add_help=False,
            formatter_class=OpenStackHelpFormatter,
        )

        # Global arguments
        parser.add_argument("-h", "--help", action="store_true", help=argparse.SUPPRESS)

        parser.add_argument("--debug", default=False, action="store_true", help="Print debugging output")

        parser.add_argument(
            "--no_cache",
            default=utils.env("OS_NO_CACHE", default=False),
            action="store_true",
            help="Don't use the auth token cache.",
        )

        parser.add_argument("--timings", default=False, action="store_true", help="Print call timing info")

        parser.add_argument(
            "--os_username", default=utils.env("OS_USERNAME", "NOVA_USERNAME"), help="Defaults to env[OS_USERNAME]."
        )

        parser.add_argument(
            "--os_password", default=utils.env("OS_PASSWORD", "NOVA_PASSWORD"), help="Defaults to env[OS_PASSWORD]."
        )

        parser.add_argument(
            "--os_tenant_name",
            default=utils.env("OS_TENANT_NAME", "NOVA_PROJECT_ID"),
            help="Defaults to env[OS_TENANT_NAME].",
        )

        parser.add_argument(
            "--os_auth_url", default=utils.env("OS_AUTH_URL", "NOVA_URL"), help="Defaults to env[OS_AUTH_URL]."
        )

        parser.add_argument(
            "--os_region_name",
            default=utils.env("OS_REGION_NAME", "NOVA_REGION_NAME"),
            help="Defaults to env[OS_REGION_NAME].",
        )

        parser.add_argument("--service_type", help="Defaults to compute for most actions")

        parser.add_argument(
            "--service_name", default=utils.env("NOVA_SERVICE_NAME"), help="Defaults to env[NOVA_SERVICE_NAME]"
        )

        parser.add_argument(
            "--volume_service_name",
            default=utils.env("NOVA_VOLUME_SERVICE_NAME"),
            help="Defaults to env[NOVA_VOLUME_SERVICE_NAME]",
        )

        parser.add_argument(
            "--endpoint_type",
            default=utils.env("NOVA_ENDPOINT_TYPE", default=DEFAULT_NOVA_ENDPOINT_TYPE),
            help="Defaults to env[NOVA_ENDPOINT_TYPE] or " + DEFAULT_NOVA_ENDPOINT_TYPE + ".",
        )

        parser.add_argument(
            "--os_compute_api_version",
            default=utils.env("OS_COMPUTE_API_VERSION", default=DEFAULT_OS_COMPUTE_API_VERSION),
            help="Accepts 1.1, defaults to env[OS_COMPUTE_API_VERSION].",
        )

        parser.add_argument(
            "--insecure",
            default=utils.env("NOVACLIENT_INSECURE", default=False),
            action="store_true",
            help='Explicitly allow novaclient to perform "insecure" '
            "SSL (https) requests. The server's certificate will "
            "not be verified against any certificate authorities. "
            "This option should be used with caution.",
        )

        # FIXME(dtroyer): The args below are here for diablo compatibility,
        #                 remove them in folsum cycle

        # alias for --os_username, left in for backwards compatibility
        parser.add_argument("--username", help="Deprecated")

        # alias for --os_region_name, left in for backwards compatibility
        parser.add_argument("--region_name", help="Deprecated")

        # alias for --os_password, left in for backwards compatibility
        parser.add_argument(
            "--apikey", "--password", dest="apikey", default=utils.env("NOVA_API_KEY"), help="Deprecated"
        )

        # alias for --os_tenant_name, left in for backward compatibility
        parser.add_argument(
            "--projectid", "--tenant_name", dest="projectid", default=utils.env("NOVA_PROJECT_ID"), help="Deprecated"
        )

        # alias for --os_auth_url, left in for backward compatibility
        parser.add_argument("--url", "--auth_url", dest="url", default=utils.env("NOVA_URL"), help="Deprecated")

        parser.add_argument(
            "--bypass_url", dest="bypass_url", help="Use this API endpoint instead of the Service Catalog"
        )

        return parser
示例#15
0
    def get_base_parser(self, argv):
        parser = NovaClientArgumentParser(
            prog='nova',
            description=__doc__.strip(),
            epilog='See "nova help COMMAND" '
                   'for help on a specific command.',
            add_help=False,
            formatter_class=OpenStackHelpFormatter,
        )

        # Global arguments
        parser.add_argument(
            '-h', '--help',
            action='store_true',
            help=argparse.SUPPRESS,
        )

        parser.add_argument('--version',
                            action='version',
                            version=novaclient.__version__)

        parser.add_argument(
            '--debug',
            default=False,
            action='store_true',
            help=_("Print debugging output."))

        parser.add_argument(
            '--os-cache',
            default=strutils.bool_from_string(
                utils.env('OS_CACHE', default=False), True),
            action='store_true',
            help=_("Use the auth token cache. Defaults to False if "
                   "env[OS_CACHE] is not set."))

        parser.add_argument(
            '--timings',
            default=False,
            action='store_true',
            help=_("Print call timing info."))

        parser.add_argument(
            '--os-region-name',
            metavar='<region-name>',
            default=utils.env('OS_REGION_NAME', 'NOVA_REGION_NAME'),
            help=_('Defaults to env[OS_REGION_NAME].'))

        parser.add_argument(
            '--service-type',
            metavar='<service-type>',
            help=_('Defaults to compute for most actions.'))

        parser.add_argument(
            '--service-name',
            metavar='<service-name>',
            default=utils.env('NOVA_SERVICE_NAME'),
            help=_('Defaults to env[NOVA_SERVICE_NAME].'))

        parser.add_argument(
            '--volume-service-name',
            action=DeprecatedAction,
            metavar='<volume-service-name>',
            default=utils.env('NOVA_VOLUME_SERVICE_NAME'),
            use=_('This option will be removed after Nova 15.0.0 is '
                  'released.'),
            help=argparse.SUPPRESS)

        parser.add_argument(
            '--os-endpoint-type',
            metavar='<endpoint-type>',
            dest='endpoint_type',
            default=utils.env(
                'NOVA_ENDPOINT_TYPE', default=utils.env(
                    'OS_ENDPOINT_TYPE',
                    default=DEFAULT_NOVA_ENDPOINT_TYPE)),
            help=_('Defaults to env[NOVA_ENDPOINT_TYPE], '
                   'env[OS_ENDPOINT_TYPE] or ') +
                 DEFAULT_NOVA_ENDPOINT_TYPE + '.')

        parser.add_argument(
            '--os-compute-api-version',
            metavar='<compute-api-ver>',
            default=utils.env('OS_COMPUTE_API_VERSION',
                              default=DEFAULT_OS_COMPUTE_API_VERSION),
            help=_('Accepts X, X.Y (where X is major and Y is minor part) or '
                   '"X.latest", defaults to env[OS_COMPUTE_API_VERSION].'))

        parser.add_argument(
            '--endpoint-override',
            metavar='<bypass-url>',
            dest='endpoint_override',
            default=utils.env('NOVACLIENT_ENDPOINT_OVERRIDE',
                              'NOVACLIENT_BYPASS_URL'),
            help=_("Use this API endpoint instead of the Service Catalog. "
                   "Defaults to env[NOVACLIENT_ENDPOINT_OVERRIDE]."))

        parser.add_argument(
            '--bypass-url',
            action=DeprecatedAction,
            use=_('use "%s"; this option will be removed after Pike OpenStack '
                  'release.') % '--os-endpoint-override',
            dest='endpoint_override',
            help=argparse.SUPPRESS)

        self._append_global_identity_args(parser, argv)

        return parser
示例#16
0
    def get_base_parser(self):
        parser = NovaClientArgumentParser(
            prog='nova',
            description=__doc__.strip(),
            epilog='See "nova help COMMAND" '
                   'for help on a specific command.',
            add_help=False,
            formatter_class=OpenStackHelpFormatter,
        )

        # Global arguments
        parser.add_argument('-h', '--help',
            action='store_true',
            help=argparse.SUPPRESS,
        )

        parser.add_argument('--version',
                            action='version',
                            version=novaclient.__version__)

        parser.add_argument('--debug',
            default=False,
            action='store_true',
            help=_("Print debugging output"))

        parser.add_argument('--os-cache',
            default=strutils.bool_from_string(
                utils.env('OS_CACHE', default=False), True),
            action='store_true',
            help=_("Use the auth token cache. Defaults to False if "
                   "env[OS_CACHE] is not set."))

        parser.add_argument('--timings',
            default=False,
            action='store_true',
            help=_("Print call timing info"))

        parser.add_argument('--os-auth-token',
                default=utils.env('OS_AUTH_TOKEN'),
                help='Defaults to env[OS_AUTH_TOKEN]')

        parser.add_argument('--os-username',
            metavar='<auth-user-name>',
            default=utils.env('OS_USERNAME', 'NOVA_USERNAME'),
            help=_('Defaults to env[OS_USERNAME].'))
        parser.add_argument('--os_username',
            help=argparse.SUPPRESS)

        parser.add_argument('--os-user-id',
            metavar='<auth-user-id>',
            default=utils.env('OS_USER_ID'),
            help=_('Defaults to env[OS_USER_ID].'))

        parser.add_argument('--os-password',
            metavar='<auth-password>',
            default=utils.env('OS_PASSWORD', 'NOVA_PASSWORD'),
            help=_('Defaults to env[OS_PASSWORD].'))
        parser.add_argument('--os_password',
            help=argparse.SUPPRESS)

        parser.add_argument('--os-tenant-name',
            metavar='<auth-tenant-name>',
            default=utils.env('OS_TENANT_NAME', 'NOVA_PROJECT_ID'),
            help=_('Defaults to env[OS_TENANT_NAME].'))
        parser.add_argument('--os_tenant_name',
            help=argparse.SUPPRESS)

        parser.add_argument('--os-tenant-id',
            metavar='<auth-tenant-id>',
            default=utils.env('OS_TENANT_ID'),
            help=_('Defaults to env[OS_TENANT_ID].'))

        parser.add_argument('--os-auth-url',
            metavar='<auth-url>',
            default=utils.env('OS_AUTH_URL', 'NOVA_URL'),
            help=_('Defaults to env[OS_AUTH_URL].'))
        parser.add_argument('--os_auth_url',
            help=argparse.SUPPRESS)

        parser.add_argument('--os-region-name',
            metavar='<region-name>',
            default=utils.env('OS_REGION_NAME', 'NOVA_REGION_NAME'),
            help=_('Defaults to env[OS_REGION_NAME].'))
        parser.add_argument('--os_region_name',
            help=argparse.SUPPRESS)

        parser.add_argument('--os-auth-system',
            metavar='<auth-system>',
            default=utils.env('OS_AUTH_SYSTEM'),
            help='Defaults to env[OS_AUTH_SYSTEM].')
        parser.add_argument('--os_auth_system',
            help=argparse.SUPPRESS)

        parser.add_argument('--service-type',
            metavar='<service-type>',
            help=_('Defaults to compute for most actions'))
        parser.add_argument('--service_type',
            help=argparse.SUPPRESS)

        parser.add_argument('--service-name',
            metavar='<service-name>',
            default=utils.env('NOVA_SERVICE_NAME'),
            help=_('Defaults to env[NOVA_SERVICE_NAME]'))
        parser.add_argument('--service_name',
            help=argparse.SUPPRESS)

        parser.add_argument('--volume-service-name',
            metavar='<volume-service-name>',
            default=utils.env('NOVA_VOLUME_SERVICE_NAME'),
            help=_('Defaults to env[NOVA_VOLUME_SERVICE_NAME]'))
        parser.add_argument('--volume_service_name',
            help=argparse.SUPPRESS)

        parser.add_argument('--os-endpoint-type',
            metavar='<endpoint-type>',
            dest='endpoint_type',
            default=utils.env('NOVA_ENDPOINT_TYPE',
                default=utils.env('OS_ENDPOINT_TYPE',
                    default=DEFAULT_NOVA_ENDPOINT_TYPE)),
            help=_('Defaults to env[NOVA_ENDPOINT_TYPE], '
                   'env[OS_ENDPOINT_TYPE] or ')
                 + DEFAULT_NOVA_ENDPOINT_TYPE + '.')

        parser.add_argument('--endpoint-type',
            help=argparse.SUPPRESS)
        # NOTE(dtroyer): We can't add --endpoint_type here due to argparse
        #                thinking usage-list --end is ambiguous; but it
        #                works fine with only --endpoint-type present
        #                Go figure.  I'm leaving this here for doc purposes.
        # parser.add_argument('--endpoint_type',
        #     help=argparse.SUPPRESS)

        parser.add_argument('--os-compute-api-version',
            metavar='<compute-api-ver>',
            default=utils.env('OS_COMPUTE_API_VERSION',
                default=DEFAULT_OS_COMPUTE_API_VERSION),
            help=_('Accepts 1.1 or 3, '
                 'defaults to env[OS_COMPUTE_API_VERSION].'))
        parser.add_argument('--os_compute_api_version',
            help=argparse.SUPPRESS)

        parser.add_argument('--bypass-url',
            metavar='<bypass-url>',
            dest='bypass_url',
            default=utils.env('NOVACLIENT_BYPASS_URL'),
            help="Use this API endpoint instead of the Service Catalog. "
                 "Defaults to env[NOVACLIENT_BYPASS_URL]")
        parser.add_argument('--bypass_url',
            help=argparse.SUPPRESS)

        # The auth-system-plugins might require some extra options
        novaclient.auth_plugin.load_auth_system_opts(parser)

        self._append_global_identity_args(parser)

        return parser
示例#17
0
    def get_base_parser(self, argv):
        parser = NovaClientArgumentParser(
            prog='nova',
            description=__doc__.strip(),
            epilog='See "nova help COMMAND" '
            'for help on a specific command.',
            add_help=False,
            formatter_class=OpenStackHelpFormatter,
        )

        # Global arguments
        parser.add_argument(
            '-h',
            '--help',
            action='store_true',
            help=argparse.SUPPRESS,
        )

        parser.add_argument('--version',
                            action='version',
                            version=novaclient.__version__)

        parser.add_argument('--debug',
                            default=False,
                            action='store_true',
                            help=_("Print debugging output."))

        parser.add_argument(
            '--os-cache',
            default=strutils.bool_from_string(
                utils.env('OS_CACHE', default=False), True),
            action='store_true',
            help=_("Use the auth token cache. Defaults to False if "
                   "env[OS_CACHE] is not set."))

        parser.add_argument('--timings',
                            default=False,
                            action='store_true',
                            help=_("Print call timing info."))

        parser.add_argument('--os-region-name',
                            metavar='<region-name>',
                            default=utils.env('OS_REGION_NAME',
                                              'NOVA_REGION_NAME'),
                            help=_('Defaults to env[OS_REGION_NAME].'))

        parser.add_argument('--os-auth-system',
                            metavar='<auth-system>',
                            default=utils.env('OS_AUTH_SYSTEM'),
                            help=argparse.SUPPRESS)

        parser.add_argument('--service-type',
                            metavar='<service-type>',
                            help=_('Defaults to compute for most actions.'))

        parser.add_argument('--service-name',
                            metavar='<service-name>',
                            default=utils.env('NOVA_SERVICE_NAME'),
                            help=_('Defaults to env[NOVA_SERVICE_NAME].'))

        parser.add_argument(
            '--volume-service-name',
            action=DeprecatedAction,
            metavar='<volume-service-name>',
            default=utils.env('NOVA_VOLUME_SERVICE_NAME'),
            use=_('This option will be removed after Nova 15.0.0 is '
                  'released.'),
            help=argparse.SUPPRESS)

        parser.add_argument('--os-endpoint-type',
                            metavar='<endpoint-type>',
                            dest='endpoint_type',
                            default=utils.env(
                                'NOVA_ENDPOINT_TYPE',
                                default=utils.env(
                                    'OS_ENDPOINT_TYPE',
                                    default=DEFAULT_NOVA_ENDPOINT_TYPE)),
                            help=_('Defaults to env[NOVA_ENDPOINT_TYPE], '
                                   'env[OS_ENDPOINT_TYPE] or ') +
                            DEFAULT_NOVA_ENDPOINT_TYPE + '.')

        parser.add_argument(
            '--os-compute-api-version',
            metavar='<compute-api-ver>',
            default=utils.env('OS_COMPUTE_API_VERSION',
                              default=DEFAULT_OS_COMPUTE_API_VERSION),
            help=_('Accepts X, X.Y (where X is major and Y is minor part) or '
                   '"X.latest", defaults to env[OS_COMPUTE_API_VERSION].'))

        parser.add_argument(
            '--bypass-url',
            metavar='<bypass-url>',
            dest='bypass_url',
            default=utils.env('NOVACLIENT_BYPASS_URL'),
            help=_("Use this API endpoint instead of the Service Catalog. "
                   "Defaults to env[NOVACLIENT_BYPASS_URL]."))

        # The auth-system-plugins might require some extra options
        novaclient.auth_plugin.load_auth_system_opts(parser)

        self._append_global_identity_args(parser, argv)

        return parser
示例#18
0
    def get_base_parser(self):
        parser = NovaClientArgumentParser(
            prog='nova',
            description=__doc__.strip(),
            epilog='See "nova help COMMAND" '
                   'for help on a specific command.',
            add_help=False,
            formatter_class=OpenStackHelpFormatter,
        )

        # Global arguments
        parser.add_argument('-h', '--help',
            action='store_true',
            help=argparse.SUPPRESS,
        )

        parser.add_argument('--version',
                            action='version',
                            version=novaclient.__version__)

        parser.add_argument('--debug',
            default=False,
            action='store_true',
            help=_("Print debugging output"))

        parser.add_argument('--os-cache',
            default=strutils.bool_from_string(
                utils.env('OS_CACHE', default=False), True),
            action='store_true',
            help=_("Use the auth token cache. Defaults to False if "
                   "env[OS_CACHE] is not set."))

        parser.add_argument('--timings',
            default=False,
            action='store_true',
            help=_("Print call timing info"))

        parser.add_argument('--timeout',
            default=600,
            metavar='<seconds>',
            type=positive_non_zero_float,
            help=_("Set HTTP call timeout (in seconds)"))

        parser.add_argument('--os-auth-token',
                default=utils.env('OS_AUTH_TOKEN'),
                help='Defaults to env[OS_AUTH_TOKEN]')

        parser.add_argument('--os-username',
            metavar='<auth-user-name>',
            default=utils.env('OS_USERNAME', 'NOVA_USERNAME'),
            help=_('Defaults to env[OS_USERNAME].'))
        parser.add_argument('--os_username',
            help=argparse.SUPPRESS)

        parser.add_argument('--os-user-id',
            metavar='<auth-user-id>',
            default=utils.env('OS_USER_ID'),
            help=_('Defaults to env[OS_USER_ID].'))

        parser.add_argument('--os-password',
            metavar='<auth-password>',
            default=utils.env('OS_PASSWORD', 'NOVA_PASSWORD'),
            help=_('Defaults to env[OS_PASSWORD].'))
        parser.add_argument('--os_password',
            help=argparse.SUPPRESS)

        parser.add_argument('--os-tenant-name',
            metavar='<auth-tenant-name>',
            default=utils.env('OS_TENANT_NAME', 'NOVA_PROJECT_ID'),
            help=_('Defaults to env[OS_TENANT_NAME].'))
        parser.add_argument('--os_tenant_name',
            help=argparse.SUPPRESS)

        parser.add_argument('--os-tenant-id',
            metavar='<auth-tenant-id>',
            default=utils.env('OS_TENANT_ID'),
            help=_('Defaults to env[OS_TENANT_ID].'))

        parser.add_argument('--os-auth-url',
            metavar='<auth-url>',
            default=utils.env('OS_AUTH_URL', 'NOVA_URL'),
            help=_('Defaults to env[OS_AUTH_URL].'))
        parser.add_argument('--os_auth_url',
            help=argparse.SUPPRESS)

        parser.add_argument('--os-region-name',
            metavar='<region-name>',
            default=utils.env('OS_REGION_NAME', 'NOVA_REGION_NAME'),
            help=_('Defaults to env[OS_REGION_NAME].'))
        parser.add_argument('--os_region_name',
            help=argparse.SUPPRESS)

        parser.add_argument('--os-auth-system',
            metavar='<auth-system>',
            default=utils.env('OS_AUTH_SYSTEM'),
            help='Defaults to env[OS_AUTH_SYSTEM].')
        parser.add_argument('--os_auth_system',
            help=argparse.SUPPRESS)

        parser.add_argument('--service-type',
            metavar='<service-type>',
            help=_('Defaults to compute for most actions'))
        parser.add_argument('--service_type',
            help=argparse.SUPPRESS)

        parser.add_argument('--service-name',
            metavar='<service-name>',
            default=utils.env('NOVA_SERVICE_NAME'),
            help=_('Defaults to env[NOVA_SERVICE_NAME]'))
        parser.add_argument('--service_name',
            help=argparse.SUPPRESS)

        parser.add_argument('--volume-service-name',
            metavar='<volume-service-name>',
            default=utils.env('NOVA_VOLUME_SERVICE_NAME'),
            help=_('Defaults to env[NOVA_VOLUME_SERVICE_NAME]'))
        parser.add_argument('--volume_service_name',
            help=argparse.SUPPRESS)

        parser.add_argument('--endpoint-type',
            metavar='<endpoint-type>',
            default=utils.env('NOVA_ENDPOINT_TYPE',
                        default=DEFAULT_NOVA_ENDPOINT_TYPE),
            help=_('Defaults to env[NOVA_ENDPOINT_TYPE] or ')
                    + DEFAULT_NOVA_ENDPOINT_TYPE + '.')
        # NOTE(dtroyer): We can't add --endpoint_type here due to argparse
        #                thinking usage-list --end is ambiguous; but it
        #                works fine with only --endpoint-type present
        #                Go figure.  I'm leaving this here for doc purposes.
        # parser.add_argument('--endpoint_type',
        #     help=argparse.SUPPRESS)

        parser.add_argument('--os-compute-api-version',
            metavar='<compute-api-ver>',
            default=utils.env('OS_COMPUTE_API_VERSION',
                default=DEFAULT_OS_COMPUTE_API_VERSION),
            help=_('Accepts 1.1 or 3, '
                 'defaults to env[OS_COMPUTE_API_VERSION].'))
        parser.add_argument('--os_compute_api_version',
            help=argparse.SUPPRESS)

        parser.add_argument('--os-cacert',
            metavar='<ca-certificate>',
            default=utils.env('OS_CACERT', default=None),
            help='Specify a CA bundle file to use in '
                 'verifying a TLS (https) server certificate. '
                 'Defaults to env[OS_CACERT]')

        parser.add_argument('--insecure',
            default=utils.env('NOVACLIENT_INSECURE', default=False),
            action='store_true',
            help=_("Explicitly allow novaclient to perform \"insecure\" "
                 "SSL (https) requests. The server's certificate will "
                 "not be verified against any certificate authorities. "
                 "This option should be used with caution."))

        parser.add_argument('--bypass-url',
            metavar='<bypass-url>',
            dest='bypass_url',
            default=utils.env('NOVACLIENT_BYPASS_URL'),
            help="Use this API endpoint instead of the Service Catalog. "
                 "Defaults to env[NOVACLIENT_BYPASS_URL]")
        parser.add_argument('--bypass_url',
            help=argparse.SUPPRESS)

        # The auth-system-plugins might require some extra options
        novaclient.auth_plugin.load_auth_system_opts(parser)

        return parser
示例#19
0
    def get_base_parser(self):
        parser = NovaClientArgumentParser(
            prog='nova',
            description=__doc__.strip(),
            epilog='See "nova help COMMAND" '\
                   'for help on a specific command.',
            add_help=False,
            formatter_class=OpenStackHelpFormatter,
        )

        # Global arguments
        parser.add_argument('-h', '--help',
            action='store_true',
            help=argparse.SUPPRESS,
        )

        parser.add_argument('--debug',
            default=False,
            action='store_true',
            help="Print debugging output")

        parser.add_argument('--os_username',
            default=utils.env('OS_USERNAME', 'NOVA_USERNAME'),
            help='Defaults to env[OS_USERNAME].')

        parser.add_argument('--os_password',
            default=utils.env('OS_PASSWORD', 'NOVA_PASSWORD'),
            help='Defaults to env[OS_PASSWORD].')

        parser.add_argument('--os_tenant_name',
            default=utils.env('OS_TENANT_NAME', 'NOVA_PROJECT_ID'),
            help='Defaults to env[OS_TENANT_NAME].')

        parser.add_argument('--os_auth_url',
            default=utils.env('OS_AUTH_URL', 'NOVA_URL'),
            help='Defaults to env[OS_AUTH_URL].')

        parser.add_argument('--os_region_name',
            default=utils.env('OS_REGION_NAME', 'NOVA_REGION_NAME'),
            help='Defaults to env[OS_REGION_NAME].')

        parser.add_argument('--service_type',
            help='Defaults to compute for most actions')

        parser.add_argument('--service_name',
            default=utils.env('NOVA_SERVICE_NAME'),
            help='Defaults to env[NOVA_SERVICE_NAME]')

        parser.add_argument('--volume_service_name',
            default=utils.env('NOVA_VOLUME_SERVICE_NAME'),
            help='Defaults to env[NOVA_VOLUME_SERVICE_NAME]')

        parser.add_argument('--endpoint_type',
            default=utils.env('NOVA_ENDPOINT_TYPE',
                        default=DEFAULT_NOVA_ENDPOINT_TYPE),
            help='Defaults to env[NOVA_ENDPOINT_TYPE] or '
                    + DEFAULT_NOVA_ENDPOINT_TYPE + '.')

        parser.add_argument('--os_compute_api_version',
            default=utils.env('OS_COMPUTE_API_VERSION',
            default=DEFAULT_OS_COMPUTE_API_VERSION),
            help='Accepts 1.1, defaults to env[OS_COMPUTE_API_VERSION].')

        parser.add_argument('--insecure',
            default=utils.env('NOVACLIENT_INSECURE', default=False),
            action='store_true',
            help=argparse.SUPPRESS)

        # FIXME(dtroyer): The args below are here for diablo compatibility,
        #                 remove them in folsum cycle

        # alias for --os_username, left in for backwards compatibility
        parser.add_argument('--username',
            help='Deprecated')

        # alias for --os_region_name, left in for backwards compatibility
        parser.add_argument('--region_name',
            help='Deprecated')

        # alias for --os_password, left in for backwards compatibility
        parser.add_argument('--apikey', '--password', dest='apikey',
            default=utils.env('NOVA_API_KEY'),
            help='Deprecated')

        # alias for --os_tenant_name, left in for backward compatibility
        parser.add_argument('--projectid', '--tenant_name', dest='projectid',
            default=utils.env('NOVA_PROJECT_ID'),
            help='Deprecated')

        # alias for --os_auth_url, left in for backward compatibility
        parser.add_argument('--url', '--auth_url', dest='url',
            default=utils.env('NOVA_URL'),
            help='Deprecated')

        return parser
示例#20
0
    def get_base_parser(self):
        parser = NovaClientArgumentParser(
            prog="nova",
            description=__doc__.strip(),
            epilog='See "nova help COMMAND" ' "for help on a specific command.",
            add_help=False,
            formatter_class=OpenStackHelpFormatter,
        )

        # Global arguments
        parser.add_argument("-h", "--help", action="store_true", help=argparse.SUPPRESS)

        parser.add_argument("--version", action="version", version=novaclient.__version__)

        parser.add_argument("--debug", default=False, action="store_true", help="Print debugging output")

        parser.add_argument(
            "--os-cache",
            default=utils.bool_from_str(utils.env("OS_CACHE", default=False)),
            action="store_true",
            help="Use the auth token cache. Defaults to False if env[OS_CACHE]" " is not set.",
        )

        parser.add_argument("--timings", default=False, action="store_true", help="Print call timing info")

        parser.add_argument(
            "--timeout",
            default=600,
            metavar="<seconds>",
            type=positive_non_zero_float,
            help="Set HTTP call timeout (in seconds)",
        )

        parser.add_argument(
            "--os-username",
            metavar="<auth-user-name>",
            default=utils.env("OS_USERNAME", "NOVA_USERNAME"),
            help="Defaults to env[OS_USERNAME].",
        )
        parser.add_argument("--os_username", help=argparse.SUPPRESS)

        parser.add_argument(
            "--os-password",
            metavar="<auth-password>",
            default=utils.env("OS_PASSWORD", "NOVA_PASSWORD"),
            help="Defaults to env[OS_PASSWORD].",
        )
        parser.add_argument("--os_password", help=argparse.SUPPRESS)

        parser.add_argument(
            "--os-tenant-name",
            metavar="<auth-tenant-name>",
            default=utils.env("OS_TENANT_NAME", "NOVA_PROJECT_ID"),
            help="Defaults to env[OS_TENANT_NAME].",
        )
        parser.add_argument("--os_tenant_name", help=argparse.SUPPRESS)

        parser.add_argument(
            "--os-tenant-id",
            metavar="<auth-tenant-id>",
            default=utils.env("OS_TENANT_ID"),
            help="Defaults to env[OS_TENANT_ID].",
        )

        parser.add_argument(
            "--os-auth-url",
            metavar="<auth-url>",
            default=utils.env("OS_AUTH_URL", "NOVA_URL"),
            help="Defaults to env[OS_AUTH_URL].",
        )
        parser.add_argument("--os_auth_url", help=argparse.SUPPRESS)

        parser.add_argument(
            "--os-region-name",
            metavar="<region-name>",
            default=utils.env("OS_REGION_NAME", "NOVA_REGION_NAME"),
            help="Defaults to env[OS_REGION_NAME].",
        )
        parser.add_argument("--os_region_name", help=argparse.SUPPRESS)

        parser.add_argument(
            "--os-auth-system",
            metavar="<auth-system>",
            default=utils.env("OS_AUTH_SYSTEM"),
            help="Defaults to env[OS_AUTH_SYSTEM].",
        )
        parser.add_argument("--os_auth_system", help=argparse.SUPPRESS)

        parser.add_argument("--service-type", metavar="<service-type>", help="Defaults to compute for most actions")
        parser.add_argument("--service_type", help=argparse.SUPPRESS)

        parser.add_argument(
            "--service-name",
            metavar="<service-name>",
            default=utils.env("NOVA_SERVICE_NAME"),
            help="Defaults to env[NOVA_SERVICE_NAME]",
        )
        parser.add_argument("--service_name", help=argparse.SUPPRESS)

        parser.add_argument(
            "--volume-service-name",
            metavar="<volume-service-name>",
            default=utils.env("NOVA_VOLUME_SERVICE_NAME"),
            help="Defaults to env[NOVA_VOLUME_SERVICE_NAME]",
        )
        parser.add_argument("--volume_service_name", help=argparse.SUPPRESS)

        parser.add_argument(
            "--endpoint-type",
            metavar="<endpoint-type>",
            default=utils.env("NOVA_ENDPOINT_TYPE", default=DEFAULT_NOVA_ENDPOINT_TYPE),
            help="Defaults to env[NOVA_ENDPOINT_TYPE] or " + DEFAULT_NOVA_ENDPOINT_TYPE + ".",
        )
        # NOTE(dtroyer): We can't add --endpoint_type here due to argparse
        #                thinking usage-list --end is ambiguous; but it
        #                works fine with only --endpoint-type present
        #                Go figure.  I'm leaving this here for doc purposes.
        # parser.add_argument('--endpoint_type',
        #    help=argparse.SUPPRESS)

        parser.add_argument(
            "--os-compute-api-version",
            metavar="<compute-api-ver>",
            default=utils.env("OS_COMPUTE_API_VERSION", default=DEFAULT_OS_COMPUTE_API_VERSION),
            help="Accepts 1.1 or 3, " "defaults to env[OS_COMPUTE_API_VERSION].",
        )
        parser.add_argument("--os_compute_api_version", help=argparse.SUPPRESS)

        parser.add_argument(
            "--os-cacert",
            metavar="<ca-certificate>",
            default=utils.env("OS_CACERT", default=None),
            help="Specify a CA bundle file to use in "
            "verifying a TLS (https) server certificate. "
            "Defaults to env[OS_CACERT]",
        )

        parser.add_argument(
            "--insecure",
            default=utils.env("NOVACLIENT_INSECURE", default=False),
            action="store_true",
            help='Explicitly allow novaclient to perform "insecure" '
            "SSL (https) requests. The server's certificate will "
            "not be verified against any certificate authorities. "
            "This option should be used with caution.",
        )

        parser.add_argument(
            "--bypass-url",
            metavar="<bypass-url>",
            dest="bypass_url",
            help="Use this API endpoint instead of the Service Catalog",
        )
        parser.add_argument("--bypass_url", help=argparse.SUPPRESS)

        # The auth-system-plugins might require some extra options
        novaclient.auth_plugin.load_auth_system_opts(parser)

        return parser
示例#21
0
 def password(self):
     if self._validate_string(self.args.os_password):
         return self.args.os_password
     verify_pass = strutils.bool_from_string(
         utils.env("OS_VERIFY_PASSWORD", default=False), True)
     return self._prompt_password(verify_pass)
示例#22
0
    def get_base_parser(self, argv):
        parser = NovaClientArgumentParser(
            prog='nova',
            description=__doc__.strip(),
            epilog='See "nova help COMMAND" '
                   'for help on a specific command.',
            add_help=False,
            formatter_class=OpenStackHelpFormatter,
        )

        # Global arguments
        parser.add_argument(
            '-h', '--help',
            action='store_true',
            help=argparse.SUPPRESS,
        )

        parser.add_argument('--version',
                            action='version',
                            version=novaclient.__version__)

        parser.add_argument(
            '--debug',
            default=False,
            action='store_true',
            help=_("Print debugging output."))

        parser.add_argument(
            '--os-cache',
            default=strutils.bool_from_string(
                utils.env('OS_CACHE', default=False), True),
            action='store_true',
            help=_("Use the auth token cache. Defaults to False if "
                   "env[OS_CACHE] is not set."))

        parser.add_argument(
            '--timings',
            default=False,
            action='store_true',
            help=_("Print call timing info."))

        parser.add_argument(
            '--os-region-name',
            metavar='<region-name>',
            default=utils.env('OS_REGION_NAME', 'NOVA_REGION_NAME'),
            help=_('Defaults to env[OS_REGION_NAME].'))

        parser.add_argument(
            '--service-type',
            metavar='<service-type>',
            help=_('Defaults to compute for most actions.'))

        parser.add_argument(
            '--service-name',
            metavar='<service-name>',
            default=utils.env('NOVA_SERVICE_NAME'),
            help=_('Defaults to env[NOVA_SERVICE_NAME].'))

        parser.add_argument(
            '--os-endpoint-type',
            metavar='<endpoint-type>',
            dest='endpoint_type',
            default=utils.env(
                'NOVA_ENDPOINT_TYPE', default=utils.env(
                    'OS_ENDPOINT_TYPE',
                    default=DEFAULT_NOVA_ENDPOINT_TYPE)),
            help=_('Defaults to env[NOVA_ENDPOINT_TYPE], '
                   'env[OS_ENDPOINT_TYPE] or ') +
                 DEFAULT_NOVA_ENDPOINT_TYPE + '.')

        parser.add_argument(
            '--os-compute-api-version',
            metavar='<compute-api-ver>',
            default=utils.env('OS_COMPUTE_API_VERSION',
                              default=DEFAULT_OS_COMPUTE_API_VERSION),
            help=_('Accepts X, X.Y (where X is major and Y is minor part) or '
                   '"X.latest", defaults to env[OS_COMPUTE_API_VERSION].'))

        parser.add_argument(
            '--os-endpoint-override',
            metavar='<bypass-url>',
            dest='endpoint_override',
            default=utils.env('OS_ENDPOINT_OVERRIDE',
                              'NOVACLIENT_ENDPOINT_OVERRIDE',
                              'NOVACLIENT_BYPASS_URL'),
            help=_("Use this API endpoint instead of the Service Catalog. "
                   "Defaults to env[OS_ENDPOINT_OVERRIDE]."))

        if osprofiler_profiler:
            parser.add_argument('--profile',
                                metavar='HMAC_KEY',
                                default=utils.env('OS_PROFILE'),
                                help='HMAC key to use for encrypting context '
                                'data for performance profiling of operation. '
                                'This key should be the value of the HMAC key '
                                'configured for the OSprofiler middleware in '
                                'nova; it is specified in the Nova '
                                'configuration file at "/etc/nova/nova.conf". '
                                'Without the key, profiling will not be '
                                'triggered even if OSprofiler is enabled on '
                                'the server side.')

        self._append_global_identity_args(parser, argv)

        return parser
示例#23
0
    def get_base_parser(self):
        parser = NovaClientArgumentParser(
            prog='nova',
            description=__doc__.strip(),
            epilog='See "nova help COMMAND" '\
                   'for help on a specific command.',
            add_help=False,
            formatter_class=OpenStackHelpFormatter,
        )

        # Global arguments
        parser.add_argument('-h', '--help',
            action='store_true',
            help=argparse.SUPPRESS,
        )

        parser.add_argument('--version',
                            action='version',
                            version=novaclient.__version__)

        parser.add_argument('--debug',
            default=False,
            action='store_true',
            help="Print debugging output")

        parser.add_argument('--no-cache',
            default=utils.env('OS_NO_CACHE', default=False),
            action='store_true',
            help="Don't use the auth token cache.")
        parser.add_argument('--no_cache',
            help=argparse.SUPPRESS)

        parser.add_argument('--timings',
            default=False,
            action='store_true',
            help="Print call timing info")

        parser.add_argument('--os-username',
            metavar='<auth-user-name>',
            default=utils.env('OS_USERNAME', 'NOVA_USERNAME'),
            help='Defaults to env[OS_USERNAME].')
        parser.add_argument('--os_username',
            help=argparse.SUPPRESS)

        parser.add_argument('--os-password',
            metavar='<auth-password>',
            default=utils.env('OS_PASSWORD', 'NOVA_PASSWORD'),
            help='Defaults to env[OS_PASSWORD].')
        parser.add_argument('--os_password',
            help=argparse.SUPPRESS)

        parser.add_argument('--os-tenant-name',
            metavar='<auth-tenant-name>',
            default=utils.env('OS_TENANT_NAME', 'NOVA_PROJECT_ID'),
            help='Defaults to env[OS_TENANT_NAME].')
        parser.add_argument('--os_tenant_name',
            help=argparse.SUPPRESS)

        parser.add_argument('--os-auth-url',
            metavar='<auth-url>',
            default=utils.env('OS_AUTH_URL', 'NOVA_URL'),
            help='Defaults to env[OS_AUTH_URL].')
        parser.add_argument('--os_auth_url',
            help=argparse.SUPPRESS)

        parser.add_argument('--os-region-name',
            metavar='<region-name>',
            default=utils.env('OS_REGION_NAME', 'NOVA_REGION_NAME'),
            help='Defaults to env[OS_REGION_NAME].')
        parser.add_argument('--os_region_name',
            help=argparse.SUPPRESS)

        parser.add_argument('--os-auth-system',
            metavar='<auth-system>',
            default=utils.env('OS_AUTH_SYSTEM'),
            help='Defaults to env[OS_AUTH_SYSTEM].')
        parser.add_argument('--os_auth_system',
            help=argparse.SUPPRESS)

        parser.add_argument('--service-type',
            metavar='<service-type>',
            help='Defaults to compute for most actions')
        parser.add_argument('--service_type',
            help=argparse.SUPPRESS)

        parser.add_argument('--service-name',
            metavar='<service-name>',
            default=utils.env('NOVA_SERVICE_NAME'),
            help='Defaults to env[NOVA_SERVICE_NAME]')
        parser.add_argument('--service_name',
            help=argparse.SUPPRESS)

        parser.add_argument('--volume-service-name',
            metavar='<volume-service-name>',
            default=utils.env('NOVA_VOLUME_SERVICE_NAME'),
            help='Defaults to env[NOVA_VOLUME_SERVICE_NAME]')
        parser.add_argument('--volume_service_name',
            help=argparse.SUPPRESS)

        parser.add_argument('--endpoint-type',
            metavar='<endpoint-type>',
            default=utils.env('NOVA_ENDPOINT_TYPE',
                        default=DEFAULT_NOVA_ENDPOINT_TYPE),
            help='Defaults to env[NOVA_ENDPOINT_TYPE] or '
                    + DEFAULT_NOVA_ENDPOINT_TYPE + '.')
        # NOTE(dtroyer): We can't add --endpoint_type here due to argparse
        #                thinking usage-list --end is ambiguous; but it
        #                works fine with only --endpoint-type present
        #                Go figure.  I'm leaving this here for doc purposes.
        #parser.add_argument('--endpoint_type',
        #    help=argparse.SUPPRESS)

        parser.add_argument('--os-compute-api-version',
            metavar='<compute-api-ver>',
            default=utils.env('OS_COMPUTE_API_VERSION',
                default=DEFAULT_OS_COMPUTE_API_VERSION),
            help='Accepts 1.1, defaults to env[OS_COMPUTE_API_VERSION].')
        parser.add_argument('--os_compute_api_version',
            help=argparse.SUPPRESS)

        parser.add_argument('--insecure',
            default=utils.env('NOVACLIENT_INSECURE', default=False),
            action='store_true',
            help="Explicitly allow novaclient to perform \"insecure\" "
                 "SSL (https) requests. The server's certificate will "
                 "not be verified against any certificate authorities. "
                 "This option should be used with caution.")

        # FIXME(dtroyer): The args below are here for diablo compatibility,
        #                 remove them in folsum cycle

        # alias for --os-username, left in for backwards compatibility
        parser.add_argument('--username',
            help=argparse.SUPPRESS)

        # alias for --os-region-name, left in for backwards compatibility
        parser.add_argument('--region_name',
            help=argparse.SUPPRESS)

        # alias for --os-password, left in for backwards compatibility
        parser.add_argument('--apikey', '--password', dest='apikey',
            default=utils.env('NOVA_API_KEY'),
            help=argparse.SUPPRESS)

        # alias for --os-tenant-name, left in for backward compatibility
        parser.add_argument('--projectid', '--tenant_name', dest='projectid',
            default=utils.env('NOVA_PROJECT_ID'),
            help=argparse.SUPPRESS)

        # alias for --os-auth-url, left in for backward compatibility
        parser.add_argument('--url', '--auth_url', dest='url',
            default=utils.env('NOVA_URL'),
            help=argparse.SUPPRESS)

        parser.add_argument('--bypass-url',
            metavar='<bypass-url>',
            dest='bypass_url',
            help="Use this API endpoint instead of the Service Catalog")
        parser.add_argument('--bypass_url',
            help=argparse.SUPPRESS)

        return parser
示例#24
0
    def get_base_parser(self):
        parser = NovaClientArgumentParser(
            prog='nova',
            description=__doc__.strip(),
            epilog='See "nova help COMMAND" '\
                   'for help on a specific command.',
            add_help=False,
            formatter_class=OpenStackHelpFormatter,
        )

        # Global arguments
        parser.add_argument('-h', '--help',
            action='store_true',
            help=argparse.SUPPRESS,
        )

        parser.add_argument('--version',
                            action='version',
                            version=novaclient.__version__)

        parser.add_argument('--debug',
            default=False,
            action='store_true',
            help="Print debugging output")

        parser.add_argument('--no-cache',
            default=utils.env('OS_NO_CACHE', default=False),
            action='store_true',
            help="Don't use the auth token cache.")
        parser.add_argument('--no_cache',
            help=argparse.SUPPRESS)

        parser.add_argument('--timings',
            default=False,
            action='store_true',
            help="Print call timing info")

        parser.add_argument('--os-username',
            metavar='<auth-user-name>',
            default=utils.env('OS_USERNAME', 'NOVA_USERNAME'),
            help='Defaults to env[OS_USERNAME].')
        parser.add_argument('--os_username',
            help=argparse.SUPPRESS)

        parser.add_argument('--os-password',
            metavar='<auth-password>',
            default=utils.env('OS_PASSWORD', 'NOVA_PASSWORD'),
            help='Defaults to env[OS_PASSWORD].')
        parser.add_argument('--os_password',
            help=argparse.SUPPRESS)

        parser.add_argument('--os-tenant-name',
            metavar='<auth-tenant-name>',
            default=utils.env('OS_TENANT_NAME', 'NOVA_PROJECT_ID'),
            help='Defaults to env[OS_TENANT_NAME].')
        parser.add_argument('--os_tenant_name',
            help=argparse.SUPPRESS)

        parser.add_argument('--os-auth-url',
            metavar='<auth-url>',
            default=utils.env('OS_AUTH_URL', 'NOVA_URL'),
            help='Defaults to env[OS_AUTH_URL].')
        parser.add_argument('--os_auth_url',
            help=argparse.SUPPRESS)

        parser.add_argument('--os-region-name',
            metavar='<region-name>',
            default=utils.env('OS_REGION_NAME', 'NOVA_REGION_NAME'),
            help='Defaults to env[OS_REGION_NAME].')
        parser.add_argument('--os_region_name',
            help=argparse.SUPPRESS)

        parser.add_argument('--os-auth-system',
            metavar='<auth-system>',
            default=utils.env('OS_AUTH_SYSTEM'),
            help='Defaults to env[OS_AUTH_SYSTEM].')
        parser.add_argument('--os_auth_system',
            help=argparse.SUPPRESS)

        parser.add_argument('--service-type',
            metavar='<service-type>',
            help='Defaults to compute for most actions')
        parser.add_argument('--service_type',
            help=argparse.SUPPRESS)

        parser.add_argument('--service-name',
            metavar='<service-name>',
            default=utils.env('NOVA_SERVICE_NAME'),
            help='Defaults to env[NOVA_SERVICE_NAME]')
        parser.add_argument('--service_name',
            help=argparse.SUPPRESS)

        parser.add_argument('--volume-service-name',
            metavar='<volume-service-name>',
            default=utils.env('NOVA_VOLUME_SERVICE_NAME'),
            help='Defaults to env[NOVA_VOLUME_SERVICE_NAME]')
        parser.add_argument('--volume_service_name',
            help=argparse.SUPPRESS)

        parser.add_argument('--endpoint-type',
            metavar='<endpoint-type>',
            default=utils.env('NOVA_ENDPOINT_TYPE',
                        default=DEFAULT_NOVA_ENDPOINT_TYPE),
            help='Defaults to env[NOVA_ENDPOINT_TYPE] or '
                    + DEFAULT_NOVA_ENDPOINT_TYPE + '.')
        # NOTE(dtroyer): We can't add --endpoint_type here due to argparse
        #                thinking usage-list --end is ambiguous; but it
        #                works fine with only --endpoint-type present
        #                Go figure.  I'm leaving this here for doc purposes.
        #parser.add_argument('--endpoint_type',
        #    help=argparse.SUPPRESS)

        parser.add_argument('--os-compute-api-version',
            metavar='<compute-api-ver>',
            default=utils.env('OS_COMPUTE_API_VERSION',
                default=DEFAULT_OS_COMPUTE_API_VERSION),
            help='Accepts 1.1, defaults to env[OS_COMPUTE_API_VERSION].')
        parser.add_argument('--os_compute_api_version',
            help=argparse.SUPPRESS)

        parser.add_argument('--insecure',
            default=utils.env('NOVACLIENT_INSECURE', default=False),
            action='store_true',
            help="Explicitly allow novaclient to perform \"insecure\" "
                 "SSL (https) requests. The server's certificate will "
                 "not be verified against any certificate authorities. "
                 "This option should be used with caution.")

        # FIXME(dtroyer): The args below are here for diablo compatibility,
        #                 remove them in folsum cycle

        # alias for --os-username, left in for backwards compatibility
        parser.add_argument('--username',
            help=argparse.SUPPRESS)

        # alias for --os-region-name, left in for backwards compatibility
        parser.add_argument('--region_name',
            help=argparse.SUPPRESS)

        # alias for --os-password, left in for backwards compatibility
        parser.add_argument('--apikey', '--password', dest='apikey',
            default=utils.env('NOVA_API_KEY'),
            help=argparse.SUPPRESS)

        # alias for --os-tenant-name, left in for backward compatibility
        parser.add_argument('--projectid', '--tenant_name', dest='projectid',
            default=utils.env('NOVA_PROJECT_ID'),
            help=argparse.SUPPRESS)

        # alias for --os-auth-url, left in for backward compatibility
        parser.add_argument('--url', '--auth_url', dest='url',
            default=utils.env('NOVA_URL'),
            help=argparse.SUPPRESS)

        parser.add_argument('--bypass-url',
            metavar='<bypass-url>',
            dest='bypass_url',
            help="Use this API endpoint instead of the Service Catalog")
        parser.add_argument('--bypass_url',
            help=argparse.SUPPRESS)

        return parser
示例#25
0
    def get_base_parser(self, argv):
        parser = NovaClientArgumentParser(
            prog='nova',
            description=__doc__.strip(),
            epilog='See "nova help COMMAND" '
            'for help on a specific command.',
            add_help=False,
            formatter_class=OpenStackHelpFormatter,
        )

        # Global arguments
        parser.add_argument(
            '-h',
            '--help',
            action='store_true',
            help=argparse.SUPPRESS,
        )

        parser.add_argument('--version',
                            action='version',
                            version=novaclient.__version__)

        parser.add_argument('--debug',
                            default=False,
                            action='store_true',
                            help=_("Print debugging output."))

        parser.add_argument(
            '--os-cache',
            default=strutils.bool_from_string(
                utils.env('OS_CACHE', default=False), True),
            action='store_true',
            help=_("Use the auth token cache. Defaults to False if "
                   "env[OS_CACHE] is not set."))

        parser.add_argument('--timings',
                            default=False,
                            action='store_true',
                            help=_("Print call timing info."))

        parser.add_argument('--os-region-name',
                            metavar='<region-name>',
                            default=utils.env('OS_REGION_NAME',
                                              'NOVA_REGION_NAME'),
                            help=_('Defaults to env[OS_REGION_NAME].'))

        parser.add_argument('--service-type',
                            metavar='<service-type>',
                            help=_('Defaults to compute for most actions.'))

        parser.add_argument('--service-name',
                            metavar='<service-name>',
                            default=utils.env('NOVA_SERVICE_NAME'),
                            help=_('Defaults to env[NOVA_SERVICE_NAME].'))

        parser.add_argument('--os-endpoint-type',
                            metavar='<endpoint-type>',
                            dest='endpoint_type',
                            default=utils.env(
                                'NOVA_ENDPOINT_TYPE',
                                default=utils.env(
                                    'OS_ENDPOINT_TYPE',
                                    default=DEFAULT_NOVA_ENDPOINT_TYPE)),
                            help=_('Defaults to env[NOVA_ENDPOINT_TYPE], '
                                   'env[OS_ENDPOINT_TYPE] or ') +
                            DEFAULT_NOVA_ENDPOINT_TYPE + '.')

        parser.add_argument(
            '--os-compute-api-version',
            metavar='<compute-api-ver>',
            default=utils.env('OS_COMPUTE_API_VERSION',
                              default=DEFAULT_OS_COMPUTE_API_VERSION),
            help=_('Accepts X, X.Y (where X is major and Y is minor part) or '
                   '"X.latest", defaults to env[OS_COMPUTE_API_VERSION].'))

        parser.add_argument(
            '--os-endpoint-override',
            metavar='<bypass-url>',
            dest='endpoint_override',
            default=utils.env('OS_ENDPOINT_OVERRIDE',
                              'NOVACLIENT_ENDPOINT_OVERRIDE',
                              'NOVACLIENT_BYPASS_URL'),
            help=_("Use this API endpoint instead of the Service Catalog. "
                   "Defaults to env[OS_ENDPOINT_OVERRIDE]."))

        if osprofiler_profiler:
            parser.add_argument('--profile',
                                metavar='HMAC_KEY',
                                default=utils.env('OS_PROFILE'),
                                help='HMAC key to use for encrypting context '
                                'data for performance profiling of operation. '
                                'This key should be the value of the HMAC key '
                                'configured for the OSprofiler middleware in '
                                'nova; it is specified in the Nova '
                                'configuration file at "/etc/nova/nova.conf". '
                                'Without the key, profiling will not be '
                                'triggered even if OSprofiler is enabled on '
                                'the server side.')

        self._append_global_identity_args(parser, argv)

        return parser
示例#26
0
    def _append_global_identity_args(self, parser):
        # Register the CLI arguments that have moved to the session object.
        ksession.Session.register_cli_options(parser)

        parser.set_defaults(insecure=utils.env('NOVACLIENT_INSECURE',
                            default=False))
示例#27
0
    def get_base_parser(self):
        parser = NovaClientArgumentParser(
            prog='nova',
            description=__doc__.strip(),
            epilog='See "nova help COMMAND" '\
                   'for help on a specific command.',
            add_help=False,
            formatter_class=OpenStackHelpFormatter,
        )

        # Global arguments
        parser.add_argument('-h', '--help',
            action='store_true',
            help=argparse.SUPPRESS,
        )

        parser.add_argument('--debug',
            default=False,
            action='store_true',
            help="Print debugging output")

        parser.add_argument('--no_cache',
            default=utils.env('OS_NO_CACHE', default=False),
            action='store_true',
            help="Don't use the auth token cache.")

        parser.add_argument('--timings',
            default=False,
            action='store_true',
            help="Print call timing info")
        
        parser.add_argument('-F', '--federated',
            default=False,
            action='store_true',
            help="Enable the federated authentication")

        parser.add_argument('-R', '--realm',
            default=None,
            dest="realm",
            help="The realm to use for federated authentication (optional)")

        parser.add_argument('--os_username',
            default=utils.env('OS_USERNAME', 'NOVA_USERNAME'),
            help='Defaults to env[OS_USERNAME].')

        parser.add_argument('--os_password',
            default=utils.env('OS_PASSWORD', 'NOVA_PASSWORD'),
            help='Defaults to env[OS_PASSWORD].')

        parser.add_argument('--os_tenant_name',
            default=utils.env('OS_TENANT_NAME', 'NOVA_PROJECT_ID'),
            help='Defaults to env[OS_TENANT_NAME].')

        parser.add_argument('--os_auth_url',
            default=utils.env('OS_AUTH_URL', 'NOVA_URL'),
            help='Defaults to env[OS_AUTH_URL].')

        parser.add_argument('--os_region_name',
            default=utils.env('OS_REGION_NAME', 'NOVA_REGION_NAME'),
            help='Defaults to env[OS_REGION_NAME].')

        parser.add_argument('--service_type',
            help='Defaults to compute for most actions')

        parser.add_argument('--service_name',
            default=utils.env('NOVA_SERVICE_NAME'),
            help='Defaults to env[NOVA_SERVICE_NAME]')

        parser.add_argument('--volume_service_name',
            default=utils.env('NOVA_VOLUME_SERVICE_NAME'),
            help='Defaults to env[NOVA_VOLUME_SERVICE_NAME]')

        parser.add_argument('--endpoint_type',
            default=utils.env('NOVA_ENDPOINT_TYPE',
                        default=DEFAULT_NOVA_ENDPOINT_TYPE),
            help='Defaults to env[NOVA_ENDPOINT_TYPE] or '
                    + DEFAULT_NOVA_ENDPOINT_TYPE + '.')

        parser.add_argument('--os_compute_api_version',
            default=utils.env('OS_COMPUTE_API_VERSION',
            default=DEFAULT_OS_COMPUTE_API_VERSION),
            help='Accepts 1.1, defaults to env[OS_COMPUTE_API_VERSION].')

        parser.add_argument('--insecure',
            default=utils.env('NOVACLIENT_INSECURE', default=False),
            action='store_true',
            help="Explicitly allow novaclient to perform \"insecure\" "
                 "SSL (https) requests. The server's certificate will "
                 "not be verified against any certificate authorities. "
                 "This option should be used with caution.")

        # FIXME(dtroyer): The args below are here for diablo compatibility,
        #                 remove them in folsum cycle

        # alias for --os_username, left in for backwards compatibility
        parser.add_argument('--username',
            help='Deprecated')

        # alias for --os_region_name, left in for backwards compatibility
        parser.add_argument('--region_name',
            help='Deprecated')

        # alias for --os_password, left in for backwards compatibility
        parser.add_argument('--apikey', '--password', dest='apikey',
            default=utils.env('NOVA_API_KEY'),
            help='Deprecated')

        # alias for --os_tenant_name, left in for backward compatibility
        parser.add_argument('--projectid', '--tenant_name', dest='projectid',
            default=utils.env('NOVA_PROJECT_ID'),
            help='Deprecated')

        # alias for --os_auth_url, left in for backward compatibility
        parser.add_argument('--url', '--auth_url', dest='url',
            default=utils.env('NOVA_URL'),
            help='Deprecated')

        parser.add_argument('--bypass_url', dest='bypass_url',
            help="Use this API endpoint instead of the Service Catalog")

        return parser
示例#28
0
    def get_base_parser(self):
        parser = NovaClientArgumentParser(
            prog='nova',
            description=__doc__.strip(),
            epilog='See "nova help COMMAND" '\
                   'for help on a specific command.',
            add_help=False,
            formatter_class=OpenStackHelpFormatter,
        )

        # Global arguments
        parser.add_argument('-h', '--help',
            action='store_true',
            help=argparse.SUPPRESS,
        )

        parser.add_argument('--debug',
            default=False,
            action='store_true',
            help="Print debugging output")

        parser.add_argument('--os_username',
            default=utils.env('OS_USERNAME', 'NOVA_USERNAME'),
            help='Defaults to env[OS_USERNAME].')

        parser.add_argument('--os_password',
            default=utils.env('OS_PASSWORD', 'NOVA_PASSWORD'),
            help='Defaults to env[OS_PASSWORD].')

        parser.add_argument('--os_tenant_name',
            default=utils.env('OS_TENANT_NAME', 'NOVA_PROJECT_ID'),
            help='Defaults to env[OS_TENANT_NAME].')

        parser.add_argument('--os_auth_url',
            default=utils.env('OS_AUTH_URL', 'NOVA_URL'),
            help='Defaults to env[OS_AUTH_URL].')

        parser.add_argument('--os_region_name',
            default=utils.env('OS_REGION_NAME', 'NOVA_REGION_NAME'),
            help='Defaults to env[OS_REGION_NAME].')

        parser.add_argument('--service_type',
            help='Defaults to compute for most actions')

        parser.add_argument('--service_name',
            default=utils.env('NOVA_SERVICE_NAME'),
            help='Defaults to env[NOVA_SERVICE_NAME]')

        parser.add_argument('--endpoint_type',
            default=utils.env('NOVA_ENDPOINT_TYPE',
                        default=DEFAULT_NOVA_ENDPOINT_TYPE),
            help='Defaults to env[NOVA_ENDPOINT_TYPE] or '
                    + DEFAULT_NOVA_ENDPOINT_TYPE + '.')

        parser.add_argument('--version',
            default=utils.env('NOVA_VERSION', default=DEFAULT_NOVA_VERSION),
            help='Accepts 1.1, defaults to env[NOVA_VERSION].')

        parser.add_argument('--insecure',
            default=utils.env('NOVACLIENT_INSECURE', default=False),
            action='store_true',
            help=argparse.SUPPRESS)

        # FIXME(dtroyer): The args below are here for diablo compatibility,
        #                 remove them in folsum cycle

        # alias for --os_username, left in for backwards compatibility
        parser.add_argument('--username',
            help='Deprecated')

        # alias for --os_region_name, left in for backwards compatibility
        parser.add_argument('--region_name',
            help='Deprecated')

        # alias for --os_password, left in for backwards compatibility
        parser.add_argument('--apikey', '--password', dest='apikey',
            default=utils.env('NOVA_API_KEY'),
            help='Deprecated')

        # alias for --os_tenant_name, left in for backward compatibility
        parser.add_argument('--projectid', '--tenant_name', dest='projectid',
            default=utils.env('NOVA_PROJECT_ID'),
            help='Deprecated')

        # alias for --os_auth_url, left in for backward compatibility
        parser.add_argument('--url', '--auth_url', dest='url',
            default=utils.env('NOVA_URL'),
            help='Deprecated')

        return parser