Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Merge pull request #22 from PatrykMatyjasek/pm-auth-api-v3-support
Browse files Browse the repository at this point in the history
Add support for authentication API v3
  • Loading branch information
PatrykMatyjasek authored Apr 4, 2017
2 parents 34d3c1d + d2b7454 commit 7516021
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ Configuration for this plugin is given via global config. Global configuration f
- `"openstack_pass"`- password used to authenticate (ex. `"admin"`),
- `"openstack_tenant"` - tenant name used to authenticate (ex. `"admin"`),
- `"openstack_auth_url"` - keystone url (ex. `"http://172.16.0.5:5000/v2.0/"`).
If you're using authentication API in v3 you need to set one of those two configuration options (Note that both keys should be present in config, but only one of them is allowed to be set):
- `"openstack_domain_name"` - domain name
- `"openstack_domain_id"` - domain name

These values should correspond to values given in `nova.conf`:
- `"allocation_ratio_cores"` - oversubscription ratio for vcpus, used to derive some metrics for hypervisors (ex. 1.5),
Expand Down
2 changes: 2 additions & 0 deletions examples/cfg/cfg.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"openstack_user": "admin",
"openstack_pass": "admin",
"openstack_tenant": "admin",
"openstack_domain_id": "",
"openstack_domain_name": "",
"allocation_ratio_cores" : 1.5,
"allocation_ratio_ram": 3,
"reserved_node_cores" : 2,
Expand Down
2 changes: 2 additions & 0 deletions novaplugin/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ func newCollector(config Config) (collectorInterface, error) {
Username: config.User,
Password: config.Pass,
TenantName: config.Tenant,
DomainID: config.DomaninID,
DomainName: config.DomainName,
AllowReauth: true,
}

Expand Down
10 changes: 6 additions & 4 deletions novaplugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ const (
)

type Config struct {
User string `c:"openstack_user"`
Pass string `c:"openstack_pass"`
Tenant string `c:"openstack_tenant"`
Url string `c:"openstack_auth_url"`
User string `c:"openstack_user"`
Pass string `c:"openstack_pass"`
Tenant string `c:"openstack_tenant"`
Url string `c:"openstack_auth_url"`
DomainName string `c:"openstack_domain_name"`
DomaninID string `c:"openstack_domain_id"`

RatioCores float64 `c:"allocation_ratio_cores"`
RatioRam float64 `c:"allocation_ratio_ram"`
Expand Down
4 changes: 4 additions & 0 deletions novaplugin/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,15 @@ func testingConfig() (cfg1 plugin.ConfigType, cfg2 *cdata.ConfigDataNode) {
cfg1.AddItem("openstack_pass", ctypes.ConfigValueStr{Value: "x"})
cfg1.AddItem("openstack_tenant", ctypes.ConfigValueStr{Value: "asdf"})
cfg1.AddItem("openstack_auth_url", ctypes.ConfigValueStr{Value: "x"})
cfg1.AddItem("openstack_domain_id", ctypes.ConfigValueStr{Value: ""})
cfg1.AddItem("openstack_domain_name", ctypes.ConfigValueStr{Value: ""})

cfg2.AddItem("openstack_user", ctypes.ConfigValueStr{Value: "x"})
cfg2.AddItem("openstack_pass", ctypes.ConfigValueStr{Value: "x"})
cfg2.AddItem("openstack_tenant", ctypes.ConfigValueStr{Value: "asdf"})
cfg2.AddItem("openstack_auth_url", ctypes.ConfigValueStr{Value: "x"})
cfg2.AddItem("openstack_domain_id", ctypes.ConfigValueStr{Value: ""})
cfg2.AddItem("openstack_domain_name", ctypes.ConfigValueStr{Value: ""})

cfg1.AddItem("allocation_ratio_cores", ctypes.ConfigValueFloat{Value: 3})
cfg1.AddItem("allocation_ratio_ram", ctypes.ConfigValueFloat{Value: 4})
Expand Down

0 comments on commit 7516021

Please sign in to comment.