include "cloud-schemas.sfp" schema Service { installed is false running is false on_machine isref Machine procedure install ( m isref Machine ) { conditions { m.running is true this.installed is false } effects { this.on_machine is m this.installed is true } } procedure uninstall { conditions { this.on_machine.running is true this.installed is true } effects { this.on_machine is null this.installed is false } } procedure start { conditions { this.installed is true this.running is false } effects { this.running is true } } procedure stop { conditions { this.installed is true this.running is true } effects { this.running is false } } } schema LoadBalancer extends Service { webs isset WebService procedure start { conditions { this.installed is true this.running is false exist (this.webs as web) { web.running is true } } effects { this.running is true } } } schema WebService extends Service { depend_on isref AppService procedure redirect ( app isref AppService ) { conditions { this.installed is true app.running is true } effects { this.depend_on is app } } procedure start { conditions { this.installed is true this.running is false this.depend_on.running is true } effects { this.running is true } } procedure stop { conditions { this.installed is true this.running is true forall (LoadBalancer as lb) { if lb.webs has this then lb.running is false } } effects { this.running is false } } } schema AppService extends Service { depend_on isref DatabaseService procedure redirect ( db isref DatabaseService ) { conditions { this.installed is true db.running is true } effects { this.depend_on is db } } procedure start { conditions { this.installed is true this.running is false this.depend_on.running is true } effects { this.running is true } } procedure stop { conditions { this.installed is true this.running is true forall (WebService as ws) { if ws.depend_on is this then ws.running is false } } effects { this.running is false } } } schema DatabaseService extends Service { procedure stop { conditions { this.installed is true this.running is true forall (AppService as app) { if app.depend_on is this then app.running is false } } effects { this.running is false } } }