This expands the timeout for opening connections
to all method/BMC interactions.
If a context with a timeout IS provided to a method call
but no per provider timeout is defined, then we default to a
timeout of the provided timeout duration divided by the
number of providers/drivers in the Client.Registry.Drivers
slice.
If a context with a timeout IS NOT provided to a method call
and no per provider timeout is defined, then we use the
defaultConnectTimeout of 30 seconds.
Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
The context deadline timeout value is shared between all the bmclib providers
that is - when creating an a new connection/session on a BMC. The shared timeout value
entails that a single provider can consume the whole timeout value depending on how long
it takes to respond, thus leaving the other providers with no chance to connect.
WithConnectTimeout sets the timeout when connecting to a BMC to create a new session.
When not defined the deadline value passed in through the context applies.
This timeout value will best work when its lesser than the passed in context deadline value.
This enables the client to optionally define Redfish versions its not compatible
with, giving the user the option to ignore the Redfish endpoint on BMCs
for cases where the Redfish version is too old or is known to not have
an expected functionality.
The UX feels unnecessarily verbose/explicit. Most other
libraries that have open/close methods just return an error.
These libraries dont return multiple implementation but with
the ability to get metadata for each Client.X call I dont
think we need to worry about making it that explicit that
we've modified the providers. Open for discussion here, but
putting this in as a PR regardless.
Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
After using the metadata for a little, i dont like the
experience. Having to pass in metadata was not easily
understood and was trying to be too clever. This update
will make metadata available for all methods. user just
has to call GetMetadata().
Public API is affected as client will no longer be able
to pass in the &metadata var. Seeing as we are not v1,
i feel comfortable with the change.
Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
Currently, if an implementation that opens a stateful session
in its Opener implementation fails when open is called and then
has a method called, for example, PowerStateGet, that needs to
use the session info, we will get a panic.
This code updates the OpenConnectionFromInterfaces to remove any
provider implementations that fails to open successfully.
We do this and then return a new registrar.Drivers from the Open
method in client.go.
This changes the existing client.go Open method signature.
Returning the registrar.Drivers instead of updating in place I
think is important. We don't want to hide the "magic" because
this can be confusing about why/which providers are being removed.
It also allows the end-user to have flexibility in deciding
if/when to use this newly updated registrar.Drivers.
Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
Updates metadata with open/close providers attempted
and successful. Also, cleaned up tests in the bmc package.
Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
Change the successfulProvider to be the bmc.Metadata
struct. This allows us to grow the metadata we can
provide during a method call.
Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
Without breaking clients, this adds the capability
of relaying to the end-user the name of the provider
that successfully executed. This give info back to
end-users to help if they need to use a certain
provider for certain hardware.
Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
Replace the local registry package with github.com/jacobweinstock/registry
makes the registry much simpler to interact with and
removes the magic of init functions and package-level
variables. Makes registering providers more understandable
through explicit registration.
Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
This is the update to ScanAndDiscover for the registry.
It will run an "isCompatible" function for all registered
providers to determine if the BMC is compatible with the
provider and then will update the registry collection
with all compatible providers.
Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
This function will integrate the ScanAndConnect functionality
to discover and register any providers that are compatible with
the BMC. discover.ScanAndConnect as is doesn't implement any of
the new design interfaces but is here to show a path forward
for how to use the very valuable discovery functionality with
the registry. We'll need to add functionality that will append
to the registry for all providers that are compatible with
a BMC.
Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
Client package purpose is to be the primary
interaction that a bmclib user would use. It interacts
with the registry to initialize registered providers
with auth and then has pass through functions to call
the interface executor functions.
Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>