Revision 08208574 lib/opcodes.py

b/lib/opcodes.py
166 166
_PAllowRuntimeChgs = ("allow_runtime_changes", True, ht.TBool,
167 167
                      "Allow runtime changes (eg. memory ballooning)")
168 168

  
169
#: a required network name
170
_PNetworkName = ("network_name", ht.NoDefault, ht.TNonEmptyString, "Set network name")
169 171

  
170 172
#: OP_ID conversion regular expression
171 173
_OPID_RE = re.compile("([a-z])([A-Z])")
......
1200 1202
    ("identify_defaults", False, ht.TBool,
1201 1203
     "Reset instance parameters to default if equal"),
1202 1204
    ("ip_check", True, ht.TBool, _PIpCheckDoc),
1205
    ("conflicts_check", True, ht.TBool, "Check for conflicting IPs"),
1203 1206
    ("mode", ht.NoDefault, ht.TElemOf(constants.INSTANCE_CREATE_MODES),
1204 1207
     "Instance creation mode"),
1205 1208
    ("nics", ht.NoDefault, ht.TListOf(_TestNicDef),
......
1531 1534
    ("wait_for_sync", True, ht.TBool,
1532 1535
     "Whether to wait for the disk to synchronize, when changing template"),
1533 1536
    ("offline", None, ht.TMaybeBool, "Whether to mark instance as offline"),
1537
    ("conflicts_check", True, ht.TBool, "Check for conflicting IPs"),
1534 1538
    ]
1535 1539
  OP_RESULT = _TSetParamsResult
1536 1540

  
......
1887 1891
  WITH_LU = False
1888 1892

  
1889 1893

  
1894
# Network opcodes
1895
class OpNetworkAdd(OpCode):
1896
  """Add an IP network to the cluster."""
1897
  OP_DSC_FIELD = "network_name"
1898
  OP_PARAMS = [
1899
    _PNetworkName,
1900
    ("network", None, ht.TString, None),
1901
    ("gateway", None, ht.TMaybeString, None),
1902
    ("network6", None, ht.TMaybeString, None),
1903
    ("gateway6", None, ht.TMaybeString, None),
1904
    ("mac_prefix", None, ht.TMaybeString, None),
1905
    ("network_type", None, ht.TMaybeString, None),
1906
    ("reserved_ips", None, ht.TOr(ht.TListOf(ht.TNonEmptyString), ht.TNone), None),
1907
    ]
1908

  
1909
class OpNetworkRemove(OpCode):
1910
  """Remove an IP network from the cluster."""
1911
  OP_DSC_FIELD = "network_name"
1912
  OP_PARAMS = [
1913
    _PNetworkName,
1914
    _PForce,
1915
    ]
1916

  
1917
class OpNetworkSetParams(OpCode):
1918
  """Set parameters of an IP network"""
1919
  OP_DSC_FIELD = "network_name"
1920
  OP_PARAMS = [
1921
    _PNetworkName,
1922
    ("gateway", None, ht.TMaybeString, None),
1923
    ("reserved_ips", None, ht.TOr(ht.TListOf(ht.TNonEmptyString), ht.TNone), None),
1924
    ("network6", None, ht.TMaybeString, None),
1925
    ("gateway6", None, ht.TMaybeString, None),
1926
    ("mac_prefix", None, ht.TMaybeString, None),
1927
    ("network_type", None, ht.TMaybeString, None),
1928
    ]
1929

  
1930
class OpNetworkConnect(OpCode):
1931
  OP_DSC_FIELD = "network_name"
1932
  OP_PARAMS = [
1933
    _PGroupName,
1934
    _PNetworkName,
1935
    ("network_mode", None, ht.TString, None),
1936
    ("network_link", None, ht.TString, None),
1937
    ("conflicts_check", True, ht.TBool, "Check for conflicting IPs"),
1938
    ]
1939

  
1940
class OpNetworkDisconnect(OpCode):
1941
  OP_DSC_FIELD = "network_name"
1942
  OP_PARAMS = [
1943
    _PGroupName,
1944
    _PNetworkName,
1945
    ("conflicts_check", True, ht.TBool, "Check for conflicting IPs"),
1946
    ]
1947

  
1948
class OpNetworkConnectAll(OpCode):
1949
  OP_DSC_FIELD = "network_name"
1950
  OP_PARAMS = [
1951
    _PNetworkName,
1952
    ("network_mode", None, ht.TString, None),
1953
    ("network_link", None, ht.TString, None),
1954
    ("conflicts_check", True, ht.TBool, "Check for conflicting IPs"),
1955
    ]
1956

  
1957
class OpNetworkDisconnectAll(OpCode):
1958
  OP_DSC_FIELD = "network_name"
1959
  OP_PARAMS = [
1960
    _PNetworkName,
1961
    ("conflicts_check", True, ht.TBool, "Check for conflicting IPs"),
1962
    ]
1963

  
1964

  
1965
class OpNetworkQuery(OpCode):
1966
  """Compute the list of networks."""
1967
  OP_PARAMS = [
1968
    _POutputFields,
1969
    ("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString),
1970
     "Empty list to query all groups, group names otherwise"),
1971
    ]
1972

  
1973

  
1890 1974
def _GetOpList():
1891 1975
  """Returns list of all defined opcodes.
1892 1976

  

Also available in: Unified diff