def validate_set_as_guest(tree, nodes, node_name, options): report_list = validate.names_in( GUEST_OPTIONS, options.keys(), "guest", ) validator_list = [ validate.value_time_interval("remote-connect-timeout"), validate.value_port_number("remote-port"), ] report_list.extend( validate.run_collection_of_option_validators(options, validator_list)) report_list.extend(validate_conflicts(tree, nodes, node_name, options)) if not node_name.strip(): report_list.append( reports.invalid_option_value( "node name", node_name, "no empty value", )) return report_list
def test_no_reports_for_valid_time_interval(self): for interval in ["0", "1s", "2sec", "3m", "4min", "5h", "6hr"]: self.assertEqual( [], validate.value_time_interval("a")({"a": interval}), "interval: {0}".format(interval) )
def test_reports_about_invalid_interval(self): assert_report_item_list_equal( validate.value_time_interval("a")({ "a": "invalid_value" }), [ (severities.ERROR, report_codes.INVALID_OPTION_VALUE, { "option_name": "a", "option_value": "invalid_value", "allowed_values": "time interval (e.g. 1, 2s, 3m, 4h, ...)", }, None), ])
def test_reports_about_invalid_interval(self): assert_report_item_list_equal( validate.value_time_interval("a")({"a": "invalid_value"}), [ ( severities.ERROR, report_codes.INVALID_OPTION_VALUE, { "option_name": "a", "option_value": "invalid_value", "allowed_values": "time interval (e.g. 1, 2s, 3m, 4h, ...)" , }, None ), ] )
def get_failcounts( env, resource=None, node=None, operation=None, interval=None ): # pylint: disable=redefined-outer-name """ List resources failcounts, optionally filtered by a resource, node or op LibraryEnvironment env string resource -- show failcounts for the specified resource only string node -- show failcounts for the specified node only string operation -- show failcounts for the specified operation only string interval -- show failcounts for the specified operation interval only """ report_items = [] if interval is not None and operation is None: report_items.append( reports.prerequisite_option_is_missing("interval", "operation") ) if interval is not None: report_items.extend( value_time_interval("interval")({"interval": interval}) ) if report_items: raise LibraryError(*report_items) interval_ms = ( None if interval is None else timeout_to_seconds(interval) * 1000 ) all_failcounts = cib_status.get_resources_failcounts( get_status(env.get_cib()) ) return cib_status.filter_resources_failcounts( all_failcounts, resource=resource, node=node, operation=operation, interval=interval_ms )
def test_no_reports_for_valid_time_interval(self): for interval in ["0", "1s", "2sec", "3m", "4min", "5h", "6hr"]: self.assertEquals([], validate.value_time_interval("a")({ "a": interval }), "interval: {0}".format(interval))