From: Michal Fojtik<[email protected]>
---
server/bin/deltacloudd | 1 +
server/config/drivers.yaml | 3 ++
.../lib/deltacloud/drivers/rhevm/rhevm_client.rb | 24 +++++++++++++++++--
.../lib/deltacloud/drivers/rhevm/rhevm_driver.rb | 20 +++++++++-------
.../lib/deltacloud/helpers/application_helper.rb | 12 ++++++++++
server/public/images/pending.png | Bin 0 -> 792 bytes
server/public/images/running.png | Bin 0 -> 740 bytes
server/public/images/stopped.png | Bin 0 -> 779 bytes
server/views/instances/index.html.haml | 6 ++--
9 files changed, 51 insertions(+), 15 deletions(-)
create mode 100644 server/public/images/pending.png
create mode 100644 server/public/images/running.png
create mode 100644 server/public/images/stopped.png
diff --git a/server/bin/deltacloudd b/server/bin/deltacloudd
index 70be6ca..addb1f5 100755
--- a/server/bin/deltacloudd
+++ b/server/bin/deltacloudd
@@ -105,6 +105,7 @@ else
argv_opts<< ['--rackup', 'config.ru' ]
argv_opts<< ['--chdir', dirname ]
argv_opts<< ['-e', options[:env] ]
+ argv_opts<< ['--timeout', '60']
argv_opts<< ['--threaded', '-D', '--stats', '/stats']
argv_opts.flatten!
diff --git a/server/config/drivers.yaml b/server/config/drivers.yaml
index 3f34521..d028ca0 100644
--- a/server/config/drivers.yaml
+++ b/server/config/drivers.yaml
@@ -5,6 +5,9 @@
:name: Mock
:rhevm:
:name: RHEVM
+ :entrypoints:
+ default:
+ default:
"https://rhev-dc.lab.eng.brq.redhat.com:8443/rhevm-api-powershell"
:rimuhosting:
:name: RimuHosting
:opennebula:
diff --git a/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb
b/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb
index 09c025f..c1c7161 100644
--- a/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb
+++ b/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb
@@ -25,6 +25,15 @@ require 'json'
module RHEVM
class FixtureNotFound< Exception; end
+ class ConnectionError< StandardError
+ attr_reader :code, :cause, :details
+ def initialize(code, cause, message, details)
+ super(message)
+ @code = code
+ @cause = cause
+ @details = details
+ end
+ end
class Client
@@ -51,7 +60,7 @@ module RHEVM
opts ||= {}
if @@COLLECTIONS.include?(method_name.to_sym)
if opts[:id]
- object =
Nokogiri::XML(get("#{@entry_points[method_name.to_s]}#{opts[:id]}"))
+ object =
Nokogiri::XML(get("#{@entry_points[method_name.to_s]}/#{opts[:id]}"))
element = method_name.to_s
element = 'data_centers' if method_name.eql?(:datacenters)
@current_element = element
@@ -105,7 +114,12 @@ module RHEVM
if ENV['RACK_ENV'] == 'test'
response = mock_request(:get, uri, {}, headers)
else
- response = RestClient.get(uri, headers).to_s
+ puts "[RHEV-M] #{uri}"
+ begin
+ response = RestClient.get(uri, headers).to_s
+ rescue Exception => e
+ raise ConnectionError::new(500, "GET #{uri}", "#{e.message} (GET
#{uri})", e.backtrace)
+ end
end
response
end
@@ -127,7 +141,11 @@ module RHEVM
def discover_entry_points()
return if @discovered
- doc = Nokogiri.XML(get(@base_uri))
+ begin
+ doc = Nokogiri.XML(get(@base_uri))
+ rescue Exception => e
+ raise ConnectionError::new(500, "RHEV-M Connection Error (#{@base_uri})",
"#{e.message} (#{@base_uri})", e.backtrace)
+ end
doc.xpath('api/link').each() do |link|
@entry_points[link['rel']] = @host + link['href']
end
diff --git a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
index 8b4282f..3fd5365 100644
--- a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
+++ b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
@@ -72,7 +72,7 @@ class RHEVMDriver< Deltacloud::BaseDriver
# or setting provider using HTTP header X-Deltacloud-Provider to URL.
#
def provider_uri
- 'https://10.34.2.122:8443/rhevm-api-powershell'
+
Deltacloud::Drivers::driver_config[:rhevm][:entrypoints]['default']['default']
end
define_instance_states do
@@ -203,7 +203,9 @@ class RHEVMDriver< Deltacloud::BaseDriver
def new_client(credentials)
url = (Thread.current[:provider] || ENV['API_PROVIDER'] || provider_uri)
- ::RHEVM::Client.new(credentials.user, credentials.password, url)
+ safely do
+ ::RHEVM::Client.new(credentials.user, credentials.password, url)
+ end
end
def convert_instance(client, inst)
@@ -299,13 +301,13 @@ class RHEVMDriver< Deltacloud::BaseDriver
# Disabling this error catching will lead to more verbose messages
# on console (eg. response from RHEV-M API (so far I didn't figure our
# how to pass those message to our exception handling tool)
- #def catched_exceptions_list
- # {
- # :auth => RestClient::Unauthorized,
- # :error => RestClient::InternalServerError,
- # :glob => [ /RestClient::(\w+)/ ]
- # }
- #end
+ def catched_exceptions_list
+ {
+ :auth => RestClient::Unauthorized,
+ :error => RestClient::InternalServerError,
+ :glob => [ /(RestClient|RHEVM)::(\w+)/ ]
+ }
+ end
end
diff --git a/server/lib/deltacloud/helpers/application_helper.rb
b/server/lib/deltacloud/helpers/application_helper.rb
index f1909b2..191a0c9 100644
--- a/server/lib/deltacloud/helpers/application_helper.rb
+++ b/server/lib/deltacloud/helpers/application_helper.rb
@@ -186,4 +186,16 @@ module ApplicationHelper
end
end
+ def image_for_state(state)
+ state_img = "stopped" if (state!='RUNNING' or state!='PENDING')
+ "<img src='/images/#{state.downcase}.png' title='#{state}'/>"
+ end
+
+ def truncate_words(text, length = 10)
+ return nil unless text
+ return text if text.length<=length
+ end_string = "...#{text[(text.length-(length/2))..text.length]}"
+ "#{text[0..(length/2)]}#{end_string}"
+ end
+
end
diff --git a/server/public/images/pending.png b/server/public/images/pending.png
new file mode 100644
index
0000000000000000000000000000000000000000..6753441a11065d1e2b10104dd0e59db34842856f
GIT binary patch
literal 792
zcmV+z1LypSP)<h;3K|Lk000e1NJLTq001BW001Be1^@s6b9#F80000PbVXQnQ*UN;
zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU!x=BPqRCwC#R!>M2Q5gT;%<MnM(RHvj
z6VVDf2$fjW!RQYjB82MDAv$ylT8M5P+EWyi9Xdo2NYtf6bm>qe(qYN4OHpD4LV~g;
zySBEjy0h!%t~1m3y&Yv;(iL~Y%e>{szIpHW?f2uo@B7U%(==f#hX7kV90861M}Sn0
zz!+Qg*cf_o*z{EQ7)(5FLcv2Aegsn=V2kO{RL}X3xU|Y#*7F)x&WMTxh>bU1_0}lL
zrBiJ!u)nDus@x*qSjg${HJX6_kqJm?+LNi9XM(t_+bKZ8<S!f4y3^OX+F>aE2f~pI
zL{m$g(^MltSE~#i4PLkx9)|c#^6AvAvzM1eR4RZ4t~@%b?ra;le)0f3`#uljbBiEh
z^$6DK82B4Y2EZ=A2QKcdg}ZORK=S90W77|UgN6KNMMdah>W<sz+FRkxSQ_G)Jk)wb
zsK(=$T>=NqX^r-XLtN%>yhE{ebb$|C-p+vE50TkCC|2SsJOZBun$sHX5r?=SxjT7m
zrCor-&9JB=ngKG-1V&Z=?_u)m0M2EFMsV99fZuc~XJFL}YbGxiL0pT+>=3{^VLq$#
zW8O&D5VyoXDiUCt3#lP3J=d{aRY5m&SW5%t6a^7}C6hogrG~WGBFtrn!}mvHG4Nmk
z$S#Q&p0@-(UWgLs5SL;o)(!#Lx&Ft43$gLn??*<!OKs<Kf$WjE6B1}nYqUok;!+I7
zmc8DM7!iIch?c<B-X5iSPxqnS&Ct579z3ps6))y>i2P2#r?E-UCP(|G9|l9XJb}>4
z8PP_qm@?IJ*FACJi0@!`5R|%o%b}d2&3?;%?(0pxd;S5RqKJ9Bta#;Rgpd&`q8?Fg
zt$~#&jYuGph>YDYqm@U?UVWCyu%h<QS$CfQU$5g$kM(j$l>|Hg2^|5B06WHC0R{m2
W(HoU0sdYgB0000<MNUMnLSTZ#=yb^d
literal 0
HcmV?d00001
diff --git a/server/public/images/running.png b/server/public/images/running.png
new file mode 100644
index
0000000000000000000000000000000000000000..f74a91436191dc62eb6ad4316c2e6807fb1ed17d
GIT binary patch
literal 740
zcmV<A0vr8_P)<h;3K|Lk000e1NJLTq001BW001Be1^@s6b9#F80000PbVXQnQ*UN;
zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU!hDk(0RCwC#R^LlgVHkeCbIy*fri-~u
zjM+t$P!K^ELaXe?q91q{{R2VLO$FXqf(WHI1$Gl&RR2J9V?V&WQLJE)6@fxUNL%7G
zQ)hEqTkZ6|=bWh%@eI$2L7Wes?d<)Ym-qS3_kGVhp=lb*IV6;MxB^@Ou7I)&P^<_-
zh@zj(ooJM{phuH%qTpdn5qS*dGiV>|LWDv^?zWNH2`eXDB|tvajXr<X){7?(oyURt
zMtIe2`b0Xrgt2G@FWx^wVlj1p;5u3<{KrWF3Kf4`8w|EwK64YX#A}RCKgB|NPUmd*
z2C#qUIfVR2aPN5s;@@W<4BWt_f(W|;#Ib8QUbn|Lbfu*WucEz}NyZ@YYcH&jkf)Ct
zUkKs)tGL_WiTFgaY4{FCjQX0bL+J5V<JRfJ7w~TCA?8ytRM5#$WtuR-&m7}9<}kM+
zfNsup;ud&?2jRLMm6%G7L7`$YWl3wmF`i=%bA^I1=i0snG*o`o)0sDrWoyL+uDLy`
z69V*OnEVxmB1$tB=86?Pwgu=47BW%D#Mbf_T*=@H;hYm{xfI_1m^1cR-v()Y@EmiP
z%Q<TeX|n>dlcVVUGC>7sRf@8{2)(#saG1+Eoa=;u^!O8u%zs0FWYj32(&h3fE7y>p
zImUC$VJ_!zuI2WYVnp;+N!Z=ghMwvW&Nl1=YHMi4<}Lr71L8Bl$4~V7V|X@v8|@VS
zO89AIM5S6WtrLF2uD#7TN^PK3t-`_O9VSY45g(`>^nD)0ONvYq5>8q1ax)@u_X!Y!
z1fLm$Stv=EC2)gSa=IC<_8E`qa4L%1LDt;!+`nqan;sk0Q0yeT{|Q|I|Am0R0t^5@
WHt<xS!(=1?0000<MNUMnLSTYd-B(%w
literal 0
HcmV?d00001
diff --git a/server/public/images/stopped.png b/server/public/images/stopped.png
new file mode 100644
index
0000000000000000000000000000000000000000..b6cfd0b8f00132d106c0e214e8d0225015feb91e
GIT binary patch
literal 779
zcmV+m1N8ifP)<h;3K|Lk000e1NJLTq001BW001Be1^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d728ec5..d0ada19 100644
--- a/server/views/instances/index.html.haml
+++ b/server/views/instances/index.html.haml
@@ -14,17 +14,17 @@
- @instances.each do |instance|
%tr
%td
- = link_to instance.id, instance_url( instance.id )
+ = link_to truncate_words(instance.id), instance_url( instance.id )
%td
= link_to instance.owner_id, images_url
%td
= instance.name
%td
- = link_to instance.image_id, image_url( instance.image_id )
+ = link_to truncate_words(instance.image_id), image_url(
instance.image_id )
%td
= instance.hardware_profile ? link_to(instance.hardware_profile,
hardware_profile_url( instance.instance_profile.id )) : 'default'
%td
- = instance.state
+ = image_for_state(instance.state)
%td
-instance.actions.each do |action|
=link_to_action action, self.send(:"#{action}_instance_url",
instance.id), instance_action_method(action)