/
usr
/
lib
/
python2.6
/
site-packages
/
novaclient
/
v2
/
/usr/lib/python2.6/site-packages/novaclient/v2
mkdir
upload
Name
Size
Mode
Actions
contrib/
-
0755
rm
agents.py
2240
0644
edit
dl
rm
agents.pyc
2774
0644
edit
dl
rm
aggregates.py
3500
0644
edit
dl
rm
aggregates.pyc
4777
0644
edit
dl
rm
availability_zones.py
1588
0644
edit
dl
rm
availability_zones.pyc
1703
0644
edit
dl
rm
certs.py
1410
0644
edit
dl
rm
certs.pyc
1651
0644
edit
dl
rm
client.py
9859
0644
edit
dl
rm
client.pyc
8652
0644
edit
dl
rm
cloudpipe.py
1906
0644
edit
dl
rm
cloudpipe.pyc
2474
0644
edit
dl
rm
fixed_ips.py
1683
0644
edit
dl
rm
fixed_ips.pyc
2099
0644
edit
dl
rm
flavors.py
6824
0644
edit
dl
rm
flavors.pyc
7623
0644
edit
dl
rm
flavor_access.py
2654
0644
edit
dl
rm
flavor_access.pyc
3257
0644
edit
dl
rm
floating_ips.py
1730
0644
edit
dl
rm
floating_ips.pyc
2222
0644
edit
dl
rm
floating_ips_bulk.py
2108
0644
edit
dl
rm
floating_ips_bulk.pyc
2286
0644
edit
dl
rm
floating_ip_dns.py
4378
0644
edit
dl
rm
floating_ip_dns.pyc
6260
0644
edit
dl
rm
floating_ip_pools.py
1064
0644
edit
dl
rm
floating_ip_pools.pyc
1255
0644
edit
dl
rm
fping.py
1750
0644
edit
dl
rm
fping.pyc
2039
0644
edit
dl
rm
hosts.py
2094
0644
edit
dl
rm
hosts.pyc
3254
0644
edit
dl
rm
hypervisors.py
2826
0644
edit
dl
rm
hypervisors.pyc
4042
0644
edit
dl
rm
images.py
3151
0644
edit
dl
rm
images.pyc
4137
0644
edit
dl
rm
keypairs.py
3497
0644
edit
dl
rm
keypairs.pyc
3944
0644
edit
dl
rm
limits.py
3092
0644
edit
dl
rm
limits.pyc
4311
0644
edit
dl
rm
networks.py
4815
0644
edit
dl
rm
networks.pyc
5836
0644
edit
dl
rm
quotas.py
2264
0644
edit
dl
rm
quotas.pyc
2619
0644
edit
dl
rm
quota_classes.py
1500
0644
edit
dl
rm
quota_classes.pyc
1775
0644
edit
dl
rm
security_groups.py
3000
0644
edit
dl
rm
security_groups.pyc
4121
0644
edit
dl
rm
security_group_default_rules.py
2741
0644
edit
dl
rm
security_group_default_rules.pyc
3326
0644
edit
dl
rm
security_group_rules.py
2681
0644
edit
dl
rm
security_group_rules.pyc
2988
0644
edit
dl
rm
servers.py
45064
0644
edit
dl
rm
servers.pyc
50236
0644
edit
dl
rm
server_groups.py
2060
0644
edit
dl
rm
server_groups.pyc
2811
0644
edit
dl
rm
server_migrations.py
2924
0644
edit
dl
rm
server_migrations.pyc
3332
0644
edit
dl
rm
services.py
3305
0644
edit
dl
rm
services.pyc
4098
0644
edit
dl
rm
shell.py
148685
0644
edit
dl
rm
shell.pyc
149090
0644
edit
dl
rm
usage.py
2019
0644
edit
dl
rm
usage.pyc
2327
0644
edit
dl
rm
versions.py
3032
0644
edit
dl
rm
versions.pyc
2634
0644
edit
dl
rm
virtual_interfaces.py
1039
0644
edit
dl
rm
virtual_interfaces.pyc
1252
0644
edit
dl
rm
volumes.py
7731
0644
edit
dl
rm
volumes.pyc
8088
0644
edit
dl
rm
volume_snapshots.py
4475
0644
edit
dl
rm
volume_snapshots.pyc
4779
0644
edit
dl
rm
volume_types.py
3698
0644
edit
dl
rm
volume_types.pyc
3989
0644
edit
dl
rm
__init__.py
649
0644
edit
dl
rm
__init__.pyc
219
0644
edit
dl
rm
Edit:
/usr/lib/python2.6/site-packages/novaclient/v2/flavors.py
(6824B)
# Copyright 2010 Jacob Kaplan-Moss # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """ Flavor interface. """ from oslo_utils import strutils from six.moves.urllib import parse from novaclient import base from novaclient import exceptions from novaclient.i18n import _ from novaclient import utils class Flavor(base.Resource): """ A flavor is an available hardware configuration for a server. """ HUMAN_ID = True def __repr__(self): return "<Flavor: %s>" % self.name @property def ephemeral(self): """ Provide a user-friendly accessor to OS-FLV-EXT-DATA:ephemeral """ return self._info.get("OS-FLV-EXT-DATA:ephemeral", 'N/A') @property def is_public(self): """ Provide a user-friendly accessor to os-flavor-access:is_public """ return self._info.get("os-flavor-access:is_public", 'N/A') def get_keys(self): """ Get extra specs from a flavor. """ _resp, body = self.manager.api.client.get( "/flavors/%s/os-extra_specs" % base.getid(self)) return body["extra_specs"] def set_keys(self, metadata): """ Set extra specs on a flavor. :param metadata: A dict of key/value pairs to be set """ utils.validate_flavor_metadata_keys(metadata.keys()) body = {'extra_specs': metadata} return self.manager._create( "/flavors/%s/os-extra_specs" % base.getid(self), body, "extra_specs", return_raw=True) def unset_keys(self, keys): """ Unset extra specs on a flavor. :param keys: A list of keys to be unset """ for k in keys: self.manager._delete( "/flavors/%s/os-extra_specs/%s" % (base.getid(self), k)) def delete(self): """ Delete this flavor. """ self.manager.delete(self) class FlavorManager(base.ManagerWithFind): """ Manage :class:`Flavor` resources. """ resource_class = Flavor is_alphanum_id_allowed = True def list(self, detailed=True, is_public=True, marker=None, limit=None): """ Get a list of all flavors. :rtype: list of :class:`Flavor`. :param limit: maximum number of flavors to return (optional). :param marker: Begin returning flavors that appear later in the flavor list than that represented by this flavor id (optional). """ qparams = {} # is_public is ternary - None means give all flavors. # By default Nova assumes True and gives admins public flavors # and flavors from their own projects only. if marker: qparams['marker'] = str(marker) if limit: qparams['limit'] = int(limit) if not is_public: qparams['is_public'] = is_public qparams = sorted(qparams.items(), key=lambda x: x[0]) query_string = "?%s" % parse.urlencode(qparams) if qparams else "" detail = "" if detailed: detail = "/detail" return self._list("/flavors%s%s" % (detail, query_string), "flavors") def get(self, flavor): """ Get a specific flavor. :param flavor: The ID of the :class:`Flavor` to get. :rtype: :class:`Flavor` """ return self._get("/flavors/%s" % base.getid(flavor), "flavor") def delete(self, flavor): """ Delete a specific flavor. :param flavor: The ID of the :class:`Flavor` to get. """ self._delete("/flavors/%s" % base.getid(flavor)) def _build_body(self, name, ram, vcpus, disk, id, swap, ephemeral, rxtx_factor, is_public): return { "flavor": { "name": name, "ram": ram, "vcpus": vcpus, "disk": disk, "id": id, "swap": swap, "OS-FLV-EXT-DATA:ephemeral": ephemeral, "rxtx_factor": rxtx_factor, "os-flavor-access:is_public": is_public, } } 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 = strutils.bool_from_string(is_public, True) except Exception: raise exceptions.CommandError(_("is_public must be a boolean.")) body = self._build_body(name, ram, vcpus, disk, flavorid, swap, ephemeral, rxtx_factor, is_public) return self._create("/flavors", body, "flavor")
Save
cmd:
run