ovirt_metrics 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b8f6eb0cee5ba8ae32e0f2fa316048a258204db1
4
- data.tar.gz: 16b8c4b956bdbf7016483bb4dc225dde3779a6c7
3
+ metadata.gz: e8531838b19b90017cbbffe7c3b13ab9d412c762
4
+ data.tar.gz: c85dace0a565248aeac3a80042d392fe22d20667
5
5
  SHA512:
6
- metadata.gz: ebde982b37176d5d7374792f54508747feda496cc2b4a4166548c6117c3fae3fab73a1a1fc434c39a16ceb727f665c7f85fd7d535acf6474927766137395520e
7
- data.tar.gz: b215b596b463b6c07b7230ada719f7f07c1c642ac28c807e7d5c93f0a266393dc17c6614a7306e8b84b227c64d0278c61a1864f588e4baf484378ca5ab5b8164
6
+ metadata.gz: a8d6b8b0904ff6a76bf561941e22dc860c86c13192710d4e2acb5e782c4cba689ec027d45751b5cd1c043bfde2fad75d5c84f13d2fb5cbe576bc02965588fdbb
7
+ data.tar.gz: 364b1d58661abb9af90a1971046d06cf98241cd0770c382916be21513773f04255714d50371f641990a52722179df44a085bbde82f4e5044cc118fdcefc8b369
@@ -111,8 +111,12 @@ module OvirtMetrics
111
111
  VmDeviceHistory.where(:vm_id => vm_id).disks.attached.pluck('DISTINCT device_id')
112
112
  end
113
113
 
114
+ def self.vms_nic_ids_for(vm_id)
115
+ VmDeviceHistory.where(:vm_id => vm_id).nics.attached.pluck("DISTINCT device_id")
116
+ end
117
+
114
118
  def self.query_vm_nic_realtime_metrics(vm_id, start_time = nil, end_time = nil)
115
- nic_ids = VmInterfaceConfiguration.where(:vm_id => vm_id).collect(&:vm_interface_id)
119
+ nic_ids = vms_nic_ids_for(vm_id)
116
120
  VmInterfaceSamplesHistory.where(:vm_interface_id => nic_ids).with_time_range(start_time, end_time)
117
121
  end
118
122
 
@@ -5,6 +5,7 @@ module OvirtMetrics
5
5
  self.inheritance_column = :_type_disabled
6
6
 
7
7
  scope :disks, -> { where(:type => "disk") }
8
+ scope :nics, -> { where(:type => "interface") }
8
9
  scope :attached, -> { where(:delete_date => nil) }
9
10
  end
10
11
  end
@@ -1,3 +1,3 @@
1
1
  module OvirtMetrics
2
- VERSION = "1.4.0"
2
+ VERSION = "1.4.1"
3
3
  end
@@ -31,6 +31,36 @@ describe OvirtMetrics do
31
31
  it { is_expected.not_to include("device_that_was_deleted") }
32
32
  end
33
33
 
34
+ describe ".vms_nic_ids_for" do
35
+ before(:each) do
36
+ @vm1_id = 1
37
+ @device_id1 = "device1"
38
+ @device_id2 = "device2"
39
+ generic_params = {
40
+ :vm_id => @vm1_id,
41
+ :device_id => @device_id1,
42
+ :type => "interface",
43
+ :address => "address",
44
+ :create_date => 1.week.ago
45
+ }
46
+ OvirtMetrics::VmDeviceHistory.create(generic_params)
47
+ OvirtMetrics::VmDeviceHistory.create(generic_params.merge(:address => "duplicate_with_same_device_id"))
48
+ OvirtMetrics::VmDeviceHistory.create(generic_params.merge(:device_id => @device_id2))
49
+ OvirtMetrics::VmDeviceHistory.create(generic_params.merge(:vm_id => 2, :device_id => "disk_from_other_vm"))
50
+ OvirtMetrics::VmDeviceHistory.create(generic_params.merge(:type => "disk",
51
+ :device_id => "device_of_non_nic_type"))
52
+ OvirtMetrics::VmDeviceHistory.create(generic_params.merge(:device_id => "device_that_was_deleted",
53
+ :delete_date => 2.days.ago))
54
+ end
55
+
56
+ subject { described_class.vms_nic_ids_for(@vm1_id) }
57
+
58
+ it { is_expected.to match_array([@device_id1, @device_id2]) }
59
+ it { is_expected.not_to include("nic_from_other_vm") }
60
+ it { is_expected.not_to include("device_of_non_nic_type") }
61
+ it { is_expected.not_to include("device_that_was_deleted") }
62
+ end
63
+
34
64
  context ".vm_realtime" do
35
65
  it "when vm_id finds no matches" do
36
66
  expect(described_class.vm_realtime(42)).to eq([{}, {}])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ovirt_metrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Barenboim
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-12-13 00:00:00.000000000 Z
12
+ date: 2017-02-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler