module Fog::Compute::Ovirt::V4::Shared

Public Instance Methods

check_arguments(id, options) click to toggle source
# File lib/fog/ovirt/requests/compute/v4/update_interface.rb, line 6
def check_arguments(id, options)
  raise ArgumentError, "instance id is a required parameter" unless id
  raise ArgumentError, "interface id is a required parameter for update-interface" unless options.key? :id
end
get_attr_value(value, opts) click to toggle source

rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity

# File lib/fog/ovirt/compute/v4.rb, line 75
def get_attr_value(value, opts)
  case value
  when OvirtSDK4::TemplateVersion, Array, Hash, OvirtSDK4::List, OvirtSDK4::DataCenter
    value
  when OvirtSDK4::Mac
    value.address
  when OvirtSDK4::Cpu
    opts[:cores] = value.topology.nil? ? nil : value.topology.cores
    opts[:sockets] = value.topology.nil? ? nil : value.topology.sockets
  when OvirtSDK4::Display
    subject = value.certificate.subject if value.certificate
    {
      :type => value.type,
      :address => value.address,
      :port => value.port,
      :secure_port => value.secure_port,
      :subject => subject,
      :monitors => value.monitors
    }
  else
    value.to_s.strip
  end
end
ovirt_attrs(obj) click to toggle source

rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity converts an OVIRT object into an hash for fog to consume.

# File lib/fog/ovirt/compute/v4.rb, line 44
def ovirt_attrs(obj)
  opts = {}
  # TODO: stop using instance_variables, they will change
  obj.instance_variables.each do |v|
    key = v.to_s.delete("@").to_sym
    value = obj.instance_variable_get(v)

    if key == :network
      opts[key] = client.follow_link(obj.vnic_profile).network.id
      next
    end

    if key == :provisioned_size
      opts[:size] = value
      next
    end

    # ignore nil values
    next if value.nil?

    if key != :data_center && value.respond_to?(:href) && value.href && value.respond_to?(:id)
      opts[key] = value.id
    end

    opts[key] ||= get_attr_value(value, opts)
  end
  opts
end