rackspace / gophercloud

A Go SDK for OpenStack. IN FEATURE FREEZE. See Issue #592
http://gophercloud.io
Other
456 stars 181 forks source link

[RFR] add admin actions #587

Closed rtrox closed 8 years ago

rtrox commented 8 years ago

This PR adds all available admin actions to the "adminactions" extension.

API Docs for these functions are available here: http://developer.openstack.org/api-ref-compute-v2.1.html#os-admin-actions-v2.1

The actions added are:

coveralls commented 8 years ago

Coverage Status

Coverage remained the same at 80.545% when pulling bf70714f06e42699e611e94c46edc6fd1d6914eb on rtrox:admin_actions into 6fbd243473c9984e40119ce8b96be8bfd1cb75d8 on rackspace:master.

coveralls commented 8 years ago

Coverage Status

Coverage increased (+0.1%) to 80.651% when pulling 5a1d55ce0b14e71050f52e477ec45208856f995e on rtrox:admin_actions into 6fbd243473c9984e40119ce8b96be8bfd1cb75d8 on rackspace:master.

coveralls commented 8 years ago

Coverage Status

Coverage increased (+0.1%) to 80.675% when pulling db76deb0acc3bd0bd75b3e41ae78e7eb18f06aa7 on rtrox:admin_actions into 6fbd243473c9984e40119ce8b96be8bfd1cb75d8 on rackspace:master.

coveralls commented 8 years ago

Coverage Status

Coverage increased (+0.1%) to 80.675% when pulling cef96db215ef33c1dde82e1e4d33135c8d1d81ff on rtrox:admin_actions into 6fbd243473c9984e40119ce8b96be8bfd1cb75d8 on rackspace:master.

coveralls commented 8 years ago

Coverage Status

Coverage increased (+0.1%) to 80.649% when pulling c1072a17294cd8a3ae389afd32e012ee652a6005 on rtrox:admin_actions into 6fbd243473c9984e40119ce8b96be8bfd1cb75d8 on rackspace:master.

rtrox commented 8 years ago

@jrperritt I think this is ready for review, would you mind taking a look?

rtrox commented 8 years ago

I should add, these features are being implemented in preparation for a PR to rack cli to allow admin functions by Rackspace admins. Thanks for looking!

jrperritt commented 8 years ago

Great, I'll take a look tomorrow.

coveralls commented 8 years ago

Coverage Status

Coverage increased (+0.5%) to 81.093% when pulling 6dfdbf581bc06c614eda10ca4d113607288a1b56 on rtrox:admin_actions into 6fbd243473c9984e40119ce8b96be8bfd1cb75d8 on rackspace:master.

rtrox commented 8 years ago

Thanks for the feedback @jrperritt !

I've addressed the line comment concerns by adding the following validation:

    if opts.Name == "" {
        return nil, fmt.Errorf("CreateBackupOpts.Name cannot be blank.")
    }
    if opts.BackupType == "" {
        return nil, fmt.Errorf("CreateBackupOpts.BackupType cannot be blank.")
    }
    if opts.Rotation < 0 {
        return nil, fmt.Errorf("CreateBackupOpts.Rotation must 0 or greater.")
    }
    backup["name"] = opts.Name
    backup["backup_type"] = opts.BackupType
    backup["rotation"] = opts.Rotation

As I mentioned in my line comment, the rotation parameter can be zero according to the openstack unit-tests, but I added validation to ensure a non negative value (this is also in line with upstream validation).

I believe that means I am once more ready for review, would you mind taking another look?

jrperritt commented 8 years ago

LGTM. +2