Revision ea9d3b40 lib/cli.py

b/lib/cli.py
108 108
  "IGNORE_REMOVE_FAILURES_OPT",
109 109
  "IGNORE_SECONDARIES_OPT",
110 110
  "IGNORE_SIZE_OPT",
111
  "INCLUDEDEFAULTS_OPT",
111 112
  "INTERVAL_OPT",
112 113
  "MAC_PREFIX_OPT",
113 114
  "MAINTAIN_NODE_HEALTH_OPT",
......
237 238
  "FormatQueryResult",
238 239
  "FormatParamsDictInfo",
239 240
  "FormatPolicyInfo",
241
  "PrintIPolicyCommand",
240 242
  "PrintGenericInfo",
241 243
  "GenerateTable",
242 244
  "AskUser",
......
1621 1623
                                  action="store_false",
1622 1624
                                  help="Don't check for conflicting IPs")
1623 1625

  
1626
INCLUDEDEFAULTS_OPT = cli_option("--include-defaults", dest="include_defaults",
1627
                                 default=False, action="store_true",
1628
                                 help="Include default values")
1629

  
1624 1630
#: Options provided by all commands
1625 1631
COMMON_OPTS = [DEBUG_OPT, REASON_OPT]
1626 1632

  
......
3751 3757
  return ret
3752 3758

  
3753 3759

  
3760
def _PrintSpecsParameters(buf, specs):
3761
  values = ("%s=%s" % (par, val) for (par, val) in sorted(specs.items()))
3762
  buf.write(",".join(values))
3763

  
3764

  
3765
def PrintIPolicyCommand(buf, ipolicy, isgroup):
3766
  """Print the command option used to generate the given instance policy.
3767

  
3768
  Currently only the parts dealing with specs are supported.
3769

  
3770
  @type buf: StringIO
3771
  @param buf: stream to write into
3772
  @type ipolicy: dict
3773
  @param ipolicy: instance policy
3774
  @type isgroup: bool
3775
  @param isgroup: whether the policy is at group level
3776

  
3777
  """
3778
  if not isgroup:
3779
    stdspecs = ipolicy.get("std")
3780
    if stdspecs:
3781
      buf.write(" %s " % IPOLICY_STD_SPECS_STR)
3782
      _PrintSpecsParameters(buf, stdspecs)
3783
  minmax = ipolicy.get("minmax")
3784
  if minmax:
3785
    minspecs = minmax.get("min")
3786
    maxspecs = minmax.get("max")
3787
    if minspecs and maxspecs:
3788
      buf.write(" %s " % IPOLICY_BOUNDS_SPECS_STR)
3789
      buf.write("min:")
3790
      _PrintSpecsParameters(buf, minspecs)
3791
      buf.write("/max:")
3792
      _PrintSpecsParameters(buf, maxspecs)
3793

  
3794

  
3754 3795
def ConfirmOperation(names, list_type, text, extra=""):
3755 3796
  """Ask the user to confirm an operation on a list of list_type.
3756 3797

  

Also available in: Unified diff