文档章节

openstack中Nova组件servers的所有python API 汇总

傻呆
 傻呆
发布于 2016/06/22 10:07
字数 2533
阅读 13
收藏 0

感谢朋友支持本博客,欢迎共同探讨交流,由于能力和时间有限,错误之处在所难免,欢迎指正!
如果转载,请保留作者信息。
博客地址:http://blog.csdn.net/qq_21398167

原博文地址:http://blog.csdn.net/qq_21398167/article/details/46530305




Servers

Server interface.

class novaclient.v2.servers. Server ( manager, info, loaded=False )

Bases: novaclient.openstack.common.apiclient.base.Resource

Populate and bind to a manager.

Parameters:
  • manager – BaseManager object
  • info – dictionary representing resource attributes
  • loaded – prevent lazy-loading if set to True
HUMAN_ID = True

add_fixed_ip ( network_id )

Add an IP address on a network.

Parameters: network_id – The ID of the network the IP should be on.
add_floating_ip ( address, fixed_address=None )

Add floating IP to an instance

Parameters:
  • address – The IP address or FloatingIP to add to the instance
  • fixed_address – The fixedIP address the FloatingIP is to beassociated with (optional)
add_security_group ( security_group )

Add a security group to an instance.

backup ( backup_name, backup_type, rotation )

Backup a server instance.

Parameters:
  • backup_name – Name of the backup image
  • backup_type – The backup type, like ‘daily’ or ‘weekly’
  • rotation – Int parameter representing how many backups tokeep around.
change_password ( password )

Update the admin password for a server.

Parameters: password – string to set as the admin password on the server
clear_password ( )

Get password for a Server.

confirm_resize ( )

Confirm that the resize worked, thus removing the original server.

create_image ( image_name, metadata=None )

Create an image based on this server.

Parameters:
  • image_name – The name to assign the newly create image.
  • metadata – Metadata to assign to the image.
delete ( )

Delete (i.e. shut down and delete the image) this server.

diagnostics ( )

Diagnostics – Retrieve server diagnostics.

evacuate ( host=None, on_shared_storage=True, password=None )

Evacuate an instance from failed host to specified host.

Parameters:
  • host – Name of the target host
  • on_shared_storage – Specifies whether instance files locatedon shared storage
  • password – string to set as admin password on the evacuatedserver.
force_delete ( )

Force delete – Force delete a server.

get_console_output ( length=None )

Get text console log output from Server.

Parameters: length – The number of lines you would like to retrieve (as int)
get_password ( private_key=None )

Get password for a Server.

Returns the clear password of an instance if private_key isprovided, returns the ciphered password otherwise.

Parameters: private_key – Path to private key file for decryption(optional)
get_rdp_console ( console_type )

Get rdp console for a Server.

Parameters: console_type – Type of console (‘rdp-html5’)
get_serial_console ( console_type )

Get serial console for a Server.

Parameters: console_type – Type of console (‘serial’)
get_spice_console ( console_type )

Get spice console for a Server.

Parameters: console_type – Type of console (‘spice-html5’)
get_vnc_console ( console_type )

Get vnc console for a Server.

Parameters: console_type – Type of console (‘novnc’ or ‘xvpvnc’)
interface_attach ( port_id, net_id, fixed_ip )

Attach a network interface to an instance.

interface_detach ( port_id )

Detach a network interface from an instance.

interface_list ( )

List interfaces attached to an instance.

list_security_group ( )

List security group(s) of an instance.

live_migrate ( host=None, block_migration=False, disk_over_commit=False )

Migrates a running instance to a new machine.

lock ( )

Lock – Lock the instance from certain operations.

migrate ( )

Migrate a server to a new host.

networks

Generate a simplified list of addresses

pause ( )

Pause – Pause the running server.

reboot ( reboot_type='SOFT' )

Reboot the server.

Parameters: reboot_type – either REBOOT_SOFT for a software-levelreboot, or REBOOT_HARD for a virtual power cycle hard reboot.
rebuild ( image, password=None, preserve_ephemeral=False, **kwargs )

Rebuild – shut down and then re-image – this server.

Parameters:
  • image – the Image (or its ID) to re-image with.
  • password – string to set as the admin password on the rebuiltserver.
  • preserve_ephemeral – If True, request that any ephemeral devicebe preserved when rebuilding the instance. Defaults to False.
remove_fixed_ip ( address )

Remove an IP address.

Parameters: address – The IP address to remove.
remove_floating_ip ( address )

Remove floating IP from an instance

Parameters: address – The IP address or FloatingIP to remove
remove_security_group ( security_group )

Remove a security group from an instance.

rescue ( password=None, image=None )

Rescue – Rescue the problematic server.

Parameters:
  • password – The admin password to be set in the rescue instance.
  • image – The Image to rescue with.
reset_network ( )

Reset network of an instance.

reset_state ( state='error' )

Reset the state of an instance to active or error.

resize ( flavor, **kwargs )

Resize the server’s resources.

Parameters: flavor – the Flavor (or its ID) to resize to.

Until a resize event is confirmed with confirm_resize(), the oldserver will be kept around and you’ll be able to roll back to the oldflavor quickly withrevert_resize(). All resizes areautomatically confirmed after 24 hours.

restore ( )

Restore – Restore a server in ‘soft-deleted’ state.

resume ( )

Resume – Resume the suspended server.

revert_resize ( )

Revert a previous resize, switching back to the old server.

shelve ( )

Shelve – Shelve the server.

shelve_offload ( )

Shelve_offload – Remove a shelved server from the compute node.

start ( )

Start – Start the paused server.

stop ( )

Stop – Stop the running server.

suspend ( )

Suspend – Suspend the running server.

unlock ( )

Unlock – Remove instance lock.

unpause ( )

Unpause – Unpause the paused server.

unrescue ( )

Unrescue – Unrescue the rescued server.

unshelve ( )

Unshelve – Unshelve the server.

update ( name=None )

Update the name for this server.

Parameters: name – Update the server’s name.
class novaclient.v2.servers. ServerManager ( api )

Bases: novaclient.base.BootingManagerWithFind

add_fixed_ip ( server, network_id )

Add an IP address on a network.

Parameters:
  • server – The Server (or its ID) to add an IP to.
  • network_id – The ID of the network the IP should be on.
add_floating_ip ( server, address, fixed_address=None )

Add a floating IP to an instance

Parameters:
  • server – The Server (or its ID) to add an IP to.
  • address – The FloatingIP or string floating address to add.
  • fixed_address – The FixedIP the floatingIP should beassociated with (optional)
add_security_group ( server, security_group )

Add a Security Group to an instance

Parameters:
  • server – ID of the instance.
  • security_group – The name of security group to add.
backup ( server, backup_name, backup_type, rotation )

Backup a server instance.

Parameters:
  • server – The Server (or its ID) to share onto.
  • backup_name – Name of the backup image
  • backup_type – The backup type, like ‘daily’ or ‘weekly’
  • rotation – Int parameter representing how many backups tokeep around.
change_password ( server, password )

Update the password for a server.

clear_password ( server )

Clear the admin password of an instance

Remove the admin password for an instance from the metadata server.

Parameters: server – The Server (or its ID) for which the adminpassword is to be cleared
confirm_resize ( server )

Confirm that the resize worked, thus removing the original server.

Parameters: server – The Server (or its ID) to share onto.
create ( name, image, flavor, meta=None, files=None, reservation_id=None, min_count=None, max_count=None, security_groups=None, userdata=None, key_name=None, availability_zone=None, block_device_mapping=None, block_device_mapping_v2=None, nics=None, scheduler_hints=None, config_drive=None, disk_config=None, **kwargs )

Create (boot) a new server.

Parameters:
  • name – Something to name the server.
  • image – The Image to boot with.
  • flavor – The Flavor to boot onto.
  • meta – A dict of arbitrary key/value metadata to store for thisserver. Both keys and values must be <=255 characters.
  • files – A dict of files to overrwrite on the server upon boot.Keys are file names (i.e./etc/passwd) and valuesare the file contents (either as a string or as afile-like object). A maximum of five entries is allowed,and each file must be 10k or less.
  • reservation_id – a UUID for the set of servers being requested.
  • min_count – (optional extension) The minimum number ofservers to launch.
  • max_count – (optional extension) The maximum number ofservers to launch.
  • security_groups – A list of security group names
  • userdata – user data to pass to be exposed by the metadataserver this can be a file type object as well or astring.
  • key_name – (optional extension) name of previously createdkeypair to inject into the instance.
  • availability_zone – Name of the availability zone for instanceplacement.
  • block_device_mapping – (optional extension) A dict of blockdevice mappings for this server.
  • block_device_mapping_v2 – (optional extension) A dict of blockdevice mappings for this server.
  • nics – (optional extension) an ordered list of nics to beadded to this server, with information aboutconnected networks, fixed IPs, port etc.
  • scheduler_hints – (optional extension) arbitrary key-value pairsspecified by the client to help boot an instance
  • config_drive – (optional extension) value for config driveeither boolean, or volume-id
  • disk_config – (optional extension) control how the disk ispartitioned when the server is created. possiblevalues are ‘AUTO’ or ‘MANUAL’.
create_image ( server, image_name, metadata=None )

Snapshot a server.

Parameters:
  • server – The Server (or its ID) to share onto.
  • image_name – Name to give the snapshot image
  • metadata – Metadata to give newly-created image entity
delete ( server )

Delete (i.e. shut down and delete the image) this server.

delete_meta ( server, keys )

Delete metadata from an server:param server: The Server to add metadata to:param keys: A list of metadata keys to delete from the server

diagnostics ( server )

Retrieve server diagnostics.

evacuate ( server, host=None, on_shared_storage=True, password=None )

Evacuate a server instance.

Parameters:
  • server – The Server (or its ID) to share onto.
  • host – Name of the target host.
  • on_shared_storage – Specifies whether instance files locatedon shared storage
  • password – string to set as password on the evacuated server.
force_delete ( server )

Force delete the server.

get ( server )

Get a server.

Parameters: server – ID of the Server to get.
Return type: Server
get_console_output ( server, length=None )

Get text console log output from Server.

Parameters:
  • server – The Server (or its ID) whose console outputyou would like to retrieve.
  • length – The number of tail loglines you would like to retrieve.
get_password ( server, private_key=None )

Get admin password of an instance

Returns the admin password of an instance in the clear if private_keyis provided, returns the ciphered password otherwise.

Requires that openssl is installed and in the path

Parameters:
  • server – The Server (or its ID) for which the adminpassword is to be returned
  • private_key – The private key to decrypt password(optional)
get_rdp_console ( server, console_type )

Get a rdp console for an instance

Parameters:
  • server – The Server (or its ID) to add an IP to.
  • console_type – Type of rdp console to get (‘rdp-html5’)
get_serial_console ( server, console_type )

Get a serial console for an instance

Parameters:
  • server – The Server (or its ID) to add an IP to.
  • console_type – Type of serial console to get (‘serial’)
get_spice_console ( server, console_type )

Get a spice console for an instance

Parameters:
  • server – The Server (or its ID) to add an IP to.
  • console_type – Type of spice console to get (‘spice-html5’)
get_vnc_console ( server, console_type )

Get a vnc console for an instance

Parameters:
  • server – The Server (or its ID) to add an IP to.
  • console_type – Type of vnc console to get (‘novnc’ or ‘xvpvnc’)
interface_attach ( server, port_id, net_id, fixed_ip )

Attach a network_interface to an instance.

Parameters:
  • server – The Server (or its ID) to attach to.
  • port_id – The port to attach.
interface_detach ( server, port_id )

Detach a network_interface from an instance.

Parameters:
  • server – The Server (or its ID) to detach from.
  • port_id – The port to detach.
interface_list ( server )

List attached network interfaces

Parameters: server – The Server (or its ID) to query.
ips ( server )

Return IP Addresses associated with the server.

Often a cheaper call then getting all the details for a server.

list ( detailed=True, search_opts=None, marker=None, limit=None, sort_keys=None, sort_dirs=None )

Get a list of servers.

Parameters:
  • detailed – Whether to return detailed server info (optional).
  • search_opts – Search options to filter out servers (optional).
  • marker – Begin returning servers that appear later in the serverlist than that represented by this server id (optional).
  • limit – Maximum number of servers to return (optional).
  • sort_keys – List of sort keys
  • sort_dirs – List of sort directions
Return type:

list of Server

list_security_group ( server )

List Security Group(s) of an instance

Parameters: server – ID of the instance.
live_migrate ( server, host, block_migration, disk_over_commit )

Migrates a running instance to a new machine.

Parameters:
  • server – instance id which comes from nova list.
  • host – destination host name.
  • block_migration – if True, do block_migration.
  • disk_over_commit – if True, Allow overcommit.
lock ( server )

Lock the server.

migrate ( server )

Migrate a server to a new host.

Parameters: server – The Server (or its ID).
pause ( server )

Pause the server.

reboot ( server, reboot_type='SOFT' )

Reboot a server.

Parameters:
  • server – The Server (or its ID) to share onto.
  • reboot_type – either REBOOT_SOFT for a software-levelreboot, or REBOOT_HARD for a virtual power cycle hard reboot.
rebuild ( server, image, password=None, disk_config=None, preserve_ephemeral=False, name=None, meta=None, files=None, **kwargs )

Rebuild – shut down and then re-image – a server.

Parameters:
  • server – The Server (or its ID) to share onto.
  • image – the Image (or its ID) to re-image with.
  • password – string to set as password on the rebuilt server.
  • disk_config – partitioning mode to use on the rebuilt server.Valid values are ‘AUTO’ or ‘MANUAL’
  • preserve_ephemeral – If True, request that any ephemeral devicebe preserved when rebuilding the instance. Defaults to False.
  • name – Something to name the server.
  • meta – A dict of arbitrary key/value metadata to store for thisserver. Both keys and values must be <=255 characters.
  • files – A dict of files to overwrite on the server upon boot.Keys are file names (i.e./etc/passwd) and valuesare the file contents (either as a string or as afile-like object). A maximum of five entries is allowed,and each file must be 10k or less.
remove_fixed_ip ( server, address )

Remove an IP address.

Parameters:
  • server – The Server (or its ID) to add an IP to.
  • address – The IP address to remove.
remove_floating_ip ( server, address )

Remove a floating IP address.

Parameters:
  • server – The Server (or its ID) to remove an IP from.
  • address – The FloatingIP or string floating address to remove.
remove_security_group ( server, security_group )

Add a Security Group to an instance

Parameters:
  • server – ID of the instance.
  • security_group – The name of security group to remove.
rescue ( server, password=None, image=None )

Rescue the server.

Parameters:
  • server – The Server to rescue.
  • password – The admin password to be set in the rescue instance.
  • image – The Image to rescue with.
reset_network ( server )

Reset network of an instance.

reset_state ( server, state='error' )

Reset the state of an instance to active or error.

Parameters:
  • server – ID of the instance to reset the state of.
  • state – Desired state; either ‘active’ or ‘error’.Defaults to ‘error’.
resize ( server, flavor, disk_config=None, **kwargs )

Resize a server’s resources.

Parameters:
  • server – The Server (or its ID) to share onto.
  • flavor – the Flavor (or its ID) to resize to.
  • disk_config – partitioning mode to use on the rebuilt server.Valid values are ‘AUTO’ or ‘MANUAL’

Until a resize event is confirmed with confirm_resize(), the oldserver will be kept around and you’ll be able to roll back to the oldflavor quickly withrevert_resize(). All resizes areautomatically confirmed after 24 hours.

resource_class

alias of Server

restore ( server )

Restore soft-deleted server.

resume ( server )

Resume the server.

revert_resize ( server )

Revert a previous resize, switching back to the old server.

Parameters: server – The Server (or its ID) to share onto.
set_meta ( server, metadata )

Set a servers metadata:param server: The Server to add metadata to:param metadata: A dict of metadata to add to the server

set_meta_item ( server, key, value )

Updates an item of server metadata:param server: The Server to add metadata to:param key: metadata key to update:param value: string value

shelve ( server )

Shelve the server.

shelve_offload ( server )

Remove a shelved instance from the compute node.

start ( server )

Start the server.

stop ( server )

Stop the server.

suspend ( server )

Suspend the server.

unlock ( server )

Unlock the server.

unpause ( server )

Unpause the server.

unrescue ( server )

Unrescue the server.

unshelve ( server )

Unshelve the server.

update ( server, name=None )

Update the name or the password for a server.

Parameters:
  • server – The Server (or its ID) to update.
  • name – Update the server’s name.

© 著作权归作者所有

共有 人打赏支持
傻呆
粉丝 1
博文 143
码字总数 138424
作品 0
成都
私信 提问
开源平台OpenStack运筹帷幄:实战学习技巧

OpenStack 学习手册 OpenStack是一种免费的开源平台,帮助服务提供 商实现类似于亚马逊EC2和S3的基础设施服务。 OpenStack当前有三个核心项目:计算(Nova),对象 存储(Swift),镜像管理(Glan...

庸人谷
2012/11/14
0
3
OpenStack是什么,OpenStack详解

1. OpenStack是什么 OpenStack官方的解释很官方,而且从不同角度,也有不同的理解,OpenStack可以理解为一个云操作系统 OpenStack旗下包含了一组由社区维护的开源项目,他们分别是OpenStack...

yaohong
2017/08/01
0
0
在 OpenStack 中启用 DB2

OpenStack 是一个云操作系统,它控制着整个数据中心中庞大的计算、存储和网络资源池。所有资源都通过一个仪表板来进行管理,这为管理员提供了控制权,同时使用户能够通过 Web 界面配制资源。...

IBMdW
2013/01/15
480
1
openstack-M版安装部署

[openstack信息简介] Openstack项目是一个开源的云计算平台,它为广大云平台提供了可大规模扩展的平台,全世界的云计算技术人员创造了这个项目,通过一组相互关联的服务来提供了Iaas基础解决...

mapleZDW
2018/06/28
0
0
在 CentOS 上安装和配置 OpenStack Nova

因为 Python 的版本问题,在 CentOS 5.6 上安装 OpenStack 不是件容易的事情,因为 OpenStack 是 Python 2.6 写的,CentOS 5.6 上默认的是 Python 2.4 的环境,一些关键工具(比如 yum 等)和...

鉴客
2012/03/10
1K
0

没有更多内容

加载失败,请刷新页面

加载更多

python 利用 descriptor 实现自己的 property

1.概念简介 1.1 property 在 python 代码中,property 是非常常见的一个内置函数。property 可以为一个 python 类的 attribute 设置 getter/setter,可以类比之 C# 的 properties。 见下面的...

御坂网络路由器
47分钟前
3
0
xssfilter-代码段

class XssHttpServletRequestWrapper extends HttpServletRequestWrapper { /** * @param request */ public XssHttpServletRequestWrapper(HttpServletRequest request) { super(request); ......

qiang123
53分钟前
3
0
05 分支管理 —— 分支管理策略

05 分支管理 —— 分支管理策略 分支管理策略 通常合并分支时,可能Git会用Fast forward模式,但这种模式下,删除分支后,会丢掉分支信息。 如果要强制禁用Fast forward模式,Git就会在merge...

lwenhao
57分钟前
4
0
lareval nginx 配置

在centos上成功编译安装nginx 1.4、php 5.4并成功启动nginx和php-fpm后,访问php提示"File not found.",同时在错误日志中看到: 代码如下: 2013/10/22 20:05:49 [error] 12691#0: *6 FastC......

李佳顺
今天
1
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部