[openstacksdk][nova] distinguish image and boot from volume instances
On 12/13/2019 1:48 AM, Blom, Merlin, NMU-OI wrote:
> I wrote a *function for distinguishing an image instance from an boot
> from volume instance* for billing purpose.
> But it does not work this way, it seems as if BfV Instances also have
> the Image property set.
> *Is there an elegant solution other than analyzing the volume attachment
> This cloud be a problem, because an image instance cloud also have volumes.
> def getBootFromVolInstances(serverId):
> Â Â Â '''Determines wether an instance is a boot frome volume instance'''
> Â Â Â server = conn.compute.find_server(serverId, ignore_missing=True)
> Â Â Â if server:
> Â Â Â Â Â Â Â if server.image:
> Â Â Â Â Â Â Â Â Â Â Â return False
> Â Â Â Â Â Â Â else:
> Â Â Â Â Â Â Â Â Â Â Â return True
> Â Â Â return False
I don't know what client-side tooling you're using (looks like the
openstacksdk?) but a volume-backed server will have an 'image' parameter
in the response body but it should be an empty string. From the API
"The UUID and links for the image for your server instance. The image
object might be an empty string when you boot the server from a volume."