github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/provider/openstack/networking_interfaces.go (about)

     1  // Copyright 2021 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package openstack
     5  
     6  import (
     7  	"github.com/go-goose/goose/v5/neutron"
     8  	"github.com/go-goose/goose/v5/nova"
     9  	"github.com/juju/collections/set"
    10  
    11  	"github.com/juju/juju/core/instance"
    12  	corenetwork "github.com/juju/juju/core/network"
    13  )
    14  
    15  // Networking is an interface providing networking-related operations
    16  // for an OpenStack Environ.
    17  type Networking interface {
    18  	// AllocatePublicIP allocates a public (floating) IP
    19  	// to the specified instance.
    20  	AllocatePublicIP(instance.Id) (*string, error)
    21  
    22  	// ResolveNetworks takes either a network ID or label
    23  	// with a string to specify whether the network is external
    24  	// and returns the corresponding matching networks.
    25  	ResolveNetworks(string, bool) ([]neutron.NetworkV2, error)
    26  
    27  	// Subnets returns basic information about subnets known
    28  	// by OpenStack for the environment.
    29  	// Needed for Environ.Networking
    30  	Subnets(instance.Id, []corenetwork.Id) ([]corenetwork.SubnetInfo, error)
    31  
    32  	// CreatePort creates a port for a given network id with a subnet ID.
    33  	CreatePort(string, string, corenetwork.Id) (*neutron.PortV2, error)
    34  
    35  	// DeletePortByID attempts to remove a port using the given port ID.
    36  	DeletePortByID(string) error
    37  
    38  	// NetworkInterfaces requests information about the network
    39  	// interfaces on the given list of instances.
    40  	// Needed for Environ.Networking
    41  	NetworkInterfaces(ids []instance.Id) ([]corenetwork.InterfaceInfos, error)
    42  
    43  	// FindNetworks returns a set of internal or external network names
    44  	// depending on the provided argument.
    45  	FindNetworks(internal bool) (set.Strings, error)
    46  }
    47  
    48  // NetworkingBase describes the EnvironProvider methods needed for Networking.
    49  type NetworkingBase interface {
    50  	client() NetworkingAuthenticatingClient
    51  	neutron() NetworkingNeutron
    52  	nova() NetworkingNova
    53  	ecfg() NetworkingEnvironConfig
    54  }
    55  
    56  // NetworkingNova describes the Nova methods needed for Networking.
    57  type NetworkingNova interface {
    58  	GetServer(string) (*nova.ServerDetail, error)
    59  }
    60  
    61  // NetworkingNeutron describes the Neutron methods needed for Networking.
    62  type NetworkingNeutron interface {
    63  	AllocateFloatingIPV2(string) (*neutron.FloatingIPV2, error)
    64  	CreatePortV2(neutron.PortV2) (*neutron.PortV2, error)
    65  	DeletePortV2(string) error
    66  	ListPortsV2(filter ...*neutron.Filter) ([]neutron.PortV2, error)
    67  	GetNetworkV2(string) (*neutron.NetworkV2, error)
    68  	ListFloatingIPsV2(...*neutron.Filter) ([]neutron.FloatingIPV2, error)
    69  	ListNetworksV2(...*neutron.Filter) ([]neutron.NetworkV2, error)
    70  	ListSubnetsV2() ([]neutron.SubnetV2, error)
    71  }
    72  
    73  // NetworkingEnvironConfig describes the environConfig methods needed for
    74  // Networking.
    75  type NetworkingEnvironConfig interface {
    76  	networks() []string
    77  	externalNetwork() string
    78  }
    79  
    80  // NetworkingAuthenticatingClient describes the AuthenticatingClient methods
    81  // needed for Networking.
    82  type NetworkingAuthenticatingClient interface {
    83  	TenantId() string
    84  }