From 7ffdb1d8e0107a3d995ede502d9ea5ad6ed0af4c Mon Sep 17 00:00:00 2001 From: Apollon Oikonomopoulos <apollon@noc.grnet.gr> Date: Mon, 18 Apr 2011 17:59:53 +0300 Subject: [PATCH] Add network-related opcodes Add opcodes for network addition and query. Signed-off-by: Apollon Oikonomopoulos <apollon@noc.grnet.gr> --- lib/opcodes.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/opcodes.py b/lib/opcodes.py index 5a331f140..b1ef8d659 100644 --- a/lib/opcodes.py +++ b/lib/opcodes.py @@ -81,6 +81,9 @@ _PTags = ("tags", ht.NoDefault, ht.TListOf(ht.TNonEmptyString)) #: Ignore consistency _PIgnoreConsistency = ("ignore_consistency", False, ht.TBool) +#: a required network name +_PNetworkName = ("network_name", ht.NoDefault, ht.TNonEmptyString) + #: OP_ID conversion regular expression _OPID_RE = re.compile("([a-z])([A-Z])") @@ -1286,6 +1289,26 @@ class OpTestDummy(OpCode): WITH_LU = False +# Network opcodes +class OpNetworkAdd(OpCode): + """Add an IP network to the cluster.""" + OP_DSC_FIELD = "network_name" + OP_PARAMS = [ + _PNetworkName, + ("network", None, ht.TString), + ("gateway", None, ht.TMaybeString), + ("reserved_ips", None, ht.TOr(ht.TListOf(ht.TNonEmptyString), ht.TNone)), + ] + + +class OpNetworkQuery(OpCode): + """Compute the list of networks.""" + OP_PARAMS = [ + _POutputFields, + ("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)), + ] + + def _GetOpList(): """Returns list of all defined opcodes. -- GitLab