incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject svn commit: r962044 - in /incubator/deltacloud/trunk/drivers/rhevm: lib/rhevm_driver.rb scripts/instances.ps1 scripts/templateById.ps1 scripts/vms.ps1
Date Thu, 08 Jul 2010 23:19:05 GMT
Author: lutter
Date: Thu Jul  8 23:19:05 2010
New Revision: 962044

URL: http://svn.apache.org/viewvc?rev=962044&view=rev
Log:
VM Selection and new model support

Added:
    incubator/deltacloud/trunk/drivers/rhevm/scripts/vms.ps1
Removed:
    incubator/deltacloud/trunk/drivers/rhevm/scripts/instances.ps1
Modified:
    incubator/deltacloud/trunk/drivers/rhevm/lib/rhevm_driver.rb
    incubator/deltacloud/trunk/drivers/rhevm/scripts/templateById.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=962044&r1=962043&r2=962044&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:19:05 2010
@@ -13,42 +13,18 @@ class RHEVMDriver < DeltaCloud::BaseDriv
   # 
   # Flavors
   # 
-  FLAVORS = [ 
-    { 
-      :id=>'m1-small',
-      :memory=>1.7,
-      :storage=>160,
-      :architecture=>'i386',
-    },
-    {
-      :id=>'m1-large', 
-      :memory=>7.5,
-      :storage=>850,
-      :architecture=>'x86_64',
-    },
-    { 
-      :id=>'m1-xlarge', 
-      :memory=>15,
-      :storage=>1690,
-      :architecture=>'x86_64',
-    },
-    { 
-      :id=>'c1-medium', 
-      :memory=>1.7,
-      :storage=>350,
-      :architecture=>'x86_64',
-    },
-    { 
-      :id=>'c1-xlarge', 
-      :memory=>7,
-      :storage=>1690,
-      :architecture=>'x86_64',
-    },
+  FLAVORS = [
+    Flavor.new({ 
+      :resource_id=>"rhevm",
+      :memory=>"Any",
+      :storage=>"Any",
+      :architecture=>"Any",
+    })
   ]
-
-  def flavors(credentials, ids=nil)
-    return FLAVORS if ( ids.nil? )
-    FLAVORS.select{|f| ids.include?(f[:id])}
+  
+  def flavors(credentials, opts=nil)
+    return FLAVORS if ( opts.nil? )
+    FLAVORS.select{|f| opts[:id] == f.resource_id}
   end
 
   #
@@ -83,11 +59,17 @@ class RHEVMDriver < DeltaCloud::BaseDriv
   
   def toYAML(output)
     yOutput = "- \n" + output
-    yOutput.gsub!(/^(\w*)[ ]*:[ ]*([A-Z0-9a-z._ -:]*)/,' \1: "\2"')
+    yOutput.gsub!(/^(\w*)[ ]*:[ ]*([A-Z0-9a-z._ -:{}]*)/,' \1: "\2"')
     yOutput.gsub!(/^[ ]*$/,"- ")
+    puts(yOutput)
     yOutput
   end
   
+  
+  #
+  # Images
+  #
+  
   def images(credentials, opts=nil )
     templates = []
     if (opts.nil?)
@@ -105,21 +87,51 @@ class RHEVMDriver < DeltaCloud::BaseDriv
   end
   
   def template_to_image(templ)
-    {
-      :id => templ["TemplateId"],
+    Image.new({
+      :resource_id => templ["TemplateId"],
+      :name => templ["Name"],
       :description => templ["Description"],
       :architecture => templ["OperatingSystem"],
-      :owner_id => "Jar jar Binks"      
-    }
+      :owner_id => "Jar Jar Binks",
+      :mem_size_md => templ["MemSizeMb"],
+      :instance_count => templ["ChildCount"],
+      :state => templ["Status"],
+      :capacity => templ["SizeGB"]
+    })
   end
 
   # 
   # Instances
   # 
 
-  def instances(credentials, ids=nil)
+  def instances(credentials, opts=nil)
+    vms = []
+    if (opts.nil?)
+      vms = execute(credentials, "vms.ps1")     
+    else
+      if (opts[:id]) 
+        vms = execute(credentials, "vmsById.ps1", [opts[:id]])
+      end
+    end
     instances = []
+    vms.each do |vm|
+      instances << vm_to_instance(vm)
+    end
+    instances
   end
+  
+  def vm_to_instance(vm)
+    Instance.new({
+      :resource_id => vm["VmId"],
+      :description => vm["Description"],
+      :name => vm["Name"],      
+      :architecture => vm["OperatingSystem"],
+      :owner_id => "Jar Jar Binks",
+      :image_id => vm["TemplateId"],
+      :state => vm["Status"],
+      :flavor_id => "rhevm",      
+    })
+  end  
 
   def create_instance(credentials, image_id, flavor_id)
     check_credentials( credentials )

Modified: incubator/deltacloud/trunk/drivers/rhevm/scripts/templateById.ps1
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/drivers/rhevm/scripts/templateById.ps1?rev=962044&r1=962043&r2=962044&view=diff
==============================================================================
--- incubator/deltacloud/trunk/drivers/rhevm/scripts/templateById.ps1 (original)
+++ incubator/deltacloud/trunk/drivers/rhevm/scripts/templateById.ps1 Thu Jul  8 23:19:05
2010
@@ -3,6 +3,7 @@ param([string]$scriptsDir,
         [string]$password,
         [string]$domain,
         [string]$id)
+
 # Get the common functions
 . "$scriptsDir\common.ps1"
 verifyLogin $username $password $domain

Added: incubator/deltacloud/trunk/drivers/rhevm/scripts/vms.ps1
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/drivers/rhevm/scripts/vms.ps1?rev=962044&view=auto
==============================================================================
--- incubator/deltacloud/trunk/drivers/rhevm/scripts/vms.ps1 (added)
+++ incubator/deltacloud/trunk/drivers/rhevm/scripts/vms.ps1 Thu Jul  8 23:19:05 2010
@@ -0,0 +1,11 @@
+param([string]$scriptsDir,
+        [string]$username,
+        [string]$password,
+        [string]$domain)
+# Get the common functions
+. "$scriptsDir\common.ps1"
+verifyLogin $username $password $domain
+beginOutput
+# The AppliacationList causes the YAML pain, so Omit it
+select-vm * | format-list -Property "VmId", "Name", "Description", "TemplateId", "Domain",
"Status", "OperatingSystem"
+endOutput
\ No newline at end of file



Mime
View raw message