waldur-mastermind icon indicating copy to clipboard operation
waldur-mastermind copied to clipboard

Accessing Attributes in Termination Script

Open mattronix opened this issue 2 years ago • 2 comments

When creating a resource with a script i use (python):

attributes = json.loads(os.environ.get("ATTRIBUTES"))

To access the attributes of a resource.

However in a termination script i cant use the same method it seems to access the attributes as it gives me the following error:

2024-02-14T13:53:32.944140165Z [2024-02-14 13:53:32,943: ERROR/ForkPoolWorker-9] Error processing order type: Terminate, offering: Storage Share fs.ti, created_by: 089353b4-782e-44ba-a88a-382920d816e8 (Matthew Frost). Order ID: 129. Exception: [ErrorDetail(string='Command '['python', 'script']' in image 'mattronix:alpine-py-3.11' returned non-zero exit status 1: b'Traceback (most recent call last):\n File "/work/script", line 117, in \n new_user = attributes["username"]\n

When i do a print its also not set it seems, however i do see them in the database.

(once im finished with these scripts il send them your way also for the examples)

mattronix avatar Feb 14 '24 13:02 mattronix

In case its useful im publishing my work here: https://github.com/mattronix/waldur-custom-offerings/blob/main/create_user_over_ssh/storage-user-add-waldur.py

its a script for a very basic add user + samba share.

mattronix avatar Feb 14 '24 14:02 mattronix

did you get a chance to look at this?

mattronix avatar Feb 26 '24 16:02 mattronix

issue has been solved in a while, closing the ticket.

livenson avatar Feb 04 '25 08:02 livenson