You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by mf...@apache.org on 2012/11/24 12:57:08 UTC
git commit: fgcp: return IP address immediately;
also add arguments to batch files
Updated Branches:
refs/heads/master 58cd62517 -> 6dfef2069
fgcp: return IP address immediately; also add arguments to batch files
Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/6dfef206
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/6dfef206
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/6dfef206
Branch: refs/heads/master
Commit: 6dfef2069573077aa73a841487657104c71ea6aa
Parents: 58cd625
Author: Dies Koper <di...@fast.au.fujitsu.com>
Authored: Fri Nov 23 14:59:28 2012 +1100
Committer: Michal fojtik <mf...@redhat.com>
Committed: Sat Nov 24 12:56:45 2012 +0100
----------------------------------------------------------------------
clients/cimi/bin/start.bat | 2 +-
server/bin/deltacloudd.bat | 2 +-
server/lib/deltacloud/drivers/fgcp/fgcp_driver.rb | 61 ++++++++++++++--
3 files changed, 56 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/6dfef206/clients/cimi/bin/start.bat
----------------------------------------------------------------------
diff --git a/clients/cimi/bin/start.bat b/clients/cimi/bin/start.bat
index bb83010..e5c7bca 100644
--- a/clients/cimi/bin/start.bat
+++ b/clients/cimi/bin/start.bat
@@ -1 +1 @@
-@ruby "%~dp0start"
+@ruby "%~dp0start" %*
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/6dfef206/server/bin/deltacloudd.bat
----------------------------------------------------------------------
diff --git a/server/bin/deltacloudd.bat b/server/bin/deltacloudd.bat
index 622d8f2..d1f13e9 100644
--- a/server/bin/deltacloudd.bat
+++ b/server/bin/deltacloudd.bat
@@ -1 +1 @@
-@ruby "%~dp0deltacloudd"
+@ruby "%~dp0deltacloudd" %*
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/6dfef206/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 24ba6ae..262ea97 100644
--- a/server/lib/deltacloud/drivers/fgcp/fgcp_driver.rb
+++ b/server/lib/deltacloud/drivers/fgcp/fgcp_driver.rb
@@ -697,6 +697,7 @@ class FgcpDriver < Deltacloud::BaseDriver
addresses
end
+ # allocates (and enables) new ip in specified vsys/network
def create_address(credentials, opts={})
safely do
client = new_client(credentials)
@@ -710,10 +711,32 @@ class FgcpDriver < Deltacloud::BaseDriver
opts[:realm_id] = xml[0]['vsys'][0]['vsysId'][0] if xml
end
+ old_ips = []
+ xml = client.list_public_ips(opts[:realm_id])['publicips']
+ old_ips = xml[0]['publicip'].collect { |ip| ip['address'][0]} if xml and xml[0]['publicip']
+
client.allocate_public_ip(opts[:realm_id])
+ # new address not returned immediately:
+ # Seems to take 15-30s. to appear in list, so poll for a while
+ # prepare dummy id in case new ip does not appear soon.
+ id = 'PENDING-xxx.xxx.xxx.xxx'
+ sleep(8)
+ 10.times {
+
+ sleep(5)
+ xml = client.list_public_ips(opts[:realm_id])['publicips']
+ if xml and xml[0]['publicip'] and xml[0]['publicip'].size > old_ips.size
+
+ new_ips = xml[0]['publicip'].collect { |ip| ip['address'][0]}
+ new_ip = (new_ips - old_ips).first
+ # enable IP address
+ client.attach_public_ip(opts[:realm_id], new_ip)
+ id = new_ip
+ break
+ end
+ }
+ Address.new(:id => id)
end
- # new address not returned immediately!
- Address.new(:id => 'PENDING-xxx.xxx.xxx.xxx')
end
def destroy_address(credentials, opts={})
@@ -731,12 +754,23 @@ class FgcpDriver < Deltacloud::BaseDriver
end
end
begin
- # detach just in case
+ # disable IP if still enabled
client.detach_public_ip(opts[:realm_id], opts[:id])
+ sleep(8)
rescue Exception => ex
raise ex unless ex.message =~ /^ALREADY_DETACHED.*/
end
- client.free_public_ip(opts[:realm_id], opts[:id])
+ attempts = 0
+ begin
+ # this may fail if the ip is still detaching, hence retry for a while
+ client.free_public_ip(opts[:realm_id], opts[:id])
+ rescue Exception => ex
+ raise unless attempts < 10 and ex.message =~ /^ILLEGAL_CONDITION.*/
+ # Detaching seems to take 15-30s, so keep trying for a while
+ sleep(5)
+ attempts += 1
+ retry
+ end
end
end
@@ -746,7 +780,9 @@ class FgcpDriver < Deltacloud::BaseDriver
vsys_id = client.extract_vsys_id(opts[:instance_id])
begin
+ # enable IP in case not enabled already
client.attach_public_ip(vsys_id, opts[:id])
+ sleep(8)
rescue Exception => ex
raise ex unless ex.message =~ /^ALREADY_ATTACHED.*/
end
@@ -768,7 +804,8 @@ class FgcpDriver < Deltacloud::BaseDriver
fw_id = "#{vsys_id}-S-0001"
nat_rules = client.get_efm_configuration(fw_id, 'FW_NAT_RULE')['efm'][0]['firewall'][0]['nat'][0]['rules'][0]
- if nat_rules and not nat_rules.empty? # happens only if no enabled IP address?
+ # TODO: if no IP address enabled yet
+ if nat_rules and not nat_rules.empty? and nat_rules['rule'].find { |rule| rule['publicIp'][0] == opts[:id] }
nat_rules['rule'].each do |rule|
@@ -830,7 +867,6 @@ class FgcpDriver < Deltacloud::BaseDriver
)
client.update_efm_configuration(fw_id, 'FW_NAT_RULE', conf_xml_new)
- client.detach_public_ip(client.extract_vsys_id(opts[:realm_id]), opts[:id])
end
end
@@ -1194,8 +1230,11 @@ eofwopxml
def create_load_balancer(credentials, opts={})
safely do
client = new_client(credentials)
- # if opts['realm_id'].nil? network id specified, pick first vsys' DMZ?
+ # if opts['realm_id'].nil? network id specified, pick first vsys' DMZ
+ # if realm has SLB already, use that, else create
# CreateEFM -vsysId vsysId -efmType SLB -efmName opts['name'] -networkId opts['realm_id']
+ # if not started already, start
+ # add group and return :id => efmId_groupId
network_id = opts[:realm_id]
if not network_id
xml = client.list_vsys['vsyss']
@@ -1215,6 +1254,9 @@ eofwopxml
def destroy_load_balancer(credentials, id)
safely do
client = new_client(credentials)
+ # remove group from SLB
+ # if no groups left, stop and destroy SLB
+ # destroy in new thread? May fail if public IP associated?
client.destroy_efm(id)
end
end
@@ -1376,6 +1418,11 @@ eofwopxml
status 404 # Not Found
end
+ # reached maximum number of attempts while polling for an update
+ on /Server did not include public IP address in FW NAT rules/ do
+ status 504 # Gateway Timeout
+ end
+
# wrong FW description (vsys descriptor)
on /does not exist. Specify one of / do
status 404 # Not Found