func (rmq *rmqPublisher) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) { cp := cpolicy.New() config := cpolicy.NewPolicyNode() r1, err := cpolicy.NewStringRule("address", true) handleErr(err) r1.Description = "RabbitMQ Address (host:port)" config.Add(r1) r2, err := cpolicy.NewStringRule("exchange_name", true) handleErr(err) r2.Description = "RabbitMQ Exchange Name" config.Add(r2) r3, err := cpolicy.NewStringRule("exchange_type", true) handleErr(err) r3.Description = "RabbitMQ Exchange Type" config.Add(r3) r4, err := cpolicy.NewStringRule("routing_key", true) handleErr(err) r4.Description = "RabbitMQ Routing Key" config.Add(r4) cp.Add([]string{""}, config) return cp, nil }
func (f *influxPublisher) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) { cp := cpolicy.New() config := cpolicy.NewPolicyNode() r1, err := cpolicy.NewStringRule("host", true) handleErr(err) r1.Description = "Influxdb host" config.Add(r1) r2, err := cpolicy.NewIntegerRule("port", true) handleErr(err) r2.Description = "Influxdb port" config.Add(r2) r3, err := cpolicy.NewStringRule("database", true) handleErr(err) r3.Description = "Influxdb db name" config.Add(r3) r4, err := cpolicy.NewStringRule("user", true) handleErr(err) r4.Description = "Influxdb user" config.Add(r4) r5, err := cpolicy.NewStringRule("password", true) handleErr(err) r5.Description = "Influxdb password" config.Add(r4) cp.Add([]string{""}, config) return cp, nil }
// GetConfigPolicy returns a config policy func (s *PostgreSQLPublisher) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) { cp := cpolicy.New() config := cpolicy.NewPolicyNode() username, err := cpolicy.NewStringRule("username", true) handleErr(err) username.Description = "Username to login to the PostgreSQL server" password, err := cpolicy.NewStringRule("password", true) handleErr(err) password.Description = "Password to login to the PostgreSQL server" database, err := cpolicy.NewStringRule("database", true) handleErr(err) database.Description = "The postgresql database that data will be pushed to" tableName, err := cpolicy.NewStringRule("table_name", true) handleErr(err) tableName.Description = "The postgresql table within the database where information will be stored" hostName, err := cpolicy.NewStringRule("hostname", true, "localhost") handleErr(err) tableName.Description = "The postgresql server ip or domain name" port, err := cpolicy.NewIntegerRule("port", true, 5432) handleErr(err) port.Description = "The postgresql server port number" config.Add(username, password, database, tableName, hostName, port) cp.Add([]string{""}, config) return cp, nil }
func (s *mysqlPublisher) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) { cp := cpolicy.New() config := cpolicy.NewPolicyNode() username, err := cpolicy.NewStringRule("username", false, usernameDefault) handleErr(err) username.Description = "Username to login to the MySQL server" password, err := cpolicy.NewStringRule("password", false, passwordDefault) handleErr(err) password.Description = "Password to login to the MySQL server" hostName, err := cpolicy.NewStringRule("hostname", false, hostnameDefault) handleErr(err) password.Description = "The host of MySQL service" port, err := cpolicy.NewStringRule("port", false, tcpPortDefault) handleErr(err) password.Description = "The host of MySQL service" database, err := cpolicy.NewStringRule("database", false, databaseDefault) handleErr(err) database.Description = "The MySQL database that data will be pushed to" tableName, err := cpolicy.NewStringRule("tablename", false, tableDefault) handleErr(err) tableName.Description = "The MySQL table within the database where information will be stored" config.Add(username, password, hostName, port, database, tableName) cp.Add([]string{""}, config) return cp, nil }
func (m *mockSessionStatePluginProxy) GetConfigPolicy(args []byte, reply *[]byte) error { cp := cpolicy.New() n1 := cpolicy.NewPolicyNode() if m.c { r1, _ := cpolicy.NewStringRule("name", false, "bob") n1.Add(r1) r2, _ := cpolicy.NewIntegerRule("someInt", true, 100) n1.Add(r2) r3, _ := cpolicy.NewStringRule("password", true) n1.Add(r3) r4, _ := cpolicy.NewFloatRule("somefloat", false, 3.14) n1.Add(r4) cp.Add([]string{"foo", "bar"}, n1) } else { r1, _ := cpolicy.NewIntegerRule("SomeRequiredInt", true, 1) r2, _ := cpolicy.NewStringRule("password", true) r3, _ := cpolicy.NewFloatRule("somefloat", false, 3.14) n1.Add(r1, r2, r3) cp.Add([]string{""}, n1) } cpr := plugin.GetConfigPolicyReply{Policy: cp} var err error *reply, err = m.e.Encode(cpr) return err }
func (rmq *rmqPublisher) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) { cp := cpolicy.New() config := cpolicy.NewPolicyNode() r1, err := cpolicy.NewStringRule("uri", true) handleErr(err) r1.Description = "RabbitMQ URI (user:password@ip:port/vhost)" config.Add(r1) r2, err := cpolicy.NewStringRule("exchange_name", true) handleErr(err) r2.Description = "RabbitMQ Exchange Name" config.Add(r2) r3, err := cpolicy.NewStringRule("exchange_type", true) handleErr(err) r3.Description = "RabbitMQ Exchange Type" config.Add(r3) r4, err := cpolicy.NewStringRule("routing_key", true) handleErr(err) r4.Description = "RabbitMQ Routing Key" config.Add(r4) r5, err := cpolicy.NewBoolRule("durable", false, true) handleErr(err) r5.Description = "RabbitMQ Durable" config.Add(r5) cp.Add([]string{""}, config) return cp, nil }
func (f *mysqlPublisher) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) { cp := cpolicy.New() config := cpolicy.NewPolicyNode() username, err := cpolicy.NewStringRule("username", true, "root") handleErr(err) username.Description = "Username to login to the MySQL server" password, err := cpolicy.NewStringRule("password", true, "root") handleErr(err) password.Description = "Password to login to the MySQL server" database, err := cpolicy.NewStringRule("database", true, "SNAP_TEST") handleErr(err) database.Description = "The MySQL database that data will be pushed to" tableName, err := cpolicy.NewStringRule("tablename", true, "info") handleErr(err) tableName.Description = "The MySQL table within the database where information will be stored" config.Add(username, password, database, tableName) cp.Add([]string{""}, config) return cp, nil }
func (e *Etcd) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) { c := cpolicy.New() rule, _ := cpolicy.NewStringRule("etcd_host", true) p := cpolicy.NewPolicyNode() p.Add(rule) c.Add([]string{"intel", "etcd"}, p) return c, nil }
func (a *Apache) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) { cfg := cpolicy.New() rule, _ := cpolicy.NewStringRule("apache_mod_status_url", false, "http://127.0.0.1:80/server-status?auto") policy := cpolicy.NewPolicyNode() policy.Add(rule) cfg.Add([]string{"intel", "apache"}, policy) return cfg, nil }
//GetConfigPolicy returns a ConfigPolicy for testing func (f *nfsCollector) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) { c := cpolicy.New() rule, _ := cpolicy.NewStringRule("command", true) p := cpolicy.NewPolicyNode() p.Add(rule) c.Add([]string{"intel", "dummy", "exec"}, p) return c, nil }
// GetConfigPolicy returns config policy // It returns error in case retrieval was not successful func (p *Plugin) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) { cp := cpolicy.New() rule, _ := cpolicy.NewStringRule("proc_path", false, "/proc") node := cpolicy.NewPolicyNode() node.Add(rule) cp.Add([]string{vendor, fs, pluginName}, node) return cp, nil }
func (p *movingAverageProcessor) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) { cp := cpolicy.New() config := cpolicy.NewPolicyNode() r1, err := cpolicy.NewIntegerRule("MovingAvgBufLength", true) handleErr(err) r1.Description = "Buffer Length for moving average " config.Add(r1) cp.Add([]string{""}, config) return cp, nil }
//GetConfigPolicy returns a ConfigPolicyTree for testing func (f *Mock) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) { c := cpolicy.New() rule, _ := cpolicy.NewStringRule("name", false, "bob") rule2, _ := cpolicy.NewStringRule("password", true) p := cpolicy.NewPolicyNode() p.Add(rule) p.Add(rule2) c.Add([]string{"intel", "mock", "foo"}, p) return c, nil }
//GetConfigPolicy returns a ConfigPolicy func (p *SmartCollector) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) { cp := cpolicy.New() rule, _ := cpolicy.NewStringRule("proc_path", false, "/proc") node := cpolicy.NewPolicyNode() node.Add(rule) cp.Add([]string{nsVendor, nsClass, nsType}, node) rule, _ = cpolicy.NewStringRule("dev_path", false, "/dev") node.Add(rule) return cp, nil }
func TestResolvePlugin(t *testing.T) { Convey("GetPlugin()", t, func() { mc := newMetricCatalog() lp2 := &loadedPlugin{} lp2.ConfigPolicy = cpolicy.New() lp2.Meta.Version = 2 lp5 := &loadedPlugin{} lp5.ConfigPolicy = cpolicy.New() lp5.Meta.Version = 5 mt2 := newMetricType(core.NewNamespace("foo", "bar"), time.Now(), lp2) mt5 := newMetricType(core.NewNamespace("foo", "bar"), time.Now(), lp5) mc.Add(mt2) mc.Add(mt5) Convey("it resolves the plugin", func() { Convey("for the latest version", func() { p, err := mc.GetPlugin(core.NewNamespace("foo", "bar"), -1) So(err, ShouldBeNil) So(p, ShouldEqual, lp5) }) Convey("for the queried version", func() { p, err := mc.GetPlugin(core.NewNamespace("foo", "bar"), 2) So(err, ShouldBeNil) So(p, ShouldEqual, lp2) }) }) Convey("it returns an error if the metricType cannot be found", func() { Convey("invalid name of metric", func() { p, err := mc.GetPlugin(core.NewNamespace("baz", "qux"), -1) So(p, ShouldBeNil) So(err.Error(), ShouldResemble, "Metric not found: /baz/qux (version: -1)") }) Convey("invalid version of metric", func() { p, err := mc.GetPlugin(core.NewNamespace("foo", "bar"), 6) So(p, ShouldBeNil) So(err.Error(), ShouldResemble, "Metric not found: /foo/bar (version: 6)") }) }) }) }
func (f *filePublisher) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) { cp := cpolicy.New() config := cpolicy.NewPolicyNode() r1, err := cpolicy.NewStringRule("file", true) handleErr(err) r1.Description = "Absolute path to the output file for publishing" config.Add(r1) cp.Add([]string{""}, config) return cp, nil }
func (p *mockPlugin) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) { cp := cpolicy.New() cpn := cpolicy.NewPolicyNode() r1, _ := cpolicy.NewStringRule("username", false, "root") r2, _ := cpolicy.NewStringRule("password", true) cpn.Add(r1, r2) ns := []string{"one", "two", "potato"} cp.Add(ns, cpn) cp.Freeze() return cp, nil }
func (f *influxPublisher) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) { cp := cpolicy.New() config := cpolicy.NewPolicyNode() r1, err := cpolicy.NewStringRule("host", true) handleErr(err) r1.Description = "Influxdb host" config.Add(r1) r2, err := cpolicy.NewIntegerRule("port", true) handleErr(err) r2.Description = "Influxdb port" config.Add(r2) r3, err := cpolicy.NewStringRule("database", true) handleErr(err) r3.Description = "Influxdb db name" config.Add(r3) r4, err := cpolicy.NewStringRule("user", true) handleErr(err) r4.Description = "Influxdb user" config.Add(r4) r5, err := cpolicy.NewStringRule("password", true) handleErr(err) r5.Description = "Influxdb password" config.Add(r5) r6, err := cpolicy.NewStringRule("retention", false, "autogen") handleErr(err) r6.Description = "Influxdb retention policy" config.Add(r6) r7, err := cpolicy.NewBoolRule("https", false, false) handleErr(err) r7.Description = "Influxdb HTTPS connection" config.Add(r7) r8, err := cpolicy.NewBoolRule("skip-verify", false, false) handleErr(err) r8.Description = "Influxdb HTTPS Skip certificate verification" config.Add(r8) r9, err := cpolicy.NewStringRule("precision", false, "s") handleErr(err) r9.Description = "Influxdb timestamp precision" config.Add(r9) cp.Add([]string{""}, config) return cp, nil }
// GetConfigPolicy returns the config policy for the Riemann Publisher Plugin func (r *riemannPublisher) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) { cp := cpolicy.New() config := cpolicy.NewPolicyNode() // Riemann server to publish event to r1, err := cpolicy.NewStringRule("broker", true) handleErr(err) r1.Description = "Broker in the format of broker-ip:port (ex: 192.168.1.1:5555)" config.Add(r1) cp.Add([]string{""}, config) return cp, nil }
// GetConfigPolicy returns a config policy func (p *Libvirt) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) { cp := cpolicy.New() config := cpolicy.NewPolicyNode() uri, err := cpolicy.NewStringRule("uri", false, "qemu:///system") handleErr(err) uri.Description = "Libvirt uri" config.Add(uri) cp.Add([]string{""}, config) return cp, nil }
//GetConfigPolicy returns a ConfigPolicyTree for testing func (f *Gitstats) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) { c := cpolicy.New() rule, _ := cpolicy.NewStringRule("access_token", true) rule1, _ := cpolicy.NewStringRule("user", false, "") rule2, _ := cpolicy.NewStringRule("repo", false, "") p := cpolicy.NewPolicyNode() p.Add(rule) p.Add(rule1) p.Add(rule2) c.Add([]string{"raintank", "apps", "gitstats"}, p) return c, nil }
//GetConfigPolicy returns a ConfigPolicyTree for testing func (p *Ping) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) { c := cpolicy.New() rule0, _ := cpolicy.NewStringRule("checkId", true) rule1, _ := cpolicy.NewStringRule("endpoint", true) rule2, _ := cpolicy.NewStringRule("raintank_agent_name", true) rule3, _ := cpolicy.NewStringRule("hostname", true) cp := cpolicy.NewPolicyNode() cp.Add(rule0) cp.Add(rule1) cp.Add(rule2) cp.Add(rule3) c.Add([]string{"worldping"}, cp) return c, nil }
func (p *passthruProcessor) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) { cp := cpolicy.New() config := cpolicy.NewPolicyNode() r1, err := cpolicy.NewBoolRule(debug, false) if err != nil { panic(err) } r1.Description = "Debug mode" config.Add(r1) cp.Add([]string{""}, config) return cp, nil }
// GetConfigPolicy returns a ConfigPolicy func (ceph *Ceph) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) { c := cpolicy.New() socketPath, _ := cpolicy.NewStringRule("socket_path", false, socketPathDefault) socketPrefix, _ := cpolicy.NewStringRule("socket_prefix", false, socketPrefixDefault) socketExt, _ := cpolicy.NewStringRule("socket_ext", false, socketExtDefault) path, _ := cpolicy.NewStringRule("path", false, cephBinPathDefault) p := cpolicy.NewPolicyNode() p.Add(socketPath) p.Add(socketPrefix) p.Add(socketExt) p.Add(path) c.Add([]string{"intel", "storage", "ceph"}, p) return c, nil }
func (f *HostedtsdbPublisher) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) { c := cpolicy.New() rule, _ := cpolicy.NewStringRule("raintank_tsdb_url", true) rule2, _ := cpolicy.NewStringRule("raintank_api_key", true) rule3, _ := cpolicy.NewIntegerRule("interval", true) rule4, _ := cpolicy.NewIntegerRule("orgId", false, 0) p := cpolicy.NewPolicyNode() p.Add(rule) p.Add(rule2) p.Add(rule3) p.Add(rule4) c.Add([]string{""}, p) return c, nil }
//GetConfigPolicy returns a ConfigPolicyTree for testing func (n *Ns1) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) { c := cpolicy.New() rule, _ := cpolicy.NewStringRule("ns1_key", true) rule2, _ := cpolicy.NewStringRule("zone", false, "") rule3, _ := cpolicy.NewStringRule("jobId", false, "") rule4, _ := cpolicy.NewStringRule("jobName", false, "") p := cpolicy.NewPolicyNode() p.Add(rule) p.Add(rule2) p.Add(rule3) p.Add(rule4) c.Add([]string{"raintank", "apps", "ns1"}, p) return c, nil }
func (k *kafkaPublisher) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) { cp := cpolicy.New() config := cpolicy.NewPolicyNode() r1, err := cpolicy.NewStringRule("topic", true) handleErr(err) r1.Description = "Kafka topic for publishing" r2, _ := cpolicy.NewStringRule("brokers", true) handleErr(err) r2.Description = "List of brokers in the format: broker-ip:port;broker-ip:port (ex: 192.168.1.1:9092;172.16.9.99:9092" config.Add(r1, r2) cp.Add([]string{""}, config) return cp, nil }
func (k *kafkaPublisher) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) { cp := cpolicy.New() config := cpolicy.NewPolicyNode() r1, err := cpolicy.NewStringRule("topic", false, "snap") handleErr(err) r1.Description = "Kafka topic for publishing" r2, _ := cpolicy.NewStringRule("brokers", false, "localhost:9092") handleErr(err) r2.Description = "List of brokers separated by semicolon in the format: <broker-ip:port;broker-ip:port> (ex: \"192.168.1.1:9092;172.16.9.99:9092\")" config.Add(r1, r2) cp.Add([]string{""}, config) return cp, nil }
// GetConfigPolicy returns a config policy func (p *Osv) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) { cp := cpolicy.New() config := cpolicy.NewPolicyNode() swagIP, err := cpolicy.NewStringRule("swagIP", true) handleErr(err) swagIP.Description = "Osv ip address" config.Add(swagIP) swagPort, err := cpolicy.NewIntegerRule("swagPort", false, 8000) handleErr(err) swagPort.Description = "Swagger port / default 8000" config.Add(swagPort) cp.Add([]string{""}, config) return cp, nil }
func (p *opentsdbPublisher) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) { cp := cpolicy.New() config := cpolicy.NewPolicyNode() r1, err := cpolicy.NewStringRule("host", true) handleErr(err) r1.Description = "Opentsdb host" config.Add(r1) r2, err := cpolicy.NewIntegerRule("port", true) handleErr(err) r2.Description = "Opentsdb port" config.Add(r2) cp.Add([]string{""}, config) return cp, nil }