-
Notifications
You must be signed in to change notification settings - Fork 48
Adding New Filesystem Nodes
Note: this howto requires some knowledge of Ruby.
Any object can be included in the RVC filesystem ("inventory") as long as it implements the interface defined by RVC::InventoryObject
in lib/rvc/inventory.rb
. Including this module into your object is the simplest way to implement most of the methods, and all subclasses of VIM::ManagedEntity
already do this. All you need to do then is write a children
method which returns a hash of child objects keyed by their names.
RVC uses the RbVmomi extension mechanism to add methods to VIM classes. Just add a file with the name of the class plus an ".rb" extension to the directory lib/rvc/extensions/
. In there, reopen the class you wish to modify and add your methods. See the ClusterComputeResource.rb
extension for an example.
Often you'll want to put child nodes in a directory underneath an existing node instead of making them its direct children. The ClusterComputeResource.rb
extension uses the convenient RVC::FakeFolder
class to do this. FakeFolder's constructor takes an object and a method name. It will route calls to its children
method to the object and method you supply. Thus, the "hosts" folder of a ClusterComputeResource gets its children from the rvc_host_children
method on the cluster.
The RVC::Util.collect_children
utility function is an efficient way to retrieve managed entities and their names from an array property. It takes as arguments a managed object and a property path, and returns a hash from names to managed entities.