zach-r-long / minimega-phenix

minimega
GNU General Public License v3.0
0 stars 1 forks source link

Extend VM Search #12

Open eric-c-wood opened 3 years ago

eric-c-wood commented 3 years ago

Describe your feature The current VM search only searches for a VM by name. It would be nice to extend the search function to able to ask the following questions/queries:

  1. Find all VMs in a specific state (running, stopped, shutdown, etc..)
  2. Find all VMs that are currently capturing packets
  3. Find all VMs that belong to a specific subnet (192.168.20.1/30, 192.168.3.1/20, etc..)
  4. Find all VMs that are running on a specific host
  5. Find all VMs with specific tags/metadata.

Search criteria should be able to be combined with verbose Boolean operators such as "and,or,etc.." and have a default Boolean operator when not explicitly specified.

Feature Details Stage of Experiment when feature is active: (Creation, Start, Post Start, Running, Stop, Delete) stage: Running and Stopped. For a stopped experiment questions 1 and 2 will not apply. For all queries, it might be necessary to block the web UI from further input and give the user appropriate feedback for searches that might take more than a few seconds.

Where should feature be visible (current phenix tab and general location or propose a new tab, or not visible) view: The query can be ran from the current search bars on both the running and stopped experiment views.

Expected behavior The running and stopped views will show only the VMs matching the search criteria. The search results can then be used for other actions.

eric-c-wood commented 3 years ago

I created a prototype for an extended search using verbose Boolean operators for both the Running and Stopped experiment views. The prototype can be viewed in this branch. https://github.com/eric-c-wood/minimega-phenix/tree/extendedSearch

Here are some example searches:

  1. 192.168.1.0/24 and dnb (Stopped experiment view to find VMs with interfaces in the specified subnet and have the do not boot flag set to true)
  2. dnb (Stopped experiment view to find all VMs with the do not boot flag set to true)
  3. capturing and router (Running experiment view to find all VMs that have an active packet capture and have router appearing in the name, host, taps, tags, or disk fields)
  4. shutdown and 10.0.0.0/8 (Running experiment view to find all VMs that have been shutdown and have interfaces in the specified subnet)
  5. 192.168.1.0/24 and 10.0.0.0/8 (Running/Stopped experiment views to find all VMs with interfaces in both the specified subnets)

It is worth noting that eventually we might want to change how the search is sent to the server. Currently, as soon as anything is typed in the "search" box, the search is sent to the server. This can potentially send a lot of unnecessary traffic to the server. Perhaps, using the "Enter" key or a "Search" button to wait for the user to enter the complete search term may be better.

eric-c-wood commented 3 years ago

I ended up using the debounce function from the lodash library to wait some period of time before sending the search query to the server. https://lodash.com/docs/#debounce