Forked from AparnaKarve/gist:092c8994bc908755d7c36f9d20cf127e
Last active
November 2, 2017 19:21
-
-
Save martinpovolny/b08a799e2174551a4d7fc6f4bac85ad2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. Create the Generic Object Definition record in Rails console - | |
go_def = GenericObjectDefinition.create( | |
:name => "LoadBalancerTest2", | |
:properties => { | |
:attributes => {:max_vms => "integer", :location => "string", :active => "boolean"}, | |
:associations => {:vms => "Vm", :abc => "Service"}, | |
:methods => [:add_vm, :remove_vm] | |
} | |
) | |
# 2. Create a Generic Object instance | |
$evm = MiqAeMethodService::MiqAeService.new(MiqAeEngine::MiqAeWorkspaceRuntime.new) | |
f = $evm.vmdb(:generic_object_definition).find_by(:name => "LoadBalancerTest2") | |
go2 = f.create_object(:name => "Test Load Balancer", :location => "Mahwah") | |
service2 = Service.create(:name => "My Service2", :description => "My Description2") | |
go2.instance_variable_set(:@ae_user, User.first) | |
go2.abc = [service] | |
go2.save | |
# 3. Add GO Resource to the Service Object | |
service.add_resource(go2) | |
service.save! | |
# Like `Service`, you can associate any other Reportable model with the GO object |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment