From 39442831dcffb533f184615f1cd29a0adc7c50bc Mon Sep 17 00:00:00 2001 From: Marcin Krolik Date: Fri, 29 Apr 2016 11:05:31 +0200 Subject: [PATCH 1/3] New metric schema - handling of new namespace added - applied changes to unit tests --- Godeps/Godeps.json | 117 +++++++++++++++++++----------------- collector/collector.go | 39 +++++++----- collector/collector_test.go | 59 +++++++++--------- 3 files changed, 113 insertions(+), 102 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 51103ea..ecfef43 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,79 +1,79 @@ { "ImportPath": "github.com/intelsdi-x/snap-plugin-collector-cinder", - "GoVersion": "go1.5", - "GodepVersion": "v60", + "GoVersion": "go1.6", + "GodepVersion": "v62", "Deps": [ { "ImportPath": "github.com/Sirupsen/logrus", - "Comment": "v0.10.0", - "Rev": "4b6ea7319e214d98c938f12692336f7ca9348d6b" + "Comment": "v0.8.7-55-gf7f79f7", + "Rev": "f7f79f729e0fbe2fcc061db48a9ba0263f588252" }, { "ImportPath": "github.com/intelsdi-x/snap-plugin-utilities/config", - "Rev": "07bd84723cf46ffdddbd7e0544bdd41856c19fa4" + "Rev": "04621af7a3979bcb8aaf08c3b6542b43fe0bf6cf" }, { "ImportPath": "github.com/intelsdi-x/snap-plugin-utilities/ns", - "Rev": "07bd84723cf46ffdddbd7e0544bdd41856c19fa4" + "Rev": "04621af7a3979bcb8aaf08c3b6542b43fe0bf6cf" }, { - "ImportPath": "github.com/intelsdi-x/snap-plugin-utilities/strings", - "Rev": "07bd84723cf46ffdddbd7e0544bdd41856c19fa4" + "ImportPath": "github.com/intelsdi-x/snap-plugin-utilities/str", + "Rev": "04621af7a3979bcb8aaf08c3b6542b43fe0bf6cf" }, { "ImportPath": "github.com/intelsdi-x/snap/control/plugin", - "Comment": "v0.12.0-beta", - "Rev": "e7bc051a9cd62781780fb090940a37f73d942c04" + "Comment": "v0.13.0-beta-67-g891c09f", + "Rev": "891c09fd7e93aaf7cc0fb976fb91407901fd3843" }, { "ImportPath": "github.com/intelsdi-x/snap/control/plugin/cpolicy", - "Comment": "v0.12.0-beta", - "Rev": "e7bc051a9cd62781780fb090940a37f73d942c04" + "Comment": "v0.13.0-beta-67-g891c09f", + "Rev": "891c09fd7e93aaf7cc0fb976fb91407901fd3843" }, { "ImportPath": "github.com/intelsdi-x/snap/control/plugin/encoding", - "Comment": "v0.12.0-beta", - "Rev": "e7bc051a9cd62781780fb090940a37f73d942c04" + "Comment": "v0.13.0-beta-67-g891c09f", + "Rev": "891c09fd7e93aaf7cc0fb976fb91407901fd3843" }, { "ImportPath": "github.com/intelsdi-x/snap/control/plugin/encrypter", - "Comment": "v0.12.0-beta", - "Rev": "e7bc051a9cd62781780fb090940a37f73d942c04" + "Comment": "v0.13.0-beta-67-g891c09f", + "Rev": "891c09fd7e93aaf7cc0fb976fb91407901fd3843" }, { "ImportPath": "github.com/intelsdi-x/snap/core", - "Comment": "v0.12.0-beta", - "Rev": "e7bc051a9cd62781780fb090940a37f73d942c04" + "Comment": "v0.13.0-beta-67-g891c09f", + "Rev": "891c09fd7e93aaf7cc0fb976fb91407901fd3843" }, { "ImportPath": "github.com/intelsdi-x/snap/core/cdata", - "Comment": "v0.12.0-beta", - "Rev": "e7bc051a9cd62781780fb090940a37f73d942c04" + "Comment": "v0.13.0-beta-67-g891c09f", + "Rev": "891c09fd7e93aaf7cc0fb976fb91407901fd3843" }, { "ImportPath": "github.com/intelsdi-x/snap/core/ctypes", - "Comment": "v0.12.0-beta", - "Rev": "e7bc051a9cd62781780fb090940a37f73d942c04" + "Comment": "v0.13.0-beta-67-g891c09f", + "Rev": "891c09fd7e93aaf7cc0fb976fb91407901fd3843" }, { "ImportPath": "github.com/intelsdi-x/snap/core/serror", - "Comment": "v0.12.0-beta", - "Rev": "e7bc051a9cd62781780fb090940a37f73d942c04" + "Comment": "v0.13.0-beta-67-g891c09f", + "Rev": "891c09fd7e93aaf7cc0fb976fb91407901fd3843" }, { "ImportPath": "github.com/intelsdi-x/snap/pkg/ctree", - "Comment": "v0.12.0-beta", - "Rev": "e7bc051a9cd62781780fb090940a37f73d942c04" + "Comment": "v0.13.0-beta-67-g891c09f", + "Rev": "891c09fd7e93aaf7cc0fb976fb91407901fd3843" }, { "ImportPath": "github.com/intelsdi-x/snap/pkg/schedule", - "Comment": "v0.12.0-beta", - "Rev": "e7bc051a9cd62781780fb090940a37f73d942c04" + "Comment": "v0.13.0-beta-67-g891c09f", + "Rev": "891c09fd7e93aaf7cc0fb976fb91407901fd3843" }, { "ImportPath": "github.com/intelsdi-x/snap/scheduler/wmap", - "Comment": "v0.12.0-beta", - "Rev": "e7bc051a9cd62781780fb090940a37f73d942c04" + "Comment": "v0.13.0-beta-67-g891c09f", + "Rev": "891c09fd7e93aaf7cc0fb976fb91407901fd3843" }, { "ImportPath": "github.com/mitchellh/mapstructure", @@ -86,71 +86,76 @@ }, { "ImportPath": "github.com/rackspace/gophercloud", - "Comment": "v1.0.0-812-g3be6938", - "Rev": "3be69380c314f60d981425ff95a36aecdb9d820a" + "Comment": "v1.0.0-884-gc54bbac", + "Rev": "c54bbac81d19eb4df3ad167764dbb6ff2e7194de" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack", - "Comment": "v1.0.0-812-g3be6938", - "Rev": "3be69380c314f60d981425ff95a36aecdb9d820a" + "Comment": "v1.0.0-884-gc54bbac", + "Rev": "c54bbac81d19eb4df3ad167764dbb6ff2e7194de" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/blockstorage/v1/apiversions", - "Comment": "v1.0.0-812-g3be6938", - "Rev": "3be69380c314f60d981425ff95a36aecdb9d820a" + "Comment": "v1.0.0-884-gc54bbac", + "Rev": "c54bbac81d19eb4df3ad167764dbb6ff2e7194de" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots", - "Comment": "v1.0.0-812-g3be6938", - "Rev": "3be69380c314f60d981425ff95a36aecdb9d820a" + "Comment": "v1.0.0-884-gc54bbac", + "Rev": "c54bbac81d19eb4df3ad167764dbb6ff2e7194de" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes", - "Comment": "v1.0.0-812-g3be6938", - "Rev": "3be69380c314f60d981425ff95a36aecdb9d820a" + "Comment": "v1.0.0-884-gc54bbac", + "Rev": "c54bbac81d19eb4df3ad167764dbb6ff2e7194de" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/identity/v2/tenants", - "Comment": "v1.0.0-812-g3be6938", - "Rev": "3be69380c314f60d981425ff95a36aecdb9d820a" + "Comment": "v1.0.0-884-gc54bbac", + "Rev": "c54bbac81d19eb4df3ad167764dbb6ff2e7194de" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/identity/v2/tokens", - "Comment": "v1.0.0-812-g3be6938", - "Rev": "3be69380c314f60d981425ff95a36aecdb9d820a" + "Comment": "v1.0.0-884-gc54bbac", + "Rev": "c54bbac81d19eb4df3ad167764dbb6ff2e7194de" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/identity/v3/tokens", - "Comment": "v1.0.0-812-g3be6938", - "Rev": "3be69380c314f60d981425ff95a36aecdb9d820a" + "Comment": "v1.0.0-884-gc54bbac", + "Rev": "c54bbac81d19eb4df3ad167764dbb6ff2e7194de" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/utils", - "Comment": "v1.0.0-812-g3be6938", - "Rev": "3be69380c314f60d981425ff95a36aecdb9d820a" + "Comment": "v1.0.0-884-gc54bbac", + "Rev": "c54bbac81d19eb4df3ad167764dbb6ff2e7194de" }, { "ImportPath": "github.com/rackspace/gophercloud/pagination", - "Comment": "v1.0.0-812-g3be6938", - "Rev": "3be69380c314f60d981425ff95a36aecdb9d820a" + "Comment": "v1.0.0-884-gc54bbac", + "Rev": "c54bbac81d19eb4df3ad167764dbb6ff2e7194de" }, { "ImportPath": "github.com/rackspace/gophercloud/testhelper", - "Comment": "v1.0.0-812-g3be6938", - "Rev": "3be69380c314f60d981425ff95a36aecdb9d820a" + "Comment": "v1.0.0-884-gc54bbac", + "Rev": "c54bbac81d19eb4df3ad167764dbb6ff2e7194de" }, { "ImportPath": "github.com/rackspace/gophercloud/testhelper/client", - "Comment": "v1.0.0-812-g3be6938", - "Rev": "3be69380c314f60d981425ff95a36aecdb9d820a" + "Comment": "v1.0.0-884-gc54bbac", + "Rev": "c54bbac81d19eb4df3ad167764dbb6ff2e7194de" + }, + { + "ImportPath": "github.com/robfig/cron", + "Comment": "v1-16-g0f39cf7", + "Rev": "0f39cf7ebc65a602f45692f9894bd6a193faf8fa" }, { "ImportPath": "golang.org/x/sys/unix", - "Rev": "320cb01ddbbf0473674c2585f9b6e245721de355" + "Rev": "c8bc69bc2db9c57ccf979550bc69655df5039a8a" }, { "ImportPath": "gopkg.in/yaml.v2", - "Rev": "a83829b6f1293c91addabc89d0571c246397bbf4" + "Rev": "c1cd2254a6dd314c9d73c338c12688c9325d85c6" } ] } diff --git a/collector/collector.go b/collector/collector.go index 2baa502..d301905 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -25,10 +25,11 @@ import ( "github.com/intelsdi-x/snap/control/plugin" "github.com/intelsdi-x/snap/control/plugin/cpolicy" + "github.com/intelsdi-x/snap/core" "github.com/intelsdi-x/snap-plugin-utilities/config" "github.com/intelsdi-x/snap-plugin-utilities/ns" - str "github.com/intelsdi-x/snap-plugin-utilities/strings" + "github.com/intelsdi-x/snap-plugin-utilities/str" openstackintel "github.com/intelsdi-x/snap-plugin-collector-cinder/openstack" "github.com/intelsdi-x/snap-plugin-collector-cinder/openstack/services" @@ -63,8 +64,8 @@ func New() *collector { // GetMetricTypes returns list of available metric types // It returns error in case retrieval was not successful -func (c *collector) GetMetricTypes(cfg plugin.PluginConfigType) ([]plugin.PluginMetricType, error) { - mts := []plugin.PluginMetricType{} +func (c *collector) GetMetricTypes(cfg plugin.ConfigType) ([]plugin.MetricType, error) { + mts := []plugin.MetricType{} var err error c.allTenants, err = getTenants(cfg) @@ -86,8 +87,8 @@ func (c *collector) GetMetricTypes(cfg plugin.PluginConfigType) ([]plugin.Plugin } for _, namespace := range namespaces { - mts = append(mts, plugin.PluginMetricType{ - Namespace_: strings.Split(namespace, "/"), + mts = append(mts, plugin.MetricType{ + Namespace_: core.NewNamespace(strings.Split(namespace, "/")...), Config_: cfg.ConfigDataNode, }) } @@ -97,7 +98,7 @@ func (c *collector) GetMetricTypes(cfg plugin.PluginConfigType) ([]plugin.Plugin // CollectMetrics returns list of requested metric values // It returns error in case retrieval was not successful -func (c *collector) CollectMetrics(metricTypes []plugin.PluginMetricType) ([]plugin.PluginMetricType, error) { +func (c *collector) CollectMetrics(metricTypes []plugin.MetricType) ([]plugin.MetricType, error) { // get admin tenant from configuration. admin tenant is needed for gathering volumes and snapshots metrics at once item, err := config.GetConfigItem(metricTypes[0], "tenant") if err != nil { @@ -123,12 +124,12 @@ func (c *collector) CollectMetrics(metricTypes []plugin.PluginMetricType) ([]plu return nil, fmt.Errorf("Incorrect namespace lenth. Expected 6 is %d", len(namespace)) } - tenant := namespace[3] + tenant := namespace[3].Value collectTenants.Add(tenant) - if str.Contains(namespace, "limits") { + if str.Contains(namespace.Strings(), "limits") { collectLimits = true - } else if str.Contains(namespace, "volumes") { + } else if str.Contains(namespace.Strings(), "volumes") { collectVolumes = true } else { collectSnapshots = true @@ -223,9 +224,15 @@ func (c *collector) CollectMetrics(metricTypes []plugin.PluginMetricType) ([]plu } } - metrics := []plugin.PluginMetricType{} + metrics := []plugin.MetricType{} for _, metricType := range metricTypes { - namespace := metricType.Namespace() + tags := metricType.Tags() + if tags == nil { + tags = map[string]string{} + } + tags["hostname"] = c.host + + namespace := metricType.Namespace().Strings() tenant := namespace[3] // Construct temporary struct to accommodate all gathered metrics metricContainer := struct { @@ -239,10 +246,10 @@ func (c *collector) CollectMetrics(metricTypes []plugin.PluginMetricType) ([]plu } // Extract values by namespace from temporary struct and create metrics - metric := plugin.PluginMetricType{ - Source_: c.host, + metric := plugin.MetricType{ + Tags_: tags, Timestamp_: time.Now(), - Namespace_: namespace, + Namespace_: metricType.Namespace(), Data_: ns.GetValueByNamespace(metricContainer, namespace[4:]), } metrics = append(metrics, metric) @@ -282,7 +289,7 @@ type collector struct { func (c *collector) authenticate(cfg interface{}, tenant string) error { if _, found := c.providers[tenant]; !found { // get credentials and endpoint from configuration - items, err := config.GetConfigItems(cfg, []string{"endpoint", "user", "password"}) + items, err := config.GetConfigItems(cfg, "endpoint", "user", "password") if err != nil { return err } @@ -307,7 +314,7 @@ func (c *collector) authenticate(cfg interface{}, tenant string) error { } func getTenants(cfg interface{}) (map[string]string, error) { - items, err := config.GetConfigItems(cfg, []string{"endpoint", "user", "password"}) + items, err := config.GetConfigItems(cfg, "endpoint", "user", "password") if err != nil { return nil, err } diff --git a/collector/collector_test.go b/collector/collector_test.go index 6fb8f25..21418c0 100644 --- a/collector/collector_test.go +++ b/collector/collector_test.go @@ -19,7 +19,7 @@ package collector import ( "fmt" "net/http" - "strings" + "net/http/httptest" "testing" "github.com/gorilla/mux" @@ -28,12 +28,11 @@ import ( "github.com/stretchr/testify/suite" "github.com/intelsdi-x/snap/control/plugin" + "github.com/intelsdi-x/snap/core" "github.com/intelsdi-x/snap/core/cdata" "github.com/intelsdi-x/snap/core/ctypes" - str "github.com/intelsdi-x/snap-plugin-utilities/strings" - - "net/http/httptest" + "github.com/intelsdi-x/snap-plugin-utilities/str" ) type CollectorSuite struct { @@ -100,23 +99,23 @@ func (s *CollectorSuite) TestGetMetricTypes() { Convey("and proper metric types are returned", func() { metricNames := []string{} for _, m := range mts { - metricNames = append(metricNames, strings.Join(m.Namespace(), "/")) + metricNames = append(metricNames, m.Namespace().String()) } So(len(mts), ShouldEqual, 12) - So(str.Contains(metricNames, "intel/openstack/cinder/demo/snapshots/count"), ShouldBeTrue) - So(str.Contains(metricNames, "intel/openstack/cinder/demo/snapshots/bytes"), ShouldBeTrue) - So(str.Contains(metricNames, "intel/openstack/cinder/demo/volumes/count"), ShouldBeTrue) - So(str.Contains(metricNames, "intel/openstack/cinder/demo/volumes/bytes"), ShouldBeTrue) - So(str.Contains(metricNames, "intel/openstack/cinder/demo/limits/MaxTotalVolumeGigabytes"), ShouldBeTrue) - So(str.Contains(metricNames, "intel/openstack/cinder/demo/limits/MaxTotalVolumes"), ShouldBeTrue) - So(str.Contains(metricNames, "intel/openstack/cinder/admin/volumes/count"), ShouldBeTrue) - So(str.Contains(metricNames, "intel/openstack/cinder/admin/volumes/bytes"), ShouldBeTrue) - So(str.Contains(metricNames, "intel/openstack/cinder/admin/limits/MaxTotalVolumeGigabytes"), ShouldBeTrue) - So(str.Contains(metricNames, "intel/openstack/cinder/admin/limits/MaxTotalVolumes"), ShouldBeTrue) - So(str.Contains(metricNames, "intel/openstack/cinder/admin/snapshots/count"), ShouldBeTrue) - So(str.Contains(metricNames, "intel/openstack/cinder/admin/snapshots/bytes"), ShouldBeTrue) + So(str.Contains(metricNames, "/intel/openstack/cinder/demo/snapshots/count"), ShouldBeTrue) + So(str.Contains(metricNames, "/intel/openstack/cinder/demo/snapshots/bytes"), ShouldBeTrue) + So(str.Contains(metricNames, "/intel/openstack/cinder/demo/volumes/count"), ShouldBeTrue) + So(str.Contains(metricNames, "/intel/openstack/cinder/demo/volumes/bytes"), ShouldBeTrue) + So(str.Contains(metricNames, "/intel/openstack/cinder/demo/limits/MaxTotalVolumeGigabytes"), ShouldBeTrue) + So(str.Contains(metricNames, "/intel/openstack/cinder/demo/limits/MaxTotalVolumes"), ShouldBeTrue) + So(str.Contains(metricNames, "/intel/openstack/cinder/admin/volumes/count"), ShouldBeTrue) + So(str.Contains(metricNames, "/intel/openstack/cinder/admin/volumes/bytes"), ShouldBeTrue) + So(str.Contains(metricNames, "/intel/openstack/cinder/admin/limits/MaxTotalVolumeGigabytes"), ShouldBeTrue) + So(str.Contains(metricNames, "/intel/openstack/cinder/admin/limits/MaxTotalVolumes"), ShouldBeTrue) + So(str.Contains(metricNames, "/intel/openstack/cinder/admin/snapshots/count"), ShouldBeTrue) + So(str.Contains(metricNames, "/intel/openstack/cinder/admin/snapshots/bytes"), ShouldBeTrue) }) }) }) @@ -126,20 +125,20 @@ func (s *CollectorSuite) TestCollectMetrics() { Convey("Given set of metric types", s.T(), func() { cfg := setupCfg(s.server.URL, "me", "secret", "admin") - m1 := plugin.PluginMetricType{ - Namespace_: []string{"intel", "openstack", "cinder", "demo", "limits", "MaxTotalVolumeGigabytes"}, + m1 := plugin.MetricType{ + Namespace_: core.NewNamespace("intel", "openstack", "cinder", "demo", "limits", "MaxTotalVolumeGigabytes"), Config_: cfg.ConfigDataNode} - m2 := plugin.PluginMetricType{ - Namespace_: []string{"intel", "openstack", "cinder", "demo", "volumes", "count"}, + m2 := plugin.MetricType{ + Namespace_: core.NewNamespace("intel", "openstack", "cinder", "demo", "volumes", "count"), Config_: cfg.ConfigDataNode} - m3 := plugin.PluginMetricType{ - Namespace_: []string{"intel", "openstack", "cinder", "demo", "snapshots", "bytes"}, + m3 := plugin.MetricType{ + Namespace_: core.NewNamespace("intel", "openstack", "cinder", "demo", "snapshots", "bytes"), Config_: cfg.ConfigDataNode} Convey("When ColelctMetrics() is called", func() { collector := New() - mts, err := collector.CollectMetrics([]plugin.PluginMetricType{m1, m2, m3}) + mts, err := collector.CollectMetrics([]plugin.MetricType{m1, m2, m3}) Convey("Then no error should be reported", func() { So(err, ShouldBeNil) @@ -148,22 +147,22 @@ func (s *CollectorSuite) TestCollectMetrics() { Convey("and proper metric types are returned", func() { metricNames := map[string]interface{}{} for _, m := range mts { - ns := strings.Join(m.Namespace(), "/") + ns := m.Namespace().String() metricNames[ns] = m.Data() fmt.Println(ns, "=", m.Data()) } So(len(mts), ShouldEqual, 3) - val, ok := metricNames["intel/openstack/cinder/demo/limits/MaxTotalVolumeGigabytes"] + val, ok := metricNames["/intel/openstack/cinder/demo/limits/MaxTotalVolumeGigabytes"] So(ok, ShouldBeTrue) So(val, ShouldEqual, s.MaxTotalVolumeGigabytes) - val, ok = metricNames["intel/openstack/cinder/demo/volumes/count"] + val, ok = metricNames["/intel/openstack/cinder/demo/volumes/count"] So(ok, ShouldBeTrue) So(val, ShouldEqual, 1) - val, ok = metricNames["intel/openstack/cinder/demo/snapshots/bytes"] + val, ok = metricNames["/intel/openstack/cinder/demo/snapshots/bytes"] So(ok, ShouldBeTrue) So(val, ShouldEqual, s.SnapShotSize*1024*1024*1024) @@ -177,13 +176,13 @@ func TestCollectorSuite(t *testing.T) { suite.Run(t, collectorTestSuite) } -func setupCfg(endpoint, user, password, tenant string) plugin.PluginConfigType { +func setupCfg(endpoint, user, password, tenant string) plugin.ConfigType { node := cdata.NewNode() node.AddItem("endpoint", ctypes.ConfigValueStr{Value: endpoint}) node.AddItem("user", ctypes.ConfigValueStr{Value: user}) node.AddItem("password", ctypes.ConfigValueStr{Value: password}) node.AddItem("tenant", ctypes.ConfigValueStr{Value: tenant}) - return plugin.PluginConfigType{ConfigDataNode: node} + return plugin.ConfigType{ConfigDataNode: node} } func registerIdentityRoot(s *CollectorSuite, r *mux.Router) { From fce68bcb6d09c0c57bfcca63d19b4e21eaf7198c Mon Sep 17 00:00:00 2001 From: Marcin Krolik Date: Fri, 29 Apr 2016 20:32:43 +0200 Subject: [PATCH 2/3] Plugin version incremented --- collector/collector.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collector/collector.go b/collector/collector.go index d301905..7a12289 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -38,7 +38,7 @@ import ( const ( name = "cinder" - version = 1 + version = 2 plgtype = plugin.CollectorPluginType vendor = "intel" fs = "openstack" From 36960bcc1f056e1f533737469586db018420cca0 Mon Sep 17 00:00:00 2001 From: Marcin Krolik Date: Tue, 10 May 2016 14:48:33 +0200 Subject: [PATCH 3/3] Removed hostname tag, updated go version, fixed examples --- .travis.yml | 4 ++-- collector/collector.go | 15 --------------- examples/cfg/cfg.json | 18 +++--------------- scripts/test.sh | 1 - 4 files changed, 5 insertions(+), 33 deletions(-) diff --git a/.travis.yml b/.travis.yml index ceae7f9..02ab01f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ sudo: required language: go go: -- 1.5.3 -- 1.6 +- 1.5.4 +- 1.6.2 before_install: - go get github.com/tools/godep - if [ ! -d $SNAP_PLUGIN_SOURCE ]; then mkdir -p $HOME/gopath/src/github.com/intelsdi-x; ln -s $TRAVIS_BUILD_DIR $SNAP_PLUGIN_SOURCE; fi # CI for forks not from intelsdi-x diff --git a/collector/collector.go b/collector/collector.go index 7a12289..7ec85dc 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -16,7 +16,6 @@ package collector import ( "fmt" - "os" "strings" "sync" "time" @@ -46,16 +45,10 @@ const ( // New creates initialized instance of Cinder collector func New() *collector { - host, err := os.Hostname() - if err != nil { - host = "localhost" - } - providers := map[string]*gophercloud.ProviderClient{} allTenants := map[string]string{} allLimits := map[string]types.Limits{} return &collector{ - host: host, allTenants: allTenants, providers: providers, allLimits: allLimits, @@ -226,12 +219,6 @@ func (c *collector) CollectMetrics(metricTypes []plugin.MetricType) ([]plugin.Me metrics := []plugin.MetricType{} for _, metricType := range metricTypes { - tags := metricType.Tags() - if tags == nil { - tags = map[string]string{} - } - tags["hostname"] = c.host - namespace := metricType.Namespace().Strings() tenant := namespace[3] // Construct temporary struct to accommodate all gathered metrics @@ -247,7 +234,6 @@ func (c *collector) CollectMetrics(metricTypes []plugin.MetricType) ([]plugin.Me // Extract values by namespace from temporary struct and create metrics metric := plugin.MetricType{ - Tags_: tags, Timestamp_: time.Now(), Namespace_: metricType.Namespace(), Data_: ns.GetValueByNamespace(metricContainer, namespace[4:]), @@ -278,7 +264,6 @@ func Meta() *plugin.PluginMeta { } type collector struct { - host string allTenants map[string]string service services.Service common openstackintel.Commoner diff --git a/examples/cfg/cfg.json b/examples/cfg/cfg.json index 547bbbb..68c9e07 100644 --- a/examples/cfg/cfg.json +++ b/examples/cfg/cfg.json @@ -1,11 +1,6 @@ { - "control": { - "cache_ttl": "5s" - }, - "scheduler": { - "default_deadline": "5s", - "worker_pool_size": 5 - }, + "control": {}, + "scheduler": {}, "plugins": { "collector": { "cinder": { @@ -16,14 +11,7 @@ } } }, - "publisher": { - "influxdb": { - "all": { - "server": "xyz.local", - "password": "$password" - } - } - }, + "publisher": {}, "processor": {} } } diff --git a/scripts/test.sh b/scripts/test.sh index 6d93d57..25c6c54 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -13,7 +13,6 @@ TEST_SUITE=$1 if [[ $TEST_SUITE == "unit" ]]; then go get github.com/axw/gocov/gocov go get github.com/mattn/goveralls - go get github.com/golang/lint/golint go get golang.org/x/tools/cmd/goimports go get github.com/smartystreets/goconvey/convey go get golang.org/x/tools/cmd/cover