Skip to content

Commit

Permalink
Demonstrate that infrastructure stack can be created and destroyed
Browse files Browse the repository at this point in the history
  • Loading branch information
foretspaisibles committed May 8, 2024
1 parent b395970 commit cbe696c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions doc/resource.texinfo
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ modifying or examining the underlying resource.
@include include/fun-org.melusina.cid-list-resources.texinfo

@include include/fun-org.melusina.cid-resource-prerequisites.texinfo
@include include/fun-org.melusina.cid-sort-resources.texinfo
1 change: 1 addition & 0 deletions src/package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
#:examine-differences-between-instance-and-resource
#:resource-prerequisites
#:resource-serial
#:sort-resources
;; Infrastructure Stacks
#:stack-name
;; Simulators and Simulations
Expand Down
9 changes: 6 additions & 3 deletions src/poc.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@
#:remove-property
#:resource-prerequisites
#:write-persistent-object
#:read-persistent-object)
#:read-persistent-object
#:sort-resources
#:create-resource
#:delete-resource)
(:export
#:configure-laboratory
#:cloud-vendor
Expand Down Expand Up @@ -404,7 +407,7 @@ defined, provisioned and modified as a unit."))
(loop :for prerequisite :in (slot-value instance 'resources)
:for deep-prerequisites = (resource-prerequisites prerequisite)
:append (cons prerequisite deep-prerequisites) :into prerequisites
:finally (return (remove-duplicates prerequisites :test #'eq))))))
:finally (return (sort-resources (remove-duplicates prerequisites :test #'eq)))))))
(support-initialize-tenant-slot-with-designator)
(support-initialize-project-slot-with-designator)
(finalize-resource-list)))
Expand Down Expand Up @@ -442,7 +445,7 @@ defined, provisioned and modified as a unit."))

(defmethod create-resource ((instance infrastructure-stack))
(with-slots (resources) instance
(loop :for resource :in resources
(loop :for resource :in (reverse resources)
:do (create-resource resource))))

(defmethod delete-resource ((instance infrastructure-stack))
Expand Down
6 changes: 6 additions & 0 deletions src/resource.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,12 @@ before its prerequisites."))
:append (cons prerequisite deep-prerequisites) :into prerequisites
:finally (return (remove-duplicates prerequisites :test #'eq))))

(defun sort-resources (resources)
"Sort RESOURCES so that any resource in the list appears before its prerequisites."
(flet ((require-p (resource1 resource2)
(member resource2 (resource-prerequisites resource1))))
(sort resources #'require-p)))


;;;;
;;;; Resource Lifecycle Methods
Expand Down

0 comments on commit cbe696c

Please sign in to comment.