mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[ninefold|compute] VM Operations + dependencies.
This commit is contained in:
parent
81ae21b0c8
commit
0f36aa31b5
19 changed files with 566 additions and 23 deletions
|
@ -25,6 +25,7 @@ module Fog
|
|||
#model :user
|
||||
|
||||
request_path 'fog/compute/requests/ninefold'
|
||||
# General list-only stuff
|
||||
request :list_accounts
|
||||
request :list_events
|
||||
request :list_service_offerings
|
||||
|
@ -34,6 +35,23 @@ module Fog
|
|||
request :list_zones
|
||||
request :list_network_offerings
|
||||
request :list_resource_limits
|
||||
# Templates
|
||||
request :list_templates
|
||||
# Virtual Machines
|
||||
request :deploy_virtual_machine
|
||||
request :destroy_virtual_machine
|
||||
request :list_virtual_machines
|
||||
request :reboot_virtual_machine
|
||||
request :stop_virtual_machine
|
||||
request :start_virtual_machine
|
||||
request :change_service_for_virtual_machine
|
||||
request :reset_password_for_virtual_machine
|
||||
request :update_virtual_machine
|
||||
# Jobs
|
||||
request :list_async_jobs
|
||||
request :query_async_job_result
|
||||
# Networks
|
||||
request :list_networks
|
||||
|
||||
class Mock
|
||||
|
||||
|
@ -73,9 +91,10 @@ module Fog
|
|||
end
|
||||
|
||||
def request(command, params, options)
|
||||
params["response"] = "json"
|
||||
params['response'] = "json"
|
||||
req = "apiKey=#{@ninefold_compute_key}&command=#{command}&"
|
||||
req += URI.escape(params.sort.collect{|e| "#{e[0].to_s}=#{e[1].to_s}"}.join('&'))
|
||||
# convert params to strings for sort
|
||||
req += URI.escape(params.sort_by{|k,v| k.to_s }.collect{|e| "#{e[0].to_s}=#{e[1].to_s}"}.join('&'))
|
||||
encoded_signature = url_escape(encode_signature(req))
|
||||
|
||||
options = {
|
||||
|
@ -98,7 +117,7 @@ module Fog
|
|||
if response[k]
|
||||
response = response[k]
|
||||
elsif options[:response_type]
|
||||
response = options[:response_type]
|
||||
response = options[:response_type].new
|
||||
break
|
||||
else
|
||||
end
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
module Fog
|
||||
module Ninefold
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
def change_service_for_virtual_machine(options = {})
|
||||
request('changeServiceForVirtualMachine', options, :expects => [200],
|
||||
:response_prefix => 'changeserviceforvirtualmachineresponse/virtualmachine', :response_type => Hash)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def change_service_for_virtual_machine(*args)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -4,10 +4,20 @@ module Fog
|
|||
class Real
|
||||
|
||||
def deploy_virtual_machine(options = {})
|
||||
request('deployVirtualMachine', options, :expects => [202])
|
||||
request('deployVirtualMachine', options, :expects => [200],
|
||||
:response_prefix => 'deployvirtualmachineresponse', :response_type => Hash)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def deploy_virtual_machine(*args)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
23
lib/fog/compute/requests/ninefold/destroy_virtual_machine.rb
Normal file
23
lib/fog/compute/requests/ninefold/destroy_virtual_machine.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
module Fog
|
||||
module Ninefold
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
def destroy_virtual_machine(options = {})
|
||||
request('destroyVirtualMachine', options, :expects => [200],
|
||||
:response_prefix => 'destroyvirtualmachineresponse', :response_type => Hash)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def destroy_virtual_machine(*args)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
24
lib/fog/compute/requests/ninefold/list_async_jobs.rb
Normal file
24
lib/fog/compute/requests/ninefold/list_async_jobs.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
module Fog
|
||||
module Ninefold
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
def list_async_jobs(options = {})
|
||||
puts "about to perf request.."
|
||||
request('listAsyncJobs', options, :expects => [200],
|
||||
:response_prefix => 'listasyncjobsresponse/asyncjobs', :response_type => Array)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def list_async_jobs(*args)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
23
lib/fog/compute/requests/ninefold/list_networks.rb
Normal file
23
lib/fog/compute/requests/ninefold/list_networks.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
module Fog
|
||||
module Ninefold
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
def list_networks(options = {})
|
||||
request('listNetworks', options, :expects => [200],
|
||||
:response_prefix => 'listnetworksresponse/network', :response_type => Array)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def list_networks(*args)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -5,7 +5,7 @@ module Fog
|
|||
|
||||
def list_virtual_machines(options = {})
|
||||
request('listVirtualMachines', options, :expects => [200],
|
||||
:response_prefix => 'listvirtualmachinesresponse/virtualmachine')
|
||||
:response_prefix => 'listvirtualmachinesresponse/virtualmachine', :response_type => Array)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
23
lib/fog/compute/requests/ninefold/query_async_job_result.rb
Normal file
23
lib/fog/compute/requests/ninefold/query_async_job_result.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
module Fog
|
||||
module Ninefold
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
def query_async_job_result(options = {})
|
||||
request('queryAsyncJobResult', options, :expects => [200],
|
||||
:response_prefix => 'queryasyncjobresultresponse', :response_type => Array)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def query_async_job_result(*args)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
23
lib/fog/compute/requests/ninefold/reboot_virtual_machine.rb
Normal file
23
lib/fog/compute/requests/ninefold/reboot_virtual_machine.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
module Fog
|
||||
module Ninefold
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
def reboot_virtual_machine(options = {})
|
||||
request('rebootVirtualMachine', options, :expects => [200],
|
||||
:response_prefix => 'rebootvirtualmachineresponse', :response_type => Hash)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def reboot_virtual_machine(*args)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,23 @@
|
|||
module Fog
|
||||
module Ninefold
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
def reset_password_for_virtual_machine(options = {})
|
||||
request('resetPasswordForVirtualMachine', options, :expects => [200],
|
||||
:response_prefix => 'resetpasswordforvirtualmachineresponse', :response_type => Hash)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def change_service_for_virtual_machine(*args)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
23
lib/fog/compute/requests/ninefold/start_virtual_machine.rb
Normal file
23
lib/fog/compute/requests/ninefold/start_virtual_machine.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
module Fog
|
||||
module Ninefold
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
def start_virtual_machine(options = {})
|
||||
request('startVirtualMachine', options, :expects => [200],
|
||||
:response_prefix => 'startvirtualmachineresponse', :response_type => Hash)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def start_virtual_machine(*args)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
23
lib/fog/compute/requests/ninefold/stop_virtual_machine.rb
Normal file
23
lib/fog/compute/requests/ninefold/stop_virtual_machine.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
module Fog
|
||||
module Ninefold
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
def stop_virtual_machine(options = {})
|
||||
request('stopVirtualMachine', options, :expects => [200],
|
||||
:response_prefix => 'stopvirtualmachineresponse', :response_type => Hash)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def stop_virtual_machine(*args)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
23
lib/fog/compute/requests/ninefold/update_virtual_machine.rb
Normal file
23
lib/fog/compute/requests/ninefold/update_virtual_machine.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
module Fog
|
||||
module Ninefold
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
def update_virtual_machine(options = {})
|
||||
request('updateVirtualMachine', options, :expects => [200],
|
||||
:response_prefix => 'updatevirtualmachineresponse', :response_type => Hash)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def update_virtual_machine(*args)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
33
tests/compute/requests/ninefold/async_job_tests.rb
Normal file
33
tests/compute/requests/ninefold/async_job_tests.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
# This will fail until there are jobs in the system.
|
||||
|
||||
Shindo.tests('Ninfold::Compute | server requests', ['ninefold']) do
|
||||
|
||||
tests('success') do
|
||||
|
||||
tests("#list_async_jobs()").formats(Ninefold::Compute::Formats::Jobs::JOBS) do
|
||||
pending if Fog.mocking?
|
||||
jobs = Ninefold[:compute].list_async_jobs()
|
||||
unless jobs[0]
|
||||
raise "No async jobs in system yet - create a VM through web UI to create"
|
||||
end
|
||||
@jobid = jobs[0]['jobid']
|
||||
jobs
|
||||
end
|
||||
|
||||
tests("#query_async_job_result()").formats(Ninefold::Compute::Formats::Jobs::JOB_QUERY) do
|
||||
pending if Fog.mocking?
|
||||
Ninefold[:compute].query_async_job_result(:jobid => @jobid)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
||||
#tests("#deploy_virtual_machine()").raises(Excon::Errors::HTTPStatusError) do
|
||||
# pending if Fog.mocking?
|
||||
# Ninefold[:compute].deploy_virtual_machine
|
||||
#end
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -1,8 +1,16 @@
|
|||
class Ninefold
|
||||
module Compute
|
||||
module TestSupport
|
||||
# image img-9vxqi = Ubuntu Maverick 10.10 server
|
||||
IMAGE_IDENTIFER = "img-9vxqi"
|
||||
# 1CPU, 1.7GB RAM, 160GB Storage
|
||||
SERVICE_OFFERING = 67
|
||||
# alternate for testing -
|
||||
ALT_SERVICE_OFFERING = 68
|
||||
# XEN Basic Ubuntu 10.04 Server x64 PV r2.0
|
||||
TEMPLATE_ID = 421
|
||||
# Sydney
|
||||
ZONE_ID = 1
|
||||
# Max time to wait for job completion (2 mins)
|
||||
MAXWAIT = 2 * 60
|
||||
end
|
||||
module Formats
|
||||
module Lists
|
||||
|
@ -132,6 +140,126 @@ class Ninefold
|
|||
"max"=>Integer
|
||||
}]
|
||||
end
|
||||
module VirtualMachines
|
||||
PENDING_VIRTUAL_MACHINE = {"id" => Integer, "jobid" => Integer}
|
||||
ASYNC_VIRTUAL_MACHINE = {"jobid" => Integer}
|
||||
VIRTUAL_MACHINE = {
|
||||
"id"=>Integer,
|
||||
"name"=>String,
|
||||
"displayname"=>String,
|
||||
"account"=>String,
|
||||
"domainid"=>Integer,
|
||||
"domain"=>String,
|
||||
"created"=>String,
|
||||
"state"=>String,
|
||||
"haenable"=>Fog::Boolean,
|
||||
"zoneid"=>Integer,
|
||||
"zonename"=>String,
|
||||
"templateid"=>Integer,
|
||||
"templatename"=>String,
|
||||
"templatedisplaytext"=>String,
|
||||
"passwordenabled"=>Fog::Boolean,
|
||||
"serviceofferingid"=>Integer,
|
||||
"serviceofferingname"=>String,
|
||||
"cpunumber"=>Integer,
|
||||
"cpuspeed"=>Integer,
|
||||
"memory"=>Integer,
|
||||
"guestosid"=>Integer,
|
||||
"rootdeviceid"=>Integer,
|
||||
"rootdevicetype"=>String,
|
||||
"securitygroup"=>Array,
|
||||
"nic"=>[{
|
||||
"id"=>Integer,
|
||||
"networkid"=>Integer,
|
||||
"netmask"=>String,
|
||||
"gateway"=>String,
|
||||
"ipaddress"=>String,
|
||||
"traffictype"=>String,
|
||||
"type"=>String,
|
||||
"isdefault"=>Fog::Boolean,
|
||||
}],
|
||||
"hypervisor"=>String,
|
||||
"cpuused"=>String,
|
||||
"networkkbsread"=>Integer,
|
||||
"networkkbswrite"=>Integer
|
||||
}
|
||||
VIRTUAL_MACHINES = [VIRTUAL_MACHINE]
|
||||
end
|
||||
module Templates
|
||||
TEMPLATES = [{
|
||||
"id"=>Integer,
|
||||
"name"=>String,
|
||||
"displaytext"=>String,
|
||||
"ispublic"=>Fog::Boolean,
|
||||
"created"=>String,
|
||||
"isready"=>Fog::Boolean,
|
||||
"passwordenabled"=>Fog::Boolean,
|
||||
"format"=>String,
|
||||
"isfeatured"=>Fog::Boolean,
|
||||
"crossZones"=>Fog::Boolean,
|
||||
"ostypeid"=>Integer,
|
||||
"ostypename"=>String,
|
||||
"account"=>String,
|
||||
"zoneid"=>Integer,
|
||||
"zonename"=>String,
|
||||
"size"=>Integer,
|
||||
"templatetype"=>String,
|
||||
"hypervisor"=>String,
|
||||
"domain"=>String,
|
||||
"domainid"=>Integer,
|
||||
"isextractable"=>Fog::Boolean,
|
||||
}]
|
||||
end
|
||||
module Jobs
|
||||
JOB = {
|
||||
"jobid"=>Integer,
|
||||
"accountid"=>Integer,
|
||||
"userid"=>Integer,
|
||||
"cmd"=>String,
|
||||
"jobstatus"=>Integer,
|
||||
"jobprocstatus"=>Integer,
|
||||
"jobresultcode"=>Integer,
|
||||
"jobresult"=>Hash,
|
||||
"created"=>String
|
||||
}
|
||||
JOBS = [JOB]
|
||||
JOB_QUERY = {
|
||||
"jobid"=>Integer,
|
||||
"jobstatus"=>Integer,
|
||||
"jobprocstatus"=>Integer,
|
||||
"jobresultcode"=>Integer,
|
||||
"jobresulttype"=>String,
|
||||
"jobresult"=>Hash
|
||||
}
|
||||
end
|
||||
module Networks
|
||||
NETWORKS=[{"id"=>Integer,
|
||||
"name"=>String,
|
||||
"displaytext"=>String,
|
||||
"broadcastdomaintype"=>String,
|
||||
"traffictype"=>String,
|
||||
"zoneid"=>Integer,
|
||||
"networkofferingid"=>Integer,
|
||||
"networkofferingname"=>String,
|
||||
"networkofferingdisplaytext"=>String,
|
||||
"networkofferingavailability"=>String,
|
||||
"isshared"=>Fog::Boolean,
|
||||
"issystem"=>Fog::Boolean,
|
||||
"state"=>String,
|
||||
"related"=>Integer,
|
||||
"broadcasturi"=>String,
|
||||
"dns1"=>String,
|
||||
"dns2"=>String,
|
||||
"type"=>String,
|
||||
"account"=>String,
|
||||
"domainid"=>Integer,
|
||||
"domain"=>String,
|
||||
"isdefault"=>Fog::Boolean,
|
||||
"service"=>Array,
|
||||
"networkdomain"=>String,
|
||||
"securitygroupenabled"=>Fog::Boolean
|
||||
}]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
21
tests/compute/requests/ninefold/network_tests.rb
Normal file
21
tests/compute/requests/ninefold/network_tests.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
Shindo.tests('Ninfold::Compute | network requests', ['ninefold']) do
|
||||
|
||||
tests('success') do
|
||||
|
||||
tests("#list_networks()").formats(Ninefold::Compute::Formats::Networks::NETWORKS) do
|
||||
pending if Fog.mocking?
|
||||
Ninefold[:compute].list_networks()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
||||
#tests("#deploy_virtual_machine()").raises(Excon::Errors::HTTPStatusError) do
|
||||
# pending if Fog.mocking?
|
||||
# Ninefold[:compute].deploy_virtual_machine
|
||||
#end
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -1,16 +0,0 @@
|
|||
Shindo.tests('Ninfold::Compute | server requests', ['ninefold']) do
|
||||
|
||||
tests('success') do
|
||||
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
||||
tests("#deploy_virtual_machine()").raises(Excon::Errors::HTTPStatusError) do
|
||||
pending if Fog.mocking?
|
||||
Ninefold[:compute].deploy_virtual_machine
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
21
tests/compute/requests/ninefold/template_tests.rb
Normal file
21
tests/compute/requests/ninefold/template_tests.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
Shindo.tests('Ninfold::Compute | server requests', ['ninefold']) do
|
||||
|
||||
tests('success') do
|
||||
|
||||
tests("#list_templates()").formats(Ninefold::Compute::Formats::Templates::TEMPLATES) do
|
||||
pending if Fog.mocking?
|
||||
Ninefold[:compute].list_templates(:templatefilter => 'executable')
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
||||
#tests("#deploy_virtual_machine()").raises(Excon::Errors::HTTPStatusError) do
|
||||
# pending if Fog.mocking?
|
||||
# Ninefold[:compute].deploy_virtual_machine
|
||||
#end
|
||||
|
||||
end
|
||||
|
||||
end
|
96
tests/compute/requests/ninefold/virtual_machine_tests.rb
Normal file
96
tests/compute/requests/ninefold/virtual_machine_tests.rb
Normal file
|
@ -0,0 +1,96 @@
|
|||
Shindo.tests('Ninefold::Compute | server requests', ['ninefold']) do
|
||||
|
||||
tests('success') do
|
||||
|
||||
|
||||
tests("#deploy_virtual_machine()").formats(Ninefold::Compute::Formats::VirtualMachines::PENDING_VIRTUAL_MACHINE) do
|
||||
pending if Fog.mocking?
|
||||
networks = Ninefold[:compute].list_networks
|
||||
|
||||
unless networks[0]
|
||||
raise "No networks, ensure a network has been created by deploying a VM from the web UI and verify list_networks test"
|
||||
end
|
||||
|
||||
newvm = Ninefold[:compute].deploy_virtual_machine(:serviceofferingid => Ninefold::Compute::TestSupport::SERVICE_OFFERING,
|
||||
:templateid => Ninefold::Compute::TestSupport::TEMPLATE_ID,
|
||||
:zoneid => Ninefold::Compute::TestSupport::ZONE_ID,
|
||||
:networkids => networks[0]['id'])
|
||||
# wait for deployment, stash the job id.
|
||||
@jobid = newvm['jobid']
|
||||
@newvmid = newvm['id']
|
||||
while Ninefold[:compute].query_async_job_result(:jobid => @jobid)['jobstatus'] == 0
|
||||
sleep 1
|
||||
end
|
||||
newvm
|
||||
end
|
||||
|
||||
tests("#list_virtual_machines()").formats(Ninefold::Compute::Formats::VirtualMachines::VIRTUAL_MACHINES) do
|
||||
pending if Fog.mocking?
|
||||
vms = Ninefold[:compute].list_virtual_machines
|
||||
# This is a hack to work around the changing format - these fields may or may not exist.
|
||||
vms.each do |vm|
|
||||
vm['cpuused'] ||= ''
|
||||
vm['networkkbsread'] ||= 0
|
||||
vm['networkkbswrite'] ||= 0
|
||||
end
|
||||
vms
|
||||
end
|
||||
|
||||
tests("#reboot_virtual_machine()").formats(Ninefold::Compute::Formats::VirtualMachines::ASYNC_VIRTUAL_MACHINE) do
|
||||
pending if Fog.mocking?
|
||||
job = Ninefold[:compute].reboot_virtual_machine(:id => @newvmid)
|
||||
while Ninefold[:compute].query_async_job_result(:jobid => job['jobid'])['jobstatus'] == 0
|
||||
sleep 1
|
||||
end
|
||||
job
|
||||
end
|
||||
|
||||
tests("#stop_virtual_machine()").formats(Ninefold::Compute::Formats::VirtualMachines::ASYNC_VIRTUAL_MACHINE) do
|
||||
pending if Fog.mocking?
|
||||
job = Ninefold[:compute].stop_virtual_machine(:id => @newvmid)
|
||||
while Ninefold[:compute].query_async_job_result(:jobid => job['jobid'])['jobstatus'] == 0
|
||||
sleep 1
|
||||
end
|
||||
job
|
||||
end
|
||||
|
||||
|
||||
tests("#change_service_for_virtual_machine()").formats(Ninefold::Compute::Formats::VirtualMachines::VIRTUAL_MACHINE) do
|
||||
pending if Fog.mocking?
|
||||
Ninefold[:compute].change_service_for_virtual_machine(:id => @newvmid,
|
||||
:serviceofferingid => Ninefold::Compute::TestSupport::ALT_SERVICE_OFFERING)
|
||||
end
|
||||
|
||||
tests("#start_virtual_machine()").formats(Ninefold::Compute::Formats::VirtualMachines::ASYNC_VIRTUAL_MACHINE) do
|
||||
pending if Fog.mocking?
|
||||
job = Ninefold[:compute].start_virtual_machine(:id => @newvmid)
|
||||
while Ninefold[:compute].query_async_job_result(:jobid => job['jobid'])['jobstatus'] == 0
|
||||
sleep 1
|
||||
end
|
||||
job
|
||||
end
|
||||
|
||||
tests("#destroy_virtual_machine()").formats(Ninefold::Compute::Formats::VirtualMachines::ASYNC_VIRTUAL_MACHINE) do
|
||||
pending if Fog.mocking?
|
||||
destvm = Ninefold[:compute].destroy_virtual_machine(:id => @newvmid)
|
||||
|
||||
# wait for destroy, stash the job id.
|
||||
@jobid = destvm['jobid']
|
||||
while Ninefold[:compute].query_async_job_result(:jobid => @jobid)['jobstatus'] == 0
|
||||
sleep 1
|
||||
end
|
||||
destvm
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
||||
tests("#deploy_virtual_machine()").raises(Excon::Errors::HTTPStatusError) do
|
||||
pending if Fog.mocking?
|
||||
Ninefold[:compute].deploy_virtual_machine
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
Loading…
Add table
Reference in a new issue