Skip to content

Commit

Permalink
Merge pull request #10824 from kbrock/delegate_vm_to_hardware_annotation
Browse files Browse the repository at this point in the history
delegate vm.annotation to hardware
  • Loading branch information
gtanzillo committed Aug 31, 2016
2 parents 10c5b9d + 1e1ff97 commit c3c2a4b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
7 changes: 1 addition & 6 deletions app/models/vm_or_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class VmOrTemplate < ApplicationRecord
virtual_column :num_cpu, :type => :integer, :uses => :hardware
virtual_column :cpu_total_cores, :type => :integer, :uses => :hardware
virtual_column :cpu_cores_per_socket, :type => :integer, :uses => :hardware
virtual_column :v_annotation, :type => :string, :uses => :hardware
virtual_delegate :annotation, :to => :hardware, :prefix => "v", :allow_nil => true
virtual_column :has_rdm_disk, :type => :boolean, :uses => {:hardware => :disks}
virtual_column :disks_aligned, :type => :string, :uses => {:hardware => {:hard_disks => :partitions_aligned}}

Expand Down Expand Up @@ -255,11 +255,6 @@ class VmOrTemplate < ApplicationRecord
virtual_column m, :type => :string, :uses => :all_relationships
end

def v_annotation
return nil if hardware.nil?
hardware.annotation
end

include RelationshipMixin
self.default_relationship_type = "genealogy"

Expand Down
12 changes: 12 additions & 0 deletions spec/models/vm_or_template_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,18 @@
end
end

describe ".v_annotation" do
let(:vm) { FactoryGirl.create(:vm) }
it "handles no hardware" do
expect(vm.v_annotation).to be_nil
end

it "handles hardware" do
FactoryGirl.create(:hardware, :vm => vm, :annotation => "the annotation")
expect(vm.v_annotation).to eq("the annotation")
end
end

describe "#disconnect_ems" do
let(:ems) { FactoryGirl.build(:ext_management_system) }
let(:vm) do
Expand Down

0 comments on commit c3c2a4b

Please sign in to comment.