forked from gophercloud/utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gnocchi: implement archive policy Create method (gophercloud#43)
* Gnocchi: implement archive policy Create method Add support for creating Gnocchi archive policies. Add unit test and example in documentation. * Gnocchi: use "ArchivePolicyDefinitionOpts" name Use more broad name for archive policy definition options struct. * Gnocchi: fix some docs for create ap request * Archive Policies: add acc test for Create method Add acceptance test for the Create method and reusable helper CreateArchivePolicy method. * Gnocchi Archive Policies: fix inline comments Fix CreateOptsBuilder and CreateOpts inline comments.
- Loading branch information
1 parent
bcab613
commit 8972859
Showing
8 changed files
with
259 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package v1 | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/gophercloud/gophercloud" | ||
"github.com/gophercloud/gophercloud/acceptance/tools" | ||
"github.com/gophercloud/utils/gnocchi/metric/v1/archivepolicies" | ||
) | ||
|
||
// CreateArchivePolicy will create a Gnocchi archive policy. An error will be returned if the | ||
// archive policy could not be created. | ||
func CreateArchivePolicy(t *testing.T, client *gophercloud.ServiceClient) (*archivepolicies.ArchivePolicy, error) { | ||
policyName := tools.RandomString("TESTACCT-", 8) | ||
createOpts := archivepolicies.CreateOpts{ | ||
Name: policyName, | ||
AggregationMethods: []string{ | ||
"mean", | ||
"sum", | ||
}, | ||
Definition: []archivepolicies.ArchivePolicyDefinitionOpts{ | ||
{ | ||
Granularity: "1:00:00", | ||
TimeSpan: "30 days, 0:00:00", | ||
}, | ||
{ | ||
Granularity: "24:00:00", | ||
TimeSpan: "90 days, 0:00:00", | ||
}, | ||
}, | ||
} | ||
|
||
t.Logf("Attempting to create a Gnocchi archive policy") | ||
archivePolicy, err := archivepolicies.Create(client, createOpts).Extract() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
t.Logf("Successfully created the Gnocchi archive policy.") | ||
return archivePolicy, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters