[racktables-users] Re: Mass delete of objects with type 'VM'

  • From: "Christopher Hupman" <chupman@xxxxxxxxxx>
  • To: racktables-users@xxxxxxxxxxxxx
  • Date: Thu, 16 Feb 2017 11:13:47 -0800


Hello,

If you used the rest API Ian Bettinger made you could accomplish the
majority of what you need to do with a couple curl statement and some
hackery
https://github.com/ibettinger/racktables/blob/master/wwwroot/api.php ;<--
link to the api

First you curl to get all the VMs. Then you apply some ugly pipes to get a
file with all the object ids
curl -s -S --trace-ascii curl.debug --location-trusted --insecure -u
<username>:<password>
"http://<server>/racktables/api.php?method=get_depot&andor=and&cfe=%7B%24typeid_1504%7D"
 | \
jq -r .response| jq -r 'keys' | sed -e '/]/d' -e 's/,//g' -e '/\[/d' -e
's/"//g' > vmkeys.json

finally loop through the list and delete the vms
for i in `cat vmkeys.json`; do curl -s -S --trace-ascii curl.debug
--location-trusted --insecure -u <username>:<password>
"http://<server>/racktables/api.php?method=delete_object&object_id=$i";
done

I personally prefer python and am using the api to automatically create VMs
with help from a pyvmomi script I wrote. If you want to look at what I have
for reference you can find it at
https://github.com/chupman/racktables-scripts

On an unrelated note does anyone know why Ians API never made it upstream?


Regards,

Chris Hupman
Network Services Specialist and Data Center Lead
IBM Open Technology and Cloud Performance
408-463-4348 work
415-264-8765 cell
JNCIS-ENT Juniper Certified Specialist




From:   Dennis Breuer <DBreuer@xxxxxxxx>
To:     racktables-users@xxxxxxxxxxxxx
Date:   02/16/2017 08:02 AM
Subject:        [racktables-users] Mass delete of objects with type 'VM'
Sent by:        racktables-users-bounce@xxxxxxxxxxxxx



Hi Racktables users,

any chance to delete all object with type 'VM'?

Mit freundlichen Grüßen

Dennis Breuer (System Services)
IT-Systemadministrator
-------------------------------------------------------------------------------

NOWIS Nordwest-Informationssysteme GmbH & Co. KG
Mittelkamp 110 - 118
26125 Oldenburg
Tel: +49(441) 3907 159
eMail : dbreuer@xxxxxxxx
-------------------------------------------------------------------------------

Besuchen Sie uns - wir freuen uns auf Sie!

Wir laden Sie herzlich zum 3. NOWIS IT-Brunch nach Oldenburg ein!
Thema "Megatrend Digitalisierung - auch im Mittelstand? Strategien und
Arbeiten 4.0"
Dienstag, 21. Februar 2017 von 08:45 Uhr bis ca. 12:30 Uhr

Seien Sie unser Gast und sichern Sie sich schon heute Ihre Teilnahme ->
https://www.nowis.de/it-brunch/

Aktuelle NOWIS-Veranstaltungen im Überblick ->
https://www.nowis.de/veranstaltungen/
----
Sollte sich bei der Adressierung dieser Nachricht ein Fehler eingeschlichen
haben und Sie sind nicht der vorgesehene Adressat oder dessen Vertreter,
setzen Sie sich bitte mit dem Absender in Verbindung.

NOWIS Nordwest-Informationssysteme GmbH, Mittelkamp 110-118, D-26125
Oldenburg
Telefon: +49 / (0)441 / 3907-0, E-Mail: info@xxxxxxxx, Web:
http://www.nowis.de
Handelsregister: Amtsgericht Oldenburg HRB 4566, Geschäftsführer: Udo
Wisniewski, Dr.-Ing. Uwe Vaihinger

GIF image

Other related posts: