You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by lu...@apache.org on 2010/07/09 01:21:05 UTC
svn commit: r962073 - in /incubator/deltacloud/trunk/drivers/rhevm:
lib/rhevm_driver.rb scripts/addVM.ps1 scripts/deleteVm.ps1
scripts/rebootVm.ps1 scripts/storageDomains.ps1 scripts/vmById.ps1
Author: lutter
Date: Thu Jul 8 23:21:04 2010
New Revision: 962073
URL: http://svn.apache.org/viewvc?rev=962073&view=rev
Log:
Destroy, not delete
Added:
incubator/deltacloud/trunk/drivers/rhevm/scripts/addVM.ps1
- copied, changed from r962072, incubator/deltacloud/trunk/drivers/rhevm/scripts/vmById.ps1
incubator/deltacloud/trunk/drivers/rhevm/scripts/deleteVm.ps1
- copied, changed from r962072, incubator/deltacloud/trunk/drivers/rhevm/scripts/vmById.ps1
incubator/deltacloud/trunk/drivers/rhevm/scripts/rebootVm.ps1
- copied, changed from r962072, incubator/deltacloud/trunk/drivers/rhevm/scripts/vmById.ps1
incubator/deltacloud/trunk/drivers/rhevm/scripts/storageDomains.ps1
- copied, changed from r962072, incubator/deltacloud/trunk/drivers/rhevm/scripts/vmById.ps1
Modified:
incubator/deltacloud/trunk/drivers/rhevm/lib/rhevm_driver.rb
incubator/deltacloud/trunk/drivers/rhevm/scripts/vmById.ps1
Modified: incubator/deltacloud/trunk/drivers/rhevm/lib/rhevm_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/drivers/rhevm/lib/rhevm_driver.rb?rev=962073&r1=962072&r2=962073&view=diff
==============================================================================
--- incubator/deltacloud/trunk/drivers/rhevm/lib/rhevm_driver.rb (original)
+++ incubator/deltacloud/trunk/drivers/rhevm/lib/rhevm_driver.rb Thu Jul 8 23:21:04 2010
@@ -9,35 +9,20 @@ class RHEVMDriver < DeltaCloud::BaseDriv
DELIM_BEGIN="<_OUTPUT>"
DELIM_END="</_OUTPUT>"
POWERSHELL="c:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe"
-
- #
- # Flavors
- #
- FLAVORS = [
- Flavor.new({
- :id=>"rhevm",
- :memory=>"Any",
- :storage=>"Any",
- :architecture=>"Any",
- })
- ]
-
- def flavors(credentials, opts=nil)
- return FLAVORS if ( opts.nil? )
- FLAVORS.select{|f| opts[:id] == f.id}
- end
+ NO_OWNER=""
#
# Execute a Powershell command, and convert the output
# to YAML in order to get back an array of maps.
#
- def execute(credentials, command, args=[])
+ def execute(credentials, command, *args)
args = args.to_a
argString = genArgString(credentials, args)
outputMaps = {}
output = `#{POWERSHELL} -command "&{#{File.join(SCRIPT_DIR, command)} #{argString}; exit $LASTEXITCODE}`
exitStatus = $?.exitstatus
puts(output)
+ puts("EXITSTATUS #{exitStatus}")
st = output.index(DELIM_BEGIN)
if (st)
st += DELIM_BEGIN.length
@@ -73,12 +58,50 @@ class RHEVMDriver < DeltaCloud::BaseDriv
return :pending if st == "POWERING UP"
end
- STATE_ACTIONS = {
- :pending=>[],
- :running=>[ :stop, :reboot ],
- :shutting_down=>[],
- :terminated=>[:start ]
- }
+ #
+ # Flavors
+ #
+ FLAVORS = [
+ Flavor.new({
+ :id=>"rhevm",
+ :memory=>"Any Memory",
+ :storage=>"Any Storage",
+ :architecture=>"Any Architecture",
+ })
+ ]
+
+ def flavors(credentials, opts=nil)
+ return FLAVORS if ( opts.nil? || (! opts[:id]))
+ FLAVORS.select{|f| opts[:id] == f.id}
+ end
+
+
+ #
+ # Realms
+ #
+
+ def realms(credentials, opts=nil)
+ domains = execute(credentials, "storageDomains.ps1")
+ if (!opts.nil? && opts[:id])
+ domains = domains.select{|d| opts[:id] == d["StorageId"]}
+ end
+
+ realms = []
+ domains.each do |dom|
+ realms << domain_to_realm(dom)
+ end
+ realms
+ end
+
+ def domain_to_realm(dom)
+ Realm.new({
+ :id => dom["StorageId"],
+ :name => dom["Name"],
+ :limit => dom["AvailableDiskSize"]
+ })
+ end
+
+
#
# Images
@@ -106,7 +129,7 @@ class RHEVMDriver < DeltaCloud::BaseDriv
:name => templ["Name"],
:description => templ["Description"],
:architecture => templ["OperatingSystem"],
- :owner_id => "Jar Jar Binks",
+ :owner_id => NO_OWNER,
:mem_size_md => templ["MemSizeMb"],
:instance_count => templ["ChildCount"],
:state => templ["Status"],
@@ -118,6 +141,14 @@ class RHEVMDriver < DeltaCloud::BaseDriv
# Instances
#
+ STATE_ACTIONS = {
+ :pending=>[],
+ :running=>[ :stop, :reboot ],
+ :shutting_down=>[],
+ :terminated=>[:start, :destroy ]
+ }
+
+
def instances(credentials, opts=nil)
vms = []
if (opts.nil?)
@@ -140,7 +171,7 @@ class RHEVMDriver < DeltaCloud::BaseDriv
:description => vm["Description"],
:name => vm["Name"],
:architecture => vm["OperatingSystem"],
- :owner_id => "Jar Jar Binks",
+ :owner_id => NO_OWNER,
:image_id => vm["TemplateId"],
:state => statify(vm["Status"]),
:flavor_id => "rhevm",
@@ -158,21 +189,29 @@ class RHEVMDriver < DeltaCloud::BaseDriv
vm_to_instance(vm[0])
end
- def create_instance(credentials, image_id, flavor_id)
- check_credentials( credentials )
+ def create_instance(credentials, image_id, opts)
+ puts(opts[:realm_id])
+ puts(opts[:flavor_id])
+ puts(opts[:name])
+ vm = execute(credentials, "addVm.ps1", image_id, opts[:name], opts[:realm_id])
+ vm_to_instance(vm[0])
end
- def reboot_instance(credentials, id)
+ def reboot_instance(credentials, image_id)
+ vm = execute(credentials, "rebootVm.ps1", image_id)
+ vm_to_instance(vm[0])
end
- def delete_instance(credentials, id)
+ def destroy_instance(credentials, image_id)
+ vm = execute(credentials, "deleteVm.ps1", image_id)
+ vm_to_instance(vm[0])
end
#
# Storage Volumes
#
- def volumes(credentials, ids=nil)
+ def storage_volumes(credentials, ids=nil)
volumes = []
volumes
end
@@ -181,7 +220,7 @@ class RHEVMDriver < DeltaCloud::BaseDriv
# Storage Snapshots
#
- def snapshots(credentials, ids=nil)
+ def storage_snapshots(credentials, ids=nil)
snapshots = []
snapshots
end
Copied: incubator/deltacloud/trunk/drivers/rhevm/scripts/addVM.ps1 (from r962072, incubator/deltacloud/trunk/drivers/rhevm/scripts/vmById.ps1)
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/drivers/rhevm/scripts/addVM.ps1?p2=incubator/deltacloud/trunk/drivers/rhevm/scripts/addVM.ps1&p1=incubator/deltacloud/trunk/drivers/rhevm/scripts/vmById.ps1&r1=962072&r2=962073&rev=962073&view=diff
==============================================================================
--- incubator/deltacloud/trunk/drivers/rhevm/scripts/vmById.ps1 (original)
+++ incubator/deltacloud/trunk/drivers/rhevm/scripts/addVM.ps1 Thu Jul 8 23:21:04 2010
@@ -2,11 +2,13 @@ param([string]$scriptsDir,
[string]$username,
[string]$password,
[string]$domain,
- [string]$id)
+ [string]$templateId,
+ [string]$name,
+ [string]$storageId)
# Get the common functions
. "$scriptsDir\common.ps1"
verifyLogin $username $password $domain
+$templ = get-template $templateId
beginOutput
-# The AppliacationList causes the YAML pain, so Omit it
-get-vm $id | format-list -Property $VM_PROPERTY_LIST
+add-vm -TemplateObject $templ -Name $name -StorageDomainId $storageId
endOutput
\ No newline at end of file
Copied: incubator/deltacloud/trunk/drivers/rhevm/scripts/deleteVm.ps1 (from r962072, incubator/deltacloud/trunk/drivers/rhevm/scripts/vmById.ps1)
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/drivers/rhevm/scripts/deleteVm.ps1?p2=incubator/deltacloud/trunk/drivers/rhevm/scripts/deleteVm.ps1&p1=incubator/deltacloud/trunk/drivers/rhevm/scripts/vmById.ps1&r1=962072&r2=962073&rev=962073&view=diff
==============================================================================
--- incubator/deltacloud/trunk/drivers/rhevm/scripts/vmById.ps1 (original)
+++ incubator/deltacloud/trunk/drivers/rhevm/scripts/deleteVm.ps1 Thu Jul 8 23:21:04 2010
@@ -2,11 +2,11 @@ param([string]$scriptsDir,
[string]$username,
[string]$password,
[string]$domain,
- [string]$id)
+ [string]$id)
# Get the common functions
. "$scriptsDir\common.ps1"
verifyLogin $username $password $domain
beginOutput
# The AppliacationList causes the YAML pain, so Omit it
-get-vm $id | format-list -Property $VM_PROPERTY_LIST
+remove-vm $id | format-list -Property $VM_PROPERTY_LIST
endOutput
\ No newline at end of file
Copied: incubator/deltacloud/trunk/drivers/rhevm/scripts/rebootVm.ps1 (from r962072, incubator/deltacloud/trunk/drivers/rhevm/scripts/vmById.ps1)
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/drivers/rhevm/scripts/rebootVm.ps1?p2=incubator/deltacloud/trunk/drivers/rhevm/scripts/rebootVm.ps1&p1=incubator/deltacloud/trunk/drivers/rhevm/scripts/vmById.ps1&r1=962072&r2=962073&rev=962073&view=diff
==============================================================================
--- incubator/deltacloud/trunk/drivers/rhevm/scripts/vmById.ps1 (original)
+++ incubator/deltacloud/trunk/drivers/rhevm/scripts/rebootVm.ps1 Thu Jul 8 23:21:04 2010
@@ -2,11 +2,12 @@ param([string]$scriptsDir,
[string]$username,
[string]$password,
[string]$domain,
- [string]$id)
+ [string]$id)
# Get the common functions
. "$scriptsDir\common.ps1"
verifyLogin $username $password $domain
-beginOutput
# The AppliacationList causes the YAML pain, so Omit it
-get-vm $id | format-list -Property $VM_PROPERTY_LIST
+stop-vm $id | format-list -Property $VM_PROPERTY_LIST
+beginOutput
+start-vm $id | format-list -Property $VM_PROPERTY_LIST
endOutput
\ No newline at end of file
Copied: incubator/deltacloud/trunk/drivers/rhevm/scripts/storageDomains.ps1 (from r962072, incubator/deltacloud/trunk/drivers/rhevm/scripts/vmById.ps1)
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/drivers/rhevm/scripts/storageDomains.ps1?p2=incubator/deltacloud/trunk/drivers/rhevm/scripts/storageDomains.ps1&p1=incubator/deltacloud/trunk/drivers/rhevm/scripts/vmById.ps1&r1=962072&r2=962073&rev=962073&view=diff
==============================================================================
--- incubator/deltacloud/trunk/drivers/rhevm/scripts/vmById.ps1 (original)
+++ incubator/deltacloud/trunk/drivers/rhevm/scripts/storageDomains.ps1 Thu Jul 8 23:21:04 2010
@@ -1,12 +1,11 @@
param([string]$scriptsDir,
[string]$username,
[string]$password,
- [string]$domain,
- [string]$id)
+ [string]$domain)
# Get the common functions
. "$scriptsDir\common.ps1"
verifyLogin $username $password $domain
beginOutput
# The AppliacationList causes the YAML pain, so Omit it
-get-vm $id | format-list -Property $VM_PROPERTY_LIST
+select-storagedomain *
endOutput
\ No newline at end of file
Modified: incubator/deltacloud/trunk/drivers/rhevm/scripts/vmById.ps1
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/drivers/rhevm/scripts/vmById.ps1?rev=962073&r1=962072&r2=962073&view=diff
==============================================================================
--- incubator/deltacloud/trunk/drivers/rhevm/scripts/vmById.ps1 (original)
+++ incubator/deltacloud/trunk/drivers/rhevm/scripts/vmById.ps1 Thu Jul 8 23:21:04 2010
@@ -2,11 +2,12 @@ param([string]$scriptsDir,
[string]$username,
[string]$password,
[string]$domain,
- [string]$id)
+ [string]$id)
# Get the common functions
. "$scriptsDir\common.ps1"
verifyLogin $username $password $domain
+$vm = get-vm $id
beginOutput
# The AppliacationList causes the YAML pain, so Omit it
-get-vm $id | format-list -Property $VM_PROPERTY_LIST
+$vm | format-list -Property $VM_PROPERTY_LIST
endOutput
\ No newline at end of file