Skip to content

Commit d33e553

Browse files
author
Tom McKay
committed
fixes #6197 - moving host/guests to virtual_host/virtual_guests
This corrects conflict with foreman host link rubocop fix spec test fix
1 parent a910ae6 commit d33e553

File tree

14 files changed

+82
-63
lines changed

14 files changed

+82
-63
lines changed

app/controllers/katello/api/v2/systems_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def index
9999
param :fact, String, :desc => N_("Any number of facts about this content host")
100100
end
101101
param :type, String, :desc => N_("Type of the content host, it should always be 'content host'"), :required => true, :action_aware => true
102-
param :guest_ids, Array, :desc => N_("IDs of the guests running on this content host")
102+
param :virtual_guest_ids, Array, :desc => N_("IDs of the virtual guests running on this content host")
103103
param :installed_products, Array, :desc => N_("List of products installed on the content host"), :action_aware => true
104104
param :release_ver, String, :desc => N_("Release version of the content host")
105105
param :service_level, String, :allow_nil => true, :desc => N_("A service level for auto-healing process, e.g. SELF-SUPPORT"), :action_aware => true
@@ -125,7 +125,7 @@ def create
125125
param :fact, String, :desc => N_("Any number of facts about this content host")
126126
end
127127
param :type, String, :desc => N_("Type of the content host, it should always be 'content host'"), :required => true, :action_aware => true
128-
param :guest_ids, Array, :desc => N_("IDs of the guests running on this content host")
128+
param :virtual_guest_ids, Array, :desc => N_("IDs of the virtual guests running on this content host")
129129
param :installed_products, Array, :desc => N_("List of products installed on the content host"), :action_aware => true
130130
param :release_ver, String, :desc => N_("Release version of the content host")
131131
param :service_level, String, :allow_nil => true, :desc => N_("A service level for auto-healing process, e.g. SELF-SUPPORT"), :action_aware => true

app/helpers/katello/systems_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def errata_type_class(errata)
8282

8383
def system_type(system)
8484

85-
return _("Guest") if system.guest
85+
return _("Guest") if system.virtual_guest
8686

8787
case system.type
8888
when "Hypervisor"

app/lib/katello/resources/candlepin.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,14 @@ def remove_certificate(uuid, serial_id)
230230
self.delete(uri, self.default_headers).code.to_i
231231
end
232232

233-
def guests(uuid)
233+
def virtual_guests(uuid)
234234
response = Candlepin::CandlepinResource.get(join_path(path(uuid), 'guests'), self.default_headers).body
235235
Util::Data.array_with_indifferent_access JSON.parse(response)
236236
rescue
237237
return []
238238
end
239239

240-
def host(uuid)
240+
def virtual_host(uuid)
241241
response = Candlepin::CandlepinResource.get(join_path(path(uuid), 'host'), self.default_headers).body
242242
if response.present?
243243
JSON.parse(response).with_indifferent_access

app/models/katello/glue/candlepin/consumer.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@ def self.included(base)
4141
lazy_accessor :pools, :initializer => lambda {|s| entitlements.collect { |ent| Resources::Candlepin::Pool.find ent["pool"]["id"]} }
4242
lazy_accessor :available_pools, :initializer => lambda {|s| Resources::Candlepin::Consumer.available_pools(uuid, false) }
4343
lazy_accessor :all_available_pools, :initializer => lambda {|s| Resources::Candlepin::Consumer.available_pools(uuid, true) }
44-
lazy_accessor :host, :initializer => (lambda do |s|
45-
host_attributes = Resources::Candlepin::Consumer.host(self.uuid)
46-
(System.find_by_uuid(host_attributes['uuid']) || System.new(host_attributes)) if host_attributes
47-
end)
48-
lazy_accessor :guests, :initializer => (lambda do |s|
49-
guests_attributes = Resources::Candlepin::Consumer.guests(self.uuid)
50-
guests_attributes.map do |attr|
51-
System.find_by_uuid(attr['uuid']) || System.new(attr)
52-
end
53-
end)
44+
lazy_accessor :virtual_host, :initializer => (lambda do |s|
45+
host_attributes = Resources::Candlepin::Consumer.virtual_host(self.uuid)
46+
(System.find_by_uuid(host_attributes['uuid']) || System.new(host_attributes)) if host_attributes
47+
end)
48+
lazy_accessor :virtual_guests, :initializer => (lambda do |s|
49+
guests_attributes = Resources::Candlepin::Consumer.virtual_guests(self.uuid)
50+
guests_attributes.map do |attr|
51+
System.find_by_uuid(attr['uuid']) || System.new(attr)
52+
end
53+
end)
5454
lazy_accessor :compliance, :initializer => lambda {|s| Resources::Candlepin::Consumer.compliance(uuid) }
5555
lazy_accessor :events, :initializer => lambda {|s| Resources::Candlepin::Consumer.events(uuid) }
5656

@@ -312,13 +312,13 @@ def sockets=(sock)
312312
facts["cpu.cpu_socket(s)"] = s if @facts
313313
end
314314

315-
def guest
315+
def virtual_guest
316316
v = facts["virt.is_guest"]
317317
return false if (v == false || v.nil?)
318318
return(v == true || v.to_bool)
319319
end
320320

321-
def guest=(val)
321+
def virtual_guest=(val)
322322
facts["virt.is_guest"] = val if @facts
323323
end
324324

app/models/katello/glue/elastic_search/system.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ def self.included(base)
5454
:memory,
5555
:sockets,
5656
:status,
57-
:host,
58-
:guests
57+
:virtual_host,
58+
:virtual_guests
5959
]
6060

6161
dynamic_templates = [
@@ -112,8 +112,8 @@ def self.included(base)
112112
indexes :environment_sort, :type => 'string', :index => :not_analyzed
113113
indexes :content_view_sort, :type => 'string', :index => :not_analyzed
114114

115-
indexes :host, :type => 'string', :analyzer => :kt_name_analyzer
116-
indexes :guests, :type => 'string', :analyzer => :kt_name_analyzer
115+
indexes :virtual_host, :type => 'string', :analyzer => :kt_name_analyzer
116+
indexes :virtual_guests, :type => 'string', :analyzer => :kt_name_analyzer
117117
end
118118

119119
# Whenever a system's 'name' field changes, the objects returned by system.host_collections
@@ -142,10 +142,10 @@ def extended_index_attrs
142142
:environment_sort => self.environment.try(:name)
143143
}
144144

145-
if self.guest
146-
attrs[:host] = self.host ? self.host.name : ''
145+
if self.virtual_guest
146+
attrs[:virtual_host] = self.virtual_host ? self.virtual_host.name : ''
147147
else
148-
attrs[:guests] = self.guests.map(&:name)
148+
attrs[:virtual_guests] = self.virtual_guests.map(&:name)
149149
end
150150

151151
attrs

app/models/katello/system.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,11 @@ def as_json(options)
200200
json['content_view'] = content_view.as_json if content_view
201201
json['ipv4_address'] = facts.try(:[], 'network.ipv4_address') if respond_to?(:facts)
202202

203-
if respond_to?(:guest)
204-
if self.guest == 'true'
205-
json['host'] = self.host.attributes if self.host
203+
if respond_to?(:virtual_guest)
204+
if self.virtual_guest == 'true'
205+
json['virtual_host'] = self.virtual_host.attributes if self.virtual_host
206206
else
207-
json['guests'] = self.guests.map(&:attributes)
207+
json['virtual_guests'] = self.virtual_guests.map(&:attributes)
208208
end
209209
end
210210

@@ -219,8 +219,8 @@ def as_json(options)
219219
end
220220

221221
def type
222-
if respond_to?(:guest) && guest
223-
_("Guest")
222+
if respond_to?(:virtual_guest) && virtual_guest
223+
_("Virtual Guest")
224224
else
225225
case self
226226
when Hypervisor

app/views/katello/api/v2/systems/show.json.rabl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ if params[:fields] == "full"
6464
attributes :compliance
6565
attributes :facts
6666

67-
if @resource.respond_to?(:guest) || @resource.respond_to?(:host)
68-
if @resource.guest
69-
node :host do |system|
70-
system.host.attributes if system.host
67+
if @resource.respond_to?(:virtual_guest) || @resource.respond_to?(:virtual_host)
68+
if @resource.virtual_guest
69+
node :virtual_host do |system|
70+
system.virtual_host.attributes if system.virtual_host
7171
end
7272
else
73-
node :guests do |system|
74-
system.guests.map(&:attributes)
73+
node :virtual_guests do |system|
74+
system.virtual_guests.map(&:attributes)
7575
end
7676
end
7777
end

engines/bastion/app/assets/javascripts/bastion/content-hosts/details/content-host-details-info.controller.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,5 +259,14 @@ angular.module('Bastion.content-hosts').controller('ContentHostDetailsInfoContro
259259
memory = Math.round(memory * 100) / 100;
260260
return memory;
261261
}
262+
263+
$scope.virtualGuestIds = function (contentHost) {
264+
var ids = 'id:%s'.replace('%s', contentHost.id);
265+
angular.forEach(contentHost['virtual_guests'], function (host) {
266+
ids += ' id:%s'.replace('%s', host.id);
267+
});
268+
269+
return ids;
270+
};
262271
}]
263272
);

engines/bastion/app/assets/javascripts/bastion/content-hosts/details/views/content-host-info.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,21 @@ <h4 translate>Basic Information</h4>
3434
<span class="info-value">{{ contentHost.type }}</span>
3535
</div>
3636

37-
<div ng-show="contentHost.guests" class="detail">
38-
<span class="info-label" translate>Guests</span>
37+
<div ng-show="contentHost.virtual_guests" class="detail">
38+
<span class="info-label" translate>Virtual Guests</span>
3939
<div class="info-value">
40-
<ul>
41-
<li ng-repeat="guest in system.guests">
42-
<a ui-sref="content-hosts.details.info({contentHostId: guest.uuid})">{{ guest.name }}</a>
43-
</li>
44-
</ul>
40+
<a ng-href="/products?search={{ virtualGuestIds(contentHost) }}"
41+
translate translate-n="contentHost.virtual_guests.length"
42+
translate-plural="{{ contentHost.virtual_guests.length }} Hosts">
43+
1 Host
44+
</a>
4545
</div>
4646
</div>
4747

48-
<div ng-show="contentHost.host" class="detail">
49-
<span class="info-label" translate>Host</span>
48+
<div ng-show="contentHost.virtual_host" class="detail">
49+
<span class="info-label" translate>Virtual Host</span>
5050
<div class="info-value">
51-
<a ui-sref="content-hosts.details.info({contentHostId: system.host.uuid })">{{ system.host.name }}</a>
51+
<a ui-sref="content-hosts.details.info({contentHostId: contentHost.virtual_host.uuid })">{{ contentHost.virtual_host.name }}</a>
5252
</div>
5353
</div>
5454

engines/bastion/test/content-hosts/details/content-host-details-info.controller.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,16 @@ describe('Controller: ContentHostDetailsInfoController', function() {
117117
expect($scope.memory(facts)).toEqual(1024);
118118
});
119119

120+
it("builds list of guest ids", function () {
121+
var host;
122+
host = {id: 1};
123+
expect($scope.virtualGuestIds(host)).toEqual("id:1");
124+
host = {id: 1, "virtual_guests":[]};
125+
expect($scope.virtualGuestIds(host)).toEqual("id:1");
126+
host = {id: 1, "virtual_guests":[{ id: 2 }, { id: 3}]};
127+
expect($scope.virtualGuestIds(host)).toEqual("id:1 id:2 id:3");
128+
});
129+
120130
describe("populates advanced content host information", function () {
121131

122132
it("creates the content host facts object by converting dot notation response to an object.", function() {

0 commit comments

Comments
 (0)