Git Product home page Git Product logo

Comments (1)

ramrexx avatar ramrexx commented on August 21, 2024

Hello,
CF 3.2 no longer ships with the xmlimple ruby gem. I have been slowly migrating those methods to convert them to use JSON instead. So you can do 1 of the following:

  1. install the xmlsimple ruby gem - I do not recommend this approach.

  2. change your REST call to use JSON formatting instead. I sent you an email with the updated methods.

Here is a snippet:

def call_rhev(action, ref=nil, body_type=:json, body=nil)
require 'rest_client'
require 'json'

servername = @vm.ext_management_system.hostname
username = @vm.ext_management_system.authentication_userid
password = @vm.ext_management_system.authentication_password

unless ref.nil?
url = ref if ref.include?('http')
end
url ||= "https://#{servername}"+"#{ref}"

params = {
:method=>action, :url=>url,:user=>username, :password=>password,
:verify_ssl=>false, :headers=>{ :content_type=>body_type, :accept=>:json }
}
body_type == :json ? (params[:payload] = JSON.generate(body) if body) : (params[:payload] = body if body)
log_and_update_message(:info, "Calling url: #{url} action: #{action} payload: #{params[:payload]}")

response = RestClient::Request.new(params).execute
log_and_update_message(:info, "response headers: #{response.headers.inspect}")
log_and_update_message(:info, "response code: #{response.code}")
log_and_update_message(:info, "response: #{response.inspect}")
return JSON.parse(response) rescue (return response)
end

body_hash = {
  "type"=>volume_option[:type],
  "size"=>volume_option[:size_in_bytes],
  "interface"=>volume_option[:interface],
  "format"=>volume_option[:format],
  "bootable"=>volume_option[:bootable],
  "storage_domain"=>{"id"=>volume_option[:storage_domain_id]}
}

log_and_update_message(:info, "Creating disk#: #{volume_option[:vol_index]} volume_options: #{volume_option}")
create_disk_response_hash = call_rhev(:post, "#{@vm.ems_ref}/disks", :json, body_hash)

from cloudformspoc.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.