deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject git commit: read machine name from json body; default realm for fgcp
Date Mon, 12 Nov 2012 10:41:12 GMT
Updated Branches:
  refs/heads/master d7258e2a3 -> 798dfe9e5


read machine name from json body; default realm for fgcp


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

Branch: refs/heads/master
Commit: 798dfe9e54af3d3ad748fe04263d13db53b9566e
Parents: d7258e2
Author: Dies Koper <diesk@fast.au.fujitsu.com>
Authored: Sat Nov 10 13:41:40 2012 +1100
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Mon Nov 12 11:31:35 2012 +0100

----------------------------------------------------------------------
 server/lib/cimi/models/machine.rb                 |   16 +++++++++---
 server/lib/deltacloud/drivers/fgcp/fgcp_driver.rb |   21 +++++++++++++---
 2 files changed, 29 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/798dfe9e/server/lib/cimi/models/machine.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/machine.rb b/server/lib/cimi/models/machine.rb
index 63520a8..c6865b6 100644
--- a/server/lib/cimi/models/machine.rb
+++ b/server/lib/cimi/models/machine.rb
@@ -47,9 +47,17 @@ class CIMI::Model::Machine < CIMI::Model::Base
 
   def self.create_from_json(body, context)
     json = JSON.parse(body)
-    hardware_profile_id = json['machineTemplate']['machineConfig']["href"].split('/').last
-    image_id = json['machineTemplate']['machineImage']["href"].split('/').last
-    instance = context.driver.create_instance(context.credentials, image_id, { :hwp_id =>
hardware_profile_id })
+    machine_template = json['machineTemplate']
+    hardware_profile_id = machine_template['machineConfig']["href"].split('/').last
+    image_id = machine_template['machineImage']["href"].split('/').last
+    additional_params = {}
+    additional_params[:name] = json['name'] if json['name']
+    if machine_template.has_key? 'credential'
+      additional_params[:keyname] = machine_template['credential']["href"].split('/').last
+    end
+    instance = context.driver.create_instance(context.credentials, image_id, {
+      :hwp_id => hardware_profile_id
+    }.merge(additional_params))
     from_instance(instance, context)
   end
 
@@ -59,7 +67,7 @@ class CIMI::Model::Machine < CIMI::Model::Base
     hardware_profile_id = machine_template['machineConfig'][0]["href"].split('/').last
     image_id = machine_template['machineImage'][0]["href"].split('/').last
     additional_params = {}
-    additional_params[:name] =xml['name'][0] if xml['name']
+    additional_params[:name] = xml['name'][0] if xml['name']
     if machine_template.has_key? 'credential'
       additional_params[:keyname] = machine_template['credential'][0]["href"].split('/').last
     end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/798dfe9e/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 7399c13..24ba6ae 100644
--- a/server/lib/deltacloud/drivers/fgcp/fgcp_driver.rb
+++ b/server/lib/deltacloud/drivers/fgcp/fgcp_driver.rb
@@ -349,6 +349,12 @@ class FgcpDriver < Deltacloud::BaseDriver
     network_id = opts[:realm_id]
     safely do
       client = new_client(credentials)
+      if not network_id
+        xml = client.list_vsys['vsyss']
+
+        # 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
@@ -485,7 +491,7 @@ class FgcpDriver < Deltacloud::BaseDriver
       elsif xml = client.list_vsys['vsyss']
 
         # use first vsys returned as realm
-        opts[:realm_id] = xml[0]['vsys'][0]['vsysId'][0]
+        opts[:realm_id] = xml[0]['vsys'][0]['vsysId'][0] if xml
       end
 
       vdisk_id = client.create_vdisk(opts[:realm_id], opts[:name], opts[:capacity])['vdiskId'][0]
@@ -700,8 +706,8 @@ class FgcpDriver < Deltacloud::BaseDriver
         opts[:realm_id] = client.extract_vsys_id(opts[:realm_id])
       else
         # get first vsys
-        xml = client.list_vsys
-        opts[:realm_id] = xml['vsyss'][0]['vsys'][0]['vsysId'][0] if xml['vsyss']
+        xml = client.list_vsys['vsyss']
+        opts[:realm_id] = xml[0]['vsys'][0]['vsysId'][0] if xml
       end
 
       client.allocate_public_ip(opts[:realm_id])
@@ -1191,6 +1197,12 @@ eofwopxml
       # if opts['realm_id'].nil? network id specified, pick first vsys' DMZ?
       # CreateEFM -vsysId vsysId -efmType SLB -efmName opts['name'] -networkId opts['realm_id']
       network_id = opts[:realm_id]
+      if not network_id
+        xml = client.list_vsys['vsyss']
+
+        # use first returned system's DMZ as realm
+        network_id = xml ? xml[0]['vsys'][0]['vsysId'][0] + '-N-DMZ' : nil
+      end
       efm = client.create_efm('SLB', opts[:name], network_id)
 #        [{:load_balancer_port => opts['listener_balancer_port'],
 #          :instance_port => opts['listener_instance_port'],
@@ -1464,7 +1476,8 @@ eofwopxml
         vsys_id = client.extract_vsys_id(instance.id)
         if slbs = client.list_efm(vsys_id, 'SLB')['efms']
           slbs[0]['efm'].find do |slb|
-            instance.private_addresses << InstanceAddress.new(slb['slbVip'][0], :type
=> :ipv4) if slb['efmId'][0] == instance.id
+            # note that slbVip may not be set yet (in just created SLBs)
+            instance.private_addresses << InstanceAddress.new(slb['slbVip'][0], :type
=> :ipv4) if slb['slbVip'] and slb['efmId'][0] == instance.id
           end
         end
       end


Mime
View raw message