mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-20 10:50:08 +03:00
L #-: Remove unneeded exceptions
(cherry picked from commit 46cca6d6cd7c3b5e85ad6f4fb3adbfc7362d0fd7)
This commit is contained in:
parent
6b28ac79d6
commit
30a79867cf
@ -185,8 +185,6 @@ module OneProvision
|
||||
end
|
||||
|
||||
[0, @facts]
|
||||
rescue StandardError => e
|
||||
raise e
|
||||
end
|
||||
|
||||
# Checks ssh connection
|
||||
@ -281,17 +279,13 @@ module OneProvision
|
||||
when /^fatal: \[([^\]]+)\]: .* => ({.*})$/i
|
||||
host = Regexp.last_match(1)
|
||||
|
||||
begin
|
||||
match = JSON.parse(Regexp.last_match(2))
|
||||
match = JSON.parse(Regexp.last_match(2))
|
||||
|
||||
msg = match['msg']
|
||||
msg = match['reason'] if msg.nil?
|
||||
msg = match['msg']
|
||||
msg = match['reason'] if msg.nil?
|
||||
|
||||
text = msg.strip.tr("\n", ' ')
|
||||
text = "- #{text}"
|
||||
rescue StandardError => e
|
||||
raise e
|
||||
end
|
||||
text = msg.strip.tr("\n", ' ')
|
||||
text = "- #{text}"
|
||||
when /^fatal: \[([^\]]+)\]: .* =>/i
|
||||
host = Regexp.last_match(1)
|
||||
end
|
||||
|
@ -33,8 +33,6 @@ class SunstoneOPTP
|
||||
@totp.verify(token,
|
||||
:drift_ahead => @five_minutes,
|
||||
:drift_behind => @five_minutes)
|
||||
rescue StandardError => e
|
||||
raise e
|
||||
end
|
||||
|
||||
def provisioning_uri(account_name)
|
||||
|
@ -374,8 +374,6 @@ class AzureDriver
|
||||
end
|
||||
rescue ThreadError
|
||||
nil
|
||||
rescue StandardError
|
||||
raise
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -929,30 +929,26 @@ module VCenterDriver
|
||||
spec.configSpec.maxMtu = mtu
|
||||
|
||||
# The DVS must be created in the networkFolder of the datacenter
|
||||
begin
|
||||
dvs_creation_task = @item
|
||||
.networkFolder
|
||||
.CreateDVS_Task(
|
||||
:spec => spec
|
||||
)
|
||||
dvs_creation_task.wait_for_completion
|
||||
dvs_creation_task = @item
|
||||
.networkFolder
|
||||
.CreateDVS_Task(
|
||||
:spec => spec
|
||||
)
|
||||
dvs_creation_task.wait_for_completion
|
||||
|
||||
# If task finished successfuly we rename the uplink portgroup
|
||||
dvs = nil
|
||||
if dvs_creation_task.info.state == 'success'
|
||||
dvs = dvs_creation_task.info.result
|
||||
dvs
|
||||
.config
|
||||
.uplinkPortgroup[0]
|
||||
.Rename_Task(
|
||||
:newName => "#{switch_name}-uplink-pg"
|
||||
).wait_for_completion
|
||||
else
|
||||
raise "The Distributed vSwitch #{switch_name} \
|
||||
could not be created. "
|
||||
end
|
||||
rescue StandardError => e
|
||||
raise e
|
||||
# If task finished successfuly we rename the uplink portgroup
|
||||
dvs = nil
|
||||
if dvs_creation_task.info.state == 'success'
|
||||
dvs = dvs_creation_task.info.result
|
||||
dvs
|
||||
.config
|
||||
.uplinkPortgroup[0]
|
||||
.Rename_Task(
|
||||
:newName => "#{switch_name}-uplink-pg"
|
||||
).wait_for_completion
|
||||
else
|
||||
raise "The Distributed vSwitch #{switch_name} \
|
||||
could not be created. "
|
||||
end
|
||||
|
||||
@net_rollback << {
|
||||
|
@ -69,25 +69,21 @@ module VCenterDriver
|
||||
end
|
||||
|
||||
def self.new_from_host(host_id)
|
||||
begin
|
||||
client = OpenNebula::Client.new
|
||||
host = OpenNebula::Host.new_with_id(host_id, client)
|
||||
rc = host.info(true)
|
||||
if OpenNebula.is_error?(rc)
|
||||
raise "Could not get host info for ID: \
|
||||
#{host_id} - #{rc.message}"
|
||||
end
|
||||
|
||||
connection = {
|
||||
:hostname => host['TEMPLATE/VCENTER_HOST'],
|
||||
:username => host['TEMPLATE/VCENTER_USER'],
|
||||
:password => host['TEMPLATE/VCENTER_PASSWORD']
|
||||
}
|
||||
|
||||
new(connection)
|
||||
rescue StandardError => e
|
||||
raise e
|
||||
client = OpenNebula::Client.new
|
||||
host = OpenNebula::Host.new_with_id(host_id, client)
|
||||
rc = host.info(true)
|
||||
if OpenNebula.is_error?(rc)
|
||||
raise "Could not get host info for ID: \
|
||||
#{host_id} - #{rc.message}"
|
||||
end
|
||||
|
||||
connection = {
|
||||
:hostname => host['TEMPLATE/VCENTER_HOST'],
|
||||
:username => host['TEMPLATE/VCENTER_USER'],
|
||||
:password => host['TEMPLATE/VCENTER_PASSWORD']
|
||||
}
|
||||
|
||||
new(connection)
|
||||
end
|
||||
|
||||
def get_or_create_tag(
|
||||
|
@ -140,90 +140,82 @@ module VCenterDriver
|
||||
end
|
||||
|
||||
def self.new_from_host(host_id, client = nil)
|
||||
begin
|
||||
client = OpenNebula::Client.new if client.nil?
|
||||
host = OpenNebula::Host.new_with_id(host_id, client)
|
||||
rc = host.info(true)
|
||||
if OpenNebula.is_error?(rc)
|
||||
raise "Could not get host info for \
|
||||
ID: #{host_id} - #{rc.message}"
|
||||
end
|
||||
|
||||
connection = {
|
||||
:host => host['TEMPLATE/VCENTER_HOST'],
|
||||
:user => host['TEMPLATE/VCENTER_USER'],
|
||||
:rp => host['TEMPLATE/VCENTER_RESOURCE_POOL'],
|
||||
:ccr => host['TEMPLATE/VCENTER_CCR_REF'],
|
||||
:password => host['TEMPLATE/VCENTER_PASSWORD']
|
||||
}
|
||||
|
||||
vc_port = host['TEMPLATE/VCENTER_PORT']
|
||||
connection[:port] = vc_port unless vc_port.nil?
|
||||
|
||||
new(connection, host_id)
|
||||
rescue StandardError => e
|
||||
raise e
|
||||
client = OpenNebula::Client.new if client.nil?
|
||||
host = OpenNebula::Host.new_with_id(host_id, client)
|
||||
rc = host.info(true)
|
||||
if OpenNebula.is_error?(rc)
|
||||
raise "Could not get host info for \
|
||||
ID: #{host_id} - #{rc.message}"
|
||||
end
|
||||
|
||||
connection = {
|
||||
:host => host['TEMPLATE/VCENTER_HOST'],
|
||||
:user => host['TEMPLATE/VCENTER_USER'],
|
||||
:rp => host['TEMPLATE/VCENTER_RESOURCE_POOL'],
|
||||
:ccr => host['TEMPLATE/VCENTER_CCR_REF'],
|
||||
:password => host['TEMPLATE/VCENTER_PASSWORD']
|
||||
}
|
||||
|
||||
vc_port = host['TEMPLATE/VCENTER_PORT']
|
||||
connection[:port] = vc_port unless vc_port.nil?
|
||||
|
||||
new(connection, host_id)
|
||||
end
|
||||
|
||||
def self.new_from_datastore(datastore_id)
|
||||
begin
|
||||
client = OpenNebula::Client.new
|
||||
datastore =
|
||||
OpenNebula::Datastore
|
||||
client = OpenNebula::Client.new
|
||||
datastore =
|
||||
OpenNebula::Datastore
|
||||
.new_with_id(
|
||||
datastore_id,
|
||||
client
|
||||
)
|
||||
rc = datastore.info
|
||||
if OpenNebula.is_error?(rc)
|
||||
raise "Could not get datastore info \
|
||||
for ID: #{datastore_id} - #{rc.message}"
|
||||
end
|
||||
|
||||
vcenter_id = datastore['TEMPLATE/VCENTER_INSTANCE_ID']
|
||||
|
||||
host_pool = OpenNebula::HostPool.new(client)
|
||||
rc = host_pool.info
|
||||
if OpenNebula.is_error?(rc)
|
||||
raise "Could not get hosts information - #{rc.message}"
|
||||
end
|
||||
|
||||
user = ''
|
||||
password = ''
|
||||
port = 0
|
||||
host_pool.each do |host|
|
||||
vc_instance_id = host['TEMPLATE/VCENTER_INSTANCE_ID']
|
||||
next unless vc_instance_id == vcenter_id
|
||||
|
||||
host_decrypted =
|
||||
OpenNebula::Host
|
||||
.new_with_id(
|
||||
datastore_id,
|
||||
host['ID'],
|
||||
client
|
||||
)
|
||||
rc = datastore.info
|
||||
if OpenNebula.is_error?(rc)
|
||||
raise "Could not get datastore info \
|
||||
for ID: #{datastore_id} - #{rc.message}"
|
||||
end
|
||||
|
||||
vcenter_id = datastore['TEMPLATE/VCENTER_INSTANCE_ID']
|
||||
|
||||
host_pool = OpenNebula::HostPool.new(client)
|
||||
rc = host_pool.info
|
||||
if OpenNebula.is_error?(rc)
|
||||
raise "Could not get hosts information - #{rc.message}"
|
||||
end
|
||||
|
||||
user = ''
|
||||
password = ''
|
||||
port = 0
|
||||
host_pool.each do |host|
|
||||
vc_instance_id = host['TEMPLATE/VCENTER_INSTANCE_ID']
|
||||
next unless vc_instance_id == vcenter_id
|
||||
|
||||
host_decrypted =
|
||||
OpenNebula::Host
|
||||
.new_with_id(
|
||||
host['ID'],
|
||||
client
|
||||
)
|
||||
host_decrypted.info(true)
|
||||
user = host_decrypted['TEMPLATE/VCENTER_USER']
|
||||
password = host_decrypted['TEMPLATE/VCENTER_PASSWORD']
|
||||
port = host_decrypted['TEMPLATE/VCENTER_PORT']
|
||||
end
|
||||
if password.empty? || user.empty?
|
||||
raise "Error getting \
|
||||
credentials for datastore #{datastore_id}"
|
||||
end
|
||||
|
||||
connection = {
|
||||
:host => datastore['TEMPLATE/VCENTER_HOST'],
|
||||
:user => user,
|
||||
:password => password
|
||||
}
|
||||
|
||||
connection[:port] = port unless port.nil?
|
||||
|
||||
new(connection)
|
||||
rescue StandardError => e
|
||||
raise e
|
||||
host_decrypted.info(true)
|
||||
user = host_decrypted['TEMPLATE/VCENTER_USER']
|
||||
password = host_decrypted['TEMPLATE/VCENTER_PASSWORD']
|
||||
port = host_decrypted['TEMPLATE/VCENTER_PORT']
|
||||
end
|
||||
if password.empty? || user.empty?
|
||||
raise "Error getting \
|
||||
credentials for datastore #{datastore_id}"
|
||||
end
|
||||
|
||||
connection = {
|
||||
:host => datastore['TEMPLATE/VCENTER_HOST'],
|
||||
:user => user,
|
||||
:password => password
|
||||
}
|
||||
|
||||
connection[:port] = port unless port.nil?
|
||||
|
||||
new(connection)
|
||||
end
|
||||
|
||||
def self.decrypt(msg, token)
|
||||
|
@ -199,8 +199,6 @@ module VNMMAD
|
||||
return
|
||||
end
|
||||
end
|
||||
rescue StandardError => e
|
||||
raise e
|
||||
ensure
|
||||
unlock
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user