[ClusterLabs] crmsh Question/Feature

Marc Smith marc.smith at mcc.edu
Wed Jan 20 16:07:39 EST 2016


First a description of what I'd like to accomplish:
- I'm using crmsh to retrieve a cluster configuration by using "crm
configure save /tmp/file".
- I am then reading the bytes from the '/tmp/file' into a string that
I'm modifying elsewhere.
- I remove some lines from that cluster configuration string (eg,
removed a stopped resource clone set and primitive).
- Now I want to replace the running cluster configuration with this
new/updated string, so I put the string back into a new file, and run
"crm configure load replace /tmp/new_file".
- Actually, using the "replace" method for the load command gives me
an error and doesn't erase the current configuration because other
resources are running, and that's okay.
- Instead I use "crm configure load update /tmp/new_file" and no
errors are given since it doesn't try to erase the configuration
- In both cases of "configure load" (replace and update) lines are not
removed from the configuration.

Using "configure edit" does remove deleted lines from the
configuration and I'd like to accomplish this same behavior by reading
a file (importing).

Looking at the source (master branch on GitHub for crmsh) of
modules/cibconfig.py I see that the behavior of removing lines (or
not) is in this method:
def import_file(self, method, fname):
    method: update or replace
    if not cib_factory.is_cib_sane():
        return False
    f = self._open_url(fname)
    if not f:
        return False
    s = f.read()
    if f != sys.stdin:
    return self.save(s, no_remove=True, method=method)

Setting no_remove to False produces the behavior where missing
configuration lines from the
import are removed from the configuration (or not added in).

My question: Is there any other way to replicate this behavior using
crmsh and importing a configuration from a file? If not, would the
group be open to accepting a patch that adds a third load-action
method that calls save() with no_remove=False?


More information about the Users mailing list