Exemple #1
0
    def get_parser(self):
        parser = argparse.ArgumentParser(
            prog='bcectool',
            description=__doc__.strip(),
            epilog=('See "%(arg)s" for help on an specific command.') % {
                'arg': "bcec-tool help COMMAND"},
            add_help=False,
            formatter_class=HelpFormatter,
        )

        parser.add_argument('-h', "--help",
                            action='store_true',
                            help=argparse.SUPPRESS)
        parser.add_argument("--version",
                            action='version',
                            version='0.1',
                            help=("Shows the client version and exit."))
        parser.add_argument("--os-username",
			    default=utils.env("OS_USERNAME"),
                            help=("Defaults to %(value)s." % {'value': 'env[OS_USERNAME]'}))
        parser.add_argument("--os-password",
			    default=utils.env("OS_PASSWORD"),
                            help=("Defaults to %(value)s." % {'value': 'env[OS_PASSWORD]'}))
        parser.add_argument("--os-auth-url",
			    default=utils.env("OS_AUTH_URL"),
                            help=("Defaults to %(value)s." % {'value': 'env[OS_AUTH_URL]'}))
        parser.add_argument("--os-tenant_name",
			    default=utils.env("OS_TENANT_NAME"),
                            help=("Defaults to %(value)s." % {'value': 'env[OS_TENANT_NAME]'}))

	return parser
Exemple #2
0
 def __init__(self, config):
     self.tenant_id = config.get('auth','tenant_id') or utils.env('OS_TENANT_ID')
     self.tenant_name = config.get('auth','tenant_name') or utils.env('OS_TENANT_NAME')
     self.password = config.get('auth', 'password') or utils.env('OS_PASSWORD')
     self.username = config.get('auth', 'username') or utils.env('OS_USERNAME')
     self.auth_url = config.get('auth', 'auth_url') or utils.env('OS_AUTH_URL')
     self.auth_token = config.get('auth', 'auth_token') or utils.env('OS_AUTH_TOKEN')
     self.heat_url = config.get('heat', 'heat_url') or utils.env('HEAT_URL')
     self.service_type = config.get('auth', 'service_type') or utils.env('OS_SERVICE_TYPE')
     self.endpoint_type = config.get('auth', 'endpoint_type') or utils.env('OS_ENDPOINT_TYPE')
     self.include_pass = config.get('heat', 'include_pass') or bool(utils.env('HEAT_INCLUDE_PASSWORD'))
Exemple #3
0
def heat_client(credentials, api_version=1):
    """Get a new Heat client using the given credentials."""
    endpoint = ''
    service_type = 'orchestration'
    keystone_session = kssession.Session(verify=True)
    os_auth_url = utils.env('OS_AUTH_URL')
    kwargs = {
        'username': credentials.username,
        'user_id': credentials.user_id,
        'password': credentials.password,
        'project_id': credentials.tenant_id,
        'project_name': credentials.tenant_name,
    }
    keystone_auth = _get_keystone_auth(keystone_session, os_auth_url, **kwargs)
    endpoint = keystone_auth.get_endpoint(keystone_session,
                                          service_type=service_type,
                                          region_name=None)

    endpoint_type = 'publicURL'
    kwargs = {
        'auth_url': os_auth_url,
        'session': keystone_session,
        'auth': keystone_auth,
        'service_type': service_type,
        'endpoint_type': endpoint_type,
        'username': credentials.username,
        'password': credentials.password,
        'include_pass': False
    }

    return client.Client(api_version, endpoint, **kwargs)
def heat_client(credentials, api_version=1):
    """Get a new Heat client using the given credentials."""
    endpoint = ''
    service_type = 'orchestration'
    keystone_session = kssession.Session(verify=True)
    os_auth_url = utils.env('OS_AUTH_URL')
    kwargs = {
        'username': credentials.username,
        'user_id': credentials.user_id,
        'password': credentials.password,
        'project_id': credentials.tenant_id,
        'project_name': credentials.tenant_name,
    }
    keystone_auth = _get_keystone_auth(keystone_session,
                                       os_auth_url, **kwargs)
    endpoint = keystone_auth.get_endpoint(keystone_session,
                                          service_type=service_type,
                                          region_name=None)

    endpoint_type = 'publicURL'
    kwargs = {
        'auth_url': os_auth_url,
        'session': keystone_session,
        'auth': keystone_auth,
        'service_type': service_type,
        'endpoint_type': endpoint_type,
        'username': credentials.username,
        'password': credentials.password,
        'include_pass': False
    }

    return client.Client(api_version, endpoint, **kwargs)
Exemple #5
0
    def __init__(self, config, stackname, stacktype='default', template_file=None, template_url=None):
        self.tenant_id = ( config.get('auth','tenant_id') or utils.env('OS_TENANT_ID') )
        self.tenant_name = ( config.get('auth','tenant_name') or utils.env('OS_TENANT_NAME') )
        self.password = ( config.get('auth', 'password') or utils.env('OS_PASSWORD') )
        self.username = ( config.get('auth', 'username') or utils.env('OS_USERNAME') )
        self.auth_url = ( config.get('auth', 'auth_url') or utils.env('OS_AUTH_URL') )
        self.heat_url = ( config.get('heat', 'heat_url') or utils.env('HEAT_URL') )
        self.endpoint_type = ( config.get('auth', 'endpoint_type') or utils.env('OS_ENDPOINT_TYPE') )
        self.include_pass = ( config.get('heat', 'include_pass') or bool(utils.env('HEAT_INCLUDE_PASSWORD')) )
        self.region_name = ( config.get('heat', 'region_name') or utils.env('OS_REGION_NAME') )
        self.api_version = ( config.get('heat', 'api_version') or utils.env('HEAT_API_VERSION') )
        self.KSclient = KSClient(config)
        self.ksclient = self.KSclient.get()
        self.token = self.ksclient.auth_token
        self.name = stackname
        self.template_file = ( template_file or config.get('stack', 'template_file') )
        self.template_url = template_url
        self.template_object = None
        self.stacktype = stacktype
        # parameters should be injected into the HeatStack object after the class has been instantiated in an external script
        #self.parameters = parameters
        
        kwargs = {
            'token': self.token,
            'insecure': False,
            'ca_file': None,
            'cert_file': None,
            'key_file': None,
            'username': self.username,
            'password': self.password,
            'endpoint_type': self.endpoint_type,
            'include_pass': self.include_pass,
            'region_name': self.region_name,
            'timeout': None
        }

        self.client = heat_client.Client(self.api_version, self.heat_url, **kwargs)
    def get_base_parser(self):
        parser = argparse.ArgumentParser(
            prog='heat',
            description=__doc__.strip(),
            epilog='See "heat help COMMAND" '
                   'for help on a specific command.',
            add_help=False,
            formatter_class=HelpFormatter,
        )

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

        parser.add_argument('--version',
                            action='version',
                            version=heatclient.__version__,
                            help="Shows the client version and exits")

        parser.add_argument('-d', '--debug',
                            default=bool(utils.env('HEATCLIENT_DEBUG')),
                            action='store_true',
                            help='Defaults to env[HEATCLIENT_DEBUG]')

        parser.add_argument('-v', '--verbose',
                            default=False, action="store_true",
                            help="Print more verbose output")

        parser.add_argument('-k', '--insecure',
                            default=False,
                            action='store_true',
                            help="Explicitly allow the client 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('--cert-file',
                            help='Path of certificate file to use in SSL '
                            'connection. This file can optionally be prepended'
                            'with the private key.')

        parser.add_argument('--key-file',
                            help='Path of client key to use in SSL connection.'
                            'This option is not necessary if your key is'
                            ' prepended to your cert file.')

        parser.add_argument('--ca-file',
                            help='Path of CA SSL certificate(s) used to verify'
                            ' the remote server\'s certificate. Without this'
                            ' option the client looks'
                            ' for the default system CA certificates.')

        parser.add_argument('--timeout',
                            default=600,
                            help='Number of seconds to wait for a response')

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

        parser.add_argument('--os_username',
                            help=argparse.SUPPRESS)

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

        parser.add_argument('--os_password',
                            help=argparse.SUPPRESS)

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

        parser.add_argument('--os_tenant_id',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-tenant-name',
                            default=utils.env('OS_TENANT_NAME'),
                            help='Defaults to env[OS_TENANT_NAME]')

        parser.add_argument('--os_tenant_name',
                            help=argparse.SUPPRESS)

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

        parser.add_argument('--os_auth_url',
                            help=argparse.SUPPRESS)

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

        parser.add_argument('--os_region_name',
                            help=argparse.SUPPRESS)

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

        parser.add_argument('--os_auth_token',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-no-client-auth',
                            default=utils.env('OS_NO_CLIENT_AUTH'),
                            action='store_true',
                            help="Do not contact keystone for a token.\
                            Defaults to env[OS_NO_CLIENT_AUTH]")

        parser.add_argument('--heat-url',
                            default=utils.env('HEAT_URL'),
                            help='Defaults to env[HEAT_URL]')

        parser.add_argument('--heat_url',
                            help=argparse.SUPPRESS)

        parser.add_argument('--heat-api-version',
                            default=utils.env('HEAT_API_VERSION', default='1'),
                            help='Defaults to env[HEAT_API_VERSION] or 1')

        parser.add_argument('--heat_api_version',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-service-type',
                            default=utils.env('OS_SERVICE_TYPE'),
                            help='Defaults to env[OS_SERVICE_TYPE]')

        parser.add_argument('--os_service_type',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-endpoint-type',
                            default=utils.env('OS_ENDPOINT_TYPE'),
                            help='Defaults to env[OS_ENDPOINT_TYPE]')

        parser.add_argument('--os_endpoint_type',
                            help=argparse.SUPPRESS)

        # This unused option should remain so that scripts that
        # use it do not break. It is suppressed so it will not
        # appear in the help.
        parser.add_argument('-t', '--token-only',
                            default=bool(False),
                            action='store_true',
                            help=argparse.SUPPRESS)

        parser.add_argument('--include-password',
                            default=bool(utils.env('HEAT_INCLUDE_PASSWORD')),
                            action='store_true',
                            help='Send os-username and os-password to heat')

        return parser
    def _append_global_identity_args(self, parser):
        # FIXME(gyee): these are global identity (Keystone) arguments which
        # should be consistent and shared by all service clients. Therefore,
        # they should be provided by python-keystoneclient. We will need to
        # refactor this code once this functionality is available in
        # python-keystoneclient.
        parser.add_argument(
            '-k', '--insecure', default=False, action='store_true',
            help=_('Explicitly allow heatclient 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(
            '--os-cert',
            help=_('Path of certificate file to use in SSL connection. '
                   'This file can optionally be prepended with '
                   'the private key.'))

        # for backward compatibility only
        parser.add_argument('--cert-file',
                            dest='os_cert',
                            help=_('DEPRECATED! Use %(arg)s.') %
                                 {'arg': '--os-cert'})

        parser.add_argument('--os-key',
                            help=_('Path of client key to use in SSL '
                                   'connection. This option is not necessary '
                                   'if your key is prepended to your cert '
                                   'file.'))

        parser.add_argument('--key-file',
                            dest='os_key',
                            help=_('DEPRECATED! Use %(arg)s.') %
                                 {'arg': '--os-key'})

        parser.add_argument('--os-cacert',
                            metavar='<ca-certificate-file>',
                            dest='os_cacert',
                            default=utils.env('OS_CACERT'),
                            help=_('Path of CA TLS certificate(s) used to '
                                   'verify the remote server\'s certificate. '
                                   'Without this option glance looks for the '
                                   'default system CA certificates.'))

        parser.add_argument('--ca-file',
                            dest='os_cacert',
                            help=_('DEPRECATED! Use %(arg)s.') %
                                 {'arg': '--os-cacert'})

        parser.add_argument('--os-username',
                            default=utils.env('OS_USERNAME'),
                            help=_('Defaults to %(value)s.') % {
                                'value': 'env[OS_USERNAME]'
                            })

        parser.add_argument('--os_username',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-user-id',
                            default=utils.env('OS_USER_ID'),
                            help=_('Defaults to %(value)s.') % {
                                'value': 'env[OS_USER_ID]'
                            })

        parser.add_argument('--os_user_id',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-user-domain-id',
                            default=utils.env('OS_USER_DOMAIN_ID'),
                            help=_('Defaults to %(value)s.') % {
                                'value': 'env[OS_USER_DOMAIN_ID]'
                            })

        parser.add_argument('--os_user_domain_id',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-user-domain-name',
                            default=utils.env('OS_USER_DOMAIN_NAME'),
                            help=_('Defaults to %(value)s.') % {
                                'value': 'env[OS_USER_DOMAIN_NAME]'
                            })

        parser.add_argument('--os_user_domain_name',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-project-id',
                            default=utils.env('OS_PROJECT_ID'),
                            help=(_('Another way to specify tenant ID. '
                                    'This option is mutually exclusive with '
                                    '%(arg)s. Defaults to %(value)s.') %
                                  {
                                      'arg': '--os-tenant-id',
                                      'value': 'env[OS_PROJECT_ID]'}))

        parser.add_argument('--os_project_id',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-project-name',
                            default=utils.env('OS_PROJECT_NAME'),
                            help=(_('Another way to specify tenant name. '
                                    'This option is mutually exclusive with '
                                    '%(arg)s. Defaults to %(value)s.') %
                                  {
                                      'arg': '--os-tenant-name',
                                      'value': 'env[OS_PROJECT_NAME]'}))

        parser.add_argument('--os_project_name',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-project-domain-id',
                            default=utils.env('OS_PROJECT_DOMAIN_ID'),
                            help=_('Defaults to %(value)s.') % {
                                'value': 'env[OS_PROJECT_DOMAIN_ID]'
                            })

        parser.add_argument('--os_project_domain_id',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-project-domain-name',
                            default=utils.env('OS_PROJECT_DOMAIN_NAME'),
                            help=_('Defaults to %(value)s.') % {
                                'value': 'env[OS_PROJECT_DOMAIN_NAME]'
                            })

        parser.add_argument('--os_project_domain_name',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-password',
                            default=utils.env('OS_PASSWORD'),
                            help=_('Defaults to %(value)s.') % {
                                'value': 'env[OS_PASSWORD]'
                            })

        parser.add_argument('--os_password',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-tenant-id',
                            default=utils.env('OS_TENANT_ID'),
                            help=_('Defaults to %(value)s.') % {
                                'value': 'env[OS_TENANT_ID]'
                            })

        parser.add_argument('--os_tenant_id',
                            default=utils.env('OS_TENANT_ID'),
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-tenant-name',
                            default=utils.env('OS_TENANT_NAME'),
                            help=_('Defaults to %(value)s.') % {
                                'value': 'env[OS_TENANT_NAME]'
                            })

        parser.add_argument('--os_tenant_name',
                            default=utils.env('OS_TENANT_NAME'),
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-auth-url',
                            default=utils.env('OS_AUTH_URL'),
                            help=_('Defaults to %(value)s.') % {
                                'value': 'env[OS_AUTH_URL]'
                            })

        parser.add_argument('--os_auth_url',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-region-name',
                            default=utils.env('OS_REGION_NAME'),
                            help=_('Defaults to %(value)s.') % {
                                'value': 'env[OS_REGION_NAME]'
                            })

        parser.add_argument('--os_region_name',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-auth-token',
                            default=utils.env('OS_AUTH_TOKEN'),
                            help=_('Defaults to %(value)s.') % {
                                'value': 'env[OS_AUTH_TOKEN]'
                            })

        parser.add_argument('--os_auth_token',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-service-type',
                            default=utils.env('OS_SERVICE_TYPE'),
                            help=_('Defaults to %(value)s.') % {
                                'value': 'env[OS_SERVICE_TYPE]'
                            })

        parser.add_argument('--os_service_type',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-endpoint-type',
                            default=utils.env('OS_ENDPOINT_TYPE'),
                            help=_('Defaults to %(value)s.') % {
                                'value': 'env[OS_ENDPOINT_TYPE]'
                            })

        parser.add_argument('--os_endpoint_type',
                            help=argparse.SUPPRESS)
    def get_base_parser(self):
        parser = argparse.ArgumentParser(
            prog='heat',
            description=__doc__.strip(),
            epilog=_('See "%(arg)s" for help on a specific command.') % {
                'arg': 'heat help COMMAND'
            },
            add_help=False,
            formatter_class=HelpFormatter,
        )

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

        parser.add_argument('--version',
                            action='version',
                            version=heatclient.__version__,
                            help=_("Shows the client version and exits."))

        parser.add_argument('-d', '--debug',
                            default=bool(utils.env('HEATCLIENT_DEBUG')),
                            action='store_true',
                            help=_('Defaults to %(value)s.') % {
                                'value': 'env[HEATCLIENT_DEBUG]'
                            })

        parser.add_argument('-v', '--verbose',
                            default=False, action="store_true",
                            help=_("Print more verbose output."))

        parser.add_argument('--api-timeout',
                            help=_('Number of seconds to wait for an '
                                   'API response, '
                                   'defaults to system socket timeout'))

        # os-no-client-auth tells heatclient to use token, instead of
        # env[OS_AUTH_URL]
        parser.add_argument('--os-no-client-auth',
                            default=utils.env('OS_NO_CLIENT_AUTH'),
                            action='store_true',
                            help=(_("Do not contact keystone for a token. "
                                    "Defaults to %(value)s.") %
                                  {'value': 'env[OS_NO_CLIENT_AUTH]'}))

        parser.add_argument('--heat-url',
                            default=utils.env('HEAT_URL'),
                            help=_('Defaults to %(value)s.') % {
                                'value': 'env[HEAT_URL]'
                            })

        parser.add_argument('--heat_url',
                            help=argparse.SUPPRESS)

        parser.add_argument('--heat-api-version',
                            default=utils.env('HEAT_API_VERSION', default='1'),
                            help=_('Defaults to %(value)s or 1.') % {
                                'value': 'env[HEAT_API_VERSION]'
                            })

        parser.add_argument('--heat_api_version',
                            help=argparse.SUPPRESS)

        # This unused option should remain so that scripts that
        # use it do not break. It is suppressed so it will not
        # appear in the help.
        parser.add_argument('-t', '--token-only',
                            default=bool(False),
                            action='store_true',
                            help=argparse.SUPPRESS)

        parser.add_argument('--include-password',
                            default=bool(utils.env('HEAT_INCLUDE_PASSWORD')),
                            action='store_true',
                            help=_('Send %(arg1)s and %(arg2)s to heat.') % {
                                'arg1': 'os-username',
                                'arg2': 'os-password'
                            })

        # FIXME(gyee): this method should come from python-keystoneclient.
        # Will refactor this code once it is available.
        # https://bugs.launchpad.net/python-keystoneclient/+bug/1332337

        self._append_global_identity_args(parser)

        if osprofiler_profiler:
            parser.add_argument(
                '--profile',
                metavar='HMAC_KEY',
                help=_('HMAC key to use for encrypting context data '
                       'for performance profiling of operation. '
                       'This key should be the value of HMAC key '
                       'configured in osprofiler middleware in heat, '
                       'it is specified in the paste configuration '
                       '(/etc/heat/api-paste.ini). Without the key, '
                       'profiling will not be triggered '
                       'even if osprofiler is enabled on server side.'))
        return parser
Exemple #9
0
    def _append_global_identity_args(self, parser):
        # FIXME(gyee): these are global identity (Keystone) arguments which
        # should be consistent and shared by all service clients. Therefore,
        # they should be provided by python-keystoneclient. We will need to
        # refactor this code once this functionality is available in
        # python-keystoneclient.
        parser.add_argument(
            '-k',
            '--insecure',
            default=False,
            action='store_true',
            help=_('Explicitly allow heatclient 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(
            '--os-cert',
            default=utils.env('OS_CERT'),
            help=_('Path of certificate file to use in SSL connection. '
                   'This file can optionally be prepended with '
                   'the private key.'))

        # for backward compatibility only
        parser.add_argument('--cert-file',
                            dest='os_cert',
                            help=_('DEPRECATED! Use %(arg)s.') %
                            {'arg': '--os-cert'})

        parser.add_argument('--os-key',
                            default=utils.env('OS_KEY'),
                            help=_('Path of client key to use in SSL '
                                   'connection. This option is not necessary '
                                   'if your key is prepended to your cert '
                                   'file.'))

        parser.add_argument('--key-file',
                            dest='os_key',
                            help=_('DEPRECATED! Use %(arg)s.') %
                            {'arg': '--os-key'})

        parser.add_argument('--os-cacert',
                            metavar='<ca-certificate-file>',
                            dest='os_cacert',
                            default=utils.env('OS_CACERT'),
                            help=_('Path of CA TLS certificate(s) used to '
                                   'verify the remote server\'s certificate. '
                                   'Without this option glance looks for the '
                                   'default system CA certificates.'))

        parser.add_argument('--ca-file',
                            dest='os_cacert',
                            help=_('DEPRECATED! Use %(arg)s.') %
                            {'arg': '--os-cacert'})

        parser.add_argument('--os-username',
                            default=utils.env('OS_USERNAME'),
                            help=_('Defaults to %(value)s.') %
                            {'value': 'env[OS_USERNAME]'})

        parser.add_argument('--os_username', help=argparse.SUPPRESS)

        parser.add_argument('--os-user-id',
                            default=utils.env('OS_USER_ID'),
                            help=_('Defaults to %(value)s.') %
                            {'value': 'env[OS_USER_ID]'})

        parser.add_argument('--os_user_id', help=argparse.SUPPRESS)

        parser.add_argument('--os-user-domain-id',
                            default=utils.env('OS_USER_DOMAIN_ID'),
                            help=_('Defaults to %(value)s.') %
                            {'value': 'env[OS_USER_DOMAIN_ID]'})

        parser.add_argument('--os_user_domain_id', help=argparse.SUPPRESS)

        parser.add_argument('--os-user-domain-name',
                            default=utils.env('OS_USER_DOMAIN_NAME'),
                            help=_('Defaults to %(value)s.') %
                            {'value': 'env[OS_USER_DOMAIN_NAME]'})

        parser.add_argument('--os_user_domain_name', help=argparse.SUPPRESS)

        parser.add_argument('--os-project-id',
                            default=utils.env('OS_PROJECT_ID'),
                            help=(_('Another way to specify tenant ID. '
                                    'This option is mutually exclusive with '
                                    '%(arg)s. Defaults to %(value)s.') % {
                                        'arg': '--os-tenant-id',
                                        'value': 'env[OS_PROJECT_ID]'
                                    }))

        parser.add_argument('--os_project_id', help=argparse.SUPPRESS)

        parser.add_argument('--os-project-name',
                            default=utils.env('OS_PROJECT_NAME'),
                            help=(_('Another way to specify tenant name. '
                                    'This option is mutually exclusive with '
                                    '%(arg)s. Defaults to %(value)s.') % {
                                        'arg': '--os-tenant-name',
                                        'value': 'env[OS_PROJECT_NAME]'
                                    }))

        parser.add_argument('--os_project_name', help=argparse.SUPPRESS)

        parser.add_argument('--os-project-domain-id',
                            default=utils.env('OS_PROJECT_DOMAIN_ID'),
                            help=_('Defaults to %(value)s.') %
                            {'value': 'env[OS_PROJECT_DOMAIN_ID]'})

        parser.add_argument('--os_project_domain_id', help=argparse.SUPPRESS)

        parser.add_argument('--os-project-domain-name',
                            default=utils.env('OS_PROJECT_DOMAIN_NAME'),
                            help=_('Defaults to %(value)s.') %
                            {'value': 'env[OS_PROJECT_DOMAIN_NAME]'})

        parser.add_argument('--os_project_domain_name', help=argparse.SUPPRESS)

        parser.add_argument('--os-password',
                            default=utils.env('OS_PASSWORD'),
                            help=_('Defaults to %(value)s.') %
                            {'value': 'env[OS_PASSWORD]'})

        parser.add_argument('--os_password', help=argparse.SUPPRESS)

        parser.add_argument('--os-tenant-id',
                            default=utils.env('OS_TENANT_ID'),
                            help=_('Defaults to %(value)s.') %
                            {'value': 'env[OS_TENANT_ID]'})

        parser.add_argument('--os_tenant_id',
                            default=utils.env('OS_TENANT_ID'),
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-tenant-name',
                            default=utils.env('OS_TENANT_NAME'),
                            help=_('Defaults to %(value)s.') %
                            {'value': 'env[OS_TENANT_NAME]'})

        parser.add_argument('--os_tenant_name',
                            default=utils.env('OS_TENANT_NAME'),
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-auth-url',
                            default=utils.env('OS_AUTH_URL'),
                            help=_('Defaults to %(value)s.') %
                            {'value': 'env[OS_AUTH_URL]'})

        parser.add_argument('--os_auth_url', help=argparse.SUPPRESS)

        parser.add_argument('--os-region-name',
                            default=utils.env('OS_REGION_NAME'),
                            help=_('Defaults to %(value)s.') %
                            {'value': 'env[OS_REGION_NAME]'})

        parser.add_argument('--os_region_name', help=argparse.SUPPRESS)

        parser.add_argument('--os-auth-token',
                            default=utils.env('OS_AUTH_TOKEN'),
                            help=_('Defaults to %(value)s.') %
                            {'value': 'env[OS_AUTH_TOKEN]'})

        parser.add_argument('--os_auth_token', help=argparse.SUPPRESS)

        parser.add_argument('--os-service-type',
                            default=utils.env('OS_SERVICE_TYPE'),
                            help=_('Defaults to %(value)s.') %
                            {'value': 'env[OS_SERVICE_TYPE]'})

        parser.add_argument('--os_service_type', help=argparse.SUPPRESS)

        parser.add_argument('--os-endpoint-type',
                            default=utils.env('OS_ENDPOINT_TYPE'),
                            help=_('Defaults to %(value)s.') %
                            {'value': 'env[OS_ENDPOINT_TYPE]'})

        parser.add_argument('--os_endpoint_type', help=argparse.SUPPRESS)
Exemple #10
0
    def get_base_parser(self):
        parser = argparse.ArgumentParser(
            prog='heat',
            description=__doc__.strip(),
            epilog=_('See "%(arg)s" for help on a specific command.') %
            {'arg': 'heat help COMMAND'},
            add_help=False,
            formatter_class=HelpFormatter,
        )

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

        parser.add_argument('--version',
                            action='version',
                            version=heatclient.__version__,
                            help=_("Shows the client version and exits."))

        parser.add_argument('-d',
                            '--debug',
                            default=bool(utils.env('HEATCLIENT_DEBUG')),
                            action='store_true',
                            help=_('Defaults to %(value)s.') %
                            {'value': 'env[HEATCLIENT_DEBUG]'})

        parser.add_argument('-v',
                            '--verbose',
                            default=False,
                            action="store_true",
                            help=_("Print more verbose output."))

        parser.add_argument('--api-timeout',
                            help=_('Number of seconds to wait for an '
                                   'API response, '
                                   'defaults to system socket timeout'))

        # os-no-client-auth tells heatclient to use token, instead of
        # env[OS_AUTH_URL]
        parser.add_argument('--os-no-client-auth',
                            default=utils.env('OS_NO_CLIENT_AUTH'),
                            action='store_true',
                            help=(_("Do not contact keystone for a token. "
                                    "Defaults to %(value)s.") % {
                                        'value': 'env[OS_NO_CLIENT_AUTH]'
                                    }))

        parser.add_argument('--heat-url',
                            default=utils.env('HEAT_URL'),
                            help=_('Defaults to %(value)s.') %
                            {'value': 'env[HEAT_URL]'})

        parser.add_argument('--heat_url', help=argparse.SUPPRESS)

        parser.add_argument('--heat-api-version',
                            default=utils.env('HEAT_API_VERSION', default='1'),
                            help=_('Defaults to %(value)s or 1.') %
                            {'value': 'env[HEAT_API_VERSION]'})

        parser.add_argument('--heat_api_version', help=argparse.SUPPRESS)

        # This unused option should remain so that scripts that
        # use it do not break. It is suppressed so it will not
        # appear in the help.
        parser.add_argument('-t',
                            '--token-only',
                            default=bool(False),
                            action='store_true',
                            help=argparse.SUPPRESS)

        parser.add_argument('--include-password',
                            default=bool(utils.env('HEAT_INCLUDE_PASSWORD')),
                            action='store_true',
                            help=_('Send %(arg1)s and %(arg2)s to heat.') % {
                                'arg1': 'os-username',
                                'arg2': 'os-password'
                            })

        # FIXME(gyee): this method should come from python-keystoneclient.
        # Will refactor this code once it is available.
        # https://bugs.launchpad.net/python-keystoneclient/+bug/1332337

        self._append_global_identity_args(parser)

        if osprofiler_profiler:
            parser.add_argument(
                '--profile',
                metavar='HMAC_KEY',
                help=_('HMAC key to use for encrypting context data '
                       'for performance profiling of operation. '
                       'This key should be the value of HMAC key '
                       'configured in osprofiler middleware in heat, '
                       'it is specified in the paste configuration '
                       '(/etc/heat/api-paste.ini). Without the key, '
                       'profiling will not be triggered '
                       'even if osprofiler is enabled on server side.'))
        return parser
Exemple #11
0
    def get_base_parser(self):
        parser = argparse.ArgumentParser(
            prog='heat',
            description=__doc__.strip(),
            epilog='See "heat help COMMAND" '
                   'for help on a specific command.',
            add_help=False,
            formatter_class=HelpFormatter,
        )

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

        parser.add_argument('-d', '--debug',
            default=bool(utils.env('HEATCLIENT_DEBUG')),
            action='store_true',
            help='Defaults to env[HEATCLIENT_DEBUG]')

        parser.add_argument('-v', '--verbose',
            default=False, action="store_true",
            help="Print more verbose output")

        parser.add_argument('-k', '--insecure',
            default=False,
            action='store_true',
            help="Explicitly allow glanceclient 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('--cert-file',
            help='Path of certificate file to use in SSL connection. This '
                 'file can optionally be prepended with the private key.')

        parser.add_argument('--key-file',
            help='Path of client key to use in SSL connection. This option is '
                 'not necessary if your key is prepended to your cert file.')

        parser.add_argument('--ca-file',
            help='Path of CA SSL certificate(s) used to verify the remote '
                 'server\'s certificate. Without this option glance looks '
                 'for the default system CA certificates.')

        parser.add_argument('--timeout',
            default=600,
            help='Number of seconds to wait for a response')

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

        parser.add_argument('--os_username',
            help=argparse.SUPPRESS)

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

        parser.add_argument('--os_password',
            help=argparse.SUPPRESS)

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

        parser.add_argument('--os_tenant_id',
            help=argparse.SUPPRESS)

        parser.add_argument('--os-tenant-name',
            default=utils.env('OS_TENANT_NAME'),
            help='Defaults to env[OS_TENANT_NAME]')

        parser.add_argument('--os_tenant_name',
            help=argparse.SUPPRESS)

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

        parser.add_argument('--os_auth_url',
            help=argparse.SUPPRESS)

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

        parser.add_argument('--os_region_name',
            help=argparse.SUPPRESS)

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

        parser.add_argument('--os_auth_token',
            help=argparse.SUPPRESS)

        parser.add_argument('--heat-url',
            default=utils.env('HEAT_URL'),
            help='Defaults to env[HEAT_URL]')

        parser.add_argument('--heat_url',
            help=argparse.SUPPRESS)

        parser.add_argument('--heat-api-version',
            default=utils.env('HEAT_API_VERSION', default='1'),
            help='Defaults to env[HEAT_API_VERSION] or 1')

        parser.add_argument('--heat_api_version',
            help=argparse.SUPPRESS)

        parser.add_argument('--os-service-type',
            default=utils.env('OS_SERVICE_TYPE'),
            help='Defaults to env[OS_SERVICE_TYPE]')

        parser.add_argument('--os_service_type',
            help=argparse.SUPPRESS)

        parser.add_argument('--os-endpoint-type',
            default=utils.env('OS_ENDPOINT_TYPE'),
            help='Defaults to env[OS_ENDPOINT_TYPE]')

        parser.add_argument('--os_endpoint_type',
            help=argparse.SUPPRESS)

        return parser
Exemple #12
0
    def get_base_parser(self):
        parser = argparse.ArgumentParser(
            prog='heat',
            description=__doc__.strip(),
            epilog='See "heat help COMMAND" '
            'for help on a specific command.',
            add_help=False,
            formatter_class=HelpFormatter,
        )

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

        parser.add_argument('--version',
                            action='version',
                            version=heatclient.__version__,
                            help="Shows the client version and exits.")

        parser.add_argument('-d',
                            '--debug',
                            default=bool(utils.env('HEATCLIENT_DEBUG')),
                            action='store_true',
                            help='Defaults to env[HEATCLIENT_DEBUG].')

        parser.add_argument('-v',
                            '--verbose',
                            default=False,
                            action="store_true",
                            help="Print more verbose output.")

        parser.add_argument('-k',
                            '--insecure',
                            default=False,
                            action='store_true',
                            help="Explicitly allow the client 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('--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('--cert-file',
                            help='Path of certificate file to use in SSL '
                            'connection. This file can optionally be '
                            'prepended with the private key.')

        parser.add_argument('--key-file',
                            help='Path of client key to use in SSL connection.'
                            'This option is not necessary if your key is'
                            ' prepended to your cert file.')

        parser.add_argument('--ca-file',
                            help='Path of CA SSL certificate(s) used to verify'
                            ' the remote server\'s certificate. Without this'
                            ' option the client looks'
                            ' for the default system CA certificates.')

        parser.add_argument('--api-timeout',
                            help='Number of seconds to wait for an '
                            'API response, '
                            'defaults to system socket timeout')

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

        parser.add_argument('--os_username', help=argparse.SUPPRESS)

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

        parser.add_argument('--os_password', help=argparse.SUPPRESS)

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

        parser.add_argument('--os_tenant_id', help=argparse.SUPPRESS)

        parser.add_argument('--os-tenant-name',
                            default=utils.env('OS_TENANT_NAME'),
                            help='Defaults to env[OS_TENANT_NAME].')

        parser.add_argument('--os_tenant_name', help=argparse.SUPPRESS)

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

        parser.add_argument('--os_auth_url', help=argparse.SUPPRESS)

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

        parser.add_argument('--os_region_name', help=argparse.SUPPRESS)

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

        parser.add_argument('--os_auth_token', help=argparse.SUPPRESS)

        parser.add_argument('--os-no-client-auth',
                            default=utils.env('OS_NO_CLIENT_AUTH'),
                            action='store_true',
                            help="Do not contact keystone for a token. "
                            "Defaults to env[OS_NO_CLIENT_AUTH].")

        parser.add_argument('--heat-url',
                            default=utils.env('HEAT_URL'),
                            help='Defaults to env[HEAT_URL].')

        parser.add_argument('--heat_url', help=argparse.SUPPRESS)

        parser.add_argument('--heat-api-version',
                            default=utils.env('HEAT_API_VERSION', default='1'),
                            help='Defaults to env[HEAT_API_VERSION] or 1.')

        parser.add_argument('--heat_api_version', help=argparse.SUPPRESS)

        parser.add_argument('--os-service-type',
                            default=utils.env('OS_SERVICE_TYPE'),
                            help='Defaults to env[OS_SERVICE_TYPE].')

        parser.add_argument('--os_service_type', help=argparse.SUPPRESS)

        parser.add_argument('--os-endpoint-type',
                            default=utils.env('OS_ENDPOINT_TYPE'),
                            help='Defaults to env[OS_ENDPOINT_TYPE].')

        parser.add_argument('--os_endpoint_type', help=argparse.SUPPRESS)

        # This unused option should remain so that scripts that
        # use it do not break. It is suppressed so it will not
        # appear in the help.
        parser.add_argument('-t',
                            '--token-only',
                            default=bool(False),
                            action='store_true',
                            help=argparse.SUPPRESS)

        parser.add_argument('--include-password',
                            default=bool(utils.env('HEAT_INCLUDE_PASSWORD')),
                            action='store_true',
                            help='Send os-username and os-password to heat.')

        return parser
Exemple #13
0
    def get_base_parser(self):
        parser = argparse.ArgumentParser(
            prog="heat",
            description=__doc__.strip(),
            epilog='See "heat help COMMAND" ' "for help on a specific command.",
            add_help=False,
            formatter_class=HelpFormatter,
        )

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

        parser.add_argument(
            "--version", action="version", version=heatclient.__version__, help="Shows the client version and exits."
        )

        parser.add_argument(
            "-d",
            "--debug",
            default=bool(utils.env("HEATCLIENT_DEBUG")),
            action="store_true",
            help="Defaults to env[HEATCLIENT_DEBUG].",
        )

        parser.add_argument("-v", "--verbose", default=False, action="store_true", help="Print more verbose output.")

        parser.add_argument(
            "-k",
            "--insecure",
            default=False,
            action="store_true",
            help="Explicitly allow the client 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(
            "--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(
            "--cert-file",
            help="Path of certificate file to use in SSL "
            "connection. This file can optionally be "
            "prepended with the private key.",
        )

        parser.add_argument(
            "--key-file",
            help="Path of client key to use in SSL connection."
            "This option is not necessary if your key is"
            " prepended to your cert file.",
        )

        parser.add_argument(
            "--ca-file",
            help="Path of CA SSL certificate(s) used to verify"
            " the remote server's certificate. Without this"
            " option the client looks"
            " for the default system CA certificates.",
        )

        parser.add_argument(
            "--api-timeout",
            help="Number of seconds to wait for an " "API response, " "defaults to system socket timeout",
        )

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

        parser.add_argument("--os_username", help=argparse.SUPPRESS)

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

        parser.add_argument("--os_password", help=argparse.SUPPRESS)

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

        parser.add_argument("--os_tenant_id", help=argparse.SUPPRESS)

        parser.add_argument(
            "--os-tenant-name", default=utils.env("OS_TENANT_NAME"), help="Defaults to env[OS_TENANT_NAME]."
        )

        parser.add_argument("--os_tenant_name", help=argparse.SUPPRESS)

        parser.add_argument("--os-auth-url", default=utils.env("OS_AUTH_URL"), help="Defaults to env[OS_AUTH_URL].")

        parser.add_argument("--os_auth_url", help=argparse.SUPPRESS)

        parser.add_argument(
            "--os-region-name", default=utils.env("OS_REGION_NAME"), help="Defaults to env[OS_REGION_NAME]."
        )

        parser.add_argument("--os_region_name", help=argparse.SUPPRESS)

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

        parser.add_argument("--os_auth_token", help=argparse.SUPPRESS)

        parser.add_argument(
            "--os-no-client-auth",
            default=utils.env("OS_NO_CLIENT_AUTH"),
            action="store_true",
            help="Do not contact keystone for a token. " "Defaults to env[OS_NO_CLIENT_AUTH].",
        )

        parser.add_argument("--heat-url", default=utils.env("HEAT_URL"), help="Defaults to env[HEAT_URL].")

        parser.add_argument("--heat_url", help=argparse.SUPPRESS)

        parser.add_argument(
            "--heat-api-version",
            default=utils.env("HEAT_API_VERSION", default="1"),
            help="Defaults to env[HEAT_API_VERSION] or 1.",
        )

        parser.add_argument("--heat_api_version", help=argparse.SUPPRESS)

        parser.add_argument(
            "--os-service-type", default=utils.env("OS_SERVICE_TYPE"), help="Defaults to env[OS_SERVICE_TYPE]."
        )

        parser.add_argument("--os_service_type", help=argparse.SUPPRESS)

        parser.add_argument(
            "--os-endpoint-type", default=utils.env("OS_ENDPOINT_TYPE"), help="Defaults to env[OS_ENDPOINT_TYPE]."
        )

        parser.add_argument("--os_endpoint_type", help=argparse.SUPPRESS)

        # This unused option should remain so that scripts that
        # use it do not break. It is suppressed so it will not
        # appear in the help.
        parser.add_argument("-t", "--token-only", default=bool(False), action="store_true", help=argparse.SUPPRESS)

        parser.add_argument(
            "--include-password",
            default=bool(utils.env("HEAT_INCLUDE_PASSWORD")),
            action="store_true",
            help="Send os-username and os-password to heat.",
        )

        return parser
Exemple #14
0
    def get_base_parser(self):
        parser = argparse.ArgumentParser(
            prog='heat',
            description=__doc__.strip(),
            epilog='See "heat help COMMAND" '
                   'for help on a specific command.',
            add_help=False,
            formatter_class=HelpFormatter,
        )

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

        parser.add_argument('--version',
                            action='version',
                            version=heatclient.__version__,
                            help="Shows the client version and exits.")

        parser.add_argument('-d', '--debug',
                            default=bool(utils.env('HEATCLIENT_DEBUG')),
                            action='store_true',
                            help='Defaults to env[HEATCLIENT_DEBUG].')

        parser.add_argument('-v', '--verbose',
                            default=False, action="store_true",
                            help="Print more verbose output.")

        parser.add_argument('--api-timeout',
                            help='Number of seconds to wait for an '
                                 'API response, '
                                 'defaults to system socket timeout')

        # os-no-client-auth tells heatclient to use token, instead of
        # env[OS_AUTH_URL]
        parser.add_argument('--os-no-client-auth',
                            default=utils.env('OS_NO_CLIENT_AUTH'),
                            action='store_true',
                            help="Do not contact keystone for a token. "
                                 "Defaults to env[OS_NO_CLIENT_AUTH].")

        parser.add_argument('--heat-url',
                            default=utils.env('HEAT_URL'),
                            help='Defaults to env[HEAT_URL].')

        parser.add_argument('--heat_url',
                            help=argparse.SUPPRESS)

        parser.add_argument('--heat-api-version',
                            default=utils.env('HEAT_API_VERSION', default='1'),
                            help='Defaults to env[HEAT_API_VERSION] or 1.')

        parser.add_argument('--heat_api_version',
                            help=argparse.SUPPRESS)

        # This unused option should remain so that scripts that
        # use it do not break. It is suppressed so it will not
        # appear in the help.
        parser.add_argument('-t', '--token-only',
                            default=bool(False),
                            action='store_true',
                            help=argparse.SUPPRESS)

        parser.add_argument('--include-password',
                            default=bool(utils.env('HEAT_INCLUDE_PASSWORD')),
                            action='store_true',
                            help='Send os-username and os-password to heat.')

        # FIXME(gyee): this method should come from python-keystoneclient.
        # Will refactor this code once it is available.
        # https://bugs.launchpad.net/python-keystoneclient/+bug/1332337

        self._append_global_identity_args(parser)

        return parser