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 +4 -4
- data/lib/ovirt_metrics.rb +5 -1
- data/lib/ovirt_metrics/models/vm_device_history.rb +1 -0
- data/lib/ovirt_metrics/version.rb +1 -1
- data/spec/ovirt_metrics_spec.rb +30 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8531838b19b90017cbbffe7c3b13ab9d412c762
|
4
|
+
data.tar.gz: c85dace0a565248aeac3a80042d392fe22d20667
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8d6b8b0904ff6a76bf561941e22dc860c86c13192710d4e2acb5e782c4cba689ec027d45751b5cd1c043bfde2fad75d5c84f13d2fb5cbe576bc02965588fdbb
|
7
|
+
data.tar.gz: 364b1d58661abb9af90a1971046d06cf98241cd0770c382916be21513773f04255714d50371f641990a52722179df44a085bbde82f4e5044cc118fdcefc8b369
|
data/lib/ovirt_metrics.rb
CHANGED
@@ -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 =
|
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
|
|
data/spec/ovirt_metrics_spec.rb
CHANGED
@@ -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.
|
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:
|
12
|
+
date: 2017-02-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|