Skip to content

Commit

Permalink
Add non-cluster-network tagging to networks (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
erl-hpe authored Jul 31, 2024
1 parent cacb537 commit ff8d9a9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
10 changes: 10 additions & 0 deletions vtds_cluster_kvm/api_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,16 @@ def ipv4_cidr(self, network_name):
"""

@abstractmethod
def non_cluster_network(self, network_name):
"""A network in the cluster configuration may be a network
used by vTDS for constructing the cluster but not intended for
use by applications running on the cluster. Such a network is
a 'non-cluster network'. Return True if the specified network
name refers to a non-cluster network otherwise return False.
"""


class NodeConnection(metaclass=ABCMeta):
"""A class containing the relevant information needed to use
Expand Down
19 changes: 14 additions & 5 deletions vtds_cluster_kvm/private/api_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,18 +170,23 @@ def __networks_by_name(self):
"the following Virtual Networks: %s" % str(missing_names)
) from err

def __network_by_name(self, network_name):
"""Return the network configuration for the named network.
"""
if network_name not in self.networks_by_name:
raise ContextualError(
"the Virtual Network named '%s' does not exist" % network_name
)
return self.networks_by_name[network_name]

def __l3_config(self, network_name, family):
"""Get the l3_info block for the specified address family from
the network of the specified name. If the network doesn't
exist raise an exception. If there is no matching l3_info,
return None.
"""
if network_name not in self.networks_by_name:
raise ContextualError(
"the Virtual Network named '%s' does not exist" % network_name
)
network = self.networks_by_name[network_name]
network = self.__network_by_name(network_name)
candidates = [
l3_info
for _, l3_info in network.get('l3_configs', {}).items()
Expand All @@ -198,6 +203,10 @@ def ipv4_cidr(self, network_name):
return None
return l3_config.get('cidr', None)

def non_cluster_network(self, network_name):
network = self.__network_by_name(network_name)
return network.get('non_cluster', False)


class PrivateNodeConnection(NodeConnection):
"""Private implementation of the NodeConnection Cluster Layer API
Expand Down
4 changes: 4 additions & 0 deletions vtds_cluster_kvm/private/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ cluster:
# automatically. This default configuration should work in most
# cases, but can be modified as needed.
network_name: bladenet
# This is not a cluster network (i.e. it should not be used by
# applications running on the cluster for anything). It is here to
# aid in setting up the cluster during deployment.
non_cluster: True
# Do not set 'delete' to true here or in an overlay. This network
# must be defined or the Cluster layer APIs that support
# deployment at the Application layer will not all work correctly.
Expand Down

0 comments on commit ff8d9a9

Please sign in to comment.