Exemple #1
0
def parse(tree):
    '''
    Parse the agent configuration file and return an _Connection object
    
    If the file cannot be parsed an AgentException is raised
    '''
    handlers = {
        'localBind': LocalBindConnection,
        'rmConnection': RessourceManagerConnection,
        'customConnection': CustomConnection,
    }

    # Delegate the parsing to the right class (according to the enabled action)
    lx = tree.xpath("//a:connections/*[@enabled='true' or @enabled='1']",
                    namespaces={'a': main.xmlns})

    l = len(lx)
    if (l == 0):
        raise errors.AgentConfigFileError(
            'One and only one connection must be enabled (not enforced by the XML Schema)'
        )
    elif (l == 1):
        name = lx[0].tag.replace("{%s}" % main.xmlns, "", 1)
        handler = handlers.get(name)()
        handler.parse(lx[0])
        return handler
    else:
        raise errors.AgentConfigFileError(
            'One connection must be enabled (not enforced by the XML Schema)')
Exemple #2
0
    def check_overlapping(self):
        ''' Check if two events overlap'''
        if len(self.events) > 1:
            for i in range(len(self.events) - 1):
                if self.events[i].stopOffset > self.events[i + 1].startOffset:
                    raise errors.AgentConfigFileError(
                        "Calendar events %s and %s overlap (not enforced by XSD)"
                        % (self.events[i], self.events[i + 1]))

            if (self.events[-1].stopOffset <= self.events[-1].startOffset
                ) and (self.events[-1].stopOffset >
                       self.events[0].startOffset):
                raise errors.AgentConfigFileError(
                    "Calendar events %s and %s overlap (not enforced by XSD)" %
                    (self.events[-1], self.events[0]))
Exemple #3
0
    def check(self):
        '''
        Check this event is in a coherent state
        '''
        if self.startOffset < 0:
            raise errors.AgentInternalError("Start offset must be positive")
        if self.startOffset > _ONE_WEEK_IN_SECS:
            raise errors.AgentInternalError(
                "Start offset must be lesser than %s" % _ONE_WEEK_IN_SECS)
        if self.duration < 1:
            raise errors.AgentConfigFileError(
                "An event must last a least one second (not enforced by XSD)")
        if self.duration >= _ONE_WEEK_IN_SECS:
            raise errors.AgentInternalError(
                "An event cannot last more than 7 days (not enforced by XSD)")

        self.config.check()
Exemple #4
0
    def check(self):
        '''
        Check the state of this event is consistent 
        '''
        if self.proactiveHome is None:
            raise errors.AgentConfigFileError("ProActive home is not set")
        if len(self.proactiveHome) < 1:
            # FIXME: Should be enforced by the XSD
            raise errors.AgentConfigFileError("ProActive home cannot be empty")

        if self.javaHome is None:
            raise errors.AgentConfigFileError("Java home is not set")
        if len(self.javaHome) < 1:
            # FIXME: Should be enforce by the XSD
            raise errors.AgentConfigFileError("Java home cannot be empty")

        if self.memoryLimit < 0:
            raise errors.AgentInternalError(
                "Memory limit must be a positive integer")
        if self.memoryLimit != 0:
            if self.memoryLimit < 128:
                logger.warning(
                    "Warning memory limit is set below 128MB. JVMs will likely crash due to the memory constraint"
                )
            if self.cgroup_mnt_point is None:
                raise errors.AgentInternalError(
                    "cgroup mount point is not defined but memory limit is set"
                )
            if len(self.cgroup_mnt_point) == 0:
                raise errors.AgentInternalError(
                    "cgroup mount point lenght is 0 but memory limit is set")
            if not os.path.exists(self.cgroup_mnt_point):
                raise errors.AgentConfigFileError(
                    "cgroup is not mounted at %s. Please mount the cgroup filesystem or remove the <memoryLimit> element from the configuration file"
                    % self.cgroup_mnt_point)
        if self.nbRuntimes < 0:
            raise errors.AgentInternalError(
                "The number of runtimes must be a positive integer")

        if self.protocol is None:
            raise errors.AgentInternalError(
                "ProActive communication protocol is not set")
        if len(self.protocol) < 1:
            raise errors.AgentConfigFileError(
                "ProActive communication protocol cannot be empty")

        if self.portRange[0] < 0 or self.portRange[0] > 65536:
            raise errors.AgentInternalError(
                "First TCP port must be an integer between 0 and 65536")
        if self.portRange[1] < 0 or self.portRange[1] > 65536:
            raise errors.AgentInternalError(
                "Last TCP port must be an integer between 0 and 65536")
        if self.portRange[0] > self.portRange[1]:
            raise errors.AgentInternalError(
                "Last TCP port must be greater or equals to the first TCP port"
            )
        if self.portRange[1] + 1 - self.portRange[0] < self.nbRuntimes:
            raise errors.AgentInternalError(
                "The port range is too small according to the number of runtimes"
            )

        if self.nice < -20 or self.nice > 19:
            raise errors.AgentInternalError(
                "Invalid nice value. Must be betweeon -20 and 19")

        if self.ionice is not None:
            if self.ionice["class"] == 1 or self.ionice["class"] == 2:
                if self.ionice["classdata"] is None:
                    raise errors.AgentConfigFileError(
                        "A class data is mandatory with the best effort and real time ionice classes"
                    )
            else:
                if self.ionice["classdata"] is not None:
                    raise errors.AgentConfigFileError(
                        "none and idle ionice classes does not accept any class data argument"
                    )