deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dko...@apache.org
Subject git commit: Fgcp: add support for instance_count feature using recently introduced FGCP API CreateMultipleVServer operation
Date Mon, 21 Jan 2013 13:02:46 GMT
Updated Branches:
  refs/heads/master 8be51e5d6 -> 9e30652e9


Fgcp: add support for instance_count feature using recently introduced FGCP API CreateMultipleVServer
operation


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/9e30652e
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/9e30652e
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/9e30652e

Branch: refs/heads/master
Commit: 9e30652e90df843f3833fdb16c823230ad538a35
Parents: 8be51e5
Author: Dies Koper <diesk@fast.au.fujitsu.com>
Authored: Sat Jan 19 22:49:17 2013 +1100
Committer: Dies Koper <diesk@fast.au.fujitsu.com>
Committed: Mon Jan 21 23:26:07 2013 +1100

----------------------------------------------------------------------
 server/lib/deltacloud/drivers/fgcp/fgcp_client.rb |   11 ++++++
 server/lib/deltacloud/drivers/fgcp/fgcp_driver.rb |   31 ++++++++++++++--
 2 files changed, 39 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/9e30652e/server/lib/deltacloud/drivers/fgcp/fgcp_client.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/fgcp/fgcp_client.rb b/server/lib/deltacloud/drivers/fgcp/fgcp_client.rb
index 74816f0..489e8c4 100644
--- a/server/lib/deltacloud/drivers/fgcp/fgcp_client.rb
+++ b/server/lib/deltacloud/drivers/fgcp/fgcp_client.rb
@@ -115,6 +115,17 @@ class FgcpClient
       'networkId'   => network_id})
   end
 
+  def create_vservers(vsys_id, vservers_xml)
+    @version = '2012-07-20'
+    request('CreateMultipleVServer',
+      {
+        'vsysId'    => vsys_id,
+      },
+      vservers_xml,
+      'vserversXMLFilePath'
+    )
+  end
+
   def destroy_vserver(vserver_id)
     request('DestroyVServer', {'vsysId' => extract_vsys_id(vserver_id), 'vserverId' =>
vserver_id})
   end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/9e30652e/server/lib/deltacloud/drivers/fgcp/fgcp_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/fgcp/fgcp_driver.rb b/server/lib/deltacloud/drivers/fgcp/fgcp_driver.rb
index 873fdf2..cbda9ea 100644
--- a/server/lib/deltacloud/drivers/fgcp/fgcp_driver.rb
+++ b/server/lib/deltacloud/drivers/fgcp/fgcp_driver.rb
@@ -30,6 +30,7 @@ class FgcpDriver < Deltacloud::BaseDriver
   feature :instances, :user_name
   feature :instances, :metrics
   feature :instances, :realm_filter
+  feature :instances, :instance_count
   feature :images, :user_name
   feature :images, :user_description
 
@@ -355,9 +356,33 @@ class FgcpDriver < Deltacloud::BaseDriver
         # use first returned system's DMZ as realm
         network_id = xml ? xml[0]['vsys'][0]['vsysId'][0] + '-N-DMZ' : nil
       end
-      xml = client.create_vserver(name, hwp, image_id, network_id)
-      # returns vserver details
-      instances(credentials, {:id => xml['vserverId'][0]}).first
+      if opts[:instance_count] and opts[:instance_count].to_i > 1
+
+        vservers = Array.new(opts[:instance_count].to_i) { |n|
+          {
+            'vserverName' => "#{name}_#{n+1}",
+            'vserverType' => hwp,
+            'diskImageId' => image_id,
+            'networkId'   => network_id
+          }
+        }
+        new_vservers = { 'vservers' => { 'vserver' => vservers } }
+        vservers_xml = XmlSimple.xml_out(new_vservers,
+          'RootName' => 'Request',
+          'NoAttr' => true
+        )
+
+        xml = client.create_vservers(client.extract_vsys_id(network_id), vservers_xml)
+        vserver_ids = xml['vservers'][0]['vserver'].collect { |vserver| vserver['vserverId'][0]
}
+        # returns vservers' details using filter
+        instances(credentials, {:realm_id => network_id}).select { |instance|
+          vserver_ids.include? instance.id
+        }
+      else
+        xml = client.create_vserver(name, hwp, image_id, network_id)
+        # returns vserver details
+        instances(credentials, {:id => xml['vserverId'][0]}).first
+      end
     end
   end
 


Mime
View raw message