예제 #1
0
    def do_weak_bond(self, context, *nodes):
        '''
        Create a 'weak' colocation:
        Colocating a non-sequential resource set with
        a dummy resource which is not monitored creates,
        in effect, a colocation which does not imply any
        internal relationship between resources.
        '''
        if len(nodes) < 2:
            context.fatal_error("Need at least two arguments")

        for node in nodes:
            obj = cib_factory.find_object(node)
            if not obj:
                context.fatal_error("Object not found: %s" % (node))
            if not xmlutil.is_primitive(obj.node):
                context.fatal_error("Object not primitive: %s" % (node))

        constraint_name = self.make_unique_name('place-constraint-')
        dummy_name = self.make_unique_name('place-dummy-')
        print "Create weak bond / independent colocation"
        print "The following elements will be created:"
        print "   * Colocation constraint, ID: %s" % (constraint_name)
        print "   * Dummy resource, ID: %s" % (dummy_name)
        if not utils.can_ask() or utils.ask("Create resources?"):
            cib_factory.create_object('primitive', dummy_name,
                                      'ocf:heartbeat:Dummy')
            colo = ['colocation', constraint_name, 'inf:', '(']
            colo.extend(nodes)
            colo.append(')')
            colo.append(dummy_name)
            cib_factory.create_object(*colo)
예제 #2
0
파일: ui_assist.py 프로젝트: icclab/crmsh
    def do_weak_bond(self, context, *nodes):
        '''
        Create a 'weak' colocation:
        Colocating a non-sequential resource set with
        a dummy resource which is not monitored creates,
        in effect, a colocation which does not imply any
        internal relationship between resources.
        '''
        if len(nodes) < 2:
            context.fatal_error("Need at least two arguments")

        for node in nodes:
            obj = cib_factory.find_object(node)
            if not obj:
                context.fatal_error("Object not found: %s" % (node))
            if not xmlutil.is_primitive(obj.node):
                context.fatal_error("Object not primitive: %s" % (node))

        constraint_name = self.make_unique_name('place-constraint-')
        dummy_name = self.make_unique_name('place-dummy-')
        print "Create weak bond / independent colocation"
        print "The following elements will be created:"
        print "   * Colocation constraint, ID: %s" % (constraint_name)
        print "   * Dummy resource, ID: %s" % (dummy_name)
        if not utils.can_ask() or utils.ask("Create resources?"):
            cib_factory.create_object('primitive', dummy_name, 'ocf:heartbeat:Dummy')
            colo = ['colocation', constraint_name, 'inf:', '(']
            colo.extend(nodes)
            colo.append(')')
            colo.append(dummy_name)
            cib_factory.create_object(*colo)
예제 #3
0
파일: ui_assist.py 프로젝트: icclab/crmsh
    def _template_primitives(self, context, primitives):
        """
        Try to template the given primitives:
        Templating means creating a rsc_template and moving
        shared attributes and other commonalities into that template
        (this second step is currently not available)
        """
        shared_template = None
        if all('template' in obj.node.attrib for obj in primitives):
            return True
        if len(set(xmlutil.mk_rsc_type(obj.node) for obj in primitives)) != 1:
            context.fatal_error("Cannot template the given primitives")

        node = primitives[0].node
        template_name = self.make_unique_name('template-%s-' % (node.get('type').lower()))
        shared_template = cib_factory.create_object('rsc_template', template_name,
                                                    xmlutil.mk_rsc_type(node))
        if not shared_template:
            context.fatal_error("Error creating template")
        for obj in primitives:
            obj.node.set('template', template_name)
            rmattrs(obj.node, 'class', 'provider', 'type')
            obj.set_updated()

        if not self._pull_attributes(context, shared_template, primitives):
            context.fatal_error("Error when copying attributes into template")

        context.info("Template created: %s" % (template_name))
        return True
예제 #4
0
    def _template_primitives(self, context, primitives):
        """
        Try to template the given primitives:
        Templating means creating a rsc_template and moving
        shared attributes and other commonalities into that template
        (this second step is currently not available)
        """
        shared_template = None
        if all('template' in obj.node.attrib for obj in primitives):
            return True
        if len(set(xmlutil.mk_rsc_type(obj.node) for obj in primitives)) != 1:
            context.fatal_error("Cannot template the given primitives")

        node = primitives[0].node
        template_name = self.make_unique_name('template-%s-' %
                                              (node.get('type').lower()))
        shared_template = cib_factory.create_object('rsc_template',
                                                    template_name,
                                                    xmlutil.mk_rsc_type(node))
        if not shared_template:
            context.fatal_error("Error creating template")
        for obj in primitives:
            obj.node.set('template', template_name)
            rmattrs(obj.node, 'class', 'provider', 'type')
            obj.set_updated()

        if not self._pull_attributes(context, shared_template, primitives):
            context.fatal_error("Error when copying attributes into template")

        context.info("Template created: %s" % (template_name))
        return True
예제 #5
0
파일: ui_configure.py 프로젝트: lge/crmsh
 def __conf_object(self, cmd, *args):
     "The configure object command."
     if cmd in constants.cib_cli_map.values() and \
             not cib_factory.is_elem_supported(cmd):
         common_err("%s not supported by the RNG schema" % cmd)
         return False
     return cib_factory.create_object(cmd, *args)
예제 #6
0
 def __conf_object(self, cmd, *args):
     "The configure object command."
     if cmd in constants.cib_cli_map.values() and \
             not cib_factory.is_elem_supported(cmd):
         common_err("%s not supported by the RNG schema" % cmd)
         return False
     return cib_factory.create_object(cmd, *args)
예제 #7
0
 def _onoff(self, resource, onoff):
     if resource is not None:
         return utils.ext_cmd(self.rsc_maintenance % (resource, onoff)) == 0
     else:
         return cib_factory.create_object('property', 'maintenance-mode=%s' % (onoff))
예제 #8
0
 def _onoff(self, resource, onoff):
     if resource is not None:
         return utils.ext_cmd(self.rsc_maintenance % (resource, onoff)) == 0
     else:
         return cib_factory.create_object('property',
                                          'maintenance-mode=%s' % (onoff))