Sha256: 133aa4bdf9f0aa1131383646bd31f5b6a66b22168e1245ae1cf20835d843f319

Contents?: true

Size: 1.35 KB

Versions: 2

Compression:

Stored size: 1.35 KB

Contents

module FogExtensions
  module Xenserver
    module Server
      extend ActiveSupport::Concern

      include ActionView::Helpers::NumberHelper

      attr_accessor :start, :image_id, :hypervisor_host, :iso, :target_sr
      attr_accessor :memory_min, :memory_max, :builtin_template
      attr_writer :volumes, :interfaces

      def id
        uuid
      end

      def to_s
        name
      end

      def nics_attributes=(attrs); end

      def volumes_attributes=(attrs); end

      def volumes
        @volumes ||= []
        disks = vbds.compact.select(&:disk?)
        disks.sort! { |x, y| x.userdevice <=> y.userdevice }
        (disks.map(&:vdi) + @volumes).uniq
      end

      def memory
        memory_static_max.to_i
      end

      def reset
        reboot
      end

      def stop
        shutdown
      end

      def ready?
        running?
      end

      def mac
        vifs.first.mac
      end

      def state
        power_state
      end

      def vm_description
        format(_('%{cpus} CPUs and %{ram} memory'), :cpus => vcpus_max, :ram => number_to_human_size(memory_max.to_i))
      end

      def interfaces
        (vifs + @interfaces).uniq
      end

      def select_nic(fog_nics, nic)
        fog_nics[0]
      end

      def user_data
        return !other_config['default_template'] if is_a_template

        false
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
foreman_xen-1.0.1 app/models/concerns/fog_extensions/xenserver/server.rb
foreman_xen-1.0.0 app/models/concerns/fog_extensions/xenserver/server.rb