Example #1
0
File: ui_cib.py Project: lge/crmsh
 def do_use(self, context, name='', withstatus=''):
     "usage: use [<shadow_cib>] [withstatus]"
     # check the name argument
     if name and not utils.is_filename_sane(name):
         context.fatal_error("Bad filename: " + name)
     if name and name != "live":
         if not os.access(xmlutil.shadowfile(name), os.F_OK):
             context.fatal_error("%s: no such shadow CIB" % name)
     if withstatus and withstatus != "withstatus":
         context.fatal_error("Expected 'withstatus', got '%s'" % (withstatus))
     # If invoked from configure
     # take special precautions
     if not context.previous_level_is("cibconfig"):
         return self._use(name, withstatus)
     if not cib_factory.has_cib_changed():
         ret = self._use(name, withstatus)
         # new CIB: refresh the CIB factory
         cib_factory.refresh()
         return ret
     saved_cib = utils.get_cib_in_use()
     self._use(name, '')  # don't load the status yet
     if not cib_factory.is_current_cib_equal(silent=True):
         # user made changes and now wants to switch to a
         # different and unequal CIB; we refuse to cooperate
         context.error_message("the requested CIB is different from the current one")
         if config.core.force:
             context.info("CIB overwrite forced")
         elif not utils.ask("All changes will be dropped. Do you want to proceed?"):
             self._use(saved_cib, '')  # revert to the previous CIB
             return False
     return self._use(name, withstatus)  # now load the status too
Example #2
0
 def do_use(self, context, name='', withstatus=''):
     "usage: use [<shadow_cib>] [withstatus]"
     # check the name argument
     if name and not utils.is_filename_sane(name):
         context.fatal_error("Bad filename: " + name)
     if name and name != "live":
         if not os.access(xmlutil.shadowfile(name), os.F_OK):
             context.fatal_error("%s: no such shadow CIB" % name)
     if withstatus and withstatus != "withstatus":
         context.fatal_error("Expected 'withstatus', got '%s'" %
                             (withstatus))
     # If invoked from configure
     # take special precautions
     if not context.previous_level_is("cibconfig"):
         return self._use(name, withstatus)
     if not cib_factory.has_cib_changed():
         ret = self._use(name, withstatus)
         # new CIB: refresh the CIB factory
         cib_factory.refresh()
         return ret
     saved_cib = utils.get_cib_in_use()
     self._use(name, '')  # don't load the status yet
     if not cib_factory.is_current_cib_equal(silent=True):
         # user made changes and now wants to switch to a
         # different and unequal CIB; we refuse to cooperate
         context.error_message(
             "the requested CIB is different from the current one")
         if config.core.force:
             context.info("CIB overwrite forced")
         elif not utils.ask(
                 "All changes will be dropped. Do you want to proceed?"):
             self._use(saved_cib, '')  # revert to the previous CIB
             return False
     return self._use(name, withstatus)  # now load the status too
Example #3
0
def cib_path(source):
    return source[0:7] == "shadow:" and xmlutil.shadowfile(source[7:]) or source
Example #4
0
 def _cib_path(self, source):
     if source[0:7] == "shadow:":
         return xmlutil.shadowfile(source[7:])
     else:
         return source
Example #5
0
def cib_path(source):
    return source[0:7] == "shadow:" and xmlutil.shadowfile(
        source[7:]) or source
Example #6
0
 def _cib_path(self, source):
     if source[0:7] == "shadow:":
         return xmlutil.shadowfile(source[7:])
     else:
         return source