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

Add support for authentication API v3 #22

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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": "",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using API v3 you need to specify one of the openstack_domain_id or openstack_domain_name. If the user specifies both of them they get an error that one can specify only one of them.
However both of them need to specified in global config as due to usage of function config.GetConfigItem() all the fields in config are mandatory.

It may be a bit confusing for the user. So:

  • we should add note to documentation that all the config options are mandatory, and one of options openstack_domain_id or openstack_domain_name needs to be set to an empty string when using v3.
  • open an issue to refactor getting config items

"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