Skip to content

Conversation

@rbtr
Copy link
Collaborator

@rbtr rbtr commented Oct 3, 2023

Previously, the Wireserver Client used a hardcoded IP, which made starting CNS locally impossible. This is because it attempted to make requests to a Wireserver that wasn't there. There is already a configuration for a WireserverIP, with the intention that that be used to redirect those requests to a mock server for local testing.

This makes the host to which those Wireserver requests are directed configurable so that this configuration is respected by the Wireserver client.

No configuration changes are necessary to end users since no configuration has changed.

To use this locally, any mocks that are in use will need to add an endpoint responding to /machine/plugins?comp=nmagent&getinterfaceinfov1 responding with XML in the form:

<Result>
  <Interfaces MacAddress="{{mac}}" IsPrimary="true">
    <IPSubnet Prefix="{{prefix}}">
      <IPAddress Address="{{addr}}" IsPrimary="true"></IPAddress>
    </IPSubnet>
  </Interfaces>
</Result>

@rbtr rbtr requested a review from a team as a code owner October 3, 2023 16:02
@rbtr rbtr requested a review from jaer-tsun October 3, 2023 16:02
@timraymond timraymond changed the title Traymond/wireserver client config Fix missing Wireserver IP configuration in Wireserver Client Oct 3, 2023
@rbtr rbtr force-pushed the traymond/wireserver-client-config branch from 7063b2c to 1f81760 Compare October 31, 2023 16:38
@rbtr rbtr enabled auto-merge (squash) October 31, 2023 16:38
@rbtr rbtr force-pushed the traymond/wireserver-client-config branch from 1f81760 to 53997a6 Compare November 2, 2023 15:19
There's a bug with the wireserver client, in that the Wireserver IP from
the CNS config isn't respected. This adds coverage so that it becomes
safer to make changes here.
This allows the Wireserver client to use a configurable host so that
this could, theoretically be mocked. As it currently stands, it's an
impediment to running CNS locally, since it uses the real Wireserver IP.
The Wireserver client now accepts a hostport configuration option so
that its requests can be redirected. This plumbs the config for the
WireserverIP to it so that it can be redirected during test.
@rbtr rbtr force-pushed the traymond/wireserver-client-config branch from 53997a6 to 59e65b7 Compare November 6, 2023 15:13
Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>
Copy link
Member

@nddq nddq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@rbtr rbtr disabled auto-merge November 7, 2023 14:50
@rbtr rbtr merged commit 5b27f4a into master Nov 7, 2023
@rbtr rbtr deleted the traymond/wireserver-client-config branch November 7, 2023 14:51
matmerr pushed a commit that referenced this pull request Jan 17, 2024
* Add coverage around GetInterfaces in WS client

There's a bug with the wireserver client, in that the Wireserver IP from
the CNS config isn't respected. This adds coverage so that it becomes
safer to make changes here.

* Allow Wireserver client to use a configurable Host

This allows the Wireserver client to use a configurable host so that
this could, theoretically be mocked. As it currently stands, it's an
impediment to running CNS locally, since it uses the real Wireserver IP.

* Add WireserverIP config into Wireserver Client

The Wireserver client now accepts a hostport configuration option so
that its requests can be redirected. This plumbs the config for the
WireserverIP to it so that it can be redirected during test.

* fix: replace nil with http.NoBody

Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>

---------

Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>
Co-authored-by: Tim Raymond <traymond@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants