-
-
Save rockpapergoat/876db847be1593b024959962493be613 to your computer and use it in GitHub Desktop.
migrator.rb
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
#!/usr/bin/env ruby -wU | |
# | |
require 'opennebula' | |
# setup the open nebula client connection | |
def one_client( | |
creds = ENV['ONE_AUTH'] || "#{ENV['ONE_USER']}:#{ENV['ONE_TOKEN']}", | |
endpoint = ENV['ONE_XMLRPC'] || 'https://url_here:2633/RPC2' | |
) | |
OpenNebula::Client.new(creds, endpoint) | |
end | |
def get_vm_pool(client) | |
OpenNebula::VirtualMachinePool.new(client, -1) | |
end | |
# returns an array of vm objects | |
# represents contents of the pool | |
def get_all_vms(pool = get_vm_pool(one_client)) | |
pool.find_all | |
end | |
# returns one OpenNebula::VirtualMachine object | |
# that matches the name passed | |
def get_vm(name) | |
get_all_vms.select {|vm| vm.name.match(name)}.first | |
end | |
# pass a vm object here to extract the image id | |
# returns a string id; should it be an integer? | |
def get_vm_image_id(vm) | |
vm.retrieve_elements('TEMPLATE/DISK/IMAGE_ID').first | |
end | |
def update_vm_template(vm) | |
end | |
def terminate_vm(vm) | |
end | |
# verify template reflects correct rbd storage location | |
# of copied/new image | |
def validate_vm_template(vm) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment