Connection¶
The Connection class is the primary interface to the Python SDK. It maintains a context for a connection to a region of a cloud provider. The Connection has an attribute to access each OpenStack service.
At a minimum, the Connection class needs to be created with a config or the parameters to build one.
While the overall system is very flexible, there are four main use cases for different ways to create a Connection.
Using config settings and keyword arguments as described in Configuring OpenStack SDK Applications
Using only keyword arguments passed to the constructor ignoring config files and environment variables.
Using an existing authenticated keystoneauth1.session.Session, such as might exist inside of an OpenStack service operational context.
Using an existing
CloudRegion.
Creating the Connection¶
Using config settings¶
For users who want to create a Connection making use of named clouds in clouds.yaml files, OS_ environment variables and python keyword arguments, the openstack.connect() factory function is the recommended way to go
import openstack
conn = openstack.connect(cloud='example', region_name='earth1')
If the application in question is a command line application that should also accept command line arguments, an argparse.Namespace can be passed to openstack.connect() that will have relevant arguments added to it and then subsequently consumed by the constructor
import argparse
import openstack
options = argparse.ArgumentParser(description='Awesome OpenStack App')
conn = openstack.connect(options=options)
Using only keyword arguments¶
If the application wants to avoid loading any settings from clouds.yaml or environment variables, use the Connection constructor directly. As long as the cloud argument is omitted or None, the Connection constructor will not load settings from files or the environment.
注意
This is a different default behavior than the connect() factory function. In connect() if cloud is omitted or None, a default cloud will be loaded, defaulting to the envvars cloud if it exists.
from openstack import connection
conn = connection.Connection(
region_name='example-region',
auth={
'auth_url': 'https://auth.example.com',
'username': 'amazing-user',
'password': 'super-secret-password',
'project_id': '33aa1afc-03fe-43b8-8201-4e0d3b4b8ab5',
'user_domain_id': '054abd68-9ad9-418b-96d3-3437bb376703',
},
compute_api_version='2',
identity_interface='internal',
)
Per-service settings as needed by keystoneauth1.adapter.Adapter such as api_version, service_name, and interface can be set, as seen above, by prefixing them with the official service-type name of the service. region_name is a setting for the entire CloudRegion and cannot be set per service.
From existing authenticated Session¶
For applications that already have an authenticated Session, simply passing it to the Connection constructor is all that is needed
from openstack import connection
conn = connection.Connection(
session=session,
region_name='example-region',
compute_api_version='2',
identity_interface='internal',
)
From oslo.conf CONF object¶
For applications that have an oslo.config CONF object that has been populated with keystoneauth1.loading.register_adapter_conf_options in groups named by the OpenStack service’s project name, it is possible to construct a Connection with the CONF object and an authenticated Session.
注意
This is primarily intended for use by OpenStack services to talk amongst themselves.
from keystoneauth1 import loading as ks_loading
from openstack import connection
from oslo_config import cfg
CONF = cfg.CONF
group = cfg.OptGroup('neutron')
ks_loading.register_session_conf_options(CONF, group)
ks_loading.register_auth_conf_options(CONF, group)
ks_loading.register_adapter_conf_options(CONF, group)
CONF()
auth = ks_loading.load_auth_from_conf_options(CONF, 'neutron')
sess = ks_loading.load_session_from_conf_options(CONF, 'neutron', auth=auth)
conn = connection.Connection(
session=sess,
oslo_conf=CONF,
)
This can then be used with an appropriate configuration file.
[neutron]
region_name = RegionOne
auth_strategy = keystone
project_domain_name = Default
project_name = service
user_domain_name = Default
password = password
username = neutron
auth_url = http://10.0.110.85/identity
auth_type = password
service_metadata_proxy = True
default_floating_pool = public
You may also wish to configure a service user. As discussed in the Keystone documentation, service users are users with specific roles that identify the user as a service. The use of service users can avoid issues caused by the expiration of the original user’s token during long running operations, as a fresh token issued for the service user will always accompany the user’s token, which may have expired.
from keystoneauth1 import loading as ks_loading
from keystoneauth1 import service_token
from oslo_config import cfg
import openstack
from openstack import connection
CONF = cfg.CONF
neutron_group = cfg.OptGroup('neutron')
ks_loading.register_session_conf_options(CONF, neutron_group)
ks_loading.register_auth_conf_options(CONF, neutron_group)
ks_loading.register_adapter_conf_options(CONF, neutron_group)
service_group = cfg.OptGroup('service_user')
ks_loading.register_session_conf_options(CONF, service_group)
ks_loading.register_auth_conf_options(CONF, service_group)
CONF()
user_auth = ks_loading.load_auth_from_conf_options(CONF, 'neutron')
service_auth = ks_loading.load_auth_from_conf_options(CONF, 'service_user')
auth = service_token.ServiceTokenAuthWrapper(user_auth, service_auth)
sess = ks_loading.load_session_from_conf_options(CONF, 'neutron', auth=auth)
conn = connection.Connection(
session=sess,
oslo_conf=CONF,
)
This will necessitate an additional section in the configuration file used.
[service_user]
auth_strategy = keystone
project_domain_name = Default
project_name = service
user_domain_name = Default
password = password
username = nova
auth_url = http://10.0.110.85/identity
auth_type = password
From existing CloudRegion¶
If you already have an CloudRegion you can pass it in instead
from openstack import connection
import openstack.config
config = openstack.config.get_cloud_region(
cloud='example',
region_name='earth',
)
conn = connection.Connection(config=config)
Using the Connection¶
Services are accessed through an attribute named after the service’s official service-type.
列出¶
An iterator containing a list of all the projects is retrieved in this manner
projects = conn.identity.projects()
Find or create¶
If you wanted to make sure you had a network named ‘zuul’, you would first try to find it and if that fails, you would create it
network = conn.network.find_network("zuul")
if network is None:
network = conn.network.create_network(name="zuul")
Additional information about the services can be found in the Service Proxies documentation.
from_config¶
- openstack.connection.from_config(cloud=None, config=None, options=None, **kwargs)¶
Create a Connection using openstack.config
- 参数:
cloud (str) – Use the cloud configuration details when creating the Connection.
config (openstack.config.cloud_region.CloudRegion) – An existing CloudRegion configuration. If no config is provided, openstack.config.OpenStackConfig will be called, and the provided name will be used in determining which cloud’s configuration details will be used in creation of the Connection instance.
options (argparse.Namespace) – Allows direct passing in of options to be added to the cloud config. This does not have to be an actual instance of argparse.Namespace, despite the naming of the openstack.config.loader.OpenStackConfig.get_one argument to which it is passed.
- 返回类型:
Connection Object¶
- class openstack.connection.Connection(cloud=None, config=None, session=None, app_name=None, app_version=None, extra_services=None, strict=False, use_direct_get=None, task_manager=None, rate_limit=None, oslo_conf=None, service_types=None, global_request_id=None, strict_proxies=False, pool_executor=None, **kwargs)¶
Create a connection to a cloud.
A connection needs information about how to connect, how to authenticate and how to select the appropriate services to use.
The recommended way to provide this information is by referencing a named cloud config from an existing clouds.yaml file. The cloud name
envvarsmay be used to consume a cloud configured viaOS_environment variables.A pre-existing
CloudRegionobject can be passed in lieu of a cloud name, for cases where the user already has a fully formed CloudRegion and just wants to use it.Similarly, if for some reason the user already has a
Sessionand wants to use it, it may be passed in.- 参数:
cloud (str) – Name of the cloud from config to use.
config (
CloudRegion) – CloudRegion object representing the config for the region of the cloud in question.session (
Session) – A session object compatible withSession.app_name (str) – Name of the application to be added to User Agent.
app_version (str) – Version of the application to be added to User Agent.
extra_services – List of
ServiceDescriptionobjects describing services that openstacksdk otherwise does not know about.use_direct_get (bool) – For get methods, make specific REST calls for server-side filtering instead of making list calls and filtering client-side. Default false.
task_manager – Ignored. Exists for backwards compat during transition. Rate limit parameters should be passed directly to the rate_limit parameter.
rate_limit – Client-side rate limit, expressed in calls per second. The parameter can either be a single float, or it can be a dict with keys as service-type and values as floats expressing the calls per second for that service. Defaults to None, which means no rate-limiting is performed.
oslo_conf (
ConfigOpts) – An oslo.configCONFobject that has been populated withkeystoneauth1.loading.register_adapter_conf_optionsin groups named by the OpenStack service’s project name.service_types – A list/set of service types this Connection should support. All other service types will be disabled (will error if used). Currently only supported in conjunction with the ``oslo_conf`` kwarg.
strict_proxies (bool) – Throw an
openstack.exceptions.ServiceDiscoveryExceptionif the endpoint for a given service doesn’t work. This is useful for OpenStack services using sdk to talk to other OpenStack services where it can be expected that the deployer config is correct and errors should be reported immediately. Default false.global_request_id (str) – A Request-id to send with all interactions.
pool_executor (
Executor) – A futuristExecutorobject to be used for concurrent background activities. Defaults to None in which case a ThreadPoolExecutor will be created if needed.kwargs – If a config is not provided, the rest of the parameters provided are assumed to be arguments to be passed to the CloudRegion constructor.
- add_service(service)¶
Add a service to the Connection.
Attaches an instance of the
Proxyclass contained inServiceDescription. TheProxywill be attached to the Connection by itsservice_typeand by anyaliasesthat may be specified.- 参数:
service (openstack.service_description.ServiceDescription) – Object describing the service to be attached. As a convenience, if
serviceis a string it will be treated as aservice_typeand a basicServiceDescriptionwill be created.
- authorize()¶
Authorize this Connection
注意
This method is optional. When an application makes a call to any OpenStack service, this method allows you to request a token manually before attempting to do anything else.
- 返回值:
A string token.
- 引发:
HttpExceptionif the authorization fails due to reasons like the credentials provided are unable to be authorized or the auth_type argument is missing, etc.
- connect_as(**kwargs)¶
Make a new Connection object with new auth context.
Take the existing settings from the current cloud and construct a new Connection object with some of the auth settings overridden. This is useful for getting an object to perform tasks with as another user, or in the context of a different project.
conn = openstack.connect(cloud='example') # Work normally servers = conn.list_servers() conn2 = conn.connect_as(username='different-user', password='') # Work as different-user servers = conn2.list_servers()
- 参数:
kwargs – keyword arguments can contain anything that would normally go in an auth dict. They will override the same settings from the parent cloud as appropriate. Entries that do not want to be overridden can be ommitted.
- connect_as_project(project)¶
Make a new Connection object with a new project.
Take the existing settings from the current cloud and construct a new Connection object with the project settings overridden. This is useful for getting an object to perform tasks with as another user, or in the context of a different project.
cloud = openstack.connect(cloud='example') # Work normally servers = cloud.list_servers() cloud2 = cloud.connect_as_project('different-project') # Work in different-project servers = cloud2.list_servers()
- 参数:
project – Either a project name or a project dict as returned by
list_projects.
- endpoint_for(service_type, interface=None, region_name=None)¶
Return the endpoint for a given service.
Respects config values for Connection, including
*_endpoint_override. For direct values from the catalog regardless of overrides, seeget_endpoint_from_catalog()- 参数:
service_type – Service Type of the endpoint to search for.
interface – Interface of the endpoint to search for. Optional, defaults to the configured value for interface for this Connection.
region_name – Region Name of the endpoint to search for. Optional, defaults to the configured value for region_name for this Connection.
- 返回值:
The endpoint of the service, or None if not found.
- add_auto_ip(server, wait=False, timeout=60, reuse=True)¶
Add a floating IP to a server.
This method is intended for basic usage. For advanced network architecture (e.g. multiple external networks or servers with multiple interfaces), use other floating IP methods.
This method can reuse available IPs, or allocate new IPs to the current project.
- 参数:
server – a server dictionary.
reuse – Whether or not to attempt to reuse IPs, defaults to True.
wait – (optional) Wait for the address to appear as assigned to the server. Defaults to False.
timeout – (optional) Seconds to wait, defaults to 60. See the
waitparameter.reuse – Try to reuse existing ips. Defaults to True.
- 返回值:
Floating IP address attached to server.
- add_flavor_access(flavor_id, project_id)¶
Grant access to a private flavor for a project/tenant.
- 参数:
flavor_id (string) – ID of the private flavor.
project_id (string) – ID of the project/tenant.
- 返回值:
无
- 引发:
SDKExceptionon operation error.
- add_host_to_aggregate(name_or_id, host_name)¶
Add a host to an aggregate.
- 参数:
name_or_id – Name or ID of the host aggregate.
host_name – Host to add.
- 引发:
SDKExceptionon operation error.
- add_ip_list(server, ips, wait=False, timeout=60, fixed_address=None, nat_destination=None)¶
Attach a list of IPs to a server.
- 参数:
server – a server object
ips – list of floating IP addresses or a single address
wait – (optional) Wait for the address to appear as assigned to the server. Defaults to False.
timeout – (optional) Seconds to wait, defaults to 60. See the
waitparameter.fixed_address – (optional) Fixed address of the server to attach the IP to
nat_destination – (optional) Name or ID of the network that the fixed IP to attach the floating IP should be on
- 返回值:
The updated server
openstack.compute.v2.server.Server- 引发:
SDKExceptionon operation error.
- add_router_interface(router, subnet_id=None, port_id=None)¶
Attach a subnet to an internal router interface.
Either a subnet ID or port ID must be specified for the internal interface. Supplying both will result in an error.
- 参数:
router (dict) – The dict object of the router being changed
subnet_id (string) – The ID of the subnet to use for the interface
port_id (string) – The ID of the port to use for the interface
- 返回值:
The raw response body from the request.
- 引发:
SDKExceptionon operation error.
- add_server_security_groups(server, security_groups)¶
Add security groups to a server.
Add existing security groups to an existing server. If the security groups are already present on the server this will continue unaffected.
- 参数:
server – The server to remove security groups from.
security_groups – A list of security groups to remove.
- 返回值:
False if server or security groups are undefined, True otherwise.
- 引发:
SDKExceptionon operation error.
- add_user_to_group(name_or_id, group_name_or_id)¶
将用户添加到组。
- 参数:
name_or_id – Name or unique ID of the user.
group_name_or_id – Group name or ID
- 引发:
SDKExceptionif something goes wrong during the OpenStack API call
- add_volume_type_access(name_or_id, project_id)¶
Grant access on a volume_type to a project.
NOTE: the call works even if the project does not exist.
- 参数:
name_or_id – ID or name of a volume_type
project_id – A project id
- 返回值:
无
- 引发:
SDKExceptionon operation error.
- attach_port_to_machine(name_or_id, port_name_or_id)¶
Attach a virtual port to the bare metal machine.
- 参数:
name_or_id (string) – A machine name or UUID.
port_name_or_id (string) – A port name or UUID. Note that this is a Network service port, not a bare metal NIC.
- 返回值:
Nothing.
- attach_volume(server, volume, device=None, wait=True, timeout=None)¶
将卷附加到服务器。
This will attach a volume, described by the passed in volume dict (as returned by get_volume()), to the server described by the passed in server dict (as returned by get_server()) on the named device on the server.
If the volume is already attached to the server, or generally not available, then an exception is raised. To re-attach to a server, but under a different device, the user must detach it first.
- 参数:
server – The server dict to attach to.
volume – The volume dict to attach.
device – The device name where the volume will attach.
wait – If true, waits for volume to be attached.
timeout – Seconds to wait for volume attachment. None is forever.
- 返回值:
a volume attachment object.
- 引发:
ResourceTimeoutif wait time exceeded.- 引发:
SDKExceptionon operation error.
- available_floating_ip(network=None, server=None)¶
Get a floating IP from a network or a pool.
Return the first available floating IP or allocate a new one.
- 参数:
network – Name or ID of the network.
server – Server the IP is for if known
- 返回值:
a (normalized) structure with a floating IP address description.
- bind_accelerator_request(uuid, properties)¶
Bind an accelerator to VM.
- 参数:
uuid – The uuid of the accelerator_request to be binded.
properties – The info of VM that will bind the accelerator.
- 返回值:
True if bind succeeded, False otherwise.
- close()¶
Release any resources held open.
- create_accelerator_request(attrs)¶
Create an accelerator_request.
- 参数:
attrs – The info of accelerator_request to be created.
- 返回值:
An accelerator
AcceleratorRequestobject.
- create_aggregate(name, availability_zone=None)¶
Create a new host aggregate.
- 参数:
name – Name of the host aggregate being created
availability_zone – Availability zone to assign hosts
- 返回值:
The created compute
Aggregateobject.- 引发:
SDKExceptionon operation error.
- create_cluster_template(name, image_id=None, keypair_id=None, coe=None, **kwargs)¶
Create a cluster template.
- 参数:
name (string) – Name of the cluster template.
image_id (string) – Name or ID of the image to use.
keypair_id (string) – Name or ID of the keypair to use.
coe (string) – Name of the coe for the cluster template. Other arguments will be passed in kwargs.
- 返回值:
a dict containing the cluster template description
- 引发:
SDKExceptionif something goes wrong during the OpenStack API call
- create_coe_cluster(name, cluster_template_id, **kwargs)¶
Create a COE cluster based on given cluster template.
- 参数:
name (string) – Name of the cluster.
cluster_template_id (string) – ID of the cluster template to use.
kwargs (dict) – Any other arguments to pass in.
- 返回值:
The created container infrastructure management
Clusterobject.- 引发:
SDKExceptionif something goes wrong during the OpenStack API call
- create_container(name, public=False)¶
Create an object-store container.
- 参数:
name (str) – Name of the container to create.
public (bool) – Whether to set this container to be public. Defaults to
False.
- 返回值:
The created object store
Containerobject.
- create_device_profile(attrs)¶
Create a device_profile.
- 参数:
attrs – The info of device_profile to be created.
- 返回值:
An accelerator
DeviceProfileobjects.
- create_directory_marker_object(container, name, **headers)¶
Create a zero-byte directory marker object
注意
This method is not needed in most cases. Modern swift does not require directory marker objects. However, some swift installs may need these.
When using swift Static Web and Web Listings to serve static content one may need to create a zero-byte object to represent each “directory”. Doing so allows Web Listings to generate an index of the objects inside of it, and allows Static Web to render index.html “files” that are “inside” the directory.
- 参数:
container – The name of the container.
name – Name for the directory marker object within the container.
headers – These will be passed through to the object creation API as HTTP Headers.
- 返回值:
The created object store
Objectobject.
- create_domain(name, description=None, enabled=True)¶
Create a domain.
- 参数:
name – The name of the domain.
description – A description of the domain.
enabled – Is the domain enabled or not (default True).
- 返回值:
The created identity
Endpointobject.- 引发:
SDKExceptionif the domain cannot be created.
- create_endpoint(service_name_or_id, url=None, interface=None, region=None, enabled=True, **kwargs)¶
Create a Keystone endpoint.
- 参数:
service_name_or_id – Service name or id for this endpoint.
url – URL of the endpoint
interface – Interface type of the endpoint
public_url – Endpoint public URL.
internal_url – Endpoint internal URL.
admin_url – Endpoint admin URL.
region – Endpoint region.
enabled – Whether the endpoint is enabled
- 返回值:
A list of identity
Endpointobjects- 引发:
SDKExceptionif the service cannot be found or if something goes wrong during the OpenStack API call.
- create_firewall_group(**kwargs)¶
Creates firewall group. The keys egress_firewall_policy and ingress_firewall_policy are looked up and mapped as egress_firewall_policy_id and ingress_firewall_policy_id respectively. Port name or ids list is transformed to port ids list before the POST request.
- 参数:
admin_state_up (bool) – State of firewall group. Will block all traffic if set to False. Defaults to True.
description – Human-readable description.
egress_firewall_policy – Name or id of egress firewall policy.
ingress_firewall_policy – Name or id of ingress firewall policy.
name – Human-readable name.
ports (list[str]) – List of associated ports (name or id)
project_id – Project id.
shared – Visibility to other projects. Defaults to False.
- 引发:
BadRequestException if parameters are malformed
- 引发:
DuplicateResource on multiple matches
- 引发:
NotFoundException if (ingress-, egress-) firewall policy or a port is not found.
- 返回值:
The created network
FirewallGroupobject.
- create_firewall_policy(**kwargs)¶
Create firewall policy.
- 参数:
audited (bool) – Status of audition of firewall policy. Set to False each time the firewall policy or the associated firewall rules are changed. Has to be explicitly set to True.
description – Human-readable description.
firewall_rules (list[str]) – List of associated firewall rules.
name – Human-readable name.
project_id – Project id.
shared (bool) – Visibility to other projects. Defaults to False.
- 引发:
BadRequestException if parameters are malformed
- 引发:
NotFoundException if a resource from firewall_list not found
- 返回值:
The created network
FirewallPolicyobject.
- create_firewall_rule(**kwargs)¶
Creates firewall rule.
- 参数:
action – Action performed on traffic. Valid values: allow, deny Defaults to deny.
description – Human-readable description.
destination_firewall_group_id – ID of destination firewall group.
destination_ip_address – IPv4-, IPv6 address or CIDR.
destination_port – Port or port range (e.g. 80:90)
enabled (bool) – Status of firewall rule. You can disable rules without disassociating them from firewall policies. Defaults to True.
ip_version (int) – IP Version. Valid values: 4, 6 Defaults to 4.
name – Human-readable name.
project_id – Project id.
protocol – IP protocol. Valid values: icmp, tcp, udp, null
shared (bool) – Visibility to other projects. Defaults to False.
source_firewall_group_id – ID of source firewall group.
source_ip_address – IPv4-, IPv6 address or CIDR.
source_port – Port or port range (e.g. 80:90)
- 引发:
BadRequestException if parameters are malformed
- 返回值:
The created network
FirewallRuleobject.
- create_flavor(name, ram, vcpus, disk, description=None, flavorid='auto', ephemeral=0, swap=0, rxtx_factor=1.0, is_public=True)¶
创建一个新的 flavor。
- 参数:
name – Descriptive name of the flavor
ram – Memory in MB for the flavor
vcpus – Number of VCPUs for the flavor
disk – Size of local disk in GB
description – Description of the flavor
flavorid – ID for the flavor (optional)
ephemeral – Ephemeral space size in GB
swap – Swap space in MB
rxtx_factor – RX/TX factor
is_public – Make flavor accessible to the public
- 返回值:
The created compute
Flavorobject.- 引发:
SDKExceptionon operation error.
- create_floating_ip(network=None, server=None, fixed_address=None, nat_destination=None, port=None, wait=False, timeout=60)¶
Allocate a new floating IP from a network or a pool.
- 参数:
network – Name or ID of the network that the floating IP should come from.
server – (optional) Server dict for the server to create the IP for and to which it should be attached.
fixed_address – (optional) Fixed IP to attach the floating ip to.
nat_destination – (optional) Name or ID of the network that the fixed IP to attach the floating IP to should be on.
port – (optional) The port ID that the floating IP should be attached to. Specifying a port conflicts with specifying a server, fixed_address or nat_destination.
wait – (optional) Whether to wait for the IP to be active. Defaults to False. Only applies if a server is provided.
timeout – (optional) How long to wait for the IP to be active. Defaults to 60. Only applies if a server is provided.
- 返回值:
a floating IP address
- 引发:
SDKExceptionon operation error.
- create_group(name, description, domain=None)¶
创建一个组。
- 参数:
name (string) – Group name.
description (string) – Group description.
domain (string) – Domain name or ID for the group.
- 返回值:
An identity
Groupobject- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- create_image(name, filename=None, container=None, md5=None, sha256=None, disk_format=None, container_format=None, disable_vendor_agent=True, wait=False, timeout=3600, tags=None, allow_duplicates=False, meta=None, volume=None, **kwargs)¶
Upload an image.
- 参数:
name (str) – Name of the image to create. If it is a pathname of an image, the name will be constructed from the extensionless basename of the path.
filename (str) – The path to the file to upload, if needed. (optional, defaults to None)
container (str) – Name of the container in swift where images should be uploaded for import if the cloud requires such a thing. (optiona, defaults to ‘images’)
md5 (str) – md5 sum of the image file. If not given, an md5 will be calculated.
sha256 (str) – sha256 sum of the image file. If not given, an md5 will be calculated.
disk_format (str) – The disk format the image is in. (optional, defaults to the os-client-config config value for this cloud)
container_format (str) – The container format the image is in. (optional, defaults to the os-client-config config value for this cloud)
tags (list) – List of tags for this image. Each tag is a string of at most 255 chars.
disable_vendor_agent (bool) – Whether or not to append metadata flags to the image to inform the cloud in question to not expect a vendor agent to be runing. (optional, defaults to True)
wait (bool) – If true, waits for image to be created. Defaults to true - however, be aware that one of the upload methods is always synchronous.
timeout – Seconds to wait for image creation. None is forever.
allow_duplicates – If true, skips checks that enforce unique image name. (optional, defaults to False)
meta – A dict of key/value pairs to use for metadata that bypasses automatic type conversion.
volume – Name or ID or volume object of a volume to create an image from. Mutually exclusive with (optional, defaults to None)
Additional kwargs will be passed to the image creation as additional metadata for the image and will have all values converted to string except for min_disk, min_ram, size and virtual_size which will be converted to int.
If you are sure you have all of your data types correct or have an advanced need to be explicit, use meta. If you are just a normal consumer, using kwargs is likely the right choice.
If a value is in meta and kwargs, meta wins.
- 返回值:
An image
openstack.image.v2.image.Imageobject.- 引发:
SDKExceptionif there are problems uploading
- create_image_snapshot(name, server, wait=False, timeout=3600, **metadata)¶
Create an image by snapshotting an existing server.
- ..note:
On most clouds this is a cold snapshot - meaning that the server in question will be shutdown before taking the snapshot. It is possible that it’s a live snapshot - but there is no way to know as a user, so caveat emptor.
- 参数:
name – Name of the image to be created
server – Server name or ID or dict representing the server to be snapshotted
wait – If true, waits for image to be created.
timeout – Seconds to wait for image creation. None is forever.
metadata – Metadata to give newly-created image entity
- 返回值:
The created image
Imageobject.- 引发:
SDKExceptionif there are problems uploading
- create_keypair(name, public_key=None)¶
Create a new keypair.
- 参数:
name – Name of the keypair being created.
public_key – Public key for the new keypair.
- 返回值:
The created compute
Keypairobject.- 引发:
SDKExceptionon operation error.
- create_network(name, shared=False, admin_state_up=True, external=False, provider=None, project_id=None, availability_zone_hints=None, port_security_enabled=None, mtu_size=None, dns_domain=None)¶
创建一个网络。
- 参数:
name (string) – Name of the network being created.
shared (bool) – Set the network as shared.
admin_state_up (bool) – Set the network administrative state to up.
external (bool) – Whether this network is externally accessible.
provider (dict) –
A dict of network provider options. Example
{'network_type': 'vlan', 'segmentation_id': 'vlan1'}
project_id (string) – Specify the project ID this network will be created on (admin-only).
availability_zone_hints (types.ListType) – A list of availability zone hints.
port_security_enabled (bool) – Enable / Disable port security
mtu_size (int) – maximum transmission unit value to address fragmentation. Minimum value is 68 for IPv4, and 1280 for IPv6.
dns_domain (string) – Specify the DNS domain associated with this network.
- 返回值:
The created network
Networkobject.- 引发:
SDKExceptionon operation error.
- create_object(container, name, filename=None, md5=None, sha256=None, segment_size=None, use_slo=True, metadata=None, generate_checksums=None, data=None, **headers)¶
Create a file object.
Automatically uses large-object segments if needed.
- 参数:
container – The name of the container to store the file in. This container will be created if it does not exist already.
name – Name for the object within the container.
filename – The path to the local file whose contents will be uploaded. Mutually exclusive with data.
data – The content to upload to the object. Mutually exclusive with filename.
md5 – A hexadecimal md5 of the file. (Optional), if it is known and can be passed here, it will save repeating the expensive md5 process. It is assumed to be accurate.
sha256 – A hexadecimal sha256 of the file. (Optional) See md5.
segment_size – Break the uploaded object into segments of this many bytes. (Optional) Shade will attempt to discover the maximum value for this from the server if it is not specified, or will use a reasonable default.
headers – These will be passed through to the object creation API as HTTP Headers.
use_slo – If the object is large enough to need to be a Large Object, use a static rather than dynamic object. Static Objects will delete segment objects when the manifest object is deleted. (optional, defaults to True)
generate_checksums – Whether to generate checksums on the client side that get added to headers for later prevention of double uploads of identical data. (optional, defaults to True)
metadata – This dict will get changed into headers that set metadata of the object
- 返回值:
The created object store
Objectobject.- 引发:
SDKExceptionon operation error.
- create_port(network_id, **kwargs)¶
创建端口
- 参数:
network_id – The ID of the network. (Required)
name – A symbolic name for the port. (Optional)
admin_state_up – The administrative status of the port, which is up (true, default) or down (false). (Optional)
mac_address – The MAC address. (Optional)
fixed_ips –
List of ip_addresses and subnet_ids. See subnet_id and ip_address. (Optional) For example
[ { "ip_address": "10.29.29.13", "subnet_id": "a78484c4-c380-4b47-85aa-21c51a2d8cbd", }, ..., ]
subnet_id – If you specify only a subnet ID, OpenStack Networking allocates an available IP from that subnet to the port. (Optional) If you specify both a subnet ID and an IP address, OpenStack Networking tries to allocate the specified address to the port.
ip_address – If you specify both a subnet ID and an IP address, OpenStack Networking tries to allocate the specified address to the port.
security_groups – List of security group UUIDs. (Optional)
allowed_address_pairs –
Allowed address pairs list (Optional) For example
[ { "ip_address": "23.23.23.1", "mac_address": "fa:16:3e:c4:cd:3f", }, ..., ]
extra_dhcp_opts –
Extra DHCP options. (Optional). For example
[{"opt_name": "opt name1", "opt_value": "value1"}, ...]
device_owner – The ID of the entity that uses this port. For example, a DHCP agent. (Optional)
device_id – The ID of the device that uses this port. For example, a virtual server. (Optional)
vnic_type (binding) – The type of the created port. (Optional)
port_security_enabled – The security port state created on the network. (Optional)
qos_policy_id – The ID of the QoS policy to apply for port. (Optional)
project_id – The project in which to create the port. (Optional)
description – Description of the port. (Optional)
dns_domain – DNS domain relevant for the port. (Optional)
dns_name – DNS name of the port. (Optional)
numa_affinity_policy – the numa affinitiy policy. May be “None”, “required”, “preferred” or “legacy”. (Optional)
propagate_uplink_status – If the uplink status of the port should be propagated. (Optional)
mac_learning_enabled – If mac learning should be enabled on the port. (Optional)
- 返回值:
The created network
Portobject.- 引发:
SDKExceptionon operation error.
- create_project(name, domain_id, description=None, enabled=True, **kwargs)¶
Create a project.
- 参数:
name
domain_id
description
enabled
- 返回值:
An identity
Projectobject.
- create_qos_bandwidth_limit_rule(policy_name_or_id, max_kbps, **kwargs)¶
创建 QoS 带宽限制规则。
- 参数:
policy_name_or_id (string) – 应关联规则的 QoS 策略的名称或 ID。
max_kbps (int) – 最大带宽限制值(以千比特每秒为单位)。
max_burst_kbps (int) – 最大突发值(以千比特为单位)。
direction (string) – 入站或出站。将限制流量的方向。
- 返回值:
创建的网络
QoSBandwidthLimitRule对象。- 引发:
SDKExceptionon operation error.
- create_qos_dscp_marking_rule(policy_name_or_id, dscp_mark)¶
创建 QoS DSCP 标记规则。
- 参数:
policy_name_or_id (string) – 应关联规则的 QoS 策略的名称或 ID。
dscp_mark (int) – DSCP 标记值
- 返回值:
创建的网络
QoSDSCPMarkingRule对象。- 引发:
SDKExceptionon operation error.
- create_qos_minimum_bandwidth_rule(policy_name_or_id, min_kbps, **kwargs)¶
创建 QoS 最小带宽限制规则。
- 参数:
policy_name_or_id (string) – 应关联规则的 QoS 策略的名称或 ID。
min_kbps (int) – 最小带宽值(以千比特每秒为单位)。
direction (string) – 入站或出站。流量将可用的方向。
- 返回值:
创建的网络
QoSMinimumBandwidthRule对象。- 引发:
SDKExceptionon operation error.
- create_qos_policy(**kwargs)¶
创建 QoS 策略。
- 参数:
name (string) – 要创建的 QoS 策略的名称。
description (string) – 创建的 QoS 策略的描述。
shared (bool) – 将 QoS 策略设置为共享。
default (bool) – 将 QoS 策略设置为项目的默认策略。
project_id (string) – 指定将在此项目上创建 QoS 策略(仅限管理员)。
- 返回值:
创建的网络
QosPolicy对象。- 引发:
SDKExceptionon operation error.
- create_recordset(zone, name, recordset_type, records, description=None, ttl=None)¶
创建记录集。
- 参数:
zone – 管理记录集的区域的名称、ID 或
openstack.dns.v2.zone.Zone实例。name – 记录集的名称
recordset_type – 记录集的类型
records – 记录集定义的列表
description – 记录集的描述
ttl – 记录集的 TTL 值
- 返回值:
一个代表创建的记录集的字典。
- 引发:
SDKExceptionon operation error.
- create_role(name, **kwargs)¶
创建 Keystone 角色。
- 参数:
name (string) – 角色的名称。
domain_id – 域 ID (v3)
- 返回值:
一个身份
Role对象- 引发:
SDKException如果无法创建角色
- create_router(name=None, admin_state_up=True, ext_gateway_net_id=None, enable_snat=None, ext_fixed_ips=None, project_id=None, availability_zone_hints=None)¶
创建逻辑路由器。
- 参数:
name (string) – 路由器的名称。
admin_state_up (bool) – 路由器的管理状态。
ext_gateway_net_id (string) – 外部网关的网络 ID。
enable_snat (bool) – 启用源 NAT (SNAT) 属性。
ext_fixed_ips –
所需 IP 和/或外部网络上的子网的字典列表。示例
[ { "subnet_id": "8ca37218-28ff-41cb-9b10-039601ea7e6b", "ip_address": "192.168.10.2", } ]
project_id (string) – 路由器的项目 ID。
availability_zone_hints (types.ListType) – A list of availability zone hints.
- 返回值:
创建的网络
Router对象。- 引发:
SDKExceptionon operation error.
- create_security_group(name, description, project_id=None, stateful=None)¶
创建新的安全组
- 参数:
name (string) – 安全组的名称。
description (string) – 描述安全组。
project_id (string) – 指定将在此项目上创建安全组(仅限管理员)。
stateful (string) – 安全组是否是有状态的。
- 返回值:
一个表示新安全组的
openstack.network.v2.security_group.SecurityGroup对象。- 引发:
SDKExceptionon operation error.- 引发:
OpenStackCloudUnavailableFeature 如果此云不支持安全组。
- create_security_group_rule(secgroup_name_or_id, port_range_min=None, port_range_max=None, protocol=None, remote_ip_prefix=None, remote_group_id=None, remote_address_group_id=None, direction='ingress', ethertype='IPv4', project_id=None, description=None)¶
创建新的安全组规则
- 参数:
secgroup_name_or_id (string) – 要与此安全组规则关联的安全组的名称或 ID。如果给出非唯一组名,将引发异常。
port_range_min (int) – 安全组规则匹配的范围中的最小端口号。如果协议是 TCP 或 UDP,此值必须小于或等于 port_range_max 属性值。如果云提供商使用 nova 来处理安全组,则 None 值将转换为 -1。
port_range_max (int) – 安全组规则匹配的范围中的最大端口号。port_range_min 属性约束 port_range_max 属性。如果云提供商使用 nova 来处理安全组,则 None 值将转换为 -1。
protocol (string) – 安全组规则匹配的协议。有效值为 None、tcp、udp 和 icmp。
remote_ip_prefix (string) – 要与此安全组规则关联的远程 IP 前缀。此属性将指定的 IP 前缀作为 IP 数据包的源 IP 地址进行匹配。
remote_group_id (string) – 要与此安全组规则关联的远程组 ID。
remote_address_group_id (string) – 要与此安全组规则关联的远程地址组 ID。
direction (string) – 入站或出站:安全组规则应用的流量方向。对于计算实例,入站安全组规则应用于该实例的入站流量。出站规则应用于离开实例的流量。
ethertype (string) – 必须是 IPv4 或 IPv6,并且 CIDR 中表示的地址必须与入站或出站规则匹配。
project_id (string) – 指定将在此项目上创建安全组(仅限管理员)。
description (string) – 规则的描述,最多 255 个字符。
- 返回值:
一个表示新安全组规则的
openstack.network.v2.security_group.SecurityGroup对象。- 引发:
SDKExceptionon operation error.
- create_server(name, image=None, flavor=None, auto_ip=True, ips=None, ip_pool=None, root_volume=None, terminate_volume=False, wait=False, timeout=180, reuse_ips=True, network=None, boot_from_volume=False, volume_size='50', boot_volume=None, volumes=None, nat_destination=None, group=None, **kwargs)¶
创建虚拟服务器实例。
- 参数:
name – 为服务器命名的内容。
image – 用于启动的镜像字典、名称或 ID。除非提供了 boot_volume,否则 image 是必需的。
flavor – 用于启动的虚拟机规格字典、名称或 ID。
auto_ip – 是否采取措施为服务器查找可路由 IP。(默认为 True)
ips – 要附加到服务器的 IP 列表(默认为 None)
ip_pool – 用于获取地址的网络或浮动 IP 池的名称。(默认为 None)
root_volume – 用于启动的卷的名称或 ID(默认为 None - 已弃用,请使用 boot_volume)
boot_volume – 用于启动的卷的名称或 ID(默认为 None)
terminate_volume – 如果从卷启动,在销毁服务器时是否应删除该卷。(默认为 False)
volumes –(可选)要附加到服务器的卷列表
meta –(可选)要为此服务器存储的任意键/值元数据字典。键和值都必须小于或等于 255 个字符。
files –(可选,已弃用)用于在启动时覆盖服务器的文件的字典。键是文件名(例如
/etc/passwd),值是文件内容(作为字符串或文件对象)。最多允许五个条目,每个文件不得超过 10k。reservation_id – 请求的服务器集的一个 UUID。
min_count –(可选扩展)要启动的服务器的最小数量。
max_count –(可选扩展)要启动的服务器的最大数量。
security_groups – 安全组名称列表
userdata – 要传递给元数据服务器的用户数据,这也可以是文件类型对象或字符串。
key_name –(可选扩展)先前创建的密钥对的名称,用于注入到实例中。
availability_zone – 用于实例放置的可用区域名称。
block_device_mapping –(可选)此服务器的块设备映射字典。
block_device_mapping_v2 –(可选)此服务器的块设备映射字典。
nics –(可选扩展)添加到此服务器的 NIC 的有序列表,包含连接的网络、固定 IP、端口等信息。
scheduler_hints –(可选扩展)客户端指定的任意键值对,用于帮助启动实例
config_drive –(可选扩展)配置驱动器的值,可以是布尔值或卷 ID
disk_config –(可选扩展)控制服务器创建时磁盘的分区方式。可能的值为“AUTO”或“MANUAL”。
admin_pass –(可选扩展)添加用户提供的管理员密码。
wait – (optional) Wait for the address to appear as assigned to the server. Defaults to False.
timeout – (optional) Seconds to wait, defaults to 60. See the
waitparameter.reuse_ips –(可选)如果需要浮动 IP,是否尝试重用预先存在的浮动 IP(默认为 True)
network –(可选)要将服务器连接到的网络字典、名称或 ID。与 nics 参数互斥。也可以是网络名称、ID 或网络字典的列表。
boot_from_volume – 是否从卷启动。“boot_volume”暗含 True,但 boot_from_volume=True 且不带 boot_volume 是有效的,它将从镜像创建卷并使用该卷。
volume_size – 当从卷启动镜像时,创建的卷应该多大?默认为 50。
nat_destination – 如果无法从云的配置中推断出,创建的浮动 IP 应该附加到哪个网络。(可选,默认为 None)
group – 用于启动服务器的 ServerGroup 字典、名称或 ID。如果在 scheduler_hints 和 group 参数中都提供了组,则 group 参数将生效。(可选,默认为 None)
- 返回值:
创建的计算
Server对象。- 引发:
SDKExceptionon operation error.
- create_server_group(name, policies=None, policy=None)¶
创建新的服务器组。
- 参数:
name – 要创建的服务器组的名称
policies – 服务器组的策略列表。
- 返回值:
创建的计算
ServerGroup对象。- 引发:
SDKExceptionon operation error.
- create_service(name, enabled=True, **kwargs)¶
创建服务。
- 参数:
name – 服务名称。
type – 服务类型。(需要 type 或 service_type。)
service_type – 服务类型。(需要 type 或 service_type。)
description – 服务描述(可选)。
enabled – 服务是否启用(仅限 v3)
- 返回值:
一个身份
Service对象- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- create_stack(name, tags=None, template_file=None, template_url=None, template_object=None, files=None, rollback=True, wait=False, timeout=3600, environment_files=None, **parameters)¶
创建堆栈。
- 参数:
name (string) – 堆栈的名称。
tags – 堆栈的标签列表。(可选)
template_file (string) – 模板文件路径。
template_url (string) – 模板 URL。
template_object (string) – 用于检索模板对象的 URL。
files (dict) – 要包含的附加文件内容的字典。
rollback (boolean) – 创建失败时启用回滚。
wait (boolean) – 是否等待删除完成。
timeout (int) – 堆栈创建超时(秒)。
environment_files – 要应用的预置文件路径。
其他参数将作为堆栈参数传递,这些参数将优先于预置中指定的任何参数。
只能指定 template_file、template_url、template_object 中的一个。
- 返回值:
一个包含堆栈描述的字典
- 引发:
SDKExceptionif something goes wrong during the OpenStack API call
- create_subnet(network_name_or_id, cidr=None, ip_version=4, enable_dhcp=False, subnet_name=None, tenant_id=None, allocation_pools=None, gateway_ip=None, disable_gateway_ip=False, dns_nameservers=None, host_routes=None, ipv6_ra_mode=None, ipv6_address_mode=None, prefixlen=None, use_default_subnetpool=False, subnetpool_name_or_id=None, **kwargs)¶
在指定网络上创建子网。
- 参数:
network_name_or_id (string) – 所连接网络的唯一名称或 ID。如果提供非唯一名称,将引发异常。
cidr (string) – CIDR。一次只能指定
cidr、use_default_subnetpool和subnetpool_name_or_id中的一个。ip_version (int) – IP 版本,为 4 或 6。
enable_dhcp (bool) – 如果启用 DHCP,则设置为
True,如果禁用,则设置为False。默认为False。subnet_name (string) – 子网的名称。
tenant_id (string) – 网络所属租户的 ID。只有管理员用户可以指定自己的项目 ID。
allocation_pools –
用于分配池的开始和结束地址的字典列表。例如
[{"start": "192.168.199.2", "end": "192.168.199.254"}]
gateway_ip (string) – 网关 IP 地址。当同时指定 allocation_pools 和 gateway_ip 时,必须确保网关 IP 不与指定的分配池重叠。
disable_gateway_ip (bool) – 如果禁用网关 IP 地址,则设置为
True,如果启用,则设置为False。不允许与 gateway_ip 一起使用。默认为False。dns_nameservers –
子网的 DNS 名称服务器列表。例如
["8.8.8.7", "8.8.8.8"]
host_routes –
子网的路由条目字典列表。例如
[ {"destination": "0.0.0.0/0", "nexthop": "123.456.78.9"}, {"destination": "192.168.0.0/24", "nexthop": "192.168.0.1"}, ]
ipv6_ra_mode (string) – IPv6 路由器通告模式。有效值为:“dhcpv6-stateful”、“dhcpv6-stateless”或“slaac”。
ipv6_address_mode (string) – IPv6 地址模式。有效值为:“dhcpv6-stateful”、“dhcpv6-stateless”或“slaac”。
prefixlen (string) – 用于从子网池分配子网的前缀长度。
use_default_subnetpool (bool) – 使用
ip_version的默认子网池来获取 CIDR。一次只能指定cidr、use_default_subnetpool和subnetpool_name_or_id中的一个。subnetpool_name_or_id (string) – 用于从其获取 CIDR 的子网池的唯一名称或 ID。一次只能指定
cidr、use_default_subnetpool和subnetpool_name_or_id中的一个。kwargs – 将传递给 Neutron API 的键值对。
- 返回值:
创建的网络
Subnet对象。- 引发:
SDKExceptionon operation error.
- create_user(name, password=None, email=None, default_project=None, enabled=True, domain_id=None, description=None)¶
创建一个用户。
- create_volume(size, wait=True, timeout=None, image=None, bootable=None, **kwargs)¶
创建卷。
- 参数:
size – 要创建的卷的大小(GB)。
wait – 如果为 True,则等待卷创建完成。
timeout – 等待卷创建的秒数。None 表示永远。
image –(可选)用于从中创建卷的镜像名称、ID 或对象
bootable –(可选)使此卷可启动。如果设置,wait 也将设置为 true。
kwargs – Cinder 客户端期望的关键字参数。
- 返回值:
创建的卷
Volume对象。- 引发:
ResourceTimeoutif wait time exceeded.- 引发:
SDKExceptionon operation error.
- create_volume_backup(volume_id, name=None, description=None, force=False, wait=True, timeout=None, incremental=False, snapshot_id=None)¶
创建卷备份。
- 参数:
volume_id – 要备份的卷的 ID。
name – 备份的名称,如果未提供,将生成一个
description – 备份的描述,如果未提供,将生成一个
force – 如果设置为 True,即使卷已附加到实例,也会创建备份;如果设置为 False,则不会。
wait – 如果为 True,则等待卷备份创建完成。
timeout – 等待卷备份创建的秒数。None 表示永远。
incremental – 如果设置为 True,则备份将是增量的。
snapshot_id – 要备份的源快照的 UUID。
- 返回值:
创建的卷
Backup对象。- 引发:
ResourceTimeoutif wait time exceeded.- 引发:
SDKExceptionon operation error.
- create_volume_snapshot(volume_id, force=False, wait=True, timeout=None, **kwargs)¶
创建快照。
- 参数:
volume_id – 要快照的卷的 ID。
force – 如果设置为 True,即使卷已附加到实例,也会创建快照;如果设置为 False,则不会。
name – 快照的名称,如果未提供,将生成一个
description – 快照的描述,如果未提供,将生成一个
wait – 如果为 True,则等待卷快照创建完成。
timeout – 等待卷快照创建的秒数。None 表示永远。
- 返回值:
创建的卷
Snapshot对象。- 引发:
ResourceTimeoutif wait time exceeded.- 引发:
SDKExceptionon operation error.
- create_zone(name, zone_type=None, email=None, description=None, ttl=None, masters=None)¶
创建新的区域。
- 参数:
name – 要创建的区域的名称。
zone_type – 区域类型(主/次)
email – 区域所有者的电子邮件(仅当 zone_type 为 primary 时适用)
description – 区域的描述
ttl – TTL(生存时间)值(秒)
masters – 主名称服务器(仅当 zone_type 为 secondary 时适用)
- 返回值:
一个代表创建的区域的字典。
- 引发:
SDKExceptionon operation error.
- property current_location¶
返回一个解释当前云位置的
utils.Munch对象。
- property current_project¶
返回一个描述当前项目的
utils.Munch对象。
- property current_project_id¶
获取当前项目 ID。
返回当前令牌范围的项目 ID。None 表示令牌是域范围的或未范围的。
- 引发:
keystoneauth1.exceptions.auth.AuthorizationFailure – 如果新的令牌获取失败。
keystoneauth1.exceptions.auth_plugins.MissingAuthPlugin – 如果插件不可用。
- property current_user_id¶
从令牌获取当前登录用户的 ID。
- delete_accelerator_request(name_or_id, filters)¶
删除 accelerator_request。
- 参数:
name_or_id – 要删除的加速器请求的名称或 UUID。
filters – 要下推的过滤条件字典
- 返回值:
如果删除成功,则为 True,否则为 False。
- delete_aggregate(name_or_id)¶
删除主机聚合。
- 参数:
name_or_id – 要删除的主机聚合的名称或 ID。
- 返回值:
如果删除成功,则为 True,否则为 False。
- 引发:
SDKExceptionon operation error.
- delete_autocreated_image_objects(container=None, segment_prefix=None)¶
删除为镜像上传自动创建的所有对象。
此方法通常不需要,因为 shade 应清理其用于基于对象的镜像创建的对象。如果出现问题且发现有泄漏的对象,此方法可用于删除 shade 代表用户在对象存储服务中创建的任何对象。
- 参数:
container (str) – 容器的名称。默认为“images”。
segment_prefix (str) – 要删除的镜像分段的名称。如果未提供,则删除所有存在的镜像上传分段。
- 返回值:
如果删除成功,则为 True,否则为 False。
- delete_cluster_template(name_or_id)¶
删除集群模板。
- 参数:
name_or_id – 集群模板的名称或唯一 ID。
- 返回值:
如果删除成功,则为 True,如果未找到集群模板,则为 False。
- 引发:
SDKExceptionon operation error.
- delete_coe_cluster(name_or_id)¶
删除 COE 集群。
- 参数:
name_or_id – 集群的名称或唯一 ID。
- 返回值:
如果删除成功,则为 True,如果未找到集群,则为 False。
- 引发:
SDKExceptionon operation error.
- delete_compute_quotas(name_or_id)¶
删除项目的配额
- 参数:
name_or_id – 项目名称或 ID
- 引发:
SDKException如果项目无效或 nova 客户端调用失败
- delete_container(name)¶
删除对象存储容器。
- 参数:
name (str) – 要删除的容器的名称。
- delete_device_profile(name_or_id, filters)¶
删除 device_profile。
- 参数:
name_or_id – 要删除的设备配置文件的名称或 UUID。
filters – 要下推的过滤条件字典
- 返回值:
如果删除成功,则为 True,否则为 False。
- delete_domain(domain_id=None, name_or_id=None)¶
删除 Keystone 域。
- 参数:
domain_id – 要删除的域的 ID。
name_or_id – 域的名称或唯一 ID。
- 返回值:
如果删除成功,则为 True,否则为 False。
- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- delete_endpoint(id)¶
删除 Keystone 端点。
- 参数:
id – 要删除的端点的 ID。
- 返回值:
如果删除成功,则为 True,否则为 False。
- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- delete_firewall_group(name_or_id, filters=None)¶
删除防火墙组。如果找不到要删除的资源,将打印调试消息。
- 参数:
name_or_id – 防火墙组名称或 ID
filters (dict) – 可选过滤器
- 引发:
DuplicateResource on multiple matches
- 返回值:
如果资源成功删除,则为 True,否则为 False。
- 返回类型:
bool
- delete_firewall_policy(name_or_id, filters=None)¶
删除防火墙策略。如果找不到要删除的资源,将打印调试消息。
- 参数:
name_or_id – 防火墙策略名称或 ID
filters –
用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
或一个包含用于进一步过滤的 jmespath 表达式的字符串。示例::: “[?last_name==`Smith`] | [?other.gender]==`Female`]”
- 引发:
DuplicateResource on multiple matches
- 返回值:
如果资源成功删除,则为 True,否则为 False。
- 返回类型:
bool
- delete_firewall_rule(name_or_id, filters=None)¶
删除防火墙规则。
如果找不到要删除的资源,将打印调试消息。
- 参数:
name_or_id – 防火墙规则名称或 ID
filters –
用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
或一个包含用于进一步过滤的 jmespath 表达式的字符串。示例::: “[?last_name==`Smith`] | [?other.gender]==`Female`]”
- 引发:
DuplicateResource on multiple matches
- 返回值:
如果资源成功删除,则为 True,否则为 False。
- 返回类型:
bool
- delete_flavor(name_or_id)¶
Delete a flavor
- 参数:
name_or_id – 要删除的虚拟机规格的 ID 或名称。
- 返回值:
如果删除成功,则为 True,否则为 False。
- 引发:
SDKExceptionon operation error.
- delete_floating_ip(floating_ip_id, retry=1)¶
从项目中释放浮动 IP。
- 参数:
floating_ip_id – 浮动 IP 地址 ID。
retry – 重试次数。可选,默认为 1,除了最初的删除调用。值为 0 也会导致不检查结果。
- 返回值:
如果 IP 地址已被删除,则为 True,如果未找到 IP 地址,则为 False。
- 引发:
SDKExceptionon operation error.
- delete_group(name_or_id)¶
删除一个组
- 参数:
name_or_id – 组的名称或唯一 ID。
- 返回值:
如果删除成功,则为 True,否则为 False。
- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- delete_image(name_or_id, wait=False, timeout=3600, delete_objects=True)¶
删除现有镜像。
- 参数:
name_or_id – 要删除的镜像的名称。
wait – 如果为 True,则等待镜像删除完成。
timeout – 等待镜像删除的秒数。None 表示永远。
delete_objects – 如果为 True,则同时删除上传的 Swift 对象。
- 返回值:
如果删除成功,则为 True,否则为 False。
- 引发:
SDKException如果删除过程中出现问题。
- delete_keypair(name)¶
删除密钥对。
- 参数:
name – 要删除的密钥对的名称。
- 返回值:
如果删除成功,则为 True,否则为 False。
- 引发:
SDKExceptionon operation error.
- delete_network(name_or_id)¶
删除网络。
- 参数:
name_or_id – 要删除的网络名称或 ID。
- 返回值:
如果删除成功,则为 True,否则为 False。
- 引发:
SDKExceptionon operation error.
- delete_network_quotas(name_or_id)¶
删除项目的网络配额
- 参数:
name_or_id – 项目名称或 ID
- 返回值:
包含配额的字典
- 引发:
SDKException如果项目无效或网络客户端调用失败
- delete_object(container, name, meta=None)¶
从容器中删除对象。
- 参数:
container (string) – 包含对象的容器名称。
name (string) – 要删除的对象的名称。
meta (dict) – 相关对象的元数据。(可选,如果未提供则会获取)
- 返回值:
如果删除成功,则为 True,如果未找到对象,则为 False。
- 引发:
SDKExceptionon operation error.
- delete_port(name_or_id)¶
删除端口
- 参数:
name_or_id – 要删除的端口的 ID 或名称。
- 返回值:
如果删除成功,则为 True,否则为 False。
- 引发:
SDKExceptionon operation error.
- delete_project(name_or_id, domain_id=None)¶
删除项目。
- 参数:
name_or_id – 项目的名称或唯一 ID。
domain_id – 用于范围界定检索到的项目的域 ID。
- 返回值:
如果删除成功,则为 True,如果未找到项目,则为 False。
- 引发:
SDKExceptionif something goes wrong during the OpenStack API call
- delete_qos_bandwidth_limit_rule(policy_name_or_id, rule_id)¶
删除 QoS 带宽限制规则。
- 参数:
policy_name_or_id (string) – 规则所属的 QoS 策略的名称或 ID。
rule_id (string) – 要更新的规则的 ID。
- 引发:
SDKExceptionon operation error.
- delete_qos_dscp_marking_rule(policy_name_or_id, rule_id)¶
删除 QoS DSCP 标记规则。
- 参数:
policy_name_or_id (string) – 规则所属的 QoS 策略的名称或 ID。
rule_id (string) – 要更新的规则的 ID。
- 引发:
SDKExceptionon operation error.
- delete_qos_minimum_bandwidth_rule(policy_name_or_id, rule_id)¶
删除 QoS 最小带宽规则。
- 参数:
policy_name_or_id (string) – 规则所属的 QoS 策略的名称或 ID。
rule_id (string) – 要删除的规则的 ID。
- 引发:
SDKExceptionon operation error.
- delete_qos_policy(name_or_id)¶
删除 QoS 策略。
- 参数:
name_or_id – 要删除的策略的名称或 ID。
- 返回值:
如果删除成功,则为 True,否则为 False。
- 引发:
SDKExceptionon operation error.
- delete_recordset(zone, name_or_id)¶
删除记录集。
- 参数:
zone – 管理记录集的区域的名称、ID 或
openstack.dns.v2.zone.Zone实例。name_or_id – 要删除的记录集的名称或 ID。
- 返回值:
如果删除成功,则为 True,否则为 False。
- 引发:
SDKExceptionon operation error.
- delete_role(name_or_id, **kwargs)¶
删除 Keystone 角色。
- 参数:
name_or_id – 角色的名称或唯一 ID。
domain_id – 域 ID (v3)
- 返回值:
如果删除成功,则为 True,否则为 False。
- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- delete_router(name_or_id)¶
删除逻辑路由器。
如果提供的是名称而不是唯一的 UUID,由于名称不要求唯一,因此可能会找到多个匹配的路由器。在这种情况下将引发错误。
- 参数:
name_or_id – 要删除的路由器的名称或 ID。
- 返回值:
如果删除成功,则为 True,否则为 False。
- 引发:
SDKExceptionon operation error.
- delete_security_group(name_or_id)¶
删除一个安全组
- 参数:
name_or_id (string) – 安全组的名称或唯一 ID。
- 返回值:
如果删除成功,则为 True,否则为 False。
- 引发:
SDKExceptionon operation error.- 引发:
OpenStackCloudUnavailableFeature 如果此云不支持安全组。
- delete_security_group_rule(rule_id)¶
删除一个安全组规则
- 参数:
rule_id (string) – 安全组规则的唯一 ID。
- 返回值:
如果删除成功,则为 True,否则为 False。
- 引发:
SDKExceptionon operation error.- 引发:
OpenStackCloudUnavailableFeature 如果此云不支持安全组。
- delete_server(name_or_id, wait=False, timeout=180, delete_ips=False, delete_ip_retry=1)¶
删除服务器实例。
- 参数:
name_or_id – 要删除的服务器的名称或 ID
wait (bool) – 如果为 True,则等待服务器删除完成。
timeout (int) – 等待服务器删除的秒数。
delete_ips (bool) – 如果为 True,则删除与实例关联的任何浮动 IP。
delete_ip_retry (int) – 如果删除浮动 IP 的第一次尝试不成功,则重试删除的次数。
- 返回值:
如果删除成功,则为 True,否则为 False;如果服务器不存在,则为 False。
- 引发:
SDKExceptionon operation error.
- delete_server_group(name_or_id)¶
删除服务器组。
- 参数:
name_or_id – 要删除的服务器组的名称或 ID
- 返回值:
如果删除成功,则为 True,否则为 False
- 引发:
SDKExceptionon operation error.
- delete_server_metadata(name_or_id, metadata_keys)¶
从服务器实例中删除元数据。
- 参数:
name_or_id (str) – 要更新的服务器实例的名称或 ID。
metadata_keys – 要从服务器实例中删除的键的列表。
- 返回值:
无
- 引发:
SDKExceptionon operation error.
- delete_service(name_or_id)¶
删除 Keystone 服务。
- 参数:
name_or_id – 服务的名称或唯一 ID。
- 返回值:
如果删除成功,则为 True,否则为 False。
- 引发:
SDKExceptionif something goes wrong during the OpenStack API call
- delete_stack(name_or_id, wait=False)¶
删除堆栈
- 参数:
name_or_id (string) – 堆栈名称或 ID。
wait (boolean) – 是否等待删除完成
- 返回值:
如果删除成功,则为 True,如果未找到堆栈,则为 False。
- 引发:
SDKExceptionif something goes wrong during the OpenStack API call
- delete_subnet(name_or_id)¶
删除子网。
如果提供的是名称而不是唯一的 UUID,由于名称不要求唯一,因此可能会找到多个匹配的子网。在这种情况下将引发错误。
- 参数:
name_or_id – 要删除的子网的名称或 ID。
- 返回值:
如果删除成功,则为 True,否则为 False。
- 引发:
SDKExceptionon operation error.
- delete_unattached_floating_ips(retry=1)¶
安全删除未附加的浮动 IP。
如果云能够安全地清除任何未附加的浮动 IP 而不出现竞态条件,则执行此操作。
安全在这里有特定含义。它意味着您在运行此命令时,没有另一个进程可能执行两步创建/附加操作。如果您在另一个进程正在创建服务器并为其附加浮动 IP 的同时运行此方法,则可以安全地执行此方法,前提是该进程使用了 shade 的 add_auto_ip,或者通过将服务器传递给 create_floating_ip 调用来创建浮动 IP。
- 参数:
retry – 重试次数。可选,默认为 1,除了最初的删除调用。值为 0 也会导致不检查结果。
- 返回值:
已删除的浮动 IP 数量,如果没有删除,则为 False。
- 引发:
SDKExceptionon operation error.
- delete_volume(name_or_id=None, wait=True, timeout=None, force=False)¶
删除卷。
- 参数:
name_or_id – 卷的名称或唯一 ID。
wait – 如果为 True,则等待卷删除完成。
timeout – 等待卷删除的秒数。None 表示永远。
force – 即使卷处于删除中或错误删除状态,也强制删除卷。
- 返回值:
如果删除成功,则为 True,否则为 False。
- 引发:
ResourceTimeoutif wait time exceeded.- 引发:
SDKExceptionon operation error.
- delete_volume_backup(name_or_id=None, force=False, wait=False, timeout=None)¶
删除卷备份。
- 参数:
name_or_id – 要删除的卷备份的名称或唯一 ID。
force – 允许在错误或可用状态以外的状态下进行删除。
wait – 如果为 True,则等待卷备份删除完成。
timeout – 等待卷备份删除的秒数。None 表示永远。
- 返回值:
如果删除成功,则为 True,否则为 False。
- 引发:
ResourceTimeoutif wait time exceeded.- 引发:
SDKExceptionon operation error.
- delete_volume_quotas(name_or_id)¶
删除项目的卷配额
- 参数:
name_or_id – 项目名称或 ID
- 返回值:
已删除的卷
QuotaSet对象。- 引发:
SDKException如果项目无效或调用失败
- delete_volume_snapshot(name_or_id=None, wait=False, timeout=None)¶
删除卷快照。
- 参数:
name_or_id – 要删除的卷快照的名称或唯一 ID。
wait – 如果为 True,则等待卷快照删除完成。
timeout – 等待卷快照删除的秒数。None 表示永远。
- 返回值:
如果删除成功,则为 True,否则为 False。
- 引发:
ResourceTimeoutif wait time exceeded.- 引发:
SDKExceptionon operation error.
- delete_zone(name_or_id)¶
删除区域。
- 参数:
name_or_id – 要删除的区域的名称或 ID。
- 返回值:
如果删除成功,则为 True,否则为 False。
- 引发:
SDKExceptionon operation error.
- detach_ip_from_server(server_id, floating_ip_id)¶
从服务器分离浮动 IP。
- 参数:
server_id – 服务器的 ID。
floating_ip_id – 要分离的浮动 IP 的 ID。
- 返回值:
如果 IP 已分离,则为 True;如果 IP 未附加到任何服务器,则为 False。
- 引发:
SDKExceptionon operation error.
- detach_port_from_machine(name_or_id, port_name_or_id)¶
从裸金属机分离虚拟端口。
- 参数:
name_or_id (string) – A machine name or UUID.
port_name_or_id (string) – A port name or UUID. Note that this is a Network service port, not a bare metal NIC.
- 返回值:
Nothing.
- detach_volume(server, volume, wait=True, timeout=None)¶
从服务器分离卷。
- 参数:
server – 要分离的服务器字典。
volume – 要分离的卷字典。
wait – 如果为 True,则等待卷分离完成。
timeout – 等待卷分离的秒数。None 表示永远。
- 返回值:
无
- 引发:
ResourceTimeoutif wait time exceeded.- 引发:
SDKExceptionon operation error.
- download_image(name_or_id, output_path=None, output_file=None, chunk_size=1048576, stream=False)¶
按名称或 ID 下载镜像
- 参数:
name_or_id (str) – 镜像的名称或 ID。
output_path – 将镜像写入的输出路径。必须指定 output_path 或 output_file 中的一个
output_file – 将镜像数据写入的文件对象(或类文件对象)。将仅对此对象调用 write()。必须指定 output_file 或 output_path 中的一个
chunk_size (int) – 一次从网络读取和缓冲的字节大小。默认为 1024 * 1024 = 1 MiB
- 参数:
bool stream: 是否以 chunk_size 流式输出。
- 返回值:
当未提供 output_path 和 output_file 时 - 构成给定镜像的字节(当 stream 为 False 时),否则为
requests.Response实例。当提供了 output_path 或 output_file 时 - 一个镜像Image实例。- 引发:
SDKException在调用 download_image 时未提供 output_path 或 output_file 中的一个时。- 引发:
BadRequestException如果未找到与提供的名称或 ID 匹配的镜像。
- export_volume_backup(backup_id)¶
导出卷备份。
- 参数:
backup_id – 备份的 ID。
- 返回值:
备份导出记录字段
- 引发:
ResourceTimeoutif wait time exceeded.- 引发:
SDKExceptionon operation error.
- get_aggregate(name_or_id, filters=None)¶
按名称或 ID 获取聚合。
- 参数:
name_or_id – 聚合的名称或 ID。
filters (dict) –
已弃用 用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{ 'availability_zone': 'nova', 'metadata': {'cpu_allocation_ratio': '1.0'}, }
- 返回值:
如果未找到匹配的聚合,则返回聚合字典或 None。
- get_cluster_template(name_or_id, filters=None, detail=False)¶
根据名称或 ID 获取集群模板。
- 参数:
name_or_id – 集群模板的名称或 ID。
filters –
用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
或一个包含用于进一步过滤的 jmespath 表达式的字符串。示例::: “[?last_name==`Smith`] | [?other.gender]==`Female`]”
- 返回值:
集群模板字典,如果未找到匹配的集群模板,则为 None。
- get_coe_cluster(name_or_id, filters=None)¶
根据名称或 ID 获取 COE 集群。
- 参数:
name_or_id – 集群的名称或 ID。
filters –
用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
或一个包含用于进一步过滤的 jmespath 表达式的字符串。示例::: “[?last_name==`Smith`] | [?other.gender]==`Female`]”
- 返回值:
找到的容器基础架构管理
Cluster对象,否则为 None。
- get_coe_cluster_certificate(cluster_id)¶
获取集群的 CA 证书详细信息,按名称或 ID。
- 参数:
cluster_id – 集群的 ID。
- 返回值:
给定集群的 CA 证书详细信息。
- get_compute_limits(name_or_id=None)¶
获取项目的绝对计算限制。
- 参数:
name_or_id – (可选)要获取限制的项目名称或 ID,如果与当前项目不同。
- 返回值:
计算
AbsoluteLimits对象。- 引发:
SDKException如果项目无效。
- get_compute_quotas(name_or_id)¶
获取项目的配额。
- 参数:
name_or_id – 项目名称或 ID
- 返回值:
找到的计算
QuotaSet对象,否则为 None。- 引发:
SDKException如果项目无效。
- get_compute_usage(name_or_id, start=None, end=None)¶
获取特定项目的用量。
- 参数:
name_or_id – 项目名称或 ID
start –
datetime.datetime或字符串。UTC 格式的开始日期。默认为 2010-07-06T12:00:00Z(OpenStack 项目启动日期)。end –
datetime.datetime或字符串。UTC 格式的结束日期。默认为当前时间。
- 返回值:
一个
Usage对象。- 引发:
SDKException如果项目无效。
- get_container(name, skip_cache=False)¶
获取容器的元数据。
- 参数:
name (str) – 要获取元数据的容器名称。
skip_cache (bool) – 已忽略。为保持向后兼容而存在。
- 返回值:
找到的对象存储
Container对象,否则为 None。
- get_container_access(name)¶
从容器获取访问控制列表。
- 参数:
name (str) – 容器的名称。
- 返回值:
容器的访问控制列表。
- 引发:
SDKException如果未找到容器或无法确定容器访问权限。
- get_default_network()¶
返回配置为默认接口的网络。
- 返回值:
找到的网络
Network对象。
- get_domain(domain_id=None, name_or_id=None, filters=None)¶
获取一个 Keystone 域。
- 参数:
domain_id – 域的 ID。
name_or_id – 域的名称或唯一 ID。
filters –
已弃用 用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
一个包含 jmespath 表达式的字符串,用于进一步过滤。例如
"[?last_name==`Smith`] | [?other.gender]==`Female`]"
- 返回值:
一个身份
Domain对象。- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- get_endpoint(id, filters=None)¶
获取一个 Keystone 端点。
- 参数:
id – 端点的 ID。
- 返回值:
一个身份
Endpoint对象。
- get_external_ipv4_floating_networks()¶
返回配置为北向路由的网络。
- 返回值:
如果找到,则返回网络
Network对象列表。
- get_external_ipv4_networks()¶
返回配置为北向路由的网络。
- 返回值:
如果找到,则返回网络
Network对象列表。
- get_external_ipv6_networks()¶
返回配置为北向路由的网络。
- 返回值:
如果找到,则返回网络
Network对象列表。
- get_external_networks()¶
返回配置为北向路由的网络。
为保持向后兼容而保留,建议使用特定的 ipv4/ipv6 方法。
- 返回值:
如果找到,则返回网络
Network对象列表。
- get_firewall_group(name_or_id, filters=None)¶
检索防火墙组。
- 参数:
name_or_id – 防火墙组名称或 ID
filters (dict) – 可选过滤器
- 引发:
DuplicateResource on multiple matches
- 返回值:
找到的网络
FirewallGroup对象,否则为 None。
- get_firewall_policy(name_or_id, filters=None)¶
检索单个防火墙策略。
- 参数:
name_or_id – 防火墙策略名称或 ID
filters –
用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
或一个包含用于进一步过滤的 jmespath 表达式的字符串。示例::: “[?last_name==`Smith`] | [?other.gender]==`Female`]”
- 引发:
DuplicateResource on multiple matches
- 返回值:
找到的网络
FirewallPolicy对象,否则为 None。
- get_firewall_rule(name_or_id, filters=None)¶
检索单个防火墙规则。
- 参数:
name_or_id – 防火墙规则名称或 ID
filters –
用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
或一个包含用于进一步过滤的 jmespath 表达式的字符串。示例::: “[?last_name==`Smith`] | [?other.gender]==`Female`]”
- 引发:
DuplicateResource on multiple matches
- 返回值:
找到的网络
FirewallRule对象,否则为 None。
- get_flavor(name_or_id, filters=None, get_extra=True)¶
根据名称或 ID 获取镜像。
- 参数:
name_or_id – 镜像的名称或 ID。
filters –
已弃用 用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
或一个包含用于进一步过滤的 jmespath 表达式的字符串。示例::: “[?last_name==`Smith`] | [?other.gender]==`Female`]”
get_extra – list_flavors 调用是否应获取额外的镜像规格。
- 返回值:
找到的计算
Flavor对象,否则为 None。
- get_flavor_by_id(id, get_extra=False)¶
根据 ID 获取镜像。
- 参数:
id – 镜像的 ID。
get_extra – list_flavors 调用是否应获取额外的镜像规格。
- 返回值:
找到的计算
Flavor对象,否则为 None。
- get_flavor_by_ram(ram, include=None, get_extra=True)¶
根据可用 RAM 量获取镜像。
查找 RAM 最少且至少等于指定数量的镜像。如果提供了 include,则根据匹配的镜像名称进行进一步过滤。
- 参数:
ram (int) – 最小 RAM 量。
include (string) – 如果提供,将返回名称包含此字符串作为子字符串的镜像。
get_extra – 是否获取额外规格。
- 返回值:
计算
Flavor对象。- 引发:
SDKException如果未找到匹配的镜像。
- get_flavor_name(flavor_id)¶
获取镜像的名称。
- 参数:
flavor_id – 镜像的 ID。
- 返回值:
找到的镜像名称,否则为 None。
- get_floating_ip(id, filters=None)¶
根据 ID 获取浮动 IP。
- 参数:
id – 浮动 IP 的 ID。
filters –
用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
或一个包含用于进一步过滤的 jmespath 表达式的字符串。示例::: “[?last_name==`Smith`] | [?other.gender]==`Female`]”
- 返回值:
找到的浮动 IP
openstack.network.v2.floating_ip.FloatingIP对象,否则为 None。
- get_floating_ip_by_id(id)¶
根据 ID 获取浮动 IP。
- 参数:
id – 浮动 IP 的 ID。
- 返回值:
浮动 IP :class:`~openstack.network.v2.floating_ip.FloatingIP。
- get_group(name_or_id, filters=None, domain_id=None)¶
获取一个 Keystone 组。
- 参数:
name_or_id – 组的名称或唯一 ID。
domain_id – 用于限定检索到的组的域 ID。
- 返回值:
An identity
Groupobject- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- get_image(name_or_id, filters=None)¶
根据名称或 ID 获取镜像。
- 参数:
name_or_id – 镜像的名称或 ID。
filters –
用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
或一个包含用于进一步过滤的 jmespath 表达式的字符串。示例::: “[?last_name==`Smith`] | [?other.gender]==`Female`]”
- 返回值:
An image
openstack.image.v2.image.Imageobject.
- get_image_by_id(id)¶
根据 ID 获取镜像。
- 参数:
id – 镜像的 ID。
- 返回值:
An image
openstack.image.v2.image.Imageobject.
- get_internal_ipv4_networks()¶
返回配置为不进行北向路由的网络。
- 返回值:
如果找到,则返回网络
Network对象列表。
- get_internal_ipv6_networks()¶
返回配置为不进行北向路由的网络。
- 返回值:
如果找到,则返回网络
Network对象列表。
- get_internal_networks()¶
返回配置为不进行北向路由的网络。
为保持向后兼容而保留,建议使用特定的 ipv4/ipv6 方法。
- 返回值:
如果找到,则返回网络
Network对象列表。
- get_keypair(name_or_id, filters=None, *, user_id=None)¶
根据名称或 ID 获取密钥对。
- 参数:
name_or_id – 密钥对的名称或 ID。
filters –
已弃用 用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
或一个包含用于进一步过滤的 jmespath 表达式的字符串。示例::: “[?last_name==`Smith`] | [?other.gender]==`Female`]”
user_id – 要从中检索密钥对的用户。
- 返回值:
找到的计算
Keypair对象,否则为 None。
- get_machine(name_or_id)¶
按名称或 UUID 获取裸机。
通过使用提供的 ID 值(可以是名称或 UUID)来搜索裸机主机。
- 参数:
name_or_id – 将被查找的节点名称或 UUID。
- 返回类型:
Node.- 返回值:
找到的节点,如果未找到节点,则为 None。
- get_machine_by_mac(mac)¶
按端口 MAC 地址获取裸机。
- 参数:
mac – 要查询的端口 MAC 地址,以便返回节点。
- 返回类型:
Node.- 返回值:
找到的节点,如果未找到节点,则为 None。
- get_nat_destination()¶
返回配置为 NAT 目标的网络。
- 返回值:
找到的网络
Network对象。
- get_nat_source()¶
返回配置为 NAT 目标的网络。
- 返回值:
找到的网络
Network对象。
- get_network(name_or_id, filters=None)¶
根据名称或 ID 获取网络。
- 参数:
name_or_id – 网络的名称或 ID。
filters –
用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
或一个包含用于进一步过滤的 jmespath 表达式的字符串。示例::: “[?last_name==`Smith`] | [?other.gender]==`Female`]”
- 返回值:
找到的网络
Network对象,否则为 None。
- get_network_by_id(id)¶
根据 ID 获取网络。
- 参数:
id – 网络的 ID。
- 返回值:
找到的网络
Network对象,否则为 None。
- get_network_extensions()¶
获取云提供的网络扩展。
- 返回值:
一组 Neutron 扩展别名。
- get_network_quotas(name_or_id, details=False)¶
获取项目的网络配额。
- 参数:
name_or_id – 项目名称或 ID
details – 如果设置为 True,将返回给定项目配额使用情况的详细信息。
- 返回值:
找到的网络
Quota对象,否则为 None。- 引发:
SDKException如果项目无效。
- get_nic_by_mac(mac)¶
按硬件地址(通常是 MAC)获取裸机 NIC。
- get_object(container, obj, query_string=None, resp_chunk_size=1024, outfile=None, stream=False)¶
获取对象的头信息和主体。
- 参数:
container (string) – 容器的名称。
obj (string) – 对象的名称。
query_string (string) – URI 的查询参数。(分隔符、前缀等)
resp_chunk_size (int) – 要读取的数据块大小。仅在使用文件或流为 True 时写入结果时使用。(可选,默认为 1k)
outfile – 将对象写入文件而不是返回内容。如果提供了此选项,返回元组中的 body 将为 None。outfile 可以是字符串形式的文件路径,也可以是类似文件的对象。
- 返回值:
对象(头信息,主体)的元组,如果未找到对象(404),则为 None。
- 引发:
SDKExceptionon operation error.
- get_object_capabilities()¶
获取对象存储服务的信息。
对象存储服务发布了一系列能力,包括最大值和阈值的元数据。
- 返回值:
一个对象存储
Info对象。
- get_object_metadata(container, name)¶
获取对象元数据。
- 参数:
container
name
- 返回值:
对象的元数据。
- get_object_raw(container, obj, query_string=None, stream=False)¶
获取对象的原始响应对象。
- 参数:
container (string) – 容器的名称。
obj (string) – 对象的名称。
query_string (string) – URI 的查询参数。(分隔符、前缀等)
stream (bool) – 是否流式传输响应。
- 返回值:
一个 requests.Response。
- 引发:
SDKExceptionon operation error.
- get_object_segment_size(segment_size)¶
获取一个可用分段大小。
- 参数:
segment_size
- 返回值:
一个分段大小。
- get_port(name_or_id, filters=None)¶
根据名称或 ID 获取端口。
- 参数:
name_or_id – 端口的名称或 ID。
filters –
用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
或一个包含用于进一步过滤的 jmespath 表达式的字符串。示例::: “[?last_name==`Smith`] | [?other.gender]==`Female`]”
- 返回值:
找到的网络
Port对象,否则为 None。
- get_port_by_id(id)¶
根据 ID 获取端口。
- 参数:
id – 端口的 ID。
- 返回值:
找到的网络
Port对象,否则为 None。
- get_project(name_or_id, filters=None, domain_id=None)¶
获取一个项目。
- 参数:
name_or_id – 项目的名称或唯一 ID。
filters –
已弃用 用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
一个包含 jmespath 表达式的字符串,用于进一步过滤。例如
"[?last_name==`Smith`] | [?other.gender]==`Female`]"domain_id – 用于范围界定检索到的项目的域 ID。
- 返回值:
An identity
Projectobject.- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- get_qos_bandwidth_limit_rule(policy_name_or_id, rule_id)¶
根据策略名称或 ID 获取 QoS 带宽限制规则。
- 参数:
policy_name_or_id (string) – 应关联规则的 QoS 策略的名称或 ID。
rule_id – 规则的 ID。
- 返回值:
找到的网络
QoSBandwidthLimitRule对象,否则为 None。
- get_qos_dscp_marking_rule(policy_name_or_id, rule_id)¶
根据策略名称或 ID 获取 QoS DSCP 标记规则。
- 参数:
policy_name_or_id (string) – 应关联规则的 QoS 策略的名称或 ID。
rule_id – 规则的 ID。
- 返回值:
找到的网络
QoSDSCPMarkingRule对象,否则为 None。
- get_qos_minimum_bandwidth_rule(policy_name_or_id, rule_id)¶
根据策略名称或 ID 获取 QoS 最低带宽规则。
- 参数:
policy_name_or_id (string) – 应关联规则的 QoS 策略的名称或 ID。
rule_id – 规则的 ID。
- 返回值:
找到的网络
QoSMinimumBandwidthRule对象,否则为 None。
- get_qos_policy(name_or_id, filters=None)¶
根据名称或 ID 获取 QoS 策略。
- 参数:
name_or_id – 策略的名称或 ID。
filters –
用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
或一个包含用于进一步过滤的 jmespath 表达式的字符串。示例::: “[?last_name==`Smith`] | [?other.gender]==`Female`]”
- 返回值:
找到的网络
QoSPolicy对象,否则为 None。
- get_qos_rule_type_details(rule_type, filters=None)¶
按规则类型名称获取 QoS 规则类型详细信息。
- 参数:
rule_type – QoS 规则类型的名称。
filters –
用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
或一个包含用于进一步过滤的 jmespath 表达式的字符串。示例::: “[?last_name==`Smith`] | [?other.gender]==`Female`]”
- 返回值:
找到的网络
QoSRuleType对象,否则为 None。
- get_recordset(zone, name_or_id)¶
根据名称或 ID 获取记录集。
- 参数:
zone – 管理记录集的区域的名称、ID 或
openstack.dns.v2.zone.Zone实例。name_or_id – 记录集的名称或 ID。
- 返回值:
记录集字典,如果未找到匹配的记录集,则为 None。
- get_role(name_or_id, filters=None, domain_id=None)¶
获取一个 Keystone 角色。
- 参数:
name_or_id – 角色的名称或唯一 ID。
domain_id – 用于限定检索到的角色的域 ID。
- 返回值:
找到的身份
Role对象,否则为 None。- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- get_router(name_or_id, filters=None)¶
根据名称或 ID 获取路由器。
- 参数:
name_or_id – 路由器的名称或 ID。
filters –
用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
或一个包含用于进一步过滤的 jmespath 表达式的字符串。示例::: “[?last_name==`Smith`] | [?other.gender]==`Female`]”
- 返回值:
找到的网络
Router对象,否则为 None。
- get_security_group(name_or_id, filters=None)¶
根据名称或 ID 获取安全组。
- 参数:
name_or_id – 安全组的名称或 ID。
filters –
用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
或一个包含用于进一步过滤的 jmespath 表达式的字符串。示例::: “[?last_name==`Smith`] | [?other.gender]==`Female`]”
- 返回值:
找到的
openstack.network.v2.security_group.SecurityGroup对象,否则为 None。
- get_security_group_by_id(id)¶
根据 ID 获取安全组。
- 参数:
id – 安全组的 ID。
- 返回值:
一个安全组
openstack.network.v2.security_group.SecurityGroup对象。
- get_server(name_or_id=None, filters=None, detailed=False, bare=False, all_projects=False)¶
根据名称或 ID 获取服务器。
- 参数:
name_or_id – 服务器的名称或 ID。
filters –
已弃用 用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
或一个包含用于进一步过滤的 jmespath 表达式的字符串。示例::: “[?last_name==`Smith`] | [?other.gender]==`Female`]”
detailed – 是否添加详细的额外信息。默认为 False。
bare – 是否跳过向服务器记录添加任何额外信息。默认为 False,表示地址字典将根据需要从 neutron 填充。设置为 True 表示 detailed = False。
all_projects – 是从所有项目获取服务器,还是仅从当前授权范围的项目获取。
- 返回值:
找到的计算
Server对象,否则为 None。
- get_server_by_id(id)¶
根据 ID 获取服务器。
- 参数:
id – 服务器的 ID。
- 返回值:
找到的计算
Server对象,否则为 None。
- get_server_console(server, length=None)¶
获取服务器的控制台日志。
- 参数:
server – 要获取控制台日志的服务器。可以是服务器字典或服务器的名称或 ID。
length (int) – 您希望从日志末尾检索的行数。(可选,默认为全部)
- 返回值:
包含控制台日志文本的字符串,如果云不支持控制台日志,则为空字符串。
- 引发:
SDKException如果提供了无效的服务器参数或发生其他意外情况。
- get_server_group(name_or_id=None, filters=None)¶
根据名称或 ID 获取服务器组。
- 参数:
name_or_id – 服务器组的名称或 ID。
filters –
已弃用 用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{ 'policy': 'affinity', }
或一个包含用于进一步过滤的 jmespath 表达式的字符串。示例::: “[?last_name==`Smith`] | [?other.gender]==`Female`]”
- 返回值:
找到的计算
ServerGroup对象,否则为 None。
- get_server_id(name_or_id)¶
获取服务器的 ID。
- 参数:
name_or_id
- 返回值:
找到的服务器名称,否则为 None。
- get_server_meta(server)¶
获取服务器的元数据。
- 参数:
server
- 返回值:
找到的服务器元数据,否则为 None。
- get_server_private_ip(server)¶
获取服务器的私有 IP。
- 参数:
server
- 返回值:
设置的服务器私有 IP,否则为 None。
- get_server_public_ip(server)¶
获取服务器的公共 IP。
- 参数:
server
- 返回值:
设置的服务器公共 IP,否则为 None。
- get_service(name_or_id, filters=None)¶
获取一个 Keystone 服务。
- 参数:
name_or_id – 服务的名称或唯一 ID。
- 返回值:
一个身份
Service对象- 引发:
SDKException如果在 OpenStack API 调用期间发生错误或找到多个匹配项。
- get_stack(name_or_id, filters=None, resolve_outputs=True)¶
获取一个堆栈。
- 参数:
name_or_id – 所需堆栈的名称或 ID。
filters – 一个包含额外过滤条件的字典。例如:{‘stack_status’: ‘CREATE_COMPLETE’}
resolve_outputs – 如果为 True,则将解析此堆栈的输出。
- 返回值:
一个包含堆栈描述的
openstack.orchestration.v1.stack.Stack。- 引发:
SDKException如果在 OpenStack API 调用期间发生错误或找到多个匹配项。
- get_subnet(name_or_id, filters=None)¶
根据名称或 ID 获取子网。
- 参数:
name_or_id – 子网的名称或 ID。
filters –
用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
- 返回值:
找到的网络
Subnet对象,否则为 None。
- get_subnet_by_id(id)¶
根据 ID 获取子网。
- 参数:
id – 子网的 ID。
- 返回值:
找到的网络
Subnet对象,否则为 None。
- get_subnetpool(name_or_id)¶
根据名称或 ID 获取子网池。
- 参数:
name_or_id – 子网池的名称或 ID。
- 返回值:
找到的网络
Subnetpool对象,否则为 None。
- get_user(name_or_id, filters=None, domain_id=None)¶
获取一个用户。
- 参数:
name_or_id – Name or unique ID of the user.
filters –
已弃用 用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
一个包含 jmespath 表达式的字符串,用于进一步过滤。例如
"[?last_name==`Smith`] | [?other.gender]==`Female`]"domain_id – 用于限定检索到的用户的域 ID。
- 返回值:
一个身份
User对象。- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- get_user_by_id(user_id, normalize=None)¶
按 ID 获取用户。
- 参数:
user_id (string) – 用户 ID。
- 返回值:
一个身份
User对象。
- get_volume(name_or_id, filters=None)¶
根据名称或 ID 获取卷。
- 参数:
name_or_id – 卷的名称或唯一 ID。
filters –
已弃用 用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
一个包含 jmespath 表达式的字符串,用于进一步过滤。例如
"[?last_name==`Smith`] | [?other.gender]==`Female`]"
- 返回值:
找到的卷
Volume对象,否则为 None。
- get_volume_attach_device(volume, server_id)¶
返回卷连接到服务器的设备名称。
也可用于验证卷是否连接到特定服务器。
- 参数:
volume – 要从中获取设备名称的卷。
server_id – 要检查的服务器 ID。
- 返回值:
如果已连接,则为设备名称;如果卷未连接,则为 None。
- get_volume_backup(name_or_id, filters=None)¶
根据名称或 ID 获取卷备份。
- 参数:
name_or_id – 要删除的卷备份的名称或唯一 ID。
filters –
已弃用 用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
一个包含 jmespath 表达式的字符串,用于进一步过滤。例如
"[?last_name==`Smith`] | [?other.gender]==`Female`]"
- 返回值:
找到的卷
Backup对象,否则为 None。
- get_volume_by_id(id)¶
根据 ID 获取卷。
- 参数:
id – 卷的 ID。
- 返回值:
找到的卷
Volume对象,否则为 None。
- get_volume_id(name_or_id)¶
获取卷的 ID。
- 参数:
name_or_id – 卷的名称或唯一 ID。
- 返回值:
找到的卷 ID,否则为 None。
- get_volume_limits(name_or_id=None)¶
获取当前项目的卷限制。
- 参数:
name_or_id – (可选)要获取限制的项目名称或 ID,如果与当前项目不同。
- 返回值:
找到的卷
Limits对象,否则为 None。
- get_volume_quotas(name_or_id)¶
获取项目的卷配额。
- 参数:
name_or_id – 项目名称或 ID
- 返回值:
带有配额的卷
QuotaSet对象。- 引发:
SDKException如果项目无效。
- get_volume_snapshot(name_or_id, filters=None)¶
根据名称或 ID 获取卷。
- 参数:
name_or_id – 要删除的卷快照的名称或唯一 ID。
filters –
已弃用 用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
一个包含 jmespath 表达式的字符串,用于进一步过滤。例如
"[?last_name==`Smith`] | [?other.gender]==`Female`]"
- 返回值:
找到的卷
Snapshot对象,否则为 None。
- get_volume_snapshot_by_id(snapshot_id)¶
接受一个 snapshot_id,并获取匹配该 ID 的快照字典。
注意:这比 get_volume_snapshot 更高效。
param: snapshot_id: 卷快照的 ID。 :returns: 找到的卷
Snapshot对象,否则为 None。
- get_volume_type(name_or_id, filters=None)¶
根据名称或 ID 获取卷类型。
- 参数:
name_or_id – 卷类型的名称或唯一 ID。
filters –
已弃用 用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
一个包含 jmespath 表达式的字符串,用于进一步过滤。例如
"[?last_name==`Smith`] | [?other.gender]==`Female`]"
- 返回值:
找到的卷
Type对象,否则为 None。
- get_volume_type_access(name_or_id)¶
返回 volume_type_access 列表。
- 参数:
name_or_id – 卷类型的名称或唯一 ID。
- 返回值:
找到的卷
Type对象,否则为 None。- 引发:
SDKExceptionon operation error.
- get_volumes(server, cache=None)¶
获取服务器的卷。
- 参数:
server – 要为其获取卷的服务器。
cache – **已弃用** 此参数不再起作用。
- 返回值:
卷
Volume对象列表。
- get_zone(name_or_id, filters=None)¶
根据名称或 ID 获取可用区。
- 参数:
name_or_id – 可用区的名称或 ID。
filters – 用于进一步过滤的元数据字典。
- 返回值:
可用区字典,如果未找到匹配的可用区,则为 None。
- global_request(global_request_id)¶
创建一个设置了全局请求 ID 的新 Connection 对象。
采用当前 Connection 的现有设置,并构建一个全局请求 ID 被覆盖的新 Connection 对象。
from oslo_context import context cloud = openstack.connect(cloud='example') # Work normally servers = cloud.list_servers() cloud2 = cloud.global_request(context.generate_request_id()) # cloud2 sends all requests with global_request_id set servers = cloud2.list_servers()
此外,这也可以用作上下文管理器。
from oslo_context import context c = openstack.connect(cloud='example') # Work normally servers = c.list_servers() with c.global_request(context.generate_request_id()) as c2: # c2 sends all requests with global_request_id set servers = c2.list_servers()
- 参数:
global_request_id – 要发送的 global_request_id。
- grant_role(name_or_id, user=None, group=None, project=None, domain=None, system=None, inherited=False, wait=False, timeout=60)¶
向用户授予角色。
- 参数:
name_or_id (string) – 角色的名称或唯一 ID。
user (string) – 用户的名称或 ID。
group (string) – 组的名称或 ID。(v3)
project (string) – 项目的名称或 ID。
domain (string) – 域的 ID。(v3)
system (bool) – 系统的名称。(v3)
inherited (bool) – 角色分配是否继承。(v3)
wait (bool) – 等待角色被授予。
timeout (int) –
等待角色授予的超时时间。
注意:当按名称指定的项目、用户或组的角色分配时,domain 是必需的参数。在这种情况下,它们都被视为在该域中。如果使用相同的角色分配使用不同的域,则需要按 ID 指定。
注意:对于 wait 和 timeout,有时授予角色不是即时的。
注意:优先顺序为项目、域、系统。
- 返回值:
如果角色已分配,则为 True,否则为 False。
- 引发:
SDKException如果无法授予角色。
- insert_rule_into_policy(name_or_id, rule_name_or_id, insert_after=None, insert_before=None, filters=None)¶
将防火墙规则添加到策略。
将防火墙规则添加到防火墙策略的 firewall_rules 列表中。如果防火墙规则 ID 已存在于 firewall_rules 列表中,则短路并提前返回防火墙策略。此方法不进行重新排序。如果要移动防火墙规则,则必须先删除再重新添加。
- 参数:
name_or_id – 防火墙策略名称或 ID
rule_name_or_id – 防火墙规则名称或 ID。
insert_after – 应置于添加规则之前的规则名称或 ID。
insert_before – 应置于添加规则之后的规则名称或 ID。
filters (dict) – 可选过滤器
- 引发:
DuplicateResource on multiple matches
- 引发:
NotFoundException,如果找不到防火墙策略或任何防火墙规则(插入的、之前的、之后的)。
- 返回值:
更新的防火墙策略。
- 返回类型:
FirewallPolicy
- inspect_machine(name_or_id, wait=False, timeout=3600)¶
检查裸机。
启用 Ironic 节点检查功能,以收集裸机元数据。
- 参数:
name_or_id – 用于标识机器的字符串,代表机器名称或 UUID 值。
wait – 布尔值,控制方法是等待达到所需状态还是发生故障。
timeout – 整数值,默认为 3600 秒,用于等待状态完成。
- 返回类型:
Node.- 返回值:
节点的当前状态。
- is_object_stale(container, name, filename, file_md5=None, file_sha256=None)¶
检查对象是否与文件的哈希值匹配。
- 参数:
container – 容器的名称。
name – 对象的名称。
filename – 文件的路径。
file_md5 – 文件内容的预计算 md5 值。默认为 None,表示本地计算。
file_sha256 – 文件内容的预计算 sha256 值。默认为 None,表示本地计算。
- is_user_in_group(name_or_id, group_name_or_id)¶
检查用户是否在组中。
- 参数:
name_or_id – Name or unique ID of the user.
group_name_or_id – Group name or ID
- 返回值:
如果用户在组中,则为 True,否则为 False。
- 引发:
SDKExceptionif something goes wrong during the OpenStack API call
- list_accelerator_requests(filters=None)¶
列出所有 accelerator_requests。
- 参数:
filters – (可选)要下推的过滤条件字典。
- 返回值:
加速器
AcceleratorRequest对象列表。
- list_aggregates(filters=None)¶
列出所有可用的主机聚合。
- 返回值:
计算
Aggregate对象列表。
- list_availability_zone_names(unavailable=False)¶
列出可用区名称。
- 参数:
unavailable (bool) – 是否在输出中包含不可用的区域。默认为 False。
- 返回值:
可用区名称列表,如果无法获取列表,则为空列表。
- list_cluster_templates(detail=False)¶
列出集群模板。
- :param bool detail. 已忽略。包含以保持向后兼容。
ClusterTemplates 始终以完整详细信息返回。
- 返回值:
包含集群模板详细信息的字典列表。
- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- list_coe_clusters()¶
列出 COE(容器编排引擎)集群。
- 返回值:
容器基础架构管理
Cluster对象列表。- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- list_containers(full_listing=None, prefix=None)¶
列出 containers。
- 参数:
full_listing – 已忽略。为保持向后兼容而存在。
prefix – 将仅返回具有此前缀的对象。(可选)
- 返回值:
对象存储
Container对象列表。- 引发:
SDKExceptionon operation error.
- list_deployables(filters=None)¶
列出所有可用的 deployables。
- 参数:
filters – (可选)要下推的过滤条件字典。
- 返回值:
加速器
Deployable对象列表。
- list_device_profiles(filters=None)¶
列出所有 device_profiles。
- 参数:
filters – (可选)要下推的过滤条件字典。
- 返回值:
加速器
DeviceProfile对象列表。
- list_devices(filters=None)¶
列出所有设备。
- 参数:
filters – (可选)要下推的过滤条件字典。
- 返回值:
加速器
Device对象列表。
- list_domains(**filters)¶
列出 Keystone 域。
- 返回值:
身份
Domain对象列表。- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- list_endpoints()¶
列出 Keystone 端点。
- 返回值:
A list of identity
Endpointobjects- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- list_firewall_groups(filters=None)¶
列出防火墙组。
- 返回值:
网络
FirewallGroup对象列表。
- list_firewall_policies(filters=None)¶
列出防火墙策略。
- 参数:
filters –
用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
或一个包含用于进一步过滤的 jmespath 表达式的字符串。示例::: “[?last_name==`Smith`] | [?other.gender]==`Female`]”
- 返回值:
网络
FirewallPolicy对象列表。- 返回类型:
list[FirewallPolicy]
- list_firewall_rules(filters=None)¶
列出防火墙规则。
- 参数:
filters –
用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
或一个包含用于进一步过滤的 jmespath 表达式的字符串。示例::: “[?last_name==`Smith`] | [?other.gender]==`Female`]”
- 返回值:
网络
FirewallRule对象列表。- 返回类型:
list[FirewallRule]
- list_flavor_access(flavor_id)¶
列出私有镜像对项目/租户的访问权限。
- 参数:
flavor_id (string) – ID of the private flavor.
- 返回值:
具有 flavor_id 和 tenant_id 属性的字典列表。
- 引发:
SDKExceptionon operation error.
- list_flavors(get_extra=False)¶
列出所有可用的镜像。
- 参数:
get_extra – 是否获取每个镜像的额外规格。默认为 True。可以通过在 clouds.yaml 中设置 openstack.cloud.get_extra_specs 为 False 来覆盖默认行为值。
- 返回值:
计算
Flavor对象列表。
- list_floating_ip_pools()¶
列出所有可用的浮动 IP 池。
注意:此函数支持 nova-net 视图。nova-net 已弃用,因此强烈建议切换到使用 neutron。您几乎肯定应该使用 get_external_ipv4_floating_networks。
- 返回值:
浮动 IP 池对象列表。
- list_floating_ips(filters=None)¶
列出所有可用的浮动 IP。
- 参数:
filters – (可选)要下推的过滤条件字典。
- 返回值:
浮动 IP
openstack.network.v2.floating_ip.FloatingIP对象列表。
- list_groups(**kwargs)¶
列出 Keystone 组。
- 参数:
domain_id – 域 ID。
- 返回值:
身份
Group对象列表。- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- list_hypervisors(filters=None)¶
列出所有虚拟机监控程序。
- 参数:
filters – 传递给 API 服务器的附加查询参数。
- 返回值:
计算
Hypervisor对象列表。
- list_images(filter_deleted=True, show_all=False)¶
获取可用镜像。
- 参数:
filter_deleted – 控制是否返回已删除的镜像。
show_all – 显示所有镜像,包括已共享但未接受的镜像。(默认情况下,在 glance v2 中,未接受的共享镜像不会显示)show_all 将覆盖 filter_deleted 的值 False。
- 返回值:
Glance 镜像列表。
- list_keypairs(filters=None)¶
列出所有可用的密钥对。
- 参数:
filters
- 返回值:
计算
Keypair对象列表。
- list_magnum_services()¶
列出所有 Magnum 服务。
- 返回值:
包含服务详细信息的字典列表。
- 引发:
SDKExceptionon operation error.
- list_networks(filters=None)¶
列出所有可用的网络。
- 参数:
filters – (可选)用于下推的过滤条件字典。
- 返回值:
网络
Network对象列表。
- list_nics()¶
返回所有裸机端口的列表。
- list_nics_for_machine(uuid)¶
返回节点上存在的端口列表。
- 参数:
uuid – 用于标识机器的字符串,代表机器 UUID 值。
- 返回值:
端口列表。
- list_objects(container, full_listing=True, prefix=None)¶
列出对象。
- 参数:
container – 要列出对象的容器的名称。
full_listing – 已忽略。为保持向后兼容而存在。
prefix – 将仅返回具有此前缀的对象。(可选)
- 返回值:
对象存储
Object对象列表。- 引发:
SDKExceptionon operation error.
- list_ports(filters=None)¶
列出所有可用的端口。
- 参数:
filters – (可选)过滤条件字典,用于下推。
- 返回值:
网络
Port对象的列表。
- list_ports_attached_to_machine(name_or_id)¶
列出附加到裸机上的虚拟端口。
- 参数:
name_or_id (string) – A machine name or UUID.
- 返回值:
表示端口的
openstack.Resource对象的列表。
- list_projects(domain_id=None, name_or_id=None, filters=None)¶
列出项目。
不带参数时,返回所有可见项目的完整列表。
- 参数:
domain_id – 域 ID,用于限定搜索的项目。
name_or_id – 项目的名称或 ID。
filters –
用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
一个包含 jmespath 表达式的字符串,用于进一步过滤。例如
"[?last_name==`Smith`] | [?other.gender]==`Female`]"
- 返回值:
身份
Project对象的列表。- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- list_qos_bandwidth_limit_rules(policy_name_or_id, filters=None)¶
列出所有可用的 QoS 带宽限制规则。
- 参数:
policy_name_or_id (string) – QoS 策略的名称或 ID,从中列出规则。
filters – (可选)过滤条件字典,用于下推。
- 返回值:
网络
QoSBandwidthLimitRule对象的列表。- 引发:
:class:`~openstack.exceptions.BadRequestException`如果找不到 QoS 策略。
- list_qos_dscp_marking_rules(policy_name_or_id, filters=None)¶
列出所有可用的 QoS DSCP 标记规则。
- 参数:
policy_name_or_id (string) – QoS 策略的名称或 ID,从中列出规则。
filters – (可选)过滤条件字典,用于下推。
- 返回值:
网络
QoSDSCPMarkingRule对象的列表。- 引发:
:class:`~openstack.exceptions.BadRequestException`如果找不到 QoS 策略。
- list_qos_minimum_bandwidth_rules(policy_name_or_id, filters=None)¶
列出所有可用的 QoS 最小带宽规则。
- 参数:
policy_name_or_id (string) – QoS 策略的名称或 ID,从中列出规则。
filters – (可选)过滤条件字典,用于下推。
- 返回值:
网络
QoSMinimumBandwidthRule对象的列表。- 引发:
:class:`~openstack.exceptions.BadRequestException`如果找不到 QoS 策略。
- list_qos_policies(filters=None)¶
列出所有可用的 QoS 策略。
- 参数:
filters – (可选)过滤条件字典,用于下推。
- 返回值:
网络
QosPolicy对象的列表。
- list_qos_rule_types(filters=None)¶
列出所有可用的 QoS 规则类型。
- 参数:
filters – (可选)过滤条件字典,用于下推。
- 返回值:
网络
QosRuleType对象的列表。
- list_recordsets(zone)¶
列出所有可用的记录集。
- 参数:
zone – 管理记录集的区域的名称、ID 或
openstack.dns.v2.zone.Zone实例。- 返回值:
记录集列表。
- list_role_assignments(filters=None)¶
列出 Keystone 角色分配。
- 参数:
filters (dict) –
过滤器条件字典。可接受的键为:
’user’ (string) - 用户 ID,用作查询过滤器。
’group’ (string) - 组 ID,用作查询过滤器。
’project’ (string) - 项目 ID,用作查询过滤器。
’domain’ (string) - 域 ID,用作查询过滤器。
’system’ (string) - 系统名称,用作查询过滤器。
’role’ (string) - 角色 ID,用作查询过滤器。
’inherited_to’ (string) - 返回‘projects’或‘domains’的继承角色分配。
’os_inherit_extension_inherited_to’ (string) - 已弃用;请改用‘inherited_to’。
’effective’ (boolean) - 返回有效角色分配。
’include_subtree’ (boolean) - 包括子树。
‘user’和‘group’是互斥的,‘domain’和‘project’也是互斥的。
- 返回值:
身份
openstack.identity.v3.role_assignment.RoleAssignment对象的列表。- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- list_roles(**kwargs)¶
列出 Keystone 角色。
- 返回值:
身份
Role对象的列表。- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- list_router_interfaces(router, interface_type=None)¶
列出路由器的所有接口。
- 参数:
router (dict) – 路由器字典对象。
interface_type (string) – None、"internal" 或 "external" 中的一个。控制是返回所有接口、内部接口还是外部接口。
- 返回值:
网络
Port对象的列表。
- list_routers(filters=None)¶
列出所有可用的路由器。
- 参数:
filters – (可选)过滤条件字典,用于下推。
- 返回值:
网络
Router对象的列表。
- list_security_groups(filters=None)¶
列出所有可用的安全组。
- 参数:
filters – (可选)要下推的过滤条件字典。
- 返回值:
安全组
openstack.network.v2.security_group.SecurityGroup对象的列表。
- list_server_groups()¶
列出所有可用的服务器组。
- 返回值:
计算
ServerGroup对象的列表。
- list_server_security_groups(server)¶
列出与给定服务器关联的所有安全组。
- 返回值:
安全组字典对象的列表。
- list_servers(detailed=False, all_projects=False, bare=False, filters=None)¶
列出所有可用的服务器。
- 参数:
detailed – 是否添加详细的额外信息。默认为 False。
all_projects – 是否列出所有项目中的服务器,还是仅列出当前已授权的项目中的服务器。
bare – 是否跳过向服务器记录添加任何额外信息。默认为 False,表示地址字典将根据需要从 neutron 填充。设置为 True 表示 detailed = False。
filters – 传递给 API 服务器的附加查询参数。
- 返回值:
计算
Server对象的列表。
- list_services()¶
列出所有 Keystone 服务。
- 返回值:
身份
Service对象的列表。- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
列出共享文件系统服务的可用区。
- 返回值:
共享文件系统可用区列表。
- list_stacks(**query)¶
列出所有堆栈。
- 参数:
query (dict) – 查询参数,用于限制堆栈。
- 返回值:
包含堆栈描述的
openstack.orchestration.v1.stack.Stack对象列表。- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- list_subnets(filters=None)¶
列出所有可用的子网。
- 参数:
filters – (可选)过滤条件字典,用于下推。
- 返回值:
网络
Subnet对象的列表。
- list_users(**kwargs)¶
列出用户。
- 参数:
name
domain_id – 域 ID,用于限定检索的用户。
- 返回值:
身份
User对象的列表。- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- list_volume_backups(detailed=True, filters=None)¶
列出所有卷备份。
- 参数:
detailed – 是否添加详细的附加信息。
filters –
用于进一步过滤的元数据字典。示例:
{ 'name': 'my-volume-backup', 'status': 'available', 'volume_id': 'e126044c-7b4c-43be-a32a-c9cbbc9ddb56', 'all_tenants': 1, }
- 返回值:
卷
Backup对象的列表。
- list_volume_snapshots(detailed=True, filters=None)¶
列出所有卷快照。
- 参数:
detailed – 是否添加详细的附加信息。
filters –
用于进一步过滤的元数据字典。示例:
{ 'name': 'my-volume-snapshot', 'volume_id': 'e126044c-7b4c-43be-a32a-c9cbbc9ddb56', 'all_tenants': 1, }
- 返回值:
卷
Snapshot对象的列表。
- list_volume_types(get_extra=None)¶
列出所有可用的卷类型。
- 参数:
get_extra – **已弃用** 此参数不再起作用。
- 返回值:
卷
Type对象的列表。
- list_volumes(cache=None)¶
列出所有可用的卷。
- 参数:
cache – **已弃用** 此参数不再起作用。
- 返回值:
卷
Volume对象列表。
- list_zones(filters=None)¶
列出所有可用的区域。
- 返回值:
区域字典列表。
- node_set_provision_state(name_or_id, state, configdrive=None, wait=False, timeout=3600)¶
设置节点预配状态。
使用户能够预配机器,并可选择定义要使用的配置驱动器。
- 参数:
name_or_id (string) – 代表裸机节点的名称或 UUID。
state (string) – 裸机节点的所需预配状态。
configdrive (string) – 可选的 URL、文件或路径,代表配置驱动器。如果是目录,客户端 API 将创建格式正确的配置驱动器文件,并将文件内容发布到 API 进行部署。
wait (boolean) – 一个布尔值,默认为 false,用于控制方法在返回之前是否等待达到所需结束状态。
timeout (integer) – 默认值为 3600 秒的整数值,表示等待达到所需结束状态的时间。
- 返回值:
方法退出时的机器当前状态。
- 返回类型:
Node.- 引发:
SDKExceptionon operation error.
- patch_machine(name_or_id, patch)¶
修补机器信息。
此方法允许用户界面操纵 Ironic 中的节点条目。
- 参数:
name_or_id (string) – 要更新的机器名称或 UUID。
patch –
JSON Patch 文档是符合 RFC 6902 的字典对象列表,可以在 https://tools.ietf.org/html/rfc6902 找到。
示例 patch 构建。
patch = [] patch.append({'op': 'remove', 'path': '/instance_info'}) patch.append( {'op': 'replace', 'path': '/name', 'value': 'newname'} ) patch.append( { 'op': 'add', 'path': '/driver_info/username', 'value': 'administrator', } )
- 返回值:
节点的当前状态。
- 返回类型:
Node.- 引发:
SDKExceptionon operation error.
- pformat(resource)¶
pformat 的包装器,它能解析 munch 对象。
- pprint(resource)¶
pprint 的包装器,它能解析 munch 对象。
- project_cleanup(dry_run=True, wait_timeout=120, status_queue=None, filters=None, resource_evaluation_fn=None, skip_resources=None)¶
清理项目资源。
清理所有服务中提供清理方法的资源。
- 参数:
dry_run (bool) – 清理或仅列出已识别的资源。
wait_timeout (int) – 每个服务完成清理的最大时间。
status_queue (queue) – 一个线程队列对象,用于获取当前进程状态。队列包含已处理的资源。
filters (dict) – 用于清理的其他过滤器(仅匹配所有过滤器的资源将被删除,如果没有其他依赖项)。
resource_evaluation_fn – 一个回调函数,将为每个资源调用,并且必须返回 True/False,具体取决于资源是否需要删除。
skip_resources – 应跳过清理的特定资源列表。
- range_search(data, filters)¶
跨字典列表执行整数范围搜索。
给定字典列表,使用给定的字典键和每个键的整数值范围在列表中进行搜索。只有匹配整个原始数据集的所有搜索条件的字典才会被返回。
每个字典不一定包含用于搜索的键。没有该键的字典将被视为不匹配。
范围值必须是字符串值,并且是代表整数的数字集,或者是一个后跟代表整数的数字集的范围运算符。如果未给出范围运算符,则使用精确值匹配。有效运算符包括:<,>,<=,>=。
- 参数:
data – 要搜索的字典列表。
filters –
描述要执行的一个或多个范围搜索的字典。如果给出多个搜索,结果将是匹配所有搜索的原始数据集的成员。例如,按多个范围过滤:
{"vcpus": "<=5", "ram": "<=2048", "disk": "1"}
- 返回值:
原始数据集的列表子集。
- 引发:
针对无效范围表达式的
SDKException。
- rebuild_server(server_id, image_id, admin_pass=None, detailed=False, bare=False, wait=False, timeout=180)¶
重建服务器。
- 参数:
server_id
image_id
admin_pass
detailed
bare
wait
timeout
- 返回值:
计算
Server对象。
- register_machine(nics, wait=False, timeout=3600, lock_timeout=600, provision_state='available', **kwargs)¶
使用 Ironic 注册裸机。
允许将裸机节点注册到 Ironic,并填充相关节点信息或配置以传递给 Ironic API。
此方法还会为要使用的 MAC 地址列表创建端口,以用于启动和潜在的网络配置。
如果创建网络端口时检测到失败,则会删除任何已创建的端口,并将节点从 Ironic 中移除。
- 参数:
nics –
表示要创建的节点网络接口的端口数组。这些端口在节点注册后但在其清理前创建。
示例
[ {'address': 'aa:bb:cc:dd:ee:01'}, {'address': 'aa:bb:cc:dd:ee:02'}, ]
或者,您也可以提供 MAC 地址数组。
wait – 布尔值,默认为 false,用于等待节点达到可用状态(可预配)。请注意,当设置为 false 时,方法仍将等待锁清除后再发送下一个必需的命令。
timeout – 整数值,默认为 3600 秒,用于等待状态完成。
lock_timeout – 锁清除的整数值,默认为 600 秒。
provision_state – 预期的预配状态,可以是 "enroll"、"manageable" 或 "available" 之一。“available”将导致自动清理。
kwargs – 传递给 Ironic API 的键值对,包括 uuid、name、chassis_uuid、driver_info、properties。
- 返回值:
节点的当前状态。
- 返回类型:
Node.- 引发:
SDKExceptionon operation error.
- remove_flavor_access(flavor_id, project_id)¶
撤销项目/租户对私有风味的访问权限。
- 参数:
flavor_id (string) – ID of the private flavor.
project_id (string) – ID of the project/tenant.
- 返回值:
无
- 引发:
SDKExceptionon operation error.
- remove_host_from_aggregate(name_or_id, host_name)¶
从聚合中移除主机。
- 参数:
name_or_id – Name or ID of the host aggregate.
host_name – 要移除的主机。
- 引发:
SDKExceptionon operation error.
- remove_machine_from_maintenance(name_or_id)¶
将裸机从维护状态中移除。
与 set_machine_maintenance_state 类似,此方法将机器从维护状态中移除。需要注意的是,此方法仅调用 set_machine_maintenace_state 来请求的 name_or_id,并将状态设置为 False。
- 参数:
name_or_id (string) – 代表裸机节点的名称或 UUID。
- 返回值:
无
- 引发:
SDKExceptionon operation error.
- remove_router_interface(router, subnet_id=None, port_id=None)¶
从内部路由器接口分离子网。
必须提供 subnet_id 或 port_id 中的至少一个。
如果同时指定了子网和端口 ID,则子网 ID 必须对应于端口 ID 指定的端口上的第一个 IP 地址。否则将发生错误。
- 参数:
router (dict) – The dict object of the router being changed
subnet_id (string) – The ID of the subnet to use for the interface
port_id (string) – The ID of the port to use for the interface
- 返回值:
成功时返回 None。
- 引发:
SDKExceptionon operation error.
- remove_rule_from_policy(name_or_id, rule_name_or_id, filters=None)¶
从防火墙策略的 firewall_rules 列表中移除防火墙规则。如果防火墙规则已不存在于 firewall_rules 列表中,则会提前短路并返回防火墙策略。
- 参数:
name_or_id – 防火墙策略名称或 ID
rule_name_or_id – 防火墙规则名称或 ID。
filters (dict) – 可选过滤器
- 引发:
DuplicateResource on multiple matches
- 引发:
如果找不到防火墙策略,则引发 NotFoundException。
- 返回值:
更新的防火墙策略。
- 返回类型:
FirewallPolicy
- remove_server_security_groups(server, security_groups)¶
从服务器移除安全组。
从现有服务器移除现有的安全组。如果服务器上不存在这些安全组,则操作将不受影响。
- 参数:
server – The server to remove security groups from.
security_groups – A list of security groups to remove.
- 返回值:
False if server or security groups are undefined, True otherwise.
- 引发:
SDKExceptionon operation error.
- remove_user_from_group(name_or_id, group_name_or_id)¶
从组中删除用户。
- 参数:
name_or_id – Name or unique ID of the user.
group_name_or_id – Group name or ID
- 引发:
SDKExceptionif something goes wrong during the OpenStack API call
- remove_volume_type_access(name_or_id, project_id)¶
撤销对项目卷类型的访问权限。
- 参数:
name_or_id – ID or name of a volume_type
project_id – A project id
- 返回值:
无
- 引发:
SDKExceptionon operation error.
- revoke_role(name_or_id, user=None, group=None, project=None, domain=None, system=None, inherited=False, wait=False, timeout=60)¶
撤销用户的角色。
- 参数:
name_or_id (string) – 角色的名称或唯一 ID。
user (string) – 用户的名称或 ID。
group (string) – 组的名称或 ID。(v3)
project (string) – 项目的名称或 ID。
domain (string) – 域的 ID。(v3)
system (bool) – 系统的名称。(v3)
inherited (bool) – 角色分配是否为继承的。
wait (bool) – 等待角色被撤销。
timeout (int) –
等待角色被撤销的超时时间。
注意:对于 wait 和 timeout,有时撤销角色并非瞬时完成。
注意:keystone v2 需要 project。
注意:优先顺序为项目、域、系统。
- 返回值:
如果角色被撤销,则返回 True,否则返回 False。
- 引发:
如果角色无法移除,则引发
SDKException。
- search_aggregates(name_or_id=None, filters=None)¶
搜索主机聚合。
- 参数:
name – 聚合名称或 ID。
filters (dict) –
用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{ 'availability_zone': 'nova', 'metadata': {'cpu_allocation_ratio': '1.0'}, }
- 返回值:
匹配搜索条件的计算
Aggregate对象列表。- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- search_cluster_templates(name_or_id=None, filters=None, detail=False)¶
搜索集群模板。
- 参数:
name_or_id – 集群模板名称或 ID。
filters – 一个字典,包含要使用的其他过滤器。
detail – 一个布尔值,控制是需要摘要输出还是详细输出。
- 返回值:
包含集群模板的字典列表。
- 引发:
在 OpenStack API 调用期间发生任何问题时引发
SDKException。
- search_coe_clusters(name_or_id=None, filters=None)¶
搜索 COE 集群。
- 参数:
name_or_id – 集群名称或 ID。
filters – 一个字典,包含要使用的其他过滤器。
detail – 一个布尔值,控制是需要摘要输出还是详细输出。
- 返回值:
容器基础架构管理
Cluster对象列表。- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- search_containers(name=None, filters=None)¶
搜索容器。
- 参数:
name (string) – 容器名称。
filters – 一个字典,包含要使用的其他过滤器。或一个包含用于进一步过滤的 jmespath 表达式的字符串。示例 :: “[?last_name==`Smith`] | [?other.gender]==`Female`]”
- 返回值:
匹配搜索条件的对象存储
Container对象列表。- 引发:
在 OpenStack API 调用期间发生任何问题时引发
SDKException。
- search_domains(filters=None, name_or_id=None)¶
搜索 Keystone 域。
- 参数:
name_or_id – 域的名称或 ID。
filters –
用于进一步过滤的元数据字典。此字典的元素本身可以是字典。示例:
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
一个包含 jmespath 表达式的字符串,用于进一步过滤。例如
"[?last_name==`Smith`] | [?other.gender]==`Female`]"
- 返回值:
身份
Domain对象列表。- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- search_endpoints(id=None, filters=None)¶
列出 Keystone 端点。
- 参数:
id – 端点的 ID。
filters –
用于进一步过滤的元数据字典。此字典的元素本身可以是字典。示例:
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
一个包含 jmespath 表达式的字符串,用于进一步过滤。例如
"[?last_name==`Smith`] | [?other.gender]==`Female`]"
- 返回值:
A list of identity
Endpointobjects- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- search_flavors(name_or_id=None, filters=None, get_extra=True)¶
搜索风味。
- 参数:
name_or_id – 风味的名称或唯一 ID。
filters
get_extra – 是否获取额外规格。
- 返回值:
匹配搜索条件的计算
Flavor对象列表。
- search_groups(name_or_id=None, filters=None, domain_id=None)¶
搜索 Keystone 组。
- 参数:
name_or_id – 组的名称或 ID。
filters –
用于进一步过滤的元数据字典。此字典的元素本身可以是字典。示例:
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
一个包含 jmespath 表达式的字符串,用于进一步过滤。例如
"[?last_name==`Smith`] | [?other.gender]==`Female`]"domain_id – 域 ID,用于限定搜索的组。
- 返回值:
身份
Group对象列表。- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- search_keypairs(name_or_id=None, filters=None)¶
搜索密钥对。
- 参数:
name_or_id – 密钥对的名称或唯一 ID。
filters –
用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
一个包含用于进一步过滤的 jmespath 表达式的字符串。无效的过滤器将被忽略。
- 返回值:
匹配搜索条件的计算
Keypair对象列表。
- search_networks(name_or_id=None, filters=None)¶
搜索网络。
- 参数:
name_or_id – 所需网络的名称或 ID。
filters – 一个字典,包含要使用的其他过滤器。例如:{‘router:external’: True}
- 返回值:
匹配搜索条件网络
Network对象列表。- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- search_objects(container, name=None, filters=None)¶
搜索对象。
- 参数:
name (string) – 对象名称。
filters – 一个字典,包含要使用的其他过滤器。或一个包含用于进一步过滤的 jmespath 表达式的字符串。示例 :: “[?last_name==`Smith`] | [?other.gender]==`Female`]”
- 返回值:
匹配搜索条件的对象存储
Object对象列表。- 引发:
在 OpenStack API 调用期间发生任何问题时引发
SDKException。
- search_ports(name_or_id=None, filters=None)¶
搜索端口。
- 参数:
name_or_id – 所需端口的名称或 ID。
filters – 一个字典,包含要使用的其他过滤器。例如:{‘device_id’: ‘2711c67a-b4a7-43dd-ace7-6187b791c3f0’}
- 返回值:
匹配搜索条件的网络
Port对象列表。- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- search_projects(name_or_id=None, filters=None, domain_id=None)¶
search_projects 的向后兼容方法。
search_projects 最初有一个参数列表,即 name_or_id、filters,并且 list 具有 domain_id 在前面。此方法以这种形式存在,以便仍然可以使用使用位置参数编写的代码。但实际上,请使用关键字参数。
- 参数:
name_or_id – 项目的名称或 ID。
filters –
用于进一步过滤的元数据字典。此字典的元素本身可以是字典。示例:
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
一个包含 jmespath 表达式的字符串,用于进一步过滤。例如
"[?last_name==`Smith`] | [?other.gender]==`Female`]"domain_id – 域 ID,用于限定搜索的项目。
- 返回值:
身份
Project对象的列表。
- search_qos_bandwidth_limit_rules(policy_name_or_id, rule_id=None, filters=None)¶
搜索 QoS 带宽限制规则。
- 参数:
policy_name_or_id (string) – 要关联规则的 QoS 策略的名称或 ID。
rule_id (string) – 被搜索规则的 ID。
filters – 一个字典,包含要使用的其他过滤器。例如:{‘max_kbps’: 1000}
- 返回值:
匹配搜索条件的网络
QoSBandwidthLimitRule对象列表。- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- search_qos_dscp_marking_rules(policy_name_or_id, rule_id=None, filters=None)¶
搜索 QoS DSCP 标记规则。
- 参数:
policy_name_or_id (string) – 要关联规则的 QoS 策略的名称或 ID。
rule_id (string) – 被搜索规则的 ID。
filters – 一个字典,包含要使用的其他过滤器。例如:{‘dscp_mark’: 32}
- 返回值:
匹配搜索条件的网络
QoSDSCPMarkingRule对象列表。- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- search_qos_minimum_bandwidth_rules(policy_name_or_id, rule_id=None, filters=None)¶
搜索 QoS 最小带宽规则。
- 参数:
policy_name_or_id (string) – 要关联规则的 QoS 策略的名称或 ID。
rule_id (string) – 被搜索规则的 ID。
filters – 一个字典,包含要使用的其他过滤器。例如:{‘min_kbps’: 1000}
- 返回值:
匹配搜索条件的网络
QoSMinimumBandwidthRule对象列表。- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- search_qos_policies(name_or_id=None, filters=None)¶
搜索 QoS 策略。
- 参数:
name_or_id – 所需策略的名称或 ID。
filters – 一个字典,包含要使用的其他过滤器。例如:{‘shared’: True}
- 返回值:
匹配搜索条件的网络
QosPolicy对象列表。- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- search_resources(resource_type, name_or_id, get_args=None, get_kwargs=None, list_args=None, list_kwargs=None, **filters)¶
搜索资源。
根据特定条件搜索资源。
- 参数:
resource_type (str) – 预期资源的字符串表示,格式为 service.resource(例如,“network.security_group”)。
name_or_id (str) – 资源的名称或 ID。
get_args (list) – 要传递给 _get 调用的可选参数。
get_kwargs (dict) – 要传递给 _get 调用的可选关键字参数。
list_args (list) – 要传递给 _list 调用的可选参数。
list_kwargs (dict) – 要传递给 _list 调用的可选关键字参数。
filters (dict) – 用于查询资源的其他过滤器。
- search_roles(name_or_id=None, filters=None, domain_id=None)¶
搜索 Keystone 角色。
- 参数:
name – 角色(复数)的名称或 ID。
filters –
用于进一步过滤的元数据字典。此字典的元素本身可以是字典。示例:
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
一个包含 jmespath 表达式的字符串,用于进一步过滤。例如
"[?last_name==`Smith`] | [?other.gender]==`Female`]"domain_id – 域 ID,用于限定搜索的角色。
- 返回值:
身份
Role对象列表。- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- search_routers(name_or_id=None, filters=None)¶
搜索路由器。
- 参数:
name_or_id – 所需路由器的名称或 ID。
filters – 一个字典,包含要使用的其他过滤器。例如:{‘admin_state_up’: True}
- 返回值:
匹配搜索条件的网络
Router对象列表。- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- search_server_groups(name_or_id=None, filters=None)¶
搜索服务器组。
- 参数:
name_or_id – 服务器组的名称或唯一 ID。
filters –
用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
一个包含用于进一步过滤的 jmespath 表达式的字符串。无效的过滤器将被忽略。
- 返回值:
匹配搜索条件的计算
ServerGroup对象列表。- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- search_servers(name_or_id=None, filters=None, detailed=False, all_projects=False, bare=False)¶
搜索服务器。
- 参数:
name_or_id – 服务器的名称或唯一 ID。
filters –
用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
一个包含用于进一步过滤的 jmespath 表达式的字符串。无效的过滤器将被忽略。
detailed
all_projects
bare
- 返回值:
匹配搜索条件的计算
Server对象列表。
- search_services(name_or_id=None, filters=None)¶
搜索 Keystone 服务。
- 参数:
name_or_id – 服务的名称或 ID。
filters –
用于进一步过滤的元数据字典。此字典的元素本身可以是字典。示例:
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
一个包含 jmespath 表达式的字符串,用于进一步过滤。例如
"[?last_name==`Smith`] | [?other.gender]==`Female`]"
- 返回值:
身份
Service对象列表。- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- search_stacks(name_or_id=None, filters=None)¶
搜索堆栈。
- 参数:
name_or_id – 所需堆栈的名称或 ID。
filters – 一个包含额外过滤条件的字典。例如:{‘stack_status’: ‘CREATE_COMPLETE’}
- 返回值:
包含堆栈描述的
openstack.orchestration.v1.stack.Stack对象列表。- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- search_subnets(name_or_id=None, filters=None)¶
搜索子网。
- 参数:
name_or_id – 所需子网的名称或 ID。
filters – 一个字典,包含要使用的其他过滤器。例如:{‘enable_dhcp’: True}
- 返回值:
匹配搜索条件的网络
Subnet对象列表。- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- search_users(name_or_id=None, filters=None, domain_id=None)¶
搜索用户。
- 参数:
name_or_id – 用户的名称或 ID。
domain_id – 域 ID,用于限定检索的用户。
filters –
用于进一步过滤的元数据字典。此字典的元素本身可以是字典。示例:
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
一个包含 jmespath 表达式的字符串,用于进一步过滤。例如
"[?last_name==`Smith`] | [?other.gender]==`Female`]"
- 返回值:
身份
User对象列表。- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- search_volume_backups(name_or_id=None, filters=None)¶
搜索一个或多个卷备份。
- 参数:
name_or_id – 卷备份的名称或唯一 ID。
filters –
已弃用 用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
一个包含 jmespath 表达式的字符串,用于进一步过滤。例如
"[?last_name==`Smith`] | [?other.gender]==`Female`]"
- 返回值:
找到的卷
Backup对象列表(如果找到)。
- search_volume_snapshots(name_or_id=None, filters=None)¶
搜索一个或多个卷快照。
- 参数:
name_or_id – 卷快照的名称或唯一 ID。
filters –
已弃用 用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
一个包含 jmespath 表达式的字符串,用于进一步过滤。例如
"[?last_name==`Smith`] | [?other.gender]==`Female`]"
- 返回值:
找到的卷
Snapshot对象列表(如果找到)。
- search_volume_types(name_or_id=None, filters=None, get_extra=None)¶
搜索一个或多个卷类型。
- 参数:
name_or_id – 卷类型的名称或唯一 ID。
filters –
已弃用 用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
一个包含 jmespath 表达式的字符串,用于进一步过滤。例如
"[?last_name==`Smith`] | [?other.gender]==`Female`]"
- 返回值:
找到的卷
Type对象列表(如果找到)。
- search_volumes(name_or_id=None, filters=None)¶
搜索一个或多个卷。
- 参数:
name_or_id – 卷的名称或唯一 ID。
filters –
已弃用 用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
一个包含 jmespath 表达式的字符串,用于进一步过滤。例如
"[?last_name==`Smith`] | [?other.gender]==`Female`]"
- 返回值:
找到的卷
Volume对象列表(如果找到)。
- set_aggregate_metadata(name_or_id, metadata)¶
设置聚合元数据,替换现有元数据。
- 参数:
name_or_id – 要更新的主机聚合的名称。
metadata – 包含要替换的元数据的字典(使用 {‘key’: None} 删除一个键)。
- 返回值:
表示新主机聚合的字典。
- 引发:
SDKExceptionon operation error.
- set_compute_quotas(name_or_id, **kwargs)¶
在项目中设置配额。
- 参数:
name_or_id – 项目名称或 ID
kwargs – 配额名称和配额值的键/值对。
- 引发:
如果用于设置配额的资源不存在,则引发
SDKException。
- set_container_access(name, access, refresh=False)¶
设置容器的访问控制列表。
- 参数:
name (str) – 容器的名称。
access (str) – 要设置在容器上的 ACL 字符串。也可以是
public或private,它们将被转换为适当的 ACL 字符串。refresh – 触发刷新容器属性的标志。
- set_flavor_specs(flavor_id, extra_specs)¶
向风味添加额外规格。
- 参数:
flavor_id (string) – 要更新的风味的 ID。
extra_specs (dict) – 键值对字典。
- 返回值:
无
- 引发:
SDKExceptionon operation error.- 引发:
如果找不到风味 ID,则引发
BadRequestException。
- set_machine_maintenance_state(name_or_id, state=True, reason=None)¶
设置裸机维护状态。
设置裸机维护状态和维护原因。
- 参数:
name_or_id (string) – 代表裸机节点的名称或 UUID。
state (boolean) – 节点的所需状态。True 表示处于维护状态,False 表示机器不在维护模式下。如果未明确设置,此值默认为 True。
reason (string) – 可选的自由格式字符串,提供给裸机 API,用于说明节点处于维护状态的原因。
- 返回值:
无
- 引发:
SDKExceptionon operation error.
- set_machine_power_off(name_or_id)¶
关闭裸机电源。
这是一个将节点电源状态设置为“off”的方法。
- Params string name_or_id:
表示要将电源关闭的裸机节点的字符串。
- 返回值:
无
- 引发:
SDKExceptionon operation error.
- set_machine_power_on(name_or_id)¶
激活裸金属机器电源
这是一个将节点电源状态设置为“on”的方法。
- Params string name_or_id:
一个字符串,表示要将电源设置为“on”状态的裸金属节点。
- 返回值:
无
- 引发:
SDKExceptionon operation error.
- set_machine_power_reboot(name_or_id)¶
关闭裸机电源。
这是一个将节点电源状态设置为“reboot”的方法,本质上是将机器电源状态更改为“off”,然后再更改回“on”。
- Params string name_or_id:
表示要将电源关闭的裸机节点的字符串。
- 返回值:
无
- 引发:
SDKExceptionon operation error.
- set_network_quotas(name_or_id, **kwargs)¶
在项目中设置网络配额
- 参数:
name_or_id – 项目名称或 ID
kwargs – 配额名称和配额值的键/值对。
- 引发:
如果用于设置配额的资源不存在,则引发
SDKException。
- set_server_metadata(name_or_id, metadata)¶
在服务器实例中设置元数据。
- 参数:
name_or_id (str) – 要更新的服务器实例的名称或 ID。
metadata (dict) – 一个字典,包含要设置在服务器实例中的键值对。它仅更新提供的键值对。现有条目将保持不变。
- 返回值:
无
- 引发:
SDKExceptionon operation error.
- set_volume_bootable(name_or_id, bootable=True)¶
设置卷的可引导标志。
- 参数:
name_or_id – 卷的名称或唯一 ID。
bootable (bool) – 卷是否应该可引导。(默认为 True)
- 返回值:
无
- 引发:
ResourceTimeoutif wait time exceeded.- 引发:
SDKExceptionon operation error.
- set_volume_quotas(name_or_id, **kwargs)¶
在项目中设置卷配额
- 参数:
name_or_id – 项目名称或 ID
kwargs – 配额名称和配额值的键/值对。
- 返回值:
无
- 引发:
如果用于设置配额的资源不存在,则引发
SDKException。
- sign_coe_cluster_certificate(cluster_id, csr)¶
为集群签名客户端密钥并生成 CA 证书
- 参数:
cluster_id – 集群的 UUID。
csr – 用于认证客户端密钥的证书签名请求 (CSR)。Magnum 将使用 CSR 生成一个签名证书,客户端将使用该证书与集群通信。
- 返回值:
一个代表签名证书的字典。
- 引发:
SDKExceptionon operation error.
- stream_object(container, obj, query_string=None, resp_chunk_size=1024)¶
通过流式迭代器下载内容。
- 参数:
container (string) – 容器的名称。
obj (string) – 对象的名称。
query_string (string) – URI 的查询参数。(分隔符、前缀等)
resp_chunk_size (int) – 读取数据的块大小。仅在使用结果时使用
- 返回值:
内容迭代器,如果找不到对象则为 None。
- 引发:
SDKExceptionon operation error.
- unbind_accelerator_request(uuid, properties)¶
将加速器从虚拟机解绑。
- 参数:
uuid – 要解绑的 accelerator_request 的 uuid。
properties – 将解绑加速器的虚拟机的信息。
- 返回值:
如果解绑成功则为 True,否则为 False。
- unregister_machine(nics, uuid, wait=None, timeout=600)¶
从 Ironic 注销裸金属
从 Ironic API 中移除网络接口和裸金属节点的条目
- 参数:
nics – 一个字符串数组,包含要删除的 MAC 地址。
uuid (string) – 要删除的节点的 UUID。
wait – 已弃用,请勿使用。
timeout – 整数值,表示秒数,默认为 600,它控制着在机器上释放锁之前阻塞的最大时间。
- 引发:
SDKException操作失败时。
- unset_flavor_specs(flavor_id, keys)¶
从風味中删除额外配置
- 参数:
flavor_id (string) – 要更新的风味的 ID。
keys – 要删除的配置键列表。
- 返回值:
无
- 引发:
SDKExceptionon operation error.- 引发:
如果找不到风味 ID,则引发
BadRequestException。
- update_aggregate(name_or_id, **kwargs)¶
更新主机聚合。
- 参数:
name_or_id – 正在更新的聚合的名称或 ID。
name – 新的聚合名称
availability_zone – 分配给主机的可用区
- 返回值:
更新后的计算
Aggregate对象。- 引发:
SDKExceptionon operation error.
- update_cluster_template(name_or_id, **kwargs)¶
更新集群模板。
- 参数:
name_or_id – 正在更新的集群模板的名称或 ID。
- 返回值:
更新后的集群模板。
- 引发:
SDKExceptionon operation error.
- update_coe_cluster(name_or_id, **kwargs)¶
更新 COE 集群。
- 参数:
name_or_id – 正在更新的 COE 集群的名称或 ID。
kwargs – 要更新的集群属性。
- 返回值:
更新后的集群
Cluster对象。- 引发:
SDKExceptionon operation error.
- update_container(name, headers)¶
更新容器中的元数据。
- 参数:
name (str) – 要更新的容器的名称。
headers (dict) – 要设置在容器上的键/值头。
- update_domain(domain_id=None, name=None, description=None, enabled=None, name_or_id=None)¶
更新 Keystone 域
- 参数:
domain_id
name
description
enabled
name_or_id – 域的名称或唯一 ID。
- 返回值:
更新后的身份
Domain对象。- 引发:
SDKException如果域无法更新。
- update_firewall_group(name_or_id, filters=None, **kwargs)¶
更新防火墙组。要取消设置出站或入站防火墙策略,请将 egress_firewall_policy 或 ingress_firewall_policy 设置为 None。您也可以直接设置 egress_firewall_policy_id 和 ingress_firewall_policy_id,这将跳过策略查找。
- 参数:
name_or_id – 防火墙组名称或 ID
filters (dict) – 可选过滤器
kwargs – 防火墙组更新参数。请参阅 create_firewall_group 的文档字符串以了解有效参数。
- 返回值:
更新后的网络
FirewallGroup对象。- 引发:
BadRequestException if parameters are malformed
- 引发:
DuplicateResource on multiple matches
- 引发:
NotFoundException 如果找不到防火墙组、防火墙策略(出站、入站)或端口。
- update_firewall_policy(name_or_id, filters=None, **kwargs)¶
更新防火墙策略。
- 参数:
name_or_id – 防火墙策略名称或 ID
filters –
用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
或一个包含用于进一步过滤的 jmespath 表达式的字符串。示例::: “[?last_name==`Smith`] | [?other.gender]==`Female`]”
kwargs – 防火墙策略更新参数。请参阅 create_firewall_policy 的文档字符串以了解有效参数。
- 返回值:
更新后的网络
FirewallPolicy对象。- 引发:
BadRequestException if parameters are malformed
- 引发:
DuplicateResource on multiple matches
- 引发:
NotFoundException 如果资源未找到。
- update_firewall_rule(name_or_id, filters=None, **kwargs)¶
更新防火墙规则。
- 参数:
name_or_id – 防火墙规则名称或 ID
filters –
用于进一步过滤的元数据字典。此字典中的元素本身可以为字典。示例
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
或一个包含用于进一步过滤的 jmespath 表达式的字符串。示例::: “[?last_name==`Smith`] | [?other.gender]==`Female`]”
kwargs – 防火墙规则更新参数。请参阅 create_firewall_rule 的文档字符串以了解有效参数。
- 返回值:
更新后的网络
FirewallRule对象。- 引发:
BadRequestException if parameters are malformed
- 引发:
NotFoundException 如果资源未找到。
- update_group(name_or_id, name=None, description=None, **kwargs)¶
更新现有组
- 参数:
name_or_id – 组的名称或唯一 ID。
name – 新的组名。
description – 新的组描述。
- 返回值:
更新后的身份
Group对象。- 引发:
SDKExceptionif something goes wrong during the OpenStack API call.
- update_machine(name_or_id, **attrs)¶
使用新的配置信息更新机器
一个用户友好的方法,用于执行机器的全部或部分更新。
- 参数:
name_or_id (string) – 要更新的机器名称或 UUID。
attrs – 要在机器上更新的属性。
- 返回值:
字典,包含从 API 更新操作返回的更新数据子字典,以及一个名为 changes 的列表,其中包含所有接收到更新的 API 路径。
- 引发:
SDKExceptionon operation error.
- update_network(name_or_id, **kwargs)¶
更新网络。
- 参数:
name_or_id (string) – 正在更新的网络名称或 ID。
name (string) – 新的网络名称。
shared (bool) – Set the network as shared.
admin_state_up (bool) – Set the network administrative state to up.
external (bool) – Whether this network is externally accessible.
provider (dict) –
A dict of network provider options. Example
{'network_type': 'vlan', 'segmentation_id': 'vlan1'}
mtu_size (int) – 新的最大传输单元值,用于处理碎片。IPv4 的最小值为 68,IPv6 的最小值为 1280。
port_security_enabled (bool) – 启用或禁用端口安全。
dns_domain (string) – Specify the DNS domain associated with this network.
- 返回值:
更新后的网络
Network对象。- 引发:
SDKExceptionon operation error.
- update_object(container, name, metadata=None, **headers)¶
更新对象的元数据
- 参数:
container – 对象所在的容器名称
name – Name for the object within the container.
metadata – This dict will get changed into headers that set metadata of the object
headers – 这些将作为 HTTP 头传递给对象更新 API。
- 返回值:
无
- 引发:
SDKExceptionon operation error.
- update_port(name_or_id, **kwargs)¶
更新端口
注意:要取消设置属性,请使用 None 值。要使属性保持不变,请省略它。
- 参数:
name_or_id – 要更新的端口的名称或 ID。(必需)
name – A symbolic name for the port. (Optional)
admin_state_up – 端口的管理状态,上 (true) 或下 (false)。(可选)
fixed_ips –
ip_addresses 和 subnet_ids 列表。(可选) 如果只指定了 subnet ID,OpenStack Networking 将从该子网中分配一个可用的 IP 给端口。如果您同时指定了 subnet ID 和 IP 地址,OpenStack Networking 将尝试将指定的地址分配给端口。例如
[ { "ip_address": "10.29.29.13", "subnet_id": "a78484c4-c380-4b47-85aa-21c51a2d8cbd", }, ..., ]
security_groups – List of security group UUIDs. (Optional)
allowed_address_pairs –
Allowed address pairs list (Optional) For example
[ { "ip_address": "23.23.23.1", "mac_address": "fa:16:3e:c4:cd:3f", }, ..., ]
extra_dhcp_opts –
Extra DHCP options. (Optional). For example
[{"opt_name": "opt name1", "opt_value": "value1"}, ...]
device_owner – The ID of the entity that uses this port. For example, a DHCP agent. (Optional)
device_id – 该端口附加到的资源的 ID。
vnic_type (binding) – The type of the created port. (Optional)
port_security_enabled – The security port state created on the network. (Optional)
qos_policy_id – 要应用于端口的 QoS 策略的 ID。
- 返回值:
更新后的网络
Port对象。- 引发:
SDKExceptionon operation error.
- update_project(name_or_id, enabled=None, domain_id=None, **kwargs)¶
更新一个项目
- 参数:
name_or_id – 项目的名称或唯一 ID。
enabled – 项目是否已启用。
domain_id – 用于范围界定检索到的项目的域 ID。
- 返回值:
An identity
Projectobject.
- update_qos_bandwidth_limit_rule(policy_name_or_id, rule_id, **kwargs)¶
更新 QoS 带宽限制规则。
- 参数:
policy_name_or_id (string) – 规则所属的 QoS 策略的名称或 ID。
rule_id (string) – 要更新的规则的 ID。
max_kbps (int) – 最大带宽限制值(以千比特每秒为单位)。
max_burst_kbps (int) – 最大突发值(以千比特为单位)。
direction (string) – 入站或出站。将限制流量的方向。
- 返回值:
更新后的网络
QoSBandwidthLimitRule对象。- 引发:
SDKExceptionon operation error.
- update_qos_dscp_marking_rule(policy_name_or_id, rule_id, **kwargs)¶
更新 QoS DSCP 标记规则。
- 参数:
policy_name_or_id (string) – 规则所属的 QoS 策略的名称或 ID。
rule_id (string) – 要更新的规则的 ID。
dscp_mark (int) – DSCP 标记值
- 返回值:
更新后的网络
QoSDSCPMarkingRule对象。- 引发:
SDKExceptionon operation error.
- update_qos_minimum_bandwidth_rule(policy_name_or_id, rule_id, **kwargs)¶
更新 QoS 最小带宽规则。
- 参数:
policy_name_or_id (string) – 规则所属的 QoS 策略的名称或 ID。
rule_id (string) – 要更新的规则的 ID。
min_kbps (int) – 最小带宽值(以千比特每秒为单位)。
direction (string) – 入站或出站。流量将可用的方向。
- 返回值:
更新后的网络
QoSMinimumBandwidthRule对象。- 引发:
SDKExceptionon operation error.
- update_qos_policy(name_or_id, **kwargs)¶
更新现有的 QoS 策略。
- 参数:
name_or_id (string) – 要更新的 QoS 策略的名称或 ID。
policy_name (string) – QoS 策略的新名称。
description (string) – QoS 策略的新描述。
shared (bool) – 如果为 True,则 QoS 策略将设置为共享。
default (bool) – 如果为 True,则 QoS 策略将设置为项目的默认策略。
- 返回值:
更新后的网络
QosPolicyRule对象。- 引发:
SDKExceptionon operation error.
- update_recordset(zone, name_or_id, **kwargs)¶
更新记录集。
- 参数:
zone – 管理记录集的区域的名称、ID 或
openstack.dns.v2.zone.Zone实例。name_or_id – 正在更新的记录集名称或 ID。
records – 记录集定义的列表
description – 记录集的描述
ttl – 记录集的 TTL (生存时间) 值(秒)
- 返回值:
一个代表更新后的记录集的字典。
- 引发:
SDKExceptionon operation error.
- update_role(name_or_id, name, **kwargs)¶
更新 Keystone 角色。
- 参数:
name_or_id – 角色的名称或唯一 ID。
name (string) – 新的角色名称
domain_id – 域 ID
- 返回值:
一个身份
Role对象- 引发:
SDKException如果无法创建角色
- update_router(name_or_id, name=None, admin_state_up=None, ext_gateway_net_id=None, enable_snat=None, ext_fixed_ips=None, routes=None)¶
更新现有的逻辑路由器。
- 参数:
name_or_id (string) – 要更新的路由器的名称或 UUID。
name (string) – 新的路由器名称。
admin_state_up (bool) – 路由器的管理状态。
ext_gateway_net_id (string) – 外部网关的网络 ID。
enable_snat (bool) – 启用源 NAT (SNAT) 属性。
ext_fixed_ips –
所需 IP 和/或外部网络上的子网的字典列表。示例
[ { "subnet_id": "8ca37218-28ff-41cb-9b10-039601ea7e6b", "ip_address": "192.168.10.2", } ]
routes (list) –
一个包含目标和下一跳参数的字典列表。要清除所有路由,请传递一个空列表 ([])。
示例
[{"destination": "179.24.1.0/24", "nexthop": "172.24.3.99"}]
- 返回值:
更新后的网络
Router对象。- 引发:
SDKExceptionon operation error.
- update_security_group(name_or_id, **kwargs)¶
更新一个安全组
- 参数:
name_or_id (string) – 要更新的安全组的名称或 ID。
name (string) – 安全组的新名称。
description (string) – 安全组的新描述。
- 返回值:
一个描述更新后的安全组的
openstack.network.v2.security_group.SecurityGroup对象。- 引发:
SDKExceptionon operation error.
- update_server(name_or_id, detailed=False, bare=False, **kwargs)¶
更新服务器。
- 参数:
name_or_id – 要更新的服务器的名称。
detailed – 是否添加详细的额外信息。默认为 False。
bare – 是否跳过向服务器记录添加任何额外信息。默认为 False,表示地址字典将根据需要从 neutron 填充。设置为 True 表示 detailed = False。
name – 服务器的新名称
description – 服务器的新描述
- 返回值:
更新后的计算
Server对象。- 引发:
SDKExceptionon operation error.
- update_stack(name_or_id, template_file=None, template_url=None, template_object=None, files=None, rollback=True, tags=None, wait=False, timeout=3600, environment_files=None, **parameters)¶
更新堆栈。
- 参数:
name_or_id (string) – 要更新的堆栈的名称或 ID。
template_file (string) – 模板文件路径。
template_url (string) – 模板 URL。
template_object (string) – 用于检索模板对象的 URL。
files (dict) – 要包含的附加文件内容的字典。
rollback (boolean) – 更新失败时启用回滚。
wait (boolean) – 是否等待删除完成。
timeout (int) – 堆栈更新超时(秒)。
environment_files – 要应用的预置文件路径。
其他参数将作为堆栈参数传递,这些参数将优先于预置中指定的任何参数。
只能指定 template_file、template_url、template_object 中的一个。
- 返回值:
一个包含堆栈描述的字典
- 引发:
SDKException如果在 OpenStack API 调用过程中出现任何问题。
- update_subnet(name_or_id, subnet_name=None, enable_dhcp=None, gateway_ip=None, disable_gateway_ip=None, allocation_pools=None, dns_nameservers=None, host_routes=None)¶
更新现有的子网。
- 参数:
name_or_id (string) – 要更新的子网的名称或 ID。
subnet_name (string) – 子网的新名称。
enable_dhcp (bool) – 如果启用 DHCP,则设置为
True,如果禁用,则设置为False。gateway_ip (string) – 网关 IP 地址。当同时指定 allocation_pools 和 gateway_ip 时,必须确保网关 IP 不与指定的分配池重叠。
disable_gateway_ip (bool) – 如果禁用网关 IP 地址,则设置为
True,如果启用,则设置为False。不允许与 gateway_ip 一起使用。默认为False。allocation_pools –
用于分配池的开始和结束地址的字典列表。例如
[{"start": "192.168.199.2", "end": "192.168.199.254"}]
dns_nameservers –
子网的 DNS 名称服务器列表。例如
["8.8.8.7", "8.8.8.8"]
host_routes –
子网的路由条目字典列表。例如
[ {"destination": "0.0.0.0/0", "nexthop": "123.456.78.9"}, {"destination": "192.168.0.0/24", "nexthop": "192.168.0.1"}, ]
- 返回值:
更新后的网络
Subnet对象。- 引发:
SDKExceptionon operation error.
- update_volume(name_or_id, **kwargs)¶
更新卷。
- 参数:
name_or_id – 卷的名称或唯一 ID。
kwargs – 要更新的卷属性。
- 返回值:
更新后的卷
Volume对象。
- update_zone(name_or_id, **kwargs)¶
更新区域。
- 参数:
name_or_id – 正在更新的区域的名称或 ID。
email – 区域所有者的电子邮件(仅当 zone_type 为 primary 时适用)
description – 区域的描述
ttl – TTL(生存时间)值(秒)
masters – 主名称服务器(仅当 zone_type 为 secondary 时适用)
- 返回值:
一个代表更新后的区域的字典。
- 引发:
SDKExceptionon operation error.
- validate_machine(name_or_id, for_deploy=True)¶
验证机器的参数。
- 参数:
name_or_id (string) – 代表裸机节点的名称或 UUID。
for_deploy (bool) – 如果为
True,则验证是否已准备好部署,否则仅验证电源管理属性。
- 引发:
- volume_exists(name_or_id)¶
检查卷是否存在。
- 参数:
name_or_id – 卷的名称或唯一 ID。
- 返回值:
如果卷存在,则为 True,否则为 False。
- wait_for_baremetal_node_lock(node, timeout=30)¶
等待裸金属节点没有锁。
已弃用,请使用 baremetal 代理上的
wait_for_node_reservation。- 引发:
SDKException客户端失败时。- 返回值:
无
- wait_for_server(server, auto_ip=True, ips=None, ip_pool=None, reuse=True, timeout=180, nat_destination=None)¶
等待服务器达到 ACTIVE 状态。
从 Profile 过渡¶
支持从使用 Profile 接口的旧版本 OpenStack SDK 用户。