@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 unit testing.
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.network.NetFloatingIP |
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.
|
static String |
getAccessIpAddress(org.openstack4j.model.compute.Server server)
Extract public address from server.
|
List<? extends org.openstack4j.model.compute.ext.AvailabilityZone> |
getAvailabilityZones() |
static String |
getFlavorInfo(org.openstack4j.model.compute.Flavor f) |
List<String> |
getFreeFipIds()
Get list of Floating IPs created for this Jenkins instance that are not connected to any server.
|
List<String> |
getImageIdsFor(String nameOrId)
Finds the Id(s) of all active
Image s with the given name or ID. |
Map<String,List<org.openstack4j.model.image.v2.Image>> |
getImages()
Finds all
Image s. |
String |
getInfo()
Get information about OpenStack deployment.
|
Map<String,org.openstack4j.model.network.Network> |
getNetworks(List<String> nameOrIds)
List all requested network details.
|
Map<org.openstack4j.model.network.Network,Integer> |
getNetworksCapacity(Map<String,org.openstack4j.model.network.Network> declaredNetworks)
For every network requested, return mapping of network and number of available fixed addresses.
|
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,List<org.openstack4j.model.storage.block.VolumeSnapshot>> |
getVolumeSnapshots()
Finds all
VolumeSnapshot s that are Volume.Status.AVAILABLE . |
static boolean |
isOccupied(org.openstack4j.model.compute.Server server)
Determine whether the server is considered occupied by openstack plugin.
|
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,org.openstack4j.model.network.Network> getNetworks(@Nonnull List<String> nameOrIds)
nameOrIds
- List of network names/IDs.@Nonnull public Map<org.openstack4j.model.network.Network,Integer> getNetworksCapacity(@Nonnull Map<String,org.openstack4j.model.network.Network> declaredNetworks)
@Nonnull public Map<String,List<org.openstack4j.model.image.v2.Image>> getImages()
Image
s.@Nonnull public Map<String,List<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> getFreeFipIds()
@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.@CheckForNull 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.public static boolean isOccupied(@Nonnull org.openstack4j.model.compute.Server server)
@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.network.NetFloatingIP assignFloatingIp(@Nonnull org.openstack4j.model.compute.Server server, @Nonnull String poolName) throws Openstack.ActionFailed
server
- Server to assign FIPpoolName
- Name of the FIP pool to use.Openstack.ActionFailed
public void destroyFip(String fip)
@CheckForNull public static String getAccessIpAddress(@Nonnull org.openstack4j.model.compute.Server server) throws IllegalArgumentException, NoSuchElementException
IllegalArgumentException
- When address can not be understood.NoSuchElementException
- When no suitable address is found.@CheckForNull public Throwable sanityCheck()
Copyright © 2016–2020. All rights reserved.