diff --git a/src/cloud/vmi/VMI.rb b/src/cloud/vmi/VMI.rb deleted file mode 100644 index 7353a9e9e9..0000000000 --- a/src/cloud/vmi/VMI.rb +++ /dev/null @@ -1,6 +0,0 @@ -require 'lib/VirtualMachineVMI' -require 'lib/VirtualMachinePoolVMI' -require 'lib/VirtualNetworkVMI' -require 'lib/VirtualNetworkPoolVMI' - -require 'lib/VMIConfiguration' diff --git a/src/cloud/vmi/VMIServer.rb b/src/cloud/vmi/VMIServer.rb deleted file mode 100644 index b80bd93d55..0000000000 --- a/src/cloud/vmi/VMIServer.rb +++ /dev/null @@ -1,441 +0,0 @@ -################################################ -# Find out where the needed ruby libraries are -################################################ -ONE_LOCATION=ENV["ONE_LOCATION"] - -if !ONE_LOCATION - RUBY_LIB_LOCATION="/usr/lib/one/ruby" -else - RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" - TEMPLATES_LOCATION=ONE_LOCATION+"/etc/vmi_templates" - CONF_LOCATION=ONE_LOCATION+"/etc" -end - -$: << RUBY_LIB_LOCATION -$: << RUBY_LIB_LOCATION+"/vmiserver" - -################################################ -# Required libraries -################################################ -require 'rubygems' -require 'sinatra' -require 'time' -require 'pp' - -require 'OpenNebula' -require 'VMI' - - -include OpenNebula - -CONFIG=VMIConfiguration.new(CONF_LOCATION+'/vmi-server.conf') -AUTH="#{CONFIG[:user]}:#{CONFIG[:password]}" -ONE_RM_DATABASE=CONFIG[:database] - -# Load Repository Manager here to use ONE_RM_DATABASE from the configuration file -require 'repo_manager' -Image.image_dir=CONFIG[:image_dir] - -INSTANCE_TYPES=Hash.new - -puts "######################################" -puts " VMI Server configuration " -puts "######################################" -puts "---------8<---------------------" -pp CONFIG -puts "------>8------------------------" - -if CONFIG[:vm_type].kind_of?(Array) - # Multiple instance types - CONFIG[:vm_type].each {|type| - INSTANCE_TYPES[type['NAME']]=type - } -else - # When only one instance type is defined - INSTANCE_TYPES[CONFIG[:vm_type]['NAME']]=CONFIG[:vm_type] -end - -puts "######################################" -puts " VMI Available Instances Types " -puts "######################################" -puts "---------8<---------------------" -pp INSTANCE_TYPES -puts "------>8------------------------" - -set :host, CONFIG[:server] -set :port, CONFIG[:port] - -# Start repository manager -$repoman=RepoManager.new - -################################################ -# Client builders for ONE communication -################################################ - -def get_one_client - Client.new(AUTH) -end - -def get_one_client_user(user_name) - user=get_user(user_name) - - - auth="#{user[:name]}:#{user[:password]}" - - client=Client.new("dummy:dummy") - client.one_auth=auth - client -end - -def get_user(name) - user=nil - - user_pool=UserPool.new(get_one_client) - user_pool.info - user_pool.each{|u| - if u.name==name - user=Hash.new - user[:id]=u.id - user[:name]=u.name - user[:password]=u[:password] - end - } - - user -end - -################################################### -# Helpers to manage authentication & authorization -################################################### - - -helpers do - - def protected! - response['WWW-Authenticate'] = %(Basic realm="Testing HTTP Auth") and \ - throw(:halt, [401, "Not authorized\n"]) and \ - return unless authorized? - end - - def authorized? - - @auth ||= Rack::Auth::Basic::Request.new(request.env) - - if !(@auth.provided? && @auth.basic? && @auth.credentials) - return false - end - - user = get_user(@auth.credentials.first) - - if user - if user[:password] == @auth.credentials[1] - return true - end - else - return false - end - end - -end - -################################################### -# Helper functions -################################################### - - -def submit_vm(params) - - if params['vmixml'] - @vm_info=Crack::XML.parse(params['vmixml']) - else - halt 400, "VMI XML representation of VM not present" - end - - @vm_info=@vm_info['VM'] - - if @vm_info['DISKS'].class==Array - disks=@vm_info['DISKS'] - else - disks=[@vm_info['DISKS']] - end - - disks.each{|disk| - next if disk['DISK']==nil - image=$repoman.get(disk['DISK']['image']) - disk['DISK']['source']=image.path - } - - @vm_info['DISKS']=disks[0] - - - if @vm_info['NICS']['NIC'].class==Array - nics=@vm_info['NICS']['NIC'] - else - nics=[@vm_info['NICS']['NIC']] - end - - nics.each{|nic| - vn=VirtualNetwork.new(VirtualNetwork.build_xml(nic['network']), get_one_client) - vn.info - vn_xml=Crack::XML.parse(vn.to_xml) - nic['network_id']=nic['network'] - nic['network']=vn_xml['VNET']['NAME'].strip - } - - @vm_info['NICS']['NIC']=nics - - instance_type_name=params['InstanceType'] - instance_type=INSTANCE_TYPES[instance_type_name] - - halt 400, "Bad instance type" if !instance_type - - @vm_info[:instance_type]=instance_type_name - - template=ERB.new(File.read( - TEMPLATES_LOCATION+"/#{instance_type['TEMPLATE']}")) - template_text=template.result(binding) - - vm=VirtualMachineVMI.new( - VirtualMachine.build_xml, get_one_client_user(@auth.credentials[0])) - response=vm.allocate(template_text) - - if OpenNebula.is_error?(response) - status 400 - response.to_str - else - vm.info - vm.to_vmi - end -end - -def change_state(params) - if params['vmixml'] - vm_info=Crack::XML.parse(params['vmixml']) - else - halt 400, "VMI XML representation of VM not present" - end - - vm=VirtualMachineVMI.new( - VirtualMachine.build_xml(params[:id]), get_one_client_user(@auth.credentials[0])) - - halt 400, "State not defined in the VMI XML, cannot change state" if !vm_info['VM']['STATE'] - - case vm_info['VM']['STATE'] - when "stopped" - rc = vm.stop - when "suspended" - rc = vm.suspend - when "resume" - rc = vm.resume - when "cancel" - rc = vm.cancel - when "done" - rc = vm.finalize - else - halt 400, "Invalid state" - end - - if OpenNebula.is_error?(rc) - status 400 - response.to_str - else - status 202 - response_text = "Changing state of VM " + params[:id] + " to " + vm_info['VM']['STATE'] - end -end - -################################################### -# Pool Resources methods -################################################### - -post '/vms' do - # Auth check - protected! - - submit_vm(params) -end - -get '/vms' do - # Auth check - protected! - # Info retrieval - vmpool = VirtualMachinePoolVMI.new(get_one_client) - vmpool.info - # VMI conversion - begin - vmpool.to_vmi(CONFIG[:server]) - rescue Exception => e - error = OpenNebula::Error.new(e.message) - return error - end -end - -post '/networks' do - # Auth check - protected! - # Info retrieval from post params - if params['vmixml'] - network_info=Crack::XML.parse(params['vmixml']) - else - halt 400, "VMI XML representation of Virtual Network not present in the request" - end - # Allocate the VirtualNetwork - network = VirtualNetworkVMI.new( - VirtualNetwork.build_xml, - get_one_client_user(@auth.credentials[0])) - - vntemplate = network.to_one_template(network_info['NETWORK'],CONFIG[:bridge]) - rc = network.allocate(vntemplate) - - # Return status 201 XML if correct, status 500 otherwise - if rc - halt 500, "Error creating the Virtual Network: " + rc - else - network.info - status 201 - network.to_vmi - end -end - -get '/networks' do - # Auth check - protected! - # Info retrieval - network_pool = VirtualNetworkPoolVMI.new(get_one_client) - network_pool.info - # VMI conversion - begin - network_pool.to_vmi(CONFIG[:server]) - rescue Exception => e - error = OpenNebula::Error.new(e.message) - return error - end -end - -post '/images' do - # Auth check - protected! - # Info retrieval from post params - if params['vmixml'] - image_info=Crack::XML.parse(params['vmixml']) - else - halt 400, "VMI XML representation of Image not present in the request" - end - - if params['file'] - file=params["file"] - else - halt 400, "File not present in the request" - end - - user = get_user(@auth.credentials[0]) - - # tmpfile where the file is stored - f_tmp=file[:tempfile] - img=$repoman.add(user[:id], f_tmp.path) - f_tmp.unlink - - img.get_image_info - img.change_metadata(:name=>image_info['IMAGE']['NAME']) - img.change_metadata(:description=>image_info['IMAGE']['URL']) - - xml_response = "" + img.uuid + "" + - "" + image_info['IMAGE']['NAME'] + "" + - "" + ((img.size/1024)/1024).to_s + "" + - "" + image_info['IMAGE']['URL'] + "" + - "" - - status 201 - xml_response -end - -get '/images' do - # Auth check - protected! - # Retrieve images owned by this user - user = get_user(@auth.credentials[0]) - images=Image.filter(:owner => user[:id]) - - image_pool = "" - for image in images do - image_pool += "" - end - image_pool += "" - image_pool -end - -################################################### -# Entity Resources Methods -################################################### - -get '/vms/:id' do - protected! - vm = VirtualMachineVMI.new(VirtualMachine.build_xml(params[:id]),get_one_client_user(@auth.credentials[0])) - vm.info - begin - vm.to_vmi() - rescue Exception => e - error = OpenNebula::Error.new(e.message) - return error - end -end - -delete '/vms/:id' do - protected! - vm = VirtualMachineVMI.new(VirtualMachine.build_xml(params[:id]),get_one_client_user(@auth.credentials[0])) - vm.finalize - "The Virtual Machine has been successfully deleted" -end - -post '/vms/:id' do - protected! - - change_state(params) -end - -get '/networks/:id' do - protected! - vn = VirtualNetworkVMI.new(VirtualNetwork.build_xml(params[:id]),get_one_client_user(@auth.credentials[0])) - vn.info - begin - vn.to_vmi() - rescue Exception => e - error = OpenNebula::Error.new(e.message) - return error - end -end - -delete '/networks/:id' do - protected! - vn = VirtualNetworkVMI.new(VirtualNetwork.build_xml(params[:id]),get_one_client_user(@auth.credentials[0])) - vn.delete - "The Virtual Network has been successfully deleted" -end - -get '/images/:id' do - protected! - image=$repoman.get(params[:id]) - - image.get_image_info - - if image - xml_response = "" + image.uuid + "" + - "" + image.name + "" + - "" + ((image.size/1024)/1024).to_s + "" + - "" + image.description + "" + - "" - else - status 404 - "Image with id = \"" + params[:id] + "\" not found" - end -end - -delete '/images/:id' do - protected! - "Not yet implemented" -end - - - - - diff --git a/src/cloud/vmi/commands/vmi-delete-image b/src/cloud/vmi/commands/vmi-delete-image deleted file mode 100755 index 0f821325a4..0000000000 --- a/src/cloud/vmi/commands/vmi-delete-image +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/env ruby - -# == Synopsis -# vmi-delete-image -# -# Uploads an image for use with an OpenNebula Cloud. -# -# == Usage -# -# vmi-delete-image[OPTIONS] IMAGE-ID -# -# -h, --help: -# show help -# -# --username , -U : -# The username of the user -# -# --password , -P : -# The password of the user -# -# --url , -U : -# Set url as the web service url to use -# -# --debug, -D -# Enables verbosity -# -# IMAGE-ID ID of the image to be deleted - -# -------------------------------------------------------------------------- # -# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad # -# Complutense de Madrid (dsa-research.org) # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -ONE_LOCATION=ENV["ONE_LOCATION"] - -if !ONE_LOCATION - RUBY_LIB_LOCATION="/usr/lib/one/ruby" -else - RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" - TEMPLATES_LOCATION=ONE_LOCATION+"/etc/vmi_templates" - CONF_LOCATION=ONE_LOCATION+"/etc" -end - -$: << RUBY_LIB_LOCATION -$: << RUBY_LIB_LOCATION+"/vmiserver" - -require 'VMIQueryClient' -require 'getoptlong' -require 'rdoc/usage' -require 'pp' - - -opts = GetoptLong.new( - ['--help', '-h',GetoptLong::NO_ARGUMENT], - ['--username', '-U',GetoptLong::REQUIRED_ARGUMENT], - ['--password', '-P',GetoptLong::REQUIRED_ARGUMENT], - ['--url', '-R',GetoptLong::REQUIRED_ARGUMENT], - ['--debug', '-D',GetoptLong::NO_ARGUMENT] - ) - -url = nil -username = nil -password = nil -auth = nil -debug = false - -begin - opts.each do |opt, arg| - case opt - when '--help' - RDoc::usage - when '--username' - username = arg - when '--password' - password = arg - when '--url' - url = arg - when '--debug' - debug = true - end - end -rescue Exception => e - exit -1 -end - -image_id = ARGV.shift - -if !image_id - puts "#{$0}: missing IMAGE-ID parameter" - exit -1 -end - -begin - vmi_client = VMIQueryClient::Client.new(url,username,password,debug) -rescue Exception => e - puts "#{$0}: #{e.message}" - exit -1 -end - -pp "Not implemented yet" - -# vmi_client.delete_image(image_id) - -exit 0 - diff --git a/src/cloud/vmi/commands/vmi-delete-network b/src/cloud/vmi/commands/vmi-delete-network deleted file mode 100755 index 32fe4a50cb..0000000000 --- a/src/cloud/vmi/commands/vmi-delete-network +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env ruby - -# == Synopsis -# vmi-delete-network -# -# Uploads an image for use with an OpenNebula Cloud. -# -# == Usage -# -# vmi-delete-network [OPTIONS] NETWORK-ID -# -# -h, --help: -# show help -# -# --username , -U : -# The username of the user -# -# --password , -P : -# The password of the user -# -# --url , -U : -# Set url as the web service url to use -# -# --debug, -D -# Enables verbosity -# -# NETWORK-ID ID of the network to be deleted - -# -------------------------------------------------------------------------- # -# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad # -# Complutense de Madrid (dsa-research.org) # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -ONE_LOCATION=ENV["ONE_LOCATION"] - -if !ONE_LOCATION - RUBY_LIB_LOCATION="/usr/lib/one/ruby" -else - RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" - TEMPLATES_LOCATION=ONE_LOCATION+"/etc/vmi_templates" - CONF_LOCATION=ONE_LOCATION+"/etc" -end - -$: << RUBY_LIB_LOCATION -$: << RUBY_LIB_LOCATION+"/vmiserver" - -require 'VMIQueryClient' -require 'getoptlong' -require 'rdoc/usage' -require 'pp' - - -opts = GetoptLong.new( - ['--help', '-h',GetoptLong::NO_ARGUMENT], - ['--username', '-U',GetoptLong::REQUIRED_ARGUMENT], - ['--password', '-P',GetoptLong::REQUIRED_ARGUMENT], - ['--url', '-R',GetoptLong::REQUIRED_ARGUMENT], - ['--debug', '-D',GetoptLong::NO_ARGUMENT] - ) - -url = nil -username = nil -password = nil -auth = nil -debug = false - -begin - opts.each do |opt, arg| - case opt - when '--help' - RDoc::usage - when '--username' - username = arg - when '--password' - password = arg - when '--url' - url = arg - when '--debug' - debug = true - end - end -rescue Exception => e - exit -1 -end - -network_id = ARGV.shift - -if !network_id - puts "#{$0}: missing NETWORK-ID parameter" - exit -1 -end - -begin - vmi_client = VMIQueryClient::Client.new(url,username,password,debug) -rescue Exception => e - puts "#{$0}: #{e.message}" - exit -1 -end - -vmi_client.delete_network(network_id) - -exit 0 - diff --git a/src/cloud/vmi/commands/vmi-delete-vms b/src/cloud/vmi/commands/vmi-delete-vms deleted file mode 100755 index 576ab1a0d9..0000000000 --- a/src/cloud/vmi/commands/vmi-delete-vms +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env ruby - -# == Synopsis -# vmi-delete-vms -# -# Deletes a Virtual Machine -# -# == Usage -# -# vmi-post-image [OPTIONS] VM-ID -# -# -h, --help: -# show help -# -# --username , -U : -# The username of the user -# -# --password , -P : -# The password of the user -# -# --url , -U : -# Set url as the web service url to use -# -# --debug, -D -# Enables verbosity -# -# VM-ID ID of the Virtual Machine to be deleted - -# -------------------------------------------------------------------------- # -# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad # -# Complutense de Madrid (dsa-research.org) # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -ONE_LOCATION=ENV["ONE_LOCATION"] - -if !ONE_LOCATION - RUBY_LIB_LOCATION="/usr/lib/one/ruby" -else - RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" - TEMPLATES_LOCATION=ONE_LOCATION+"/etc/vmi_templates" - CONF_LOCATION=ONE_LOCATION+"/etc" -end - -$: << RUBY_LIB_LOCATION -$: << RUBY_LIB_LOCATION+"/vmiserver" - -require 'VMIQueryClient' -require 'getoptlong' -require 'rdoc/usage' -require 'pp' - - -opts = GetoptLong.new( - ['--help', '-h',GetoptLong::NO_ARGUMENT], - ['--username', '-U',GetoptLong::REQUIRED_ARGUMENT], - ['--password', '-P',GetoptLong::REQUIRED_ARGUMENT], - ['--url', '-R',GetoptLong::REQUIRED_ARGUMENT], - ['--debug', '-D',GetoptLong::NO_ARGUMENT] - ) - -url = nil -username = nil -password = nil -auth = nil -debug = false - -begin - opts.each do |opt, arg| - case opt - when '--help' - RDoc::usage - when '--username' - username = arg - when '--password' - password = arg - when '--url' - url = arg - when '--debug' - debug = true - end - end -rescue Exception => e - exit -1 -end - -vm_id = ARGV.shift - -if !vm_id - puts "#{$0}: missing VM-ID parameter" - exit -1 -end - -begin - vmi_client = VMIQueryClient::Client.new(url,username,password,debug) -rescue Exception => e - puts "#{$0}: #{e.message}" - exit -1 -end - -vmi_client.delete_vm(vm_id) - -exit 0 - diff --git a/src/cloud/vmi/commands/vmi-get-image b/src/cloud/vmi/commands/vmi-get-image deleted file mode 100755 index c87ad93f04..0000000000 --- a/src/cloud/vmi/commands/vmi-get-image +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env ruby - -# == Synopsis -# vmi-get-image -# -# Retrieves the VMI representation of an Image -# -# == Usage -# -# vmi-post-network [OPTIONS] IMAGE-ID -# -# -h, --help: -# show help -# -# --username , -U : -# The username of the user -# -# --password , -P : -# The password of the user -# -# --url , -U : -# Set url as the web service url to use -# -# --debug, -D -# Enables verbosity -# -# IMAGE-ID Image Identifier - -# -------------------------------------------------------------------------- # -# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad # -# Complutense de Madrid (dsa-research.org) # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -ONE_LOCATION=ENV["ONE_LOCATION"] - -if !ONE_LOCATION - RUBY_LIB_LOCATION="/usr/lib/one/ruby" -else - RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" - TEMPLATES_LOCATION=ONE_LOCATION+"/etc/vmi_templates" - CONF_LOCATION=ONE_LOCATION+"/etc" -end - -$: << RUBY_LIB_LOCATION -$: << RUBY_LIB_LOCATION+"/vmiserver" - -require 'VMIQueryClient' -require 'getoptlong' -require 'rdoc/usage' -require 'pp' - - -opts = GetoptLong.new( - ['--help', '-h',GetoptLong::NO_ARGUMENT], - ['--username', '-U',GetoptLong::REQUIRED_ARGUMENT], - ['--password', '-P',GetoptLong::REQUIRED_ARGUMENT], - ['--url', '-R',GetoptLong::REQUIRED_ARGUMENT], - ['--debug', '-D',GetoptLong::NO_ARGUMENT] - ) - -url = nil -username = nil -password = nil -auth = nil -debug = false - -begin - opts.each do |opt, arg| - case opt - when '--help' - RDoc::usage - when '--username' - username = arg - when '--password' - password = arg - when '--url' - url = arg - when '--debug' - debug = true - end - end -rescue Exception => e - exit -1 -end - -image_id = ARGV.shift - -if !image_id - puts "#{$0}: missing IMAGE-ID parameter or file not found" - exit -1 -end - -begin - vmi_client = VMIQueryClient::Client.new(url,username,password,debug) -rescue Exception => e - puts "#{$0}: #{e.message}" - exit -1 -end - -vmi_client.get_image(image_id) - -exit 0 - diff --git a/src/cloud/vmi/commands/vmi-get-images b/src/cloud/vmi/commands/vmi-get-images deleted file mode 100755 index 24c6c8b524..0000000000 --- a/src/cloud/vmi/commands/vmi-get-images +++ /dev/null @@ -1,107 +0,0 @@ -#!/usr/bin/env ruby - -# == Synopsis -# vmi-get-images -# -# Retrieves all availables images -# -# == Usage -# -# vmi-get-images [OPTIONS] -# -# -h, --help: -# show help -# -# --username , -U : -# The username of the user -# -# --password , -P : -# The password of the user -# -# --url , -U : -# Set url as the web service url to use -# -# --debug, -D -# Enables verbosity -# - -# -------------------------------------------------------------------------- # -# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad # -# Complutense de Madrid (dsa-research.org) # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -ONE_LOCATION=ENV["ONE_LOCATION"] - -if !ONE_LOCATION - RUBY_LIB_LOCATION="/usr/lib/one/ruby" -else - RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" - TEMPLATES_LOCATION=ONE_LOCATION+"/etc/vmi_templates" - CONF_LOCATION=ONE_LOCATION+"/etc" -end - -$: << RUBY_LIB_LOCATION -$: << RUBY_LIB_LOCATION+"/vmiserver" - -require 'VMIQueryClient' -require 'getoptlong' -require 'rdoc/usage' -require 'pp' - - -opts = GetoptLong.new( - ['--help', '-h',GetoptLong::NO_ARGUMENT], - ['--username', '-U',GetoptLong::REQUIRED_ARGUMENT], - ['--password', '-P',GetoptLong::REQUIRED_ARGUMENT], - ['--url', '-R',GetoptLong::REQUIRED_ARGUMENT], - ['--debug', '-D',GetoptLong::NO_ARGUMENT] - ) - -url = nil -username = nil -password = nil -auth = nil -debug = false - -begin - opts.each do |opt, arg| - case opt - when '--help' - RDoc::usage - when '--username' - username = arg - when '--password' - password = arg - when '--url' - url = arg - when '--debug' - debug = true - end - end -rescue Exception => e - exit -1 -end - -begin - vmi_client = VMIQueryClient::Client.new(url,username,password,debug) -rescue Exception => e - puts "#{$0}: #{e.message}" - exit -1 -end - -vmi_client.get_images - -exit 0 - diff --git a/src/cloud/vmi/commands/vmi-get-network b/src/cloud/vmi/commands/vmi-get-network deleted file mode 100755 index 21c1297284..0000000000 --- a/src/cloud/vmi/commands/vmi-get-network +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env ruby - -# == Synopsis -# vmi-get-network -# -# Retrieves the VMI representation of a Virtual Network -# -# == Usage -# -# vmi-post-network [OPTIONS] NETWORK-ID -# -# -h, --help: -# show help -# -# --username , -U : -# The username of the user -# -# --password , -P : -# The password of the user -# -# --url , -U : -# Set url as the web service url to use -# -# --debug, -D -# Enables verbosity -# -# NETWORK-ID Network Identifier - -# -------------------------------------------------------------------------- # -# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad # -# Complutense de Madrid (dsa-research.org) # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -ONE_LOCATION=ENV["ONE_LOCATION"] - -if !ONE_LOCATION - RUBY_LIB_LOCATION="/usr/lib/one/ruby" -else - RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" - TEMPLATES_LOCATION=ONE_LOCATION+"/etc/vmi_templates" - CONF_LOCATION=ONE_LOCATION+"/etc" -end - -$: << RUBY_LIB_LOCATION -$: << RUBY_LIB_LOCATION+"/vmiserver" - -require 'VMIQueryClient' -require 'getoptlong' -require 'rdoc/usage' -require 'pp' - - -opts = GetoptLong.new( - ['--help', '-h',GetoptLong::NO_ARGUMENT], - ['--username', '-U',GetoptLong::REQUIRED_ARGUMENT], - ['--password', '-P',GetoptLong::REQUIRED_ARGUMENT], - ['--url', '-R',GetoptLong::REQUIRED_ARGUMENT], - ['--debug', '-D',GetoptLong::NO_ARGUMENT] - ) - -url = nil -username = nil -password = nil -auth = nil -debug = false - -begin - opts.each do |opt, arg| - case opt - when '--help' - RDoc::usage - when '--username' - username = arg - when '--password' - password = arg - when '--url' - url = arg - when '--debug' - debug = true - end - end -rescue Exception => e - exit -1 -end - -network_id = ARGV.shift - -if !network_id - puts "#{$0}: missing NETWORK-ID parameter or file not found" - exit -1 -end - -begin - vmi_client = VMIQueryClient::Client.new(url,username,password,debug) -rescue Exception => e - puts "#{$0}: #{e.message}" - exit -1 -end - -vmi_client.get_network(network_id) - -exit 0 - diff --git a/src/cloud/vmi/commands/vmi-get-networks b/src/cloud/vmi/commands/vmi-get-networks deleted file mode 100755 index b097498789..0000000000 --- a/src/cloud/vmi/commands/vmi-get-networks +++ /dev/null @@ -1,107 +0,0 @@ -#!/usr/bin/env ruby - -# == Synopsis -# vmi-get-networks -# -# Retrieves all availables networks -# -# == Usage -# -# vmi-get-networks [OPTIONS] -# -# -h, --help: -# show help -# -# --username , -U : -# The username of the user -# -# --password , -P : -# The password of the user -# -# --url , -U : -# Set url as the web service url to use -# -# --debug, -D -# Enables verbosity -# - -# -------------------------------------------------------------------------- # -# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad # -# Complutense de Madrid (dsa-research.org) # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -ONE_LOCATION=ENV["ONE_LOCATION"] - -if !ONE_LOCATION - RUBY_LIB_LOCATION="/usr/lib/one/ruby" -else - RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" - TEMPLATES_LOCATION=ONE_LOCATION+"/etc/vmi_templates" - CONF_LOCATION=ONE_LOCATION+"/etc" -end - -$: << RUBY_LIB_LOCATION -$: << RUBY_LIB_LOCATION+"/vmiserver" - -require 'VMIQueryClient' -require 'getoptlong' -require 'rdoc/usage' -require 'pp' - - -opts = GetoptLong.new( - ['--help', '-h',GetoptLong::NO_ARGUMENT], - ['--username', '-U',GetoptLong::REQUIRED_ARGUMENT], - ['--password', '-P',GetoptLong::REQUIRED_ARGUMENT], - ['--url', '-R',GetoptLong::REQUIRED_ARGUMENT], - ['--debug', '-D',GetoptLong::NO_ARGUMENT] - ) - -url = nil -username = nil -password = nil -auth = nil -debug = false - -begin - opts.each do |opt, arg| - case opt - when '--help' - RDoc::usage - when '--username' - username = arg - when '--password' - password = arg - when '--url' - url = arg - when '--debug' - debug = true - end - end -rescue Exception => e - exit -1 -end - -begin - vmi_client = VMIQueryClient::Client.new(url,username,password,debug) -rescue Exception => e - puts "#{$0}: #{e.message}" - exit -1 -end - -vmi_client.get_networks - -exit 0 - diff --git a/src/cloud/vmi/commands/vmi-get-vm b/src/cloud/vmi/commands/vmi-get-vm deleted file mode 100755 index 9bbcf967be..0000000000 --- a/src/cloud/vmi/commands/vmi-get-vm +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/env ruby - -# == Synopsis -# vmi-get-vm -# -# Retrieves the VMI representation of a Virtual Machine -# -# == Usage -# -# vmi-get-vm [OPTIONS] VM-ID -# -# -h, --help: -# show help -# -# --username , -U : -# The username of the user -# -# --password , -P : -# The password of the user -# -# --url , -U : -# Set url as the web service url to use -# -# --debug, -D -# Enables verbosity -# -# VM-ID VM Identifier - -# -------------------------------------------------------------------------- # -# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad # -# Complutense de Madrid (dsa-research.org) # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -ONE_LOCATION=ENV["ONE_LOCATION"] - -if !ONE_LOCATION - RUBY_LIB_LOCATION="/usr/lib/one/ruby" -else - RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" - TEMPLATES_LOCATION=ONE_LOCATION+"/etc/vmi_templates" - CONF_LOCATION=ONE_LOCATION+"/etc" -end - -$: << RUBY_LIB_LOCATION -$: << RUBY_LIB_LOCATION+"/vmiserver" - -require 'VMIQueryClient' -require 'getoptlong' -require 'rdoc/usage' -require 'pp' - - -opts = GetoptLong.new( - ['--help', '-h',GetoptLong::NO_ARGUMENT], - ['--username', '-U',GetoptLong::REQUIRED_ARGUMENT], - ['--password', '-P',GetoptLong::REQUIRED_ARGUMENT], - ['--url', '-R',GetoptLong::REQUIRED_ARGUMENT], - ['--debug', '-D',GetoptLong::NO_ARGUMENT] - ) - -url = nil -username = nil -password = nil -debug = false - -begin - opts.each do |opt, arg| - case opt - when '--help' - RDoc::usage - when '--username' - username = arg - when '--password' - password = arg - when '--url' - url = arg - when '--debug' - debug = true - end - end -rescue Exception => e - exit -1 -end - -vm_id = ARGV.shift - -if !vm_id - puts "#{$0}: missing VM-ID parameter or file not found" - exit -1 -end - -begin - vmi_client = VMIQueryClient::Client.new(url,username,password,debug) -rescue Exception => e - puts "#{$0}: #{e.message}" - exit -1 -end - -vmi_client.get_vm(vm_id) - -exit 0 - diff --git a/src/cloud/vmi/commands/vmi-get-vms b/src/cloud/vmi/commands/vmi-get-vms deleted file mode 100755 index a649248241..0000000000 --- a/src/cloud/vmi/commands/vmi-get-vms +++ /dev/null @@ -1,107 +0,0 @@ -#!/usr/bin/env ruby - -# == Synopsis -# vmi-get-vms -# -# Retrieves all availables Virtual Machines -# -# == Usage -# -# vmi-get-vms [OPTIONS] -# -# -h, --help: -# show help -# -# --username , -U : -# The username of the user -# -# --password , -P : -# The password of the user -# -# --url , -U : -# Set url as the web service url to use -# -# --debug, -D -# Enables verbosity -# - -# -------------------------------------------------------------------------- # -# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad # -# Complutense de Madrid (dsa-research.org) # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -ONE_LOCATION=ENV["ONE_LOCATION"] - -if !ONE_LOCATION - RUBY_LIB_LOCATION="/usr/lib/one/ruby" -else - RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" - TEMPLATES_LOCATION=ONE_LOCATION+"/etc/vmi_templates" - CONF_LOCATION=ONE_LOCATION+"/etc" -end - -$: << RUBY_LIB_LOCATION -$: << RUBY_LIB_LOCATION+"/vmiserver" - -require 'VMIQueryClient' -require 'getoptlong' -require 'rdoc/usage' -require 'pp' - - -opts = GetoptLong.new( - ['--help', '-h',GetoptLong::NO_ARGUMENT], - ['--username', '-U',GetoptLong::REQUIRED_ARGUMENT], - ['--password', '-P',GetoptLong::REQUIRED_ARGUMENT], - ['--url', '-R',GetoptLong::REQUIRED_ARGUMENT], - ['--debug', '-D',GetoptLong::NO_ARGUMENT] - ) - -url = nil -username = nil -password = nil -auth = nil -debug = false - -begin - opts.each do |opt, arg| - case opt - when '--help' - RDoc::usage - when '--username' - username = arg - when '--password' - password = arg - when '--url' - url = arg - when '--debug' - debug = true - end - end -rescue Exception => e - exit -1 -end - -begin - vmi_client = VMIQueryClient::Client.new(url,username,password,debug) -rescue Exception => e - puts "#{$0}: #{e.message}" - exit -1 -end - -vmi_client.get_vms - -exit 0 - diff --git a/src/cloud/vmi/commands/vmi-post-image b/src/cloud/vmi/commands/vmi-post-image deleted file mode 100755 index 91b03251f7..0000000000 --- a/src/cloud/vmi/commands/vmi-post-image +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env ruby - -# == Synopsis -# vmi-post-image -# -# Uploads an image for use with an OpenNebula Cloud. -# -# == Usage -# -# vmi-post-image [OPTIONS] VMI-XML -# -# -h, --help: -# show help -# -# --username , -U : -# The username of the user -# -# --password , -P : -# The password of the user -# -# --url , -U : -# Set url as the web service url to use -# -# --debug, -D -# Enables verbosity -# -# VMI-XML Path to the xml file containing the VMI description of the image - -# -------------------------------------------------------------------------- # -# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad # -# Complutense de Madrid (dsa-research.org) # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -ONE_LOCATION=ENV["ONE_LOCATION"] - -if !ONE_LOCATION - RUBY_LIB_LOCATION="/usr/lib/one/ruby" -else - RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" - TEMPLATES_LOCATION=ONE_LOCATION+"/etc/vmi_templates" - CONF_LOCATION=ONE_LOCATION+"/etc" -end - -$: << RUBY_LIB_LOCATION -$: << RUBY_LIB_LOCATION+"/vmiserver" - -require 'VMIQueryClient' -require 'getoptlong' -require 'rdoc/usage' -require 'pp' - - -opts = GetoptLong.new( - ['--help', '-h',GetoptLong::NO_ARGUMENT], - ['--username', '-U',GetoptLong::REQUIRED_ARGUMENT], - ['--password', '-P',GetoptLong::REQUIRED_ARGUMENT], - ['--url', '-R',GetoptLong::REQUIRED_ARGUMENT], - ['--debug', '-D',GetoptLong::NO_ARGUMENT] - ) - -url = nil -username = nil -password = nil -auth = nil -debug = false - -begin - opts.each do |opt, arg| - case opt - when '--help' - RDoc::usage - when '--username' - username = arg - when '--password' - password = arg - when '--url' - url = arg - when '--debug' - debug = true - end - end -rescue Exception => e - exit -1 -end - -image_xml = ARGV.shift - -if !image_xml || !File.exists?(image_xml) - puts "#{$0}: missing VMI-XML parameter or file not found" - exit -1 -end - -begin - vmi_client = VMIQueryClient::Client.new(url,username,password,debug) -rescue Exception => e - puts "#{$0}: #{e.message}" - exit -1 -end - -vmi_client.post_image(image_xml) - -exit 0 - diff --git a/src/cloud/vmi/commands/vmi-post-network b/src/cloud/vmi/commands/vmi-post-network deleted file mode 100755 index 36ce74ae75..0000000000 --- a/src/cloud/vmi/commands/vmi-post-network +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env ruby - -# == Synopsis -# vmi-post-network -# -# Creates a virtual network -# -# == Usage -# -# vmi-post-network [OPTIONS] VMI-XML -# -# -h, --help: -# show help -# -# --username , -U : -# The username of the user -# -# --password , -P : -# The password of the user -# -# --url , -U : -# Set url as the web service url to use -# -# --debug, -D -# Enables verbosity -# -# VMI-XML Path to the xml file containing the VMI description of the Virtual Network - -# -------------------------------------------------------------------------- # -# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad # -# Complutense de Madrid (dsa-research.org) # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -ONE_LOCATION=ENV["ONE_LOCATION"] - -if !ONE_LOCATION - RUBY_LIB_LOCATION="/usr/lib/one/ruby" -else - RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" - TEMPLATES_LOCATION=ONE_LOCATION+"/etc/vmi_templates" - CONF_LOCATION=ONE_LOCATION+"/etc" -end - -$: << RUBY_LIB_LOCATION -$: << RUBY_LIB_LOCATION+"/vmiserver" - -require 'VMIQueryClient' -require 'getoptlong' -require 'rdoc/usage' -require 'pp' - - -opts = GetoptLong.new( - ['--help', '-h',GetoptLong::NO_ARGUMENT], - ['--username', '-U',GetoptLong::REQUIRED_ARGUMENT], - ['--password', '-P',GetoptLong::REQUIRED_ARGUMENT], - ['--url', '-R',GetoptLong::REQUIRED_ARGUMENT], - ['--debug', '-D',GetoptLong::NO_ARGUMENT] - ) - -url = nil -username = nil -password = nil -auth = nil -debug = false - -begin - opts.each do |opt, arg| - case opt - when '--help' - RDoc::usage - when '--username' - username = arg - when '--password' - password = arg - when '--url' - url = arg - when '--debug' - debug = true - end - end -rescue Exception => e - exit -1 -end - -network_xml = ARGV.shift - -if !network_xml || !File.exists?(network_xml) - puts "#{$0}: missing VMI-XML parameter or file not found" - exit -1 -end - -begin - vmi_client = VMIQueryClient::Client.new(url,username,password,debug) -rescue Exception => e - puts "#{$0}: #{e.message}" - exit -1 -end - -vmi_client.post_network(network_xml) - -exit 0 - diff --git a/src/cloud/vmi/commands/vmi-post-vm b/src/cloud/vmi/commands/vmi-post-vm deleted file mode 100755 index f67b255b5a..0000000000 --- a/src/cloud/vmi/commands/vmi-post-vm +++ /dev/null @@ -1,127 +0,0 @@ -#!/usr/bin/env ruby - -# == Synopsis -# vmi-post-vm -# -# Creates a new Virtual Machine from its VMI representation -# -# == Usage -# -# vmi-post-vm [OPTIONS] VMI-XML -# -# -h, --help: -# show help -# -# --username , -U : -# The username of the user -# -# --password , -P : -# The password of the user -# -# --url , -U : -# Set url as the web service url to use -# -# --debug, -D -# Enables verbosity -# -# --instance-type, -T -# Specifies the type of Virtual Machine we want -# -# VMI-XML Path to the xml file containing the VMI description of the Virtual Machine - -# -------------------------------------------------------------------------- # -# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad # -# Complutense de Madrid (dsa-research.org) # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -ONE_LOCATION=ENV["ONE_LOCATION"] - -if !ONE_LOCATION - RUBY_LIB_LOCATION="/usr/lib/one/ruby" -else - RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" - TEMPLATES_LOCATION=ONE_LOCATION+"/etc/vmi_templates" - CONF_LOCATION=ONE_LOCATION+"/etc" -end - -$: << RUBY_LIB_LOCATION -$: << RUBY_LIB_LOCATION+"/vmiserver" - -require 'VMIQueryClient' -require 'getoptlong' -require 'rdoc/usage' -require 'pp' - - -opts = GetoptLong.new( - ['--help', '-h',GetoptLong::NO_ARGUMENT], - ['--username', '-U',GetoptLong::REQUIRED_ARGUMENT], - ['--password', '-P',GetoptLong::REQUIRED_ARGUMENT], - ['--url', '-R',GetoptLong::REQUIRED_ARGUMENT], - ['--instance-type','-T',GetoptLong::REQUIRED_ARGUMENT], - ['--debug', '-D',GetoptLong::NO_ARGUMENT] - ) - -url = nil -username = nil -password = nil -auth = nil -type = nil -debug = false - -begin - opts.each do |opt, arg| - case opt - when '--help' - RDoc::usage - when '--username' - username = arg - when '--password' - password = arg - when '--url' - url = arg - when '--instance-type' - type = arg - when '--debug' - debug = true - end - end -rescue Exception => e - exit -1 -end - -if !type - puts "#{$0}: missing compulsory instance type" - exit -1 -end - -vm_xml = ARGV.shift - -if !vm_xml || !File.exists?(vm_xml) - puts "#{$0}: missing VMI-XML parameter or file not found" - exit -1 -end - -begin - vmi_client = VMIQueryClient::Client.new(url,username,password,debug) -rescue Exception => e - puts "#{$0}: #{e.message}" - exit -1 -end - -vmi_client.post_vms(type, vm_xml) - -exit 0 - diff --git a/src/cloud/vmi/commands/vmi-put-vm b/src/cloud/vmi/commands/vmi-put-vm deleted file mode 100755 index 8c9dce04ac..0000000000 --- a/src/cloud/vmi/commands/vmi-put-vm +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/env ruby - -# == Synopsis -# vmi-put-vms -# -# Updates the representation of a Virtual Machine -# -# == Usage -# -# vmi-put-vms [OPTIONS] VMI-XML -# -# -h, --help: -# show help -# -# --username , -U : -# The username of the user -# -# --password , -P : -# The password of the user -# -# --url , -U : -# Set url as the web service url to use -# -# --debug, -D -# Enables verbosity -# -# -# VMI-XML Path to the xml file containing the VMI description of the Virtual Machine - -# -------------------------------------------------------------------------- # -# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad # -# Complutense de Madrid (dsa-research.org) # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -ONE_LOCATION=ENV["ONE_LOCATION"] - -if !ONE_LOCATION - RUBY_LIB_LOCATION="/usr/lib/one/ruby" -else - RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" - TEMPLATES_LOCATION=ONE_LOCATION+"/etc/vmi_templates" - CONF_LOCATION=ONE_LOCATION+"/etc" -end - -$: << RUBY_LIB_LOCATION -$: << RUBY_LIB_LOCATION+"/vmiserver" - -require 'VMIQueryClient' -require 'getoptlong' -require 'rdoc/usage' -require 'pp' - - -opts = GetoptLong.new( - ['--help', '-h',GetoptLong::NO_ARGUMENT], - ['--username', '-U',GetoptLong::REQUIRED_ARGUMENT], - ['--password', '-P',GetoptLong::REQUIRED_ARGUMENT], - ['--url', '-R',GetoptLong::REQUIRED_ARGUMENT], - ['--debug', '-D',GetoptLong::NO_ARGUMENT] - ) - -url = nil -username = nil -password = nil -auth = nil -type = nil -debug = false - -begin - opts.each do |opt, arg| - case opt - when '--help' - RDoc::usage - when '--username' - username = arg - when '--password' - password = arg - when '--url' - url = arg - when '--debug' - debug = true - end - end -rescue Exception => e - exit -1 -end - -vm_xml = ARGV.shift - -if !vm_xml || !File.exists?(vm_xml) - puts "#{$0}: missing VMI-XML parameter or file not found" - exit -1 -end - -begin - vmi_client = VMIQueryClient::Client.new(url,username,password,debug) -rescue Exception => e - puts "#{$0}: #{e.message}" - exit -1 -end - -vmi_client.put_vm(vm_xml) - -exit 0 - diff --git a/src/cloud/vmi/lib/VMIConfiguration.rb b/src/cloud/vmi/lib/VMIConfiguration.rb deleted file mode 100644 index 7a1106aac8..0000000000 --- a/src/cloud/vmi/lib/VMIConfiguration.rb +++ /dev/null @@ -1,73 +0,0 @@ - -class VMIConfiguration - - NAME_REG=/[\w\d_-]+/ - VARIABLE_REG=/\s*(#{NAME_REG})\s*=\s*/ - SIMPLE_VARIABLE_REG=/#{VARIABLE_REG}([^\[]+?)(#.*)?/ - SINGLE_VARIABLE_REG=/^#{SIMPLE_VARIABLE_REG}$/ - ARRAY_VARIABLE_REG=/^#{VARIABLE_REG}\[(.*?)\]/m - - def initialize(file) - @conf=parse_conf(file) - end - - def add_value(conf, key, value) - if conf[key] - if !conf[key].kind_of?(Array) - conf[key]=[conf[key]] - end - conf[key]< e - error = OpenNebula::Error.new(e.message) - return error - end - - puts curl.body_str - end - - ####################################################################### - # Retieves the pool of Virtual Machines - ####################################################################### - def get_vms - curl=Curl::Easy.new(@endpoint+"/vms") - curl.userpwd=@vmiauth - curl.verbose=true if @debug - - begin - curl.http_get - rescue Exception => e - error = OpenNebula::Error.new(e.message) - return error - end - puts curl.body_str - end - - ####################################################################### - # Post a new Network to the VN Pool - # :xmlfile xml description of the Virtual Network - ####################################################################### - def post_network(xmlfile) - curl=Curl::Easy.new(@endpoint+"/networks") - curl.userpwd=@vmiauth - curl.verbose=true if @debug - - xml=File.read(xmlfile) - - begin - curl.http_post( - Curl::PostField.content('vmixml', xml) - ) - rescue Exception => e - error = OpenNebula::Error.new(e.message) - return error - end - - puts curl.body_str - end - - ####################################################################### - # Retieves the pool of Virtual Networks - ####################################################################### - def get_networks - curl=Curl::Easy.new(@endpoint+"/networks") - curl.userpwd=@vmiauth - curl.verbose=true if @debug - - begin - curl.http_get - rescue Exception => e - error = OpenNebula::Error.new(e.message) - return error - end - puts curl.body_str - end - - ####################################################################### - # Post a new Image to the Image Pool - # :xmlfile - ####################################################################### - def post_image(xmlfile) - xml=File.read(xmlfile) - image_info=Crack::XML.parse(xml) - - curl=Curl::Easy.new(@endpoint+"/images") - curl.userpwd=@vmiauth - curl.verbose=true if @debug - curl.multipart_form_post = true - - file_path = image_info['IMAGE']['URL'] - - m=file_path.match(/^\w+:\/\/(.*)$/) - - if m - file_path="/"+m[1] - end - - begin - curl.http_post( - Curl::PostField.content('vmixml', xml), - Curl::PostField.file('file', file_path) - ) - rescue Exception => e - error = OpenNebula::Error.new(e.message) - return error - end - - puts curl.body_str - end - - ####################################################################### - # Retieves the pool of Images owned by the user - ####################################################################### - def get_images - curl=Curl::Easy.new(@endpoint+"/images") - curl.userpwd=@vmiauth - curl.verbose=true if @debug - - begin - curl.http_get - rescue Exception => e - error = OpenNebula::Error.new(e.message) - return error - end - puts curl.body_str - end - - ####################################################################### - # Entity Resource Request Methods - ####################################################################### - - ####################################################################### - # :id VM identifier - ####################################################################### - def get_vm(id) - curl=Curl::Easy.new(@endpoint+"/vms/" + id.to_s) - curl.userpwd=@vmiauth - curl.verbose=true if @debug - - begin - curl.http_get - rescue Exception => e - error = OpenNebula::Error.new(e.message) - return error - end - pp curl.body_str - end - - ####################################################################### - # Puts a new VM representation in order to change VM state - # :xmlfile VM VMI xml representation - ####################################################################### - def put_vm(id,xmlfile) - xml=File.read(xmlfile) - vm_info=Crack::XML.parse(xml) - - curl=Curl::Easy.new(@endpoint+"/vms/"+id) - curl.userpwd=@vmiauth - curl.verbose=true if @debug - - begin - curl.http_post(Curl::PostField.content('vmixml', xml)) - rescue Exception => e - error = OpenNebula::Error.new(e.message) - return error - end - - puts curl.body_str - end - - ####################################################################### - # :id VM identifier - ####################################################################### - def delete_vm(id) - curl=Curl::Easy.new(@endpoint+"/vms/" + id.to_s) - curl.userpwd=@vmiauth - curl.verbose=true if @debug - - begin - curl.http_delete - rescue Exception => e - error = OpenNebula::Error.new(e.message) - return error - end - pp curl.body_str - end - - ####################################################################### - # Retrieves a Virtual Network - # :id Virtual Network identifier - ####################################################################### - def get_network(id) - curl=Curl::Easy.new(@endpoint+"/networks/" + id.to_s) - curl.userpwd=@vmiauth - curl.verbose=true if @debug - - begin - curl.http_get - rescue Exception => e - error = OpenNebula::Error.new(e.message) - return error - end - pp curl.body_str - end - - ####################################################################### - # :id VM identifier - ####################################################################### - def delete_network(id) - curl=Curl::Easy.new(@endpoint+"/networks/" + id.to_s) - curl.userpwd=@vmiauth - curl.verbose=true if @debug - - begin - curl.http_delete - rescue Exception => e - error = OpenNebula::Error.new(e.message) - return error - end - pp curl.body_str - end - - ####################################################################### - # Retieves an Image - # :image_uuid Image identifier - ####################################################################### - def get_image(image_uuid) - curl=Curl::Easy.new(@endpoint+"/images/"+image_uuid) - curl.userpwd=@vmiauth - curl.verbose=true if @debug - - begin - curl.http_get - rescue Exception => e - error = OpenNebula::Error.new(e.message) - return error - end - puts curl.body_str - end - end -end - -if $0 == __FILE__ - vmiqc = VMIQueryClient::Client.new("http://localhost:4567","tinova","opennebula",true) - #vmiqc.get_networks - #vmiqc.post_network("vnxml") - #vmiqc.post_image("imagexml") - #vmiqc.get_images - #vmiqc.get_image("988117f0-752a-012c-f16c-00254bd6f386") - #vmiqc.post_vms("small","vmxml") - #vmiqc.delete_vm("11") - #vmiqc.delete_network("1") - #vmiqc.put_vm("8","vmxml") -end - - - - diff --git a/src/cloud/vmi/lib/VirtualMachinePoolVMI.rb b/src/cloud/vmi/lib/VirtualMachinePoolVMI.rb deleted file mode 100644 index 2b5ecddba4..0000000000 --- a/src/cloud/vmi/lib/VirtualMachinePoolVMI.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'OpenNebula' -require 'Crack' - -include OpenNebula - -class VirtualMachinePoolVMI < VirtualMachinePool - # Creates the VMI representation of a Virtual Machine Pool - def to_vmi(base_url) - pool_hash=Crack::XML.parse(to_xml) - vmi_xml = "" - - pool_hash['VM_POOL']['VM'].each{|vm| - vmi_xml+='' - } - vmi_xml += "" - end -end - diff --git a/src/cloud/vmi/lib/VirtualMachineVMI.rb b/src/cloud/vmi/lib/VirtualMachineVMI.rb deleted file mode 100644 index 912e366e2b..0000000000 --- a/src/cloud/vmi/lib/VirtualMachineVMI.rb +++ /dev/null @@ -1,69 +0,0 @@ -require 'OpenNebula' - -include OpenNebula - -class VirtualMachineVMI < VirtualMachine - # Creates the VMI representation of a Virtual Machine - def to_vmi - vmi_xml = "" - vmi_xml += "" + id.to_s + "" - vmi_xml += "" + self['NAME'] + "" - vmi_xml += "" + self['VMI_SIZE_TYPE'] + "" if self['VMI_SIZE_TYPE'] - vmi_xml += "" + state_str + "" - - # Now let's parse the template - template=self.to_hash("TEMPLATE") - - template['DISK']=[template['DISK']].flatten - - if template['DISK'] - - vmi_xml += "" - - template['DISK'].each{|disk| - case disk['TYPE'] - when "disk" then - vmi_xml += "" - when "swap" then - vmi_xml += "" - when "fs" then - vmi_xml += "" - end - } - - vmi_xml += "" - end - - template['NIC']=[template['NIC']].flatten - - if template['NIC'] - vmi_xml += "" - - template['NIC'].each{|nic| - - vmi_xml += "' - } - - vmi_xml += "" - end -end \ No newline at end of file diff --git a/src/cloud/vmi/lib/VirtualNetworkVMI.rb b/src/cloud/vmi/lib/VirtualNetworkVMI.rb deleted file mode 100644 index 1df87d7dd2..0000000000 --- a/src/cloud/vmi/lib/VirtualNetworkVMI.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'OpenNebula' -require 'Crack' - -include OpenNebula - -class VirtualNetworkVMI < VirtualNetwork - # Creates the VMI representation of a Virtual Network - def to_vmi() - vn_hash=Crack::XML.parse(to_xml) - vmi_xml = "" - - vmi_xml += "" + vn_hash['VNET']['ID'].strip + "" - vmi_xml += "" + vn_hash['VNET']['NAME'].strip + "" - vmi_xml += "
" + vn_hash['VNET']['TEMPLATE']['NETWORK_ADDRESS'].strip + "
" - vmi_xml += "" + vn_hash['VNET']['TEMPLATE']['NETWORK_SIZE'].strip + "" - - vmi_xml += "
" - end - - def to_one_template(network_hash, bridge) - one_template = "NAME=" + network_hash['NAME'] + "\n" - one_template += "TYPE=RANGED\n" - one_template += "BRIDGE=" + bridge + "\n" - one_template += "NETWORK_ADDRESS=" + network_hash['ADDRESS'] + "\n" - one_template += "NETWORK_SIZE=" + network_hash['SIZE'] + "\n" - end -end - diff --git a/src/cloud/vmi/templates/large.erb b/src/cloud/vmi/templates/large.erb deleted file mode 100644 index 67bb5f8632..0000000000 --- a/src/cloud/vmi/templates/large.erb +++ /dev/null @@ -1,45 +0,0 @@ -NAME = <%= @vm_info['NAME']%> - -CPU = 8 -MEMORY = 8192 - -OS = [ kernel = /vmlinuz, - initrd = /initrd.img, - root = sda1, - kernel_cmd = "ro xencons=tty console=tty1"] -<% @vm_info['DISKS'].each do |key, image| - -case key - - when "SWAP" -%> -DISK = [ type = "swap", - size=<%= image['size']%>, - dev=<%= image['dev']%> ] -<% - when "DISK" -%> -DISK = [ type = "disk", - dev=<%= image['dev']%>, - source=<%= image['source']%>, - image_id=<%= image['image']%> ] -<% - when "FS" -%> -DISK = [ type = "fs", - dev=<%= image['dev']%>, - size=<%= image['size']%>, - format=<%= CONFIG[:fs_format]||"ext3"%> ] -<% end %> -<% end %> -<% @vm_info['NICS']['NIC'].each do |nic| %> -NIC = [ -<% if nic['ip'] %> - IP=<%= nic['ip'] %>, -<% end %> - NETWORK=<%= nic['network']%>, - NETWORK_ID=<%= nic['network_id'] %> -] -<% end %> -INSTANCE_TYPE = <%= @vm_info[:instance_type ]%> - diff --git a/src/cloud/vmi/templates/medium.erb b/src/cloud/vmi/templates/medium.erb deleted file mode 100644 index 91bfe55ab6..0000000000 --- a/src/cloud/vmi/templates/medium.erb +++ /dev/null @@ -1,45 +0,0 @@ -NAME = <%= @vm_info['NAME']%> - -CPU = 4 -MEMORY = 4096 - -OS = [ kernel = /vmlinuz, - initrd = /initrd.img, - root = sda1, - kernel_cmd = "ro xencons=tty console=tty1"] -<% @vm_info['DISKS'].each do |key, image| - -case key - - when "SWAP" -%> -DISK = [ type = "swap", - size=<%= image['size']%>, - dev=<%= image['dev']%> ] -<% - when "DISK" -%> -DISK = [ type = "disk", - dev=<%= image['dev']%>, - source=<%= image['source']%>, - image_id=<%= image['image']%> ] -<% - when "FS" -%> -DISK = [ type = "fs", - dev=<%= image['dev']%>, - size=<%= image['size']%>, - format=<%= CONFIG[:fs_format]||"ext3"%> ] -<% end %> -<% end %> -<% @vm_info['NICS']['NIC'].each do |nic| %> -NIC = [ -<% if nic['ip'] %> - IP=<%= nic['ip'] %>, -<% end %> - NETWORK=<%= nic['network']%>, - NETWORK_ID=<%= nic['network_id'] %> -] -<% end %> -INSTANCE_TYPE = <%= @vm_info[:instance_type ]%> - diff --git a/src/cloud/vmi/templates/small.erb b/src/cloud/vmi/templates/small.erb deleted file mode 100644 index db28df9dc9..0000000000 --- a/src/cloud/vmi/templates/small.erb +++ /dev/null @@ -1,45 +0,0 @@ -NAME = <%= @vm_info['NAME']%> - -CPU = 1 -MEMORY = 1024 - -OS = [ kernel = /vmlinuz, - initrd = /initrd.img, - root = sda1, - kernel_cmd = "ro xencons=tty console=tty1"] -<% @vm_info['DISKS'].each do |key, image| - -case key - - when "SWAP" -%> -DISK = [ type = "swap", - size=<%= image['size']%>, - dev=<%= image['dev']%> ] -<% - when "DISK" -%> -DISK = [ type = "disk", - dev=<%= image['dev']%>, - source=<%= image['source']%>, - image_id=<%= image['image']%> ] -<% - when "FS" -%> -DISK = [ type = "fs", - dev=<%= image['dev']%>, - size=<%= image['size']%>, - format=<%= CONFIG[:fs_format]||"ext3"%> ] -<% end %> -<% end %> -<% @vm_info['NICS']['NIC'].each do |nic| %> -NIC = [ -<% if nic['ip'] %> - IP=<%= nic['ip'] %>, -<% end %> - NETWORK=<%= nic['network']%>, - NETWORK_ID=<%= nic['network_id'] %> -] -<% end %> -INSTANCE_TYPE = <%= @vm_info[:instance_type ]%> - diff --git a/src/cloud/vmi/vmi-server.conf b/src/cloud/vmi/vmi-server.conf deleted file mode 100644 index 5a10b4ec5a..0000000000 --- a/src/cloud/vmi/vmi-server.conf +++ /dev/null @@ -1,26 +0,0 @@ -# OpenNebula administrator user -USER=oneadmin -PASSWORD= - -# OpenNebula server contact information -ONE_XMLRPC=http://localhost:2633/RPC2 - -# Host and port where the vmi server will run -SERVER= -PORT=4567 - -# Configuration for the image repository -DATABASE=/var/vmi.db -IMAGE_DIR= - -# Configuration for OpenNebula's Virtual Networks -BRIDGE= - -# Default format for FS -FS_FORMAT=ext3 - -# VM types allowed and its template file (inside templates directory) -VM_TYPE=[NAME=small, TEMPLATE=small.erb] -VM_TYPE=[NAME=medium, TEMPLATE=medium.erb] -VM_TYPE=[NAME=large, TEMPLATE=large.erb] -