Upgrade service / Service versioning


I’m trying to implement a “service upgrade” lifecycle action on active services. Let’s suppose we have a service ordered from service template template_v1 . We offer an new template_v2 with extended capabilities (for example optional monitoring service).

I want to allow upgrading the active services to v2. I create a button “Upgrade to v2” with an upgrade_to_v2 method. This method carefully creates/configures (additional) resources of the service to match template_v2. I also want to reflect the change in the catalog item relationship (parent catalog item) of the service. The following code seems to do the trick:

service = $evm.root['service']
template_id = $evm.vmdb(:service_template).find_by_name("template_v2").id
service[:service_template_id] = template_id

This seems to correctly update the catalog item relationship. Does that look right to you? Any objections?

Another approach I thought of would be to create a new service and add the resources of the old one to the new, based on this example:

template = $evm.vmdb(:service_template).find_by_name("template_v2")
new_service = $evm.vmdb('service').create(:name => "service v2", :service_template => template)
# ... adding child services, VMs, generic objects to new_service, copying options
# ... deleting old service

This looks to be harder but probably safer than the first approach. One drawback is that we have a new service object losing the history of the old one.


From Automate instance_variable_get(:@object) returned nil so I was not able to call save on it. This must be due to dRuby processing.

I tried to call service.method_missing(:send, "instance_variable_get", '@object') but this gave me a DRb::DRbUnknown object with a name Service, I believe this is a Class not an instance. So I could not call .save at the end. The workaround was to call another method that would save the instance variable (by calling a rewrite to the description of the service):

service = $evm.root['service']
description = service.description
template_id = $evm.vmdb(:service_template).find_by_name("template_v2").id
service[:service_template_id] = template_id
service.method_missing(:send, "description=", description)

This is now working as as Automate method.