Exemple #1
0
 def validate_config(_config):
     monasca_comb_schema = voluptuous.Schema(
         {
             "module":
             voluptuous.And(basestring, vu.NoSpaceCharacter()),
             "metric":
             basestring,
             "period":
             voluptuous.And(
                 voluptuous.Or(float, int),
                 lambda i: i >= 0 and math.floor(i) == math.ceil(i)),
             "lambda":
             basestring,
             "bindings": {
                 basestring:
                 voluptuous.Or(
                     "apache.net.kbytes_sec", "apache.net.requests_sec",
                     "apache.performance.cpu_load_perc", "cpu.idle_perc",
                     "cpu.stolen_perc", "cpu.system_perc",
                     "cpu.total_logical_cores", "cpu.user_perc",
                     "cpu.wait_perc", "disk.allocation",
                     "disk.inode_used_perc", "disk.space_used_perc",
                     "disk.total_space_mb", "disk.total_used_space_mb",
                     "host_alive_status", "io.read_kbytes_sec",
                     "io.read_req_sec", "io.write_time_sec",
                     "kafka.consumer_lag", "load.avg_1_min",
                     "load.avg_5_min", "mem.free_mb", "mem.swap_free_mb",
                     "mem.swap_total_mb", "mem.total_mb", "mem.usable_mb",
                     "mem.used_cache", "metrics-added-to-batch-counter[0]",
                     "mysql.innodb.buffer_pool_free",
                     "mysql.innodb.buffer_pool_used",
                     "mysql.innodb.data_reads",
                     "mysql.innodb.mutex_spin_rounds",
                     "mysql.performance.com_delete_multi",
                     "mysql.performance.com_insert",
                     "mysql.performance.com_insert_select",
                     "mysql.performance.com_select",
                     "mysql.performance.com_update",
                     "mysql.performance.created_tmp_disk_tables",
                     "mysql.performance.created_tmp_files",
                     "mysql.performance.open_files",
                     "mysql.performance.questions",
                     "mysql.performance.user_time", "net.in_bytes_sec",
                     "net.in_errors_sec", "net.in_packets_dropped_sec",
                     "net.in_packets_sec", "net.out_bytes_sec",
                     "net.out_errors_sec", "net.out_packets_dropped_sec",
                     "net.out_packets_sec",
                     "nova.vm.disk.total_allocated_gb", "process.pid_count",
                     "raw-sql.time.max", "vcpus", "vm.cpu.utilization_perc",
                     "vm.host_alive_status", "vm.mem.total_mb",
                     "zookeeper.out_bytes", "zookeeper.outstanding_bytes")
             }
         },
         required=True)
     monasca_comb_schema(_config)
     # Checks the expression and the environment
     handle = parsing.validate_expression(_config["lambda"])
     parsing.validate_name_binding(handle, _config["bindings"])
Exemple #2
0
 def test_validate_name_binding_is_invalid(self):
     self.assertRaises(BananaInvalidExpression,
                       validate_name_binding,
                       validate_expression("a + b * c"),
                       {"a": "foo", "c": "bar"})
Exemple #3
0
 def test_validate_name_binding_is_valid(self):
     validate_name_binding(
         validate_expression("a + b * c"),
         {"a": "foo", "b": "foo", "c": "bar"}
     )
Exemple #4
0
 def test_validate_expression_is_valid(self):
     validate_expression("a + b")
     validate_expression("a * b")
     validate_expression("a - b")
     validate_expression("a / b")
     validate_expression("a / b + 12 * (1 - a)")
 def validate_config(_config):
     monasca_comb_schema = voluptuous.Schema({
         "module": voluptuous.And(six.string_types[0],
                                  vu.NoSpaceCharacter()),
         "metric": six.string_types[0],
         "period": voluptuous.And(
             voluptuous.Or(float, int),
             lambda i: i >= 0 and math.floor(i) == math.ceil(i)),
         "lambda": six.string_types[0],
         "bindings": {
             six.string_types[0]: voluptuous.Or(
                 "apache.net.kbytes_sec",
                 "apache.net.requests_sec",
                 "apache.performance.cpu_load_perc",
                 "cpu.idle_perc",
                 "cpu.stolen_perc",
                 "cpu.system_perc",
                 "cpu.total_logical_cores",
                 "cpu.user_perc",
                 "cpu.wait_perc",
                 "disk.allocation",
                 "disk.inode_used_perc",
                 "disk.space_used_perc",
                 "disk.total_space_mb",
                 "disk.total_used_space_mb",
                 "host_alive_status",
                 "io.read_kbytes_sec",
                 "io.read_req_sec",
                 "io.write_time_sec",
                 "kafka.consumer_lag",
                 "load.avg_1_min",
                 "load.avg_5_min",
                 "mem.free_mb",
                 "mem.swap_free_mb",
                 "mem.swap_total_mb",
                 "mem.total_mb",
                 "mem.usable_mb",
                 "mem.used_cache",
                 "metrics-added-to-batch-counter[0]",
                 "mysql.innodb.buffer_pool_free",
                 "mysql.innodb.buffer_pool_used",
                 "mysql.innodb.data_reads",
                 "mysql.innodb.mutex_spin_rounds",
                 "mysql.performance.com_delete_multi",
                 "mysql.performance.com_insert",
                 "mysql.performance.com_insert_select",
                 "mysql.performance.com_select",
                 "mysql.performance.com_update",
                 "mysql.performance.created_tmp_disk_tables",
                 "mysql.performance.created_tmp_files",
                 "mysql.performance.open_files",
                 "mysql.performance.questions",
                 "mysql.performance.user_time",
                 "net.in_bytes_sec",
                 "net.in_errors_sec",
                 "net.in_packets_dropped_sec",
                 "net.in_packets_sec",
                 "net.out_bytes_sec",
                 "net.out_errors_sec",
                 "net.out_packets_dropped_sec",
                 "net.out_packets_sec",
                 "nova.vm.disk.total_allocated_gb",
                 "process.pid_count",
                 "raw-sql.time.max",
                 "vcpus",
                 "vm.cpu.utilization_perc",
                 "vm.host_alive_status",
                 "vm.mem.total_mb",
                 "zookeeper.out_bytes",
                 "zookeeper.outstanding_bytes"
             )
         }
     }, required=True)
     monasca_comb_schema(_config)
     # Checks the expression and the environment
     handle = parsing.validate_expression(_config["lambda"])
     parsing.validate_name_binding(handle,
                                   _config["bindings"])