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.getenv("OS_VERIFY_PASSWORD"))
     return self._prompt_password(verify_pass)
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
    def create(self, name, ram, vcpus, disk, flavorid="auto",
               ephemeral=0, swap=0, rxtx_factor=1.0, is_public=True):
        """
        Create a flavor.

        :param name: Descriptive name of the flavor
        :param ram: Memory in MB for the flavor
        :param vcpus: Number of VCPUs for the flavor
        :param disk: Size of local disk in GB
        :param flavorid: ID for the flavor (optional). You can use the reserved
                         value ``"auto"`` to have Nova generate a UUID for the
                         flavor in cases where you cannot simply pass ``None``.
        :param swap: Swap space in MB
        :param rxtx_factor: RX/TX factor
        :rtype: :class:`Flavor`
        """

        try:
            ram = int(ram)
        except (TypeError, ValueError):
            raise exceptions.CommandError("Ram must be an integer.")
        try:
            vcpus = int(vcpus)
        except (TypeError, ValueError):
            raise exceptions.CommandError("VCPUs must be an integer.")
        try:
            disk = int(disk)
        except (TypeError, ValueError):
            raise exceptions.CommandError("Disk must be an integer.")

        if flavorid == "auto":
            flavorid = None

        try:
            swap = int(swap)
        except (TypeError, ValueError):
            raise exceptions.CommandError("Swap must be an integer.")
        try:
            ephemeral = int(ephemeral)
        except (TypeError, ValueError):
            raise exceptions.CommandError("Ephemeral must be an integer.")
        try:
            rxtx_factor = float(rxtx_factor)
        except (TypeError, ValueError):
            raise exceptions.CommandError("rxtx_factor must be a float.")

        try:
            is_public = utils.bool_from_str(is_public)
        except Exception:
            raise exceptions.CommandError("is_public must be a boolean.")

        body = {
            "flavor": {
                "name": name,
                "ram": ram,
                "vcpus": vcpus,
                "disk": disk,
                "id": flavorid,
                "swap": swap,
                "OS-FLV-EXT-DATA:ephemeral": ephemeral,
                "rxtx_factor": rxtx_factor,
                "os-flavor-access:is_public": is_public,
            }
        }

        return self._create("/flavors", body, "flavor")
Ejemplo n.º 4
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=not utils.bool_from_str(
                    utils.env('OS_NO_CACHE', default='true')),
            action='store_false',
            dest='os_cache',
            help=argparse.SUPPRESS)
        parser.add_argument('--no_cache',
            action='store_false',
            dest='os_cache',
            help=argparse.SUPPRESS)

        parser.add_argument('--os-cache',
            default=utils.env('OS_CACHE', default=False),
            action='store_true',
            help="Use the auth token cache.")

        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-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('--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
Ejemplo n.º 5
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
Ejemplo n.º 6
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=not utils.bool_from_str(
                                utils.env('OS_NO_CACHE', default='true')),
                            action='store_false',
                            dest='os_cache',
                            help=argparse.SUPPRESS)
        parser.add_argument('--no_cache',
                            action='store_false',
                            dest='os_cache',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-cache',
                            default=utils.env('OS_CACHE', default=False),
                            action='store_true',
                            help="Use the auth token cache.")

        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-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('--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.")

        # 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
Ejemplo n.º 7
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=not utils.bool_from_str(
                    utils.env('OS_NO_CACHE', default='true')),
            action='store_false',
            dest='os_cache',
            help=argparse.SUPPRESS)
        parser.add_argument('--no_cache',
            action='store_false',
            dest='os_cache',
            help=argparse.SUPPRESS)

        parser.add_argument('--os-cache',
            default=utils.env('OS_CACHE', default=False),
            action='store_true',
            help="Use the auth token cache.")

        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
Ejemplo n.º 8
0
    def create(self, name, ram, vcpus, disk, flavorid,
               ephemeral=0, swap=0, rxtx_factor=1, is_public=True):
        """
        Create (allocate) a  floating ip for a tenant

        :param name: Descriptive name of the flavor
        :param ram: Memory in MB for the flavor
        :param vcpu: Number of VCPUs for the flavor
        :param disk: Size of local disk in GB
        :param flavorid: Integer ID for the flavor
        :param swap: Swap space in MB
        :param rxtx_factor: RX/TX factor
        :rtype: :class:`Flavor`
        """

        try:
            ram = int(ram)
        except:
            raise exceptions.CommandError("Ram must be an integer.")

        try:
            vcpus = int(vcpus)
        except:
            raise exceptions.CommandError("VCPUs must be an integer.")

        try:
            disk = int(disk)
        except:
            raise exceptions.CommandError("Disk must be an integer.")

        if flavorid == "auto":
            flavorid = None

        try:
            swap = int(swap)
        except:
            raise exceptions.CommandError("Swap must be an integer.")

        try:
            ephemerel = int(ephemeral)
        except:
            raise exceptions.CommandError("Ephemerel must be an integer.")

        try:
            rxtx_factor = int(rxtx_factor)
        except:
            raise exceptions.CommandError("rxtx_factor must be an integer.")

        try:
            is_public = utils.bool_from_str(is_public)
        except:
            raise exceptions.CommandError("is_public must be a boolean.")

        body = {
            "flavor": {
                "name": name,
                "ram": int(ram),
                "vcpus": int(vcpus),
                "disk": int(disk),
                "id": flavorid,
                "swap": int(swap),
                "OS-FLV-EXT-DATA:ephemeral": int(ephemeral),
                "rxtx_factor": int(rxtx_factor),
                "os-flavor-access:is_public": bool(is_public),
            }
        }

        return self._create("/flavors", body, "flavor")