Class Openstack
java.lang.Object
jenkins.plugins.openstack.compute.internal.Openstack
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
@ThreadSafe
public class Openstack
extends Object
Encapsulate 
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.- Author:
- ogondza
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic final classstatic final classstatic class
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionorg.openstack4j.model.compute.Server_bootAndWaitActive(org.openstack4j.model.compute.builder.ServerCreateBuilder request, int timeout) List<? extends org.openstack4j.model.network.Network>org.openstack4j.model.compute.ServerassignFloatingIp(org.openstack4j.model.compute.Server server, String poolName) Assign floating ip address to the server.voidattachFingerprint(org.openstack4j.model.compute.builder.ServerCreateBuilder request) org.openstack4j.model.compute.ServerbootAndWaitActive(org.openstack4j.model.compute.builder.ServerCreateBuilder request, int timeout) Provision machine and wait until ready.voiddestroyFip(String fip) voiddestroyServer(org.openstack4j.model.compute.Server server) Delete server eagerly.static StringgetAccessIpAddress(org.openstack4j.model.compute.Server server) Extract public address from server.static org.openstack4j.model.compute.AddressgetAccessIpAddressObject(org.openstack4j.model.compute.Server server) List<? extends org.openstack4j.model.compute.ext.AvailabilityZone>static StringgetFlavorInfo(org.openstack4j.model.compute.Flavor f) Get list of Floating IPs created for this Jenkins instance that are not connected to any server.getImageIdsFor(String nameOrId) Finds the Id(s) of all activeImages with the given name or ID.Finds allImages.getInfo()Get information about OpenStack deployment.List<? extends org.openstack4j.model.network.ext.NetworkIPAvailability>getNetworks(List<String> nameOrIds) List all requested network details.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>org.openstack4j.model.compute.ServergetServerById(String id) List<org.openstack4j.model.compute.Server>getServersByName(String name) Collection<? extends org.openstack4j.model.compute.Flavor>getVolumeSnapshotDescription(String volumeSnapshotId) Gets the description of aVolumeSnapshot.getVolumeSnapshotIdsFor(String nameOrId) Finds the Id(s) of all availableVolumeSnapshots with the given name or ID.Finds allVolumeSnapshots that areVolume.Status.AVAILABLE.Binary fingerprint to be unique worldwide.Identification for instances launched by this instance via this plugin.static booleanisOccupied(org.openstack4j.model.compute.Server server) Determine whether the server is considered occupied by openstack plugin.Perform some tests before calling the connection successfully established.voidsetVolumeNameAndDescription(String volumeId, String newVolumeName, String newVolumeDescription) Sets the name and description of aVolume.org.openstack4j.model.compute.ServerupdateInfo(org.openstack4j.model.compute.Server server) Fetch updated info about the server.
- 
Field Details- 
FINGERPRINT_KEY_URL- See Also:
 
- 
FINGERPRINT_KEY_FINGERPRINT- See Also:
 
 
- 
- 
Constructor Details- 
Openstackpublic Openstack(@Nonnull org.openstack4j.api.OSClient<?> client) 
 
- 
- 
Method Details- 
getFlavorInfo
- 
getInfoGet information about OpenStack deployment.
- 
_listNetworks
- 
getNetworks@Nonnull public Map<String,org.openstack4j.model.network.Network> getNetworks(@Nonnull List<String> nameOrIds) List all requested network details.- Parameters:
- nameOrIds- List of network names/IDs.
- Returns:
- Map of ID and network.
 
- 
getNetworksCapacity@Nonnull public Map<org.openstack4j.model.network.Network,Integer> getNetworksCapacity(@Nonnull Map<String, org.openstack4j.model.network.Network> declaredNetworks) For every network requested, return mapping of network and number of available fixed addresses. Note the network-ip-availability is usually available for admins only so the method may returnnullin that case.- Returns:
- Map of requested networks and their free capacity. Might be empty.
 
- 
getNetworkIPAvailabilitypublic List<? extends org.openstack4j.model.network.ext.NetworkIPAvailability> getNetworkIPAvailability()
- 
getImagesFinds allImages.- Returns:
- A Map of collections of images, indexed by name (or id if the image has no name) in ascending order and, in the event of name-collisions, the images for a given name are sorted by creation date.
 
- 
getVolumeSnapshots@Nonnull public Map<String,List<org.openstack4j.model.storage.block.VolumeSnapshot>> getVolumeSnapshots()Finds allVolumeSnapshots that areVolume.Status.AVAILABLE.- Returns:
- A Map of collections of VolumeSnapshots, 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.
 
- 
getSortedFlavors
- 
getSortedIpPools
- 
getAvailabilityZones@Nonnull public List<? extends org.openstack4j.model.compute.ext.AvailabilityZone> getAvailabilityZones()
- 
getRunningNodes
- 
getFreeFipIdsGet list of Floating IPs created for this Jenkins instance that are not connected to any server.
- 
getSortedKeyPairNames
- 
getImageIdsForFinds the Id(s) of all activeImages with the given name or ID. If we have found multipleImages then they will be listed in ascending date order (oldest first).- Parameters:
- nameOrId- The- Imagename or ID.
- Returns:
- Zero, one or multiple IDs.
 
- 
getVolumeSnapshotIdsForFinds the Id(s) of all availableVolumeSnapshots with the given name or ID. If we have found multipleVolumeSnapshots then they will be listed in ascending date order (oldest first).- Parameters:
- nameOrId- The- VolumeSnapshotname or ID.
- Returns:
- Zero, one or multiple IDs.
 
- 
getVolumeSnapshotDescriptionGets the description of aVolumeSnapshot. This will be visible if a user looks at volume snapshots using the OpenStack command-line or WebUI and may well contain useful information.- Parameters:
- volumeSnapshotId- The ID of the volume snapshot whose description is to be retrieved.
- Returns:
- The description string, or null if there isn't one.
 
- 
setVolumeNameAndDescriptionpublic void setVolumeNameAndDescription(String volumeId, String newVolumeName, String newVolumeDescription) Sets the name and description of aVolume. These will be visible if a user looks at volumes using the OpenStack command-line or WebUI.- Parameters:
- 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.
 
- 
isOccupiedpublic static boolean isOccupied(@Nonnull org.openstack4j.model.compute.Server server) Determine whether the server is considered occupied by openstack plugin.
- 
instanceUrlIdentification for instances launched by this instance via this plugin.- Returns:
- Identifier to filter instances we control.
 
- 
instanceFingerprintBinary fingerprint to be unique worldwide.
- 
getServerById@Nonnull public org.openstack4j.model.compute.Server getServerById(@Nonnull String id) throws NoSuchElementException - Throws:
- NoSuchElementException
 
- 
getServersByName
- 
bootAndWaitActive@Nonnull public org.openstack4j.model.compute.Server bootAndWaitActive(@Nonnull org.openstack4j.model.compute.builder.ServerCreateBuilder request, @Nonnegative int timeout) throws Openstack.ActionFailed Provision machine and wait until ready.- Throws:
- Openstack.ActionFailed- Openstack failed to provision the slave or it was in erroneous state (server will be deleted in such case).
 
- 
attachFingerprintpublic void attachFingerprint(@Nonnull org.openstack4j.model.compute.builder.ServerCreateBuilder request) 
- 
_bootAndWaitActive@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public org.openstack4j.model.compute.Server _bootAndWaitActive(@Nonnull org.openstack4j.model.compute.builder.ServerCreateBuilder request, @Nonnegative int timeout) 
- 
updateInfo@Nonnull public org.openstack4j.model.compute.Server updateInfo(@Nonnull org.openstack4j.model.compute.Server server) Fetch updated info about the server.
- 
destroyServerpublic void destroyServer(@Nonnull org.openstack4j.model.compute.Server server) throws Openstack.ActionFailed Delete server eagerly. The deletion tends to fail a couple of time before it succeeds. This method throws on any such failure. UseDestroyMachineto destroy the server reliably.- Throws:
- Openstack.ActionFailed
 
- 
assignFloatingIp@Nonnull public org.openstack4j.model.compute.Server assignFloatingIp(@Nonnull org.openstack4j.model.compute.Server server, @Nonnull String poolName) throws Openstack.ActionFailed Assign floating ip address to the server. Note that after the successful assignment, the old Server instance becomes outdated as it does not contain the IP details. The IP description will contain fingerprint linking it back to server it was created for. It is guaranteed it will be created after the server so any IP found without its server running is a leaked one.- Parameters:
- server- Server to assign FIP
- poolName- Name of the FIP pool to use.
- Returns:
- Updated server.
- Throws:
- Openstack.ActionFailed
 
- 
destroyFip
- 
getAccessIpAddress@CheckForNull public static String getAccessIpAddress(@Nonnull org.openstack4j.model.compute.Server server) throws IllegalArgumentException, NoSuchElementException Extract public address from server.- Returns:
- Preferring IPv4 over IPv6 and floating address over fixed.
- Throws:
- IllegalArgumentException- When address can not be understood.
- NoSuchElementException- When no suitable address is found.
 
- 
getAccessIpAddressObjectpublic static org.openstack4j.model.compute.Address getAccessIpAddressObject(@Nonnull org.openstack4j.model.compute.Server server) 
- 
sanityCheckPerform some tests before calling the connection successfully established.
 
-