From: Michal Fojtik <mfoj...@redhat.com>
Signed-off-by: Michal fojtik <mfoj...@redhat.com> --- .../lib/deltacloud/drivers/rhevm/rhevm_client.rb | 27 ++++++------------- 1 files changed, 9 insertions(+), 18 deletions(-) diff --git a/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb b/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb index 49f6509..ddb8e78 100644 --- a/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb +++ b/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb @@ -92,24 +92,15 @@ module RHEVM return true end - def api_version?(major) - headers = { - :content_type => 'application/xml', - :accept => 'application/xml' - } + def has_capability?(name) + headers = {} headers.merge!(auth_header) - result_xml = Nokogiri::XML(RHEVM::client(@api_entrypoint)["/"].get(headers)) - (result_xml/'/api/system_version').first[:major].strip == major - end - - def cluster_version?(cluster_id, major) - headers = { + headers.merge!({ :content_type => 'application/xml', - :accept => 'application/xml' - } - headers.merge!(auth_header) - result_xml = Nokogiri::XML(RHEVM::client(@api_entrypoint)["/clusters/%s" % cluster_id].get(headers)) - (result_xml/'/cluster/version').first[:major].strip == major + :accept => 'application/xml', + }) + capabilities_xml = Nokogiri::XML(RHEVM::client(@api_entrypoint)['/capabilities'].get(headers)) + ! (capabilities_xml/"/capabilities/version/custom_properties/custom_property[@name='#{name}']").empty? end def create_vm(template_id, opts={}) @@ -124,8 +115,8 @@ module RHEVM cpu { topology( :cores => (opts[:hwp_cpu] || '1'), :sockets => '1' ) } - if opts[:user_data] and not opts[:user_data].empty? - if api_version?('3') and cluster_version?((opts[:realm_id] || clusters.first.id), '3') + if (opts[:user_data] and not opts[:user_data].empty?) + if has_capability?('floppyinject') custom_properties { # # FIXME: 'regexp' parameter is just a temporary workaround. This -- 1.7.4.4