@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) @ThreadSafe public class Openstack extends Object
OSClient
.
It is needed to make sure the client is truly immutable and provide easy-to-mock abstraction for unittesting.
For server manipulation, this implementation provides metadata fingerprinting
to identify machines started via this plugin from given instance so it will not
manipulate servers it does not "own". In other words, pretends that there are no
other machines running in connected tenant except for those started using this class.Modifier and Type | Class and Description |
---|---|
static class |
Openstack.ActionFailed |
static class |
Openstack.Factory |
static class |
Openstack.FactoryEP |
Modifier and Type | Field and Description |
---|---|
static String |
FINGERPRINT_KEY |
Constructor and Description |
---|
Openstack(org.openstack4j.api.OSClient<?> client) |
Modifier and Type | Method and Description |
---|---|
org.openstack4j.model.compute.Server |
_bootAndWaitActive(org.openstack4j.model.compute.builder.ServerCreateBuilder request,
int timeout) |
List<? extends org.openstack4j.model.network.Network> |
_listNetworks() |
org.openstack4j.model.compute.FloatingIP |
assignFloatingIp(org.openstack4j.model.compute.Server server,
String poolName)
Assign floating ip address to the server.
|
org.openstack4j.model.compute.Server |
bootAndWaitActive(org.openstack4j.model.compute.builder.ServerCreateBuilder request,
int timeout)
Provision machine and wait until ready.
|
void |
destroyFip(String fip) |
void |
destroyServer(org.openstack4j.model.compute.Server server)
Delete server eagerly.
|
List<? extends org.openstack4j.model.compute.ext.AvailabilityZone> |
getAvailabilityZones() |
static String |
getFlavorInfo(org.openstack4j.model.compute.Flavor f) |
List<String> |
getFreeFipIds() |
List<String> |
getImageIdsFor(String nameOrId)
Finds the Id(s) of all active
Image s with the given name or ID. |
Map<String,Collection<org.openstack4j.model.image.v2.Image>> |
getImages()
Finds all
Image s. |
String |
getInfo()
Get information about OpenStack deployment.
|
List<String> |
getNetworkIds(List<String> nameOrIds) |
static String |
getPublicAddress(org.openstack4j.model.compute.Server server)
Extract public address from server info.
|
static String |
getPublicAddressIpv4(org.openstack4j.model.compute.Server server)
Extract public address from server info.
|
static org.openstack4j.model.compute.Address |
getPublicAddressObject(org.openstack4j.model.compute.Server server)
Extract public address from server info.
|
List<org.openstack4j.model.compute.Server> |
getRunningNodes() |
org.openstack4j.model.compute.Server |
getServerById(String id) |
List<org.openstack4j.model.compute.Server> |
getServersByName(String name) |
Collection<? extends org.openstack4j.model.compute.Flavor> |
getSortedFlavors() |
List<String> |
getSortedIpPools() |
List<String> |
getSortedKeyPairNames() |
String |
getVolumeSnapshotDescription(String volumeSnapshotId)
Gets the description of a
VolumeSnapshot . |
List<String> |
getVolumeSnapshotIdsFor(String nameOrId)
Finds the Id(s) of all available
VolumeSnapshot s with the given name
or ID. |
Map<String,Collection<org.openstack4j.model.storage.block.VolumeSnapshot>> |
getVolumeSnapshots()
Finds all
VolumeSnapshot s that are Volume.Status.AVAILABLE . |
Throwable |
sanityCheck()
Perform some tests before calling the connection successfully established.
|
void |
setVolumeNameAndDescription(String volumeId,
String newVolumeName,
String newVolumeDescription)
Sets the name and description of a
Volume . |
org.openstack4j.model.compute.Server |
updateInfo(org.openstack4j.model.compute.Server server)
Fetch updated info about the server.
|
public static final String FINGERPRINT_KEY
public Openstack(@Nonnull org.openstack4j.api.OSClient<?> client)
@Nonnull public static String getFlavorInfo(@Nonnull org.openstack4j.model.compute.Flavor f)
@Nonnull public Map<String,Collection<org.openstack4j.model.image.v2.Image>> getImages()
Image
s.@Nonnull public Map<String,Collection<org.openstack4j.model.storage.block.VolumeSnapshot>> getVolumeSnapshots()
VolumeSnapshot
s that are Volume.Status.AVAILABLE
.VolumeSnapshot
s, indexed by name
(or id if the volume snapshot has no name) in ascending order
and, in the event of name-collisions, the volume snapshots for a
given name are sorted by creation date.@Nonnull public Collection<? extends org.openstack4j.model.compute.Flavor> getSortedFlavors()
@Nonnull public List<? extends org.openstack4j.model.compute.ext.AvailabilityZone> getAvailabilityZones()
@Nonnull public List<String> getImageIdsFor(String nameOrId)
Image
s with the given name or ID.
If we have found multiple Image
s then they will be listed in
ascending date order (oldest first).nameOrId
- The Image
name or ID.@Nonnull public List<String> getVolumeSnapshotIdsFor(String nameOrId)
VolumeSnapshot
s with the given name
or ID. If we have found multiple VolumeSnapshot
s then they will
be listed in ascending date order (oldest first).nameOrId
- The VolumeSnapshot
name or ID.public String getVolumeSnapshotDescription(String volumeSnapshotId)
VolumeSnapshot
. This will be visible
if a user looks at volume snapshots using the OpenStack command-line or WebUI
and may well contain useful information.volumeSnapshotId
- The ID of the volume snapshot whose description is to be retrieved.public void setVolumeNameAndDescription(String volumeId, String newVolumeName, String newVolumeDescription)
Volume
. These will be visible
if a user looks at volumes using the OpenStack command-line or WebUI.volumeId
- The ID of the volume whose name and description are to be set.newVolumeName
- The new name for the volume.newVolumeDescription
- The new description for the volume.@Nonnull public org.openstack4j.model.compute.Server getServerById(@Nonnull String id) throws NoSuchElementException
NoSuchElementException
@Nonnull public List<org.openstack4j.model.compute.Server> getServersByName(@Nonnull String name)
@Nonnull public org.openstack4j.model.compute.Server bootAndWaitActive(@Nonnull org.openstack4j.model.compute.builder.ServerCreateBuilder request, @Nonnegative int timeout) throws Openstack.ActionFailed
Openstack.ActionFailed
- Openstack failed to provision the slave or it was in erroneous state (server will be deleted in such case).@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public org.openstack4j.model.compute.Server _bootAndWaitActive(@Nonnull org.openstack4j.model.compute.builder.ServerCreateBuilder request, @Nonnegative int timeout)
@Nonnull public org.openstack4j.model.compute.Server updateInfo(@Nonnull org.openstack4j.model.compute.Server server)
public void destroyServer(@Nonnull org.openstack4j.model.compute.Server server) throws Openstack.ActionFailed
DestroyMachine
to destroy the server reliably.Openstack.ActionFailed
@Nonnull public org.openstack4j.model.compute.FloatingIP assignFloatingIp(@Nonnull org.openstack4j.model.compute.Server server, @CheckForNull String poolName) throws Openstack.ActionFailed
server
- Server to assign FIPpoolName
- Name of the FIP pool to use. If null, openstack default pool will be used.Openstack.ActionFailed
public void destroyFip(String fip)
@CheckForNull public static org.openstack4j.model.compute.Address getPublicAddressObject(@Nonnull org.openstack4j.model.compute.Server server)
@CheckForNull public static String getPublicAddress(@Nonnull org.openstack4j.model.compute.Server server)
@CheckForNull public static String getPublicAddressIpv4(@Nonnull org.openstack4j.model.compute.Server server)
@CheckForNull public Throwable sanityCheck()
Copyright © 2016–2018. All rights reserved.