You are here: 17 Object Triggers > References > Environment Creation Example

17.20 Environment Creation Example

Example scenario

An administrator wants to create the following setup in Moab: 

If a user requests an environment, she must have the permission of her two managers and the administrator. If all three approve, then the environment builds. The user is sent email messages informing her of the environment's end date in case she would like an extension. These are sent 7, 3, and 1 days prior to the environment's ending.

The administrator wants to require his and the managers' approval of any modifications the user makes to her environment so that it cannot be extended without consent.

The first trigger requests manager and administrator approval in response to the user's environment request. So in the event of a reservation's creation, a script is used to send messages to the administrator and manager. The internal variable OWNER is used to indicate to the recipients (via the script) which user is requesting the environment.

RSVPROFILE[envSetup] TRIGGER=EType=create,AType=exec,Action="envRequest.sh $OWNER"

The managers and administrator use an external program to approve or reject the request. On approval, a variable is sent back to Moab (to the reservation specifically). Once all three variables are set, the environment can start. In this example, the variables are called approval1, approval2, and approval3.

RSVPROFILE[envSetup] TRIGGER=EType=start,AType=exec,Action="buildScript",Requires=approval1.approval2.approval3

As it is configured now, the reservation will continue to reserve the requested resources regardless of whether all three approvals are given. So, in case approval is not given, the next trigger cancels the reservation 7 days after its creation if the three variables are not set.

RSVPROFILE[envSetup] TRIGGER=EType=create,Offset=7:00:00,AType=internal,Action="rsv:-:cancel",Requires=!approval1.!approval2.!approval3

Every remaining trigger in this series is meant to fire for an approved environment and must require the approval variables. Otherwise these notifications would be sent to users who do not have the environment they requested. The next triggers must be rearmable so that it can fire again if necessary; however, they should be set to just over the amount of time left on the reservation so that it doesn't fire again for the same environment. The notification triggers use the Offset attribute to fire at the administrator's requested times (7, 3, and 1 day(s) prior to the environment's end).

RSVPROFILE[envSetup] TRIGGER=EType=end,Offset=-7:00:00,AType=exec,Action="weekNotification.sh",RearmTime=7:00:00:02,Requires=approval1.approval2.approval3


RSVPROFILE[envSetup] TRIGGER=EType=end,Offset=-3:00:00,AType=exec,Action="3dayNotification.sh",RearmTime=3:00:00:02,Requires=approval1.approval2.approval3


RSVPROFILE[envSetup] TRIGGER=EType=end,Offset=-1:00:00,AType=exec,Action="dayNotification.sh",RearmTime=1:00:00:02,Requires=approval1.approval2.approval3

The next trigger requests administrator and manager approval when the environment is modified. The problem is that the trigger must be rearmable in case of multiple modifications and each time the RearmTime is reached, Moab will fire the trigger based on the first instance of modification. To resolve this issue, this modification trigger requires a modify variable. When the reservation is modified, the modify variable is set.

RSVPROFILE[envSetup] TRIGGER=EType=modify,AType=exec,Action="modify.sh",RearmTime=1:00:00,Requires=approval1.approval2.approval3.!modify,Sets=modify

RSVPROFILE[envSetup] TRIGGER=EType=modify,AType=exec,Action="modificationRequest.sh",RearmTime=5:00,Requires=approval1.approval2.approval3.modify,Unsets=modify

The final triggers notify the user of the end of the environment.

RSVPROFILE[envSetup] TRIGGER=EType=end,AType=exec,Action="end.sh",Requires=approval1.approval2.approval3

The same trigger is repeated for the cancelEType in case the environment ends unexpectedly.

RSVPROFILE[envSetup] TRIGGER=EType=cancel,AType=exec,Action="end.sh",Requires=approval1.approval2.approval3

© 2016 Adaptive Computing