net-ssh-multi icon indicating copy to clipboard operation
net-ssh-multi copied to clipboard

Is there any way to filter ungrouped servers with specific properties?

Open andrewhavens opened this issue 4 years ago • 1 comments
trafficstars

Looking through the code, I see an example for finding a server that has been added to a specific group:

session.group :db do
  session.use 'dbmain', 'user', :properties => { :primary => true }
end

primary = session.servers_for(:db => { :only => { :primary => true } })

But what if that server was never added to a group? Something like this:

session.use 'server', 'user', :properties => { :something => 'unique' }

server = session.servers_for({ :only => { :something => 'unique' } })

If there is no way to do this, is this a feature that we can add?

andrewhavens avatar Apr 09 '21 22:04 andrewhavens

I won't lie, it's been a hot minute since I've looked at this code. But would session.server_list suffice? It'll show all defined servers, even those in groups, but it will also give you those that were not placed in groups.

If that's tricky (e.g., you're using ungrouped AND grouped servers, and you only want the ungrouped ones) you might be better off putting the ungrouped servers in their own group (like, :ungrouped) and query them that way.

jamis avatar Apr 10 '21 02:04 jamis