[openstacksdk][nova] distinguish image and boot from volume instances
Hey, 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 state? 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 Merlin Blom Cloud System Engineer E-Mail: <mailto:merlin.blom@bertelsmann.de> merlin.blom@bertelsmann.de <https://www.arvato-systems.de> arvato-systems.de
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 state?*
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 reference [1]: "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." [1] https://docs.openstack.org/api-ref/compute/?expanded=show-server-details-det... -- Thanks, Matt
On 12/13/2019 10:03 AM, Matt Riedemann wrote:
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.
The problem is you're getting an image.v2.image.Image object in the SDK so it's not Falsey. I'm not sure how you translate the empty string from the server.image response body parameter to knowing the SDK Image object is essentially empty. -- Thanks, Matt
On Fri, Dec 13, 2019 at 2:54 AM Blom, Merlin, NMU-OI <merlin.blom@bertelsmann.de> wrote:
Hey,
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 state?
This cloud be a problem, because an image instance cloud also have volumes.
Except that would make it not a boot from volume instance, it would be an instances with attached 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
Merlin Blom
Cloud System Engineer
E-Mail: merlin.blom@bertelsmann.de
arvato-systems.de
-- Mohammed Naser — vexxhost ----------------------------------------------------- D. 514-316-8872 D. 800-910-1726 ext. 200 E. mnaser@vexxhost.com W. https://vexxhost.com
participants (3)
-
Blom, Merlin, NMU-OI
-
Matt Riedemann
-
Mohammed Naser