Skip to content

Commit

Permalink
Fix networking
Browse files Browse the repository at this point in the history
Signed-off-by: Volker Theile <[email protected]>
  • Loading branch information
votdev committed Oct 28, 2024
1 parent f5cea3e commit 99bb135
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/source/openstack/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type Client struct {
storageClient *gophercloud.ServiceClient
computeClient *gophercloud.ServiceClient
imageClient *gophercloud.ServiceClient
networkClient *gophercloud.ServiceClient
}

type ExtendedVolume struct {
Expand Down Expand Up @@ -138,13 +139,19 @@ func NewClient(ctx context.Context, endpoint string, region string, secret *core
return nil, fmt.Errorf("error generating image client: %v", err)
}

networkClient, err := openstack.NewNetworkV2(client, endPointOpts)
if err != nil {
return nil, fmt.Errorf("error generating network client: %v", err)
}

return &Client{
ctx: ctx,
pClient: client,
opts: endPointOpts,
storageClient: storageClient,
computeClient: computeClient,
imageClient: imageClient,
networkClient: networkClient,
}, nil
}

Expand Down Expand Up @@ -181,7 +188,7 @@ func (c *Client) Verify() error {
func (c *Client) PreFlightChecks(vm *migration.VirtualMachineImport) (err error) {
// Check the source network mappings.
for _, nm := range vm.Spec.Mapping {
_, err := networks.Get(c.computeClient, nm.SourceNetwork).Extract()
_, err := networks.Get(c.networkClient, nm.SourceNetwork).Extract()
if err != nil {
return fmt.Errorf("error getting source network '%s': %v", nm.SourceNetwork, err)
}
Expand Down

0 comments on commit 99bb135

Please sign in to comment.