Skip to main content

SearchIndex

Struct SearchIndex 

Source
pub struct SearchIndex { /* private fields */ }
Expand description

The SearchIndex service allows a client to efficiently query the inventory for a specific managed entity by attributes such as UUID, IP address, DNS name, or datastore path.

Such searches typically return a VirtualMachine or a HostSystem. While searching, only objects for which the user has sufficient privileges are considered. The findByInventoryPath and findChild operations only search on entities for which the user has view privileges; all other SearchIndex find operations only search virtual machines and hosts for which the user has read privileges. If the user does not have sufficient privileges for an object that matches the search criteria, that object is not returned.

Implementations§

Source§

impl SearchIndex

Source

pub fn new(client: Arc<dyn VimClient>, mo_id: &str) -> Self

Source

pub async fn find_all_by_dns_name( &self, datacenter: Option<&ManagedObjectReference>, dns_name: &str, vm_search: bool, ) -> Result<Vec<ManagedObjectReference>>

Finds all virtual machines or hosts by DNS name.

The DNS name for a virtual machine is the one returned from VMware tools, GuestInfo.hostName.

Required privileges: System.View

§Parameters:
§datacenter

If specified, restricts the query to entities in a particular datacenter. If not specified, the entire inventory is searched.

Refers instance of Datacenter.

§dns_name

The fully qualified domain name to find.

If true, search for virtual machines, otherwise search for hosts.

§Returns:

The list of all virtual machines or hosts that are found. If no managed entities are found, an empty list is returned. If there are multiple matches, all matching entities are returned.

Refers instances of ManagedEntity.

Source

pub async fn find_all_by_ip( &self, datacenter: Option<&ManagedObjectReference>, ip: &str, vm_search: bool, ) -> Result<Vec<ManagedObjectReference>>

Finds all virtual machines or hosts by IP address, where the IP address is in dot-decimal notation.

For example, 10.17.12.12. The IP address for a virtual machine is the one returned from VMware tools, GuestInfo.ipAddress.

Required privileges: System.View

§Parameters:
§datacenter

If specified, restricts the query to entities in a particular datacenter. If not specified, the entire inventory is searched.

Refers instance of Datacenter.

§ip

The dot-decimal notation formatted IP address to find.

§vm_search

If true, search for virtual machines, otherwise search for hosts.

§Returns:

The list of all virtual machines or hosts that are found. If no managed entities are found, an empty list is returned. If there are multiple matches, all matching entities are returned.

Refers instances of ManagedEntity.

Source

pub async fn find_all_by_uuid( &self, datacenter: Option<&ManagedObjectReference>, uuid: &str, vm_search: bool, instance_uuid: Option<bool>, ) -> Result<Vec<ManagedObjectReference>>

Finds all virtual machines or hosts by UUID.

Required privileges: System.View

§Parameters:
§datacenter

If specified, restricts the query to entities in a particular datacenter. If not specified, the entire inventory is searched.

Refers instance of Datacenter.

§uuid

The UUID to find. If vmSearch is true, the UUID can be either BIOS or instance UUID.

§vm_search

If true, search for virtual machines, otherwise search for hosts.

§instance_uuid

Should only be set when vmSearch is true. If specified, search for virtual machines whose instance UUID matches the given uuid. Otherwise, search for virtual machines whose BIOS UUID matches the given uuid.

§Returns:

The list of all virtual machines or hosts that are matching with the given UUID. If no managed entities are found, an empty list is returned. If there are multiple matches, all matching entities are returned.

Refers instances of ManagedEntity.

Source

pub async fn find_by_datastore_path( &self, datacenter: &ManagedObjectReference, path: &str, ) -> Result<Option<ManagedObjectReference>>

Finds a virtual machine by its location on a datastore.

Required privileges: System.View

§Parameters:
§datacenter

Specifies the datacenter to which the datastore path belongs.

Refers instance of Datacenter.

§path

A datastore path to the .vmx file for the virtual machine.

§Returns:

The virtual machine that is found. If no virtual machine is found, null is returned. Only a single entity is returned, even if there are multiple matches.

Refers instance of VirtualMachine.

§Errors:

InvalidDatastore: if a datastore has not been specified in the path or if the specified datastore does not exist on the specified datacenter.

Source

pub async fn find_by_dns_name( &self, datacenter: Option<&ManagedObjectReference>, dns_name: &str, vm_search: bool, ) -> Result<Option<ManagedObjectReference>>

Finds a virtual machine or host by DNS name.

The DNS name for a virtual machine is the one returned from VMware tools, GuestInfo.hostName.

Required privileges: System.View

§Parameters:
§datacenter

If specified, restricts the query to entities in a particular datacenter. If not specified, the entire inventory is searched.

Refers instance of Datacenter.

§dns_name

The fully qualified domain name to find.

§vm_search

if true, search for virtual machines, otherwise search for hosts.

§Returns:

The virtual machine or host managed entity that is found. If no managed entities are found, null is returned. Only a single entity is returned, even if there are multiple matches.

Refers instance of ManagedEntity.

Source

pub async fn find_by_inventory_path( &self, inventory_path: &str, ) -> Result<Option<ManagedObjectReference>>

Finds a managed entity based on its location in the inventory.

The path is separated by slashes (‘/’). For example, a path should be of the form “My Folder/My Datacenter/vm/Discovered VM/VM1”. A leading slash or trailing slash is ignored. Thus, the following paths all represents the same object: “a/b”, “/a/b”, “a/b/”, and ‘/a/b/’. Slashes in names must be represented using %2f, following the standard URL syntax. Any object in the inventory can be retrieved using this method, including resource pools and hosts.

Required privileges: System.View

§Parameters:
§inventory_path

The path to the entity.

§Returns:

The managed entity that is found. If no match is found, null is returned.

Refers instance of ManagedEntity.

Source

pub async fn find_by_ip( &self, datacenter: Option<&ManagedObjectReference>, ip: &str, vm_search: bool, ) -> Result<Option<ManagedObjectReference>>

Finds a virtual machine or host by IP address, where the IP address is in dot-decimal notation.

For example, 10.17.12.12. The IP address for a virtual machine is the one returned from VMware tools, GuestInfo.ipAddress.

Required privileges: System.View

§Parameters:
§datacenter

If specified, restricts the query to entities in a particular datacenter. If not specified, the entire inventory is searched.

Refers instance of Datacenter.

§ip

The dot-decimal notation formatted IP address to find.

§vm_search

if true, search for virtual machines, otherwise search for hosts.

§Returns:

The virtual machine or host managed entity that is found. If no managed entities are found, null is returned. Only a single entity is returned, even if there are multiple matches. If called directly on an ESX server with vmSearch set to false, returns the host managed entity if the address matches any of the Console OS IP addresses.

Refers instance of ManagedEntity.

Source

pub async fn find_by_uuid( &self, datacenter: Option<&ManagedObjectReference>, uuid: &str, vm_search: bool, instance_uuid: Option<bool>, ) -> Result<Option<ManagedObjectReference>>

Finds a virtual machine or host by BIOS or instance UUID.

Required privileges: System.View

§Parameters:
§datacenter

If specified, restricts the query to entities in a particular datacenter. If not specified, the entire inventory is searched.

Refers instance of Datacenter.

§uuid

The UUID to find. If vmSearch is true, the uuid can be either BIOS or instance UUID.

§vm_search

If true, search for virtual machines, otherwise search for hosts.

§instance_uuid

Should only be set when vmSearch is true. If specified, search for virtual machines whose instance UUID matches the given uuid. Otherwise, search for virtual machines whose BIOS UUID matches the given uuid.

§Returns:

The virtual machine or host managed entity that is found. If no managed entities are found, null is returned. Only a single entity is returned, even if there are multiple matches.

Refers instance of ManagedEntity.

Source

pub async fn find_child( &self, entity: &ManagedObjectReference, name: &str, ) -> Result<Option<ManagedObjectReference>>

Finds a particular child based on a managed entity name.

This only searches the immediate children of a managed entity. For a Datacenter, the host and vm folders are considered children. For a ComputeResource, the hosts and root ResourcePool are considered children.

Required privileges: System.View

§Parameters:
§entity

A reference to a managed entity.

Refers instance of ManagedEntity.

§name

The name of the child object.

§Returns:

The managed entity that is found, or null if no match is found.

Refers instance of ManagedEntity.

Trait Implementations§

Source§

impl Clone for SearchIndex

Source§

fn clone(&self) -> SearchIndex

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsAny for T
where T: 'static,

Source§

fn as_any_ref<'a>(&'a self) -> &'a (dyn Any + 'static)

Cast a reference to Any trait.

Source§

fn as_any_box(self: Box<T>) -> Box<dyn Any>

Cast to a boxed reference to Any trait.

Source§

fn type_id(&self) -> TypeId

Get the underlying type identifier.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<To, T> CastInto<To> for T
where To: CastFrom<T> + ?Sized, T: 'static + ?Sized,

Source§

fn into_ref<'a>(&'a self) -> Option<&'a To>

Casts a reference to a trait object. If the cast fails, std::option::Option::None is returned.
Source§

fn into_box(self: Box<T>) -> Result<Box<To>, Box<dyn Any>>

Casts a boxed trait object to another trait object. If the cast fails, the original boxed trait object is returned in std::result::Result::Err.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,