[OpenStack]openstack4j里的ServerService API

本文档详细介绍了如何使用openstack4j库进行OpenStack服务器的相关操作,包括查询、创建、删除、恢复、重启、重建、迁移、暂停、恢复、快照、备份等多样化的功能。此外,还涵盖了服务器的密码管理、元数据和网络设置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Server query

  • List<? extends Server> org.openstack4j.api.compute.ServerService.list()
    List all servers (detailed) that the current tenant has access to
    Returns:
              list of all servers

  • List<? extends Server> org.openstack4j.api.compute.ServerService.list(boolean detail)
    List all servers (detailed / brief) that the current tenant has access to
    Parameters:
              detail
    if true all attributes will be populated, false (brief) will be ID, Name and Links
    Returns:
              list of all servers

  • List<? extends Server> org.openstack4j.api.compute.ServerService.list(Map filteringParams)
    Returns list of servers filtered by parameters.
    Parameters:
              filteringParams
    map (name, value) of filtering parameters
    Returns:
              list of all servers

  • List<? extends Server> org.openstack4j.api.compute.ServerService.listAll(boolean detail)
    List all servers for all tenants (detailed / brief)
    Parameters:
              detail
    if true all attributes will be populated, false (brief) will be ID, Name and Links
    Returns:
              list of all servers

  • Server org.openstack4j.api.compute.ServerService.get(String serverId)
    Get the specified server by ID
    Parameters:
              serverId
    the server id
    Returns:
              the server or null if not found

Server creation

  • Server org.openstack4j.api.compute.ServerService.boot(ServerCreate server)
    Create (boot) a new Server
    Parameters:
              server
    the server to boot
    Returns:
              the newly created server

  • Server org.openstack4j.api.compute.ServerService.bootAndWaitActive(ServerCreate server, int maxWaitTime)
    Create (boot) a new Server
    Parameters:
              server
    the server to boot
              maxWaitTime the max time to wait in milliseconds for the server to become ACTIVE
    Returns:
              the newly created server

Server actions

Delete, Restore

  • ActionResponse org.openstack4j.api.compute.ServerService.delete(String serverId)
    Delete (i.e shut down and delete the image) of the server
    Parameters:
              serverId
    the server identifier
    Returns:
              the action response

Reboot

  • ActionResponse org.openstack4j.api.compute.ServerService.reboot(String serverId, RebootType type)
    Reboot a server by SOFT (software-level) or HARD (hardware power cycle)
    Parameters:
              serverId
    the server id
              type the type of reboot
    Returns:
              the action response

Rebuild

  • ActionResponse org.openstack4j.api.compute.ServerService.rebuild(String serverId, RebuildOptions options)
    Rebuilds the specified server
    Parameters:
              serverId
    the server id
              options additional options used during the rebuild. (OPTIONAL, can be null)
    Returns:
              the action response

Evacuate

Resize, Confirm resize, Revert resize

  • ActionResponse org.openstack4j.api.compute.ServerService.resize(String serverId, String flavorId)
    Resize a server's resources. Until a resize event is confirmed confirmResize(String), the old server will be kept around and you'll be able to roll back to the old flavor quick with revertResize(String). All resizes will be automatically confirmed after 24 hours.
    Parameters:
              serverId
    the server identifier
              flavorId the new flavor id to resize to
    Returns:
              the action response

  • ActionResponse org.openstack4j.api.compute.ServerService.confirmResize(String serverId)
    Confirm that the resize worked, thus removing the original server
    Parameters:
              serverId
    the server identifier
    Returns:
              the action response

  • ActionResponse org.openstack4j.api.compute.ServerService.revertResize(String serverId)
    Revert a previous resize, switching back to the old server
    Parameters:
              serverId
    the server identifier
    Returns:
              the action response

Pause, Unpause

  • ActionResponse org.openstack4j.api.compute.ServerService.action(String serverId, Action.PAUSE)
    Pause the server

  • ActionResponse org.openstack4j.api.compute.ServerService.action(String serverId, Action.UNPAUSE)
    UnPause the paused server

Suspend, Resume

  • ActionResponse org.openstack4j.api.compute.ServerService.action(String serverId, Action.SUSPEND)
    Suspend a server

  • ActionResponse org.openstack4j.api.compute.ServerService.action(String serverId, Action.RESUME)
    Rescue the server

Snapshot

  • String org.openstack4j.api.compute.ServerService.createSnapshot(String serverId, String snapshotName)
    Creates the snapshot for a Server
    Parameters:
              serverId
    the server id
              snapshotName the snapshot name
    Returns:
              the newly created snapshot UUID

Backup

  • ActionResponse org.openstack4j.api.compute.ServerService.backupServer(String serverId, BackupOptions options)
    Sets up a new backup schedule service for the given serverId
    Parameters:
              serverId
    the server identifier
              options the backup options
    Returns:
              the action response

Start, Stop

  • ActionResponse org.openstack4j.api.compute.ServerService.action(String serverId, Action.START)
    Start the server

  • ActionResponse org.openstack4j.api.compute.ServerService.action(String serverId, Action.STOP)
    Stop the server

Shelve, Shelve offload, Unshelve

  • ActionResponse org.openstack4j.api.compute.ServerService.action(String serverId, Action.SHELVE)
    Shelve the server

  • ActionResponse org.openstack4j.api.compute.ServerService.action(String serverId, Action.SHELVE_OFFLOAD)
    Remove a shelved instance from the compute node

  • ActionResponse org.openstack4j.api.compute.ServerService.action(String serverId, Action.UNSHELVE)
    Unshelve the server

Lock, Unlock

  • ActionResponse org.openstack4j.api.compute.ServerService.action(String serverId, Action.LOCK)
    Lock the server

  • ActionResponse org.openstack4j.api.compute.ServerService.action(String serverId, Action.UNLOCK)
    Unlock a locked server

Rescue, Unrescue

  • ActionResponse org.openstack4j.api.compute.ServerService.action(String serverId, Action.RESCUE)
    Rescue the server

  • ActionResponse org.openstack4j.api.compute.ServerService.action(String serverId, Action.UNRESCUE)
    Unrescue the server

Set administrator password

  • ActionResponse org.openstack4j.api.compute.ServerService.changeAdminPassword(String serverId, String adminPassword)
    Changes the admin/root password on the server
    Parameters:
              serverId
    the server identifier
              adminPassword the new password
    Returns:
              the action response

Migrate, Live migrate

  • ActionResponse org.openstack4j.api.compute.ServerService.migrateServer(String serverId)
    Only user with admin role can do this. Migrate a server. The new host will be selected by the scheduler. Until a resize event is confirmed confirmResize(String), the old server will be kept around and you'll be able to roll back to the old host quick with revertResize(String). All resizes will be automatically confirmed after 24 hours.
    Parameters:
              serverId
    the server identifier
    Returns:
              the action response

  • ActionResponse org.openstack4j.api.compute.ServerService.liveMigrate(String serverId, LiveMigrateOptions options)
    Live-migrates a server identified with {@code serverId} to a new host without rebooting
    Parameters:
              serverId
    the server identifier
              options live migration options
    Returns:
              the action response

Trigger crash dump

Server passwords

See Server creation and Set administrator password.

Server metadata

  • Map org.openstack4j.api.compute.ServerService.getMetadata(String serverId)
    Returns the metadata for the specified server
    Parameters:
              serverId
    the server identifier
    Returns:
              Map of metadata of key and value

  • Map org.openstack4j.api.compute.ServerService.updateMetadata(String serverId, Map metadata)
    Creates or replaces metadata items for the specified server
    Parameters:
              serverId
    the server identifier
              metadata the metadata to create or update
    Returns:
              Map of metadata as the current state on the server

  • ActionResponse org.openstack4j.api.compute.ServerService.deleteMetadataItem(String serverId, String key)
    Removes the specified metadata item via the specified key and serverId
    Parameters:
              serverId
    the server identifier
              key the metadata key to remove
    Returns:
              the action response

Server networks

See Server creation.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值