Example #1
0
    def test_invalid_manager_adding(self):
        """
        Tests sanity checks for Manager object adding.
        """
        system_data = SystemData()
        self._invalid_wrong_node_type(system_data)

        system_data = SystemData()
        self._invalid_node_missing(system_data)
    def test_invalid_alert_adding(self):
        """
        Tests sanity checks for Alert object adding.
        """
        system_data = SystemData()
        self._invalid_wrong_node_type(system_data)

        system_data = SystemData()
        self._invalid_node_missing(system_data)

        system_data = SystemData()
        self._invalid_alert_level_missing(system_data)
Example #3
0
    def _create_options(self,
                        system_data: Optional[SystemData] = None
                        ) -> SystemData:

        if system_data is None:
            system_data = SystemData()
            self.alert_levels = []
            self.alerts = []
            self.managers = []
            self.nodes = []
            self.options = []
            self.sensors = []

        option = ManagerObjOption()
        option.type = "type_1"
        option.value = 1.0
        self.options.append(option)
        system_data.update_option(ManagerObjOption().deepcopy(option))

        option = ManagerObjOption()
        option.type = "type_2"
        option.value = 2.0
        self.options.append(option)
        system_data.update_option(ManagerObjOption().deepcopy(option))

        option = ManagerObjOption()
        option.type = "type_3"
        option.value = 3.0
        self.options.append(option)
        system_data.update_option(ManagerObjOption().deepcopy(option))

        return system_data
Example #4
0
    def _create_profiles(self,
                         system_data: Optional[SystemData] = None
                         ) -> SystemData:

        if system_data is None:
            system_data = SystemData()
            self.alert_levels = []
            self.alerts = []
            self.managers = []
            self.nodes = []
            self.options = []
            self.profiles = []
            self.sensors = []

        profile = ManagerObjProfile()
        profile.profileId = 0
        profile.name = "profile_0"
        self.profiles.append(profile)
        system_data.update_profile(ManagerObjProfile().deepcopy(profile))

        profile = ManagerObjProfile()
        profile.profileId = 1
        profile.name = "profile_1"
        self.profiles.append(profile)
        system_data.update_profile(ManagerObjProfile().deepcopy(profile))

        profile = ManagerObjProfile()
        profile.profileId = 2
        profile.name = "profile_2"
        self.profiles.append(profile)
        system_data.update_profile(ManagerObjProfile().deepcopy(profile))

        return system_data
Example #5
0
    def _invalid_wrong_node_type(self, system_data: SystemData):
        # Test invalid node type.
        node = ManagerObjNode()
        node.nodeId = 1
        node.hostname = "hostname_1"
        node.nodeType = "alert"
        node.instance = "instance_1"
        node.connected = 1
        node.version = 1.0
        node.rev = 0
        node.username = "******"
        node.persistent = 1
        system_data.update_node(node)

        sensor = ManagerObjSensor()
        sensor.nodeId = 1
        sensor.sensorId = 1
        sensor.clientSensorId = 1
        sensor.alertDelay = 0
        sensor.alertLevels = []
        sensor.description = "sensor_1"
        sensor.lastStateUpdated = 0
        sensor.state = 0
        sensor.dataType = SensorDataType.NONE
        is_exception = False
        try:
            system_data.update_sensor(sensor)
        except ValueError:
            is_exception = True
        if not is_exception:
            self.fail("Exception because of wrong node type expected.")

        system_data = SystemData()
Example #6
0
    def _create_alert_levels(self,
                             system_data: Optional[SystemData] = None
                             ) -> SystemData:

        if system_data is None:
            system_data = SystemData()
            self.alert_levels = []
            self.alerts = []
            self.managers = []
            self.nodes = []
            self.options = []
            self.sensors = []

        alert_level = ManagerObjAlertLevel()
        alert_level.level = 1
        alert_level.name = "alert_level_1"
        alert_level.triggerAlways = 1
        alert_level.instrumentation_active = True
        alert_level.instrumentation_cmd = "instrumentation_cmd_1"
        alert_level.instrumentation_timeout = 1234
        self.alert_levels.append(alert_level)
        system_data.update_alert_level(
            ManagerObjAlertLevel().deepcopy(alert_level))

        alert_level = ManagerObjAlertLevel()
        alert_level.level = 2
        alert_level.name = "alert_level_2"
        alert_level.triggerAlways = 1
        alert_level.instrumentation_active = False
        self.alert_levels.append(alert_level)
        system_data.update_alert_level(
            ManagerObjAlertLevel().deepcopy(alert_level))

        alert_level = ManagerObjAlertLevel()
        alert_level.level = 3
        alert_level.name = "alert_level_3"
        alert_level.triggerAlways = 1
        alert_level.instrumentation_active = False
        self.alert_levels.append(alert_level)
        system_data.update_alert_level(
            ManagerObjAlertLevel().deepcopy(alert_level))

        return system_data
Example #7
0
    def _create_managers(self,
                         system_data: Optional[SystemData] = None
                         ) -> SystemData:

        if system_data is None:
            system_data = SystemData()
            self.alert_levels = []
            self.alerts = []
            self.managers = []
            self.nodes = []
            self.options = []
            self.sensors = []

        node = ManagerObjNode()
        node.nodeId = 4
        node.hostname = "hostname_4"
        node.nodeType = "manager"
        node.instance = "instance_4"
        node.connected = 1
        node.version = 1.0
        node.rev = 0
        node.username = "******"
        node.persistent = 1
        self.nodes.append(node)
        system_data.update_node(ManagerObjNode().deepcopy(node))

        manager = ManagerObjManager()
        manager.nodeId = 4
        manager.managerId = 1
        manager.description = "manager_1"
        self.managers.append(manager)
        system_data.update_manager(ManagerObjManager().deepcopy(manager))

        node = ManagerObjNode()
        node.nodeId = 5
        node.hostname = "hostname_5"
        node.nodeType = "manager"
        node.instance = "instance_5"
        node.connected = 1
        node.version = 1.0
        node.rev = 0
        node.username = "******"
        node.persistent = 1
        self.nodes.append(node)
        system_data.update_node(ManagerObjNode().deepcopy(node))

        manager = ManagerObjManager()
        manager.nodeId = 5
        manager.managerId = 2
        manager.description = "manager_2"
        self.managers.append(manager)
        system_data.update_manager(ManagerObjManager().deepcopy(manager))

        node = ManagerObjNode()
        node.nodeId = 6
        node.hostname = "hostname_6"
        node.nodeType = "manager"
        node.instance = "instance_6"
        node.connected = 1
        node.version = 1.0
        node.rev = 0
        node.username = "******"
        node.persistent = 1
        self.nodes.append(node)
        system_data.update_node(ManagerObjNode().deepcopy(node))

        manager = ManagerObjManager()
        manager.nodeId = 6
        manager.managerId = 3
        manager.description = "manager_3"
        self.managers.append(manager)
        system_data.update_manager(ManagerObjManager().deepcopy(manager))

        return system_data