@@ -326,9 +326,9 @@ def cmd_hosts(*args)
326
326
output = nil
327
327
default_columns = ::Mdm ::Host . column_names . sort
328
328
default_columns << 'tags' # Special case
329
- virtual_columns = [ 'svcs' , 'vulns' , 'workspace' ]
329
+ virtual_columns = [ 'svcs' , 'vulns' , 'workspace' , 'tags' ]
330
330
331
- col_search = [ 'address' , 'mac' , 'name' , 'os_name' , 'os_flavor' , 'os_sp' , 'purpose' , 'info' , 'comments' , 'tags' ]
331
+ col_search = [ 'address' , 'mac' , 'name' , 'os_name' , 'os_flavor' , 'os_sp' , 'purpose' , 'info' , 'comments' ]
332
332
333
333
default_columns . delete_if { |v | ( v [ -2 , 2 ] == "id" ) }
334
334
while ( arg = args . shift )
@@ -469,13 +469,13 @@ def cmd_hosts(*args)
469
469
when "svcs" ; host . services . length
470
470
when "vulns" ; host . vulns . length
471
471
when "workspace" ; host . workspace . name
472
+ when "tags"
473
+ found_tags = Mdm ::Tag . includes ( :hosts ) . where ( "hosts.workspace_id = ? and hosts.address = ?" , framework . db . workspace . id , host . address ) . order ( "tags.id DESC" )
474
+ tag_names = [ ]
475
+ found_tags . each { |t | tag_names << t . name }
476
+ found_tags * ", "
472
477
end
473
478
# Otherwise, it's just an attribute
474
- elsif n == 'tags'
475
- found_tags = Mdm ::Tag . includes ( :hosts ) . where ( "hosts.workspace_id = ? and hosts.address = ?" , framework . db . workspace . id , host . address ) . order ( "tags.id DESC" )
476
- tag_names = [ ]
477
- found_tags . each { |t | tag_names << t . name }
478
- found_tags * ", "
479
479
else
480
480
host . attributes [ n ] || ""
481
481
end
0 commit comments