-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[EVS] V3 API Update #466
Draft
Aloento
wants to merge
51
commits into
devel
Choose a base branch
from
evs
base: devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
[EVS] V3 API Update #466
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
57353b0
Copy
Aloento 1f1b77b
Replace
Aloento c1e8296
Replace
Aloento 4d7b0c3
Create
Aloento bc69d51
Create
Aloento c77043b
Delete
Aloento 3361565
Update
Aloento ac36160
Update
Aloento e8b0dbb
List
Aloento 048589a
Get
Aloento 676cc54
Test
Aloento 7bb8570
extract
Aloento 09a6f66
List
Aloento d20e07f
volumetypes
Aloento a67046a
move
Aloento c4c676a
reverse
Aloento 70cfe31
move
Aloento bff1475
List
Aloento 5dea94c
os-quota-sets
Aloento f04f739
List
Aloento eaafa7b
QuotaSet
Aloento a397d31
metadata
Aloento 83c8394
Create
Aloento 8621116
Get
Aloento 57fa244
Update
Aloento da6e8de
One
Aloento 90f815c
ListAvailabilityZone
Aloento a8f7485
ExtendSize
Aloento f8c9ccd
SetBootable
Aloento 32721e0
SetReadonly
Aloento 4738699
UploadImage
Aloento 0ffd28f
clr
Aloento 9256085
Create
Aloento 26f1541
Delete
Aloento 828854a
Update
Aloento 00b9bd1
List
Aloento 3fe9730
metadata unf
Aloento 4b4036e
Get
Aloento 4fbc771
snapshot_id
Aloento 2a0f3e9
Create
Aloento ec20199
Delete
Aloento 503fe5e
Get
Aloento 85893ae
List
Aloento 0e30094
test
Aloento ced95f3
test
Aloento 29ba3d5
fix
Aloento 0e0b02e
fix
Aloento d0cf3be
rm
Aloento 3d6c6b0
mv
Aloento fe4fade
AvailabilityZone
Aloento 5a313a0
VolumeTenantExt
Aloento File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,80 @@ | ||
package v2 | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
golangsdk "github.com/opentelekomcloud/gophertelekomcloud" | ||
"github.com/opentelekomcloud/gophertelekomcloud/acceptance/clients" | ||
"github.com/opentelekomcloud/gophertelekomcloud/acceptance/openstack" | ||
"github.com/opentelekomcloud/gophertelekomcloud/acceptance/tools" | ||
"github.com/opentelekomcloud/gophertelekomcloud/openstack/compute/v2/flavors" | ||
"github.com/opentelekomcloud/gophertelekomcloud/openstack/compute/v2/images" | ||
"github.com/opentelekomcloud/gophertelekomcloud/openstack/compute/v2/servers" | ||
th "github.com/opentelekomcloud/gophertelekomcloud/testhelper" | ||
) | ||
|
||
func CreateServer(t *testing.T, client *golangsdk.ServiceClient) (*servers.Server, error) { | ||
t.Logf("Attempting to create ECSv2") | ||
ecsName := tools.RandomString("create-ecs-", 3) | ||
|
||
az := clients.EnvOS.GetEnv("AVAILABILITY_ZONE") | ||
if az == "" { | ||
az = "eu-de-01" | ||
} | ||
|
||
networkID := clients.EnvOS.GetEnv("NETWORK_ID") | ||
if networkID == "" { | ||
t.Skip("OS_NETWORK_ID env var is missing but ECS test requires using existing network") | ||
} | ||
|
||
// TODO: API discarded and not working. | ||
imageID, err := images.IDFromName(client, "Standard_Debian_10_latest") | ||
th.AssertNoErr(t, err) | ||
|
||
flavorID, err := flavors.IDFromName(client, "s2.large.2") | ||
th.AssertNoErr(t, err) | ||
|
||
ecs, err := servers.Create(client, servers.CreateOpts{ | ||
Name: ecsName, | ||
ImageRef: imageID, | ||
FlavorRef: flavorID, | ||
SecurityGroups: []string{ | ||
openstack.DefaultSecurityGroup(t), | ||
}, | ||
AvailabilityZone: az, | ||
Networks: []servers.Network{ | ||
{ | ||
UUID: networkID, | ||
}, | ||
}, | ||
}).Extract() | ||
th.AssertNoErr(t, err) | ||
|
||
err = servers.WaitForStatus(client, ecs.ID, "ACTIVE", 1200) | ||
th.AssertNoErr(t, err) | ||
t.Logf("Created ECSv2: %s", ecs.ID) | ||
return ecs, err | ||
} | ||
|
||
func DeleteServer(t *testing.T, client *golangsdk.ServiceClient, ecs *servers.Server) { | ||
t.Logf("Attempting to delete ECSv2: %s", ecs.ID) | ||
|
||
_, err := servers.Delete(client, ecs.ID).ExtractJobResponse() | ||
th.AssertNoErr(t, err) | ||
|
||
err = golangsdk.WaitFor(1200, func() (bool, error) { | ||
_, err := servers.Get(client, ecs.ID).Extract() | ||
if err != nil { | ||
if _, ok := err.(golangsdk.ErrDefault400); ok { | ||
time.Sleep(10 * time.Second) | ||
return false, nil | ||
} | ||
return false, err | ||
} | ||
return true, nil | ||
}) | ||
th.AssertNoErr(t, err) | ||
|
||
t.Logf("ECSv2 instance deleted: %s", ecs.ID) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
package v3 | ||
|
||
import ( | ||
"testing" | ||
|
||
golangsdk "github.com/opentelekomcloud/gophertelekomcloud" | ||
"github.com/opentelekomcloud/gophertelekomcloud/acceptance/clients" | ||
"github.com/opentelekomcloud/gophertelekomcloud/acceptance/tools" | ||
"github.com/opentelekomcloud/gophertelekomcloud/openstack/evs/v3/snapshots" | ||
"github.com/opentelekomcloud/gophertelekomcloud/openstack/evs/v3/volumes" | ||
"github.com/opentelekomcloud/gophertelekomcloud/openstack/evs/v3/volumetypes" | ||
th "github.com/opentelekomcloud/gophertelekomcloud/testhelper" | ||
) | ||
|
||
// CreateSnapshot will create a snapshot of the specified volume. | ||
// Snapshot will be assigned a random name and description. | ||
func CreateSnapshot(t *testing.T, client *golangsdk.ServiceClient, volume *volumes.Volume) (*snapshots.Snapshot, error) { | ||
snapshotName := tools.RandomString("ACPTTEST", 16) | ||
snapshotDescription := tools.RandomString("ACPTTEST", 16) | ||
t.Logf("Attempting to create snapshot: %s", snapshotName) | ||
|
||
createOpts := snapshots.CreateOpts{ | ||
VolumeID: volume.ID, | ||
Name: snapshotName, | ||
Description: snapshotDescription, | ||
} | ||
|
||
snapshot, err := snapshots.Create(client, createOpts) | ||
if err != nil { | ||
return snapshot, err | ||
} | ||
|
||
err = snapshots.WaitForStatus(client, snapshot.ID, "available", 60) | ||
if err != nil { | ||
return snapshot, err | ||
} | ||
|
||
tools.PrintResource(t, snapshot) | ||
th.AssertEquals(t, snapshot.Name, snapshotName) | ||
th.AssertEquals(t, snapshot.VolumeID, volume.ID) | ||
|
||
t.Logf("Successfully created snapshot: %s", snapshot.ID) | ||
|
||
return snapshot, nil | ||
} | ||
|
||
// CreateVolume will create a volume with a random name and size of 1GB. An | ||
// error will be returned if the volume was unable to be created. | ||
func CreateVolume(t *testing.T, client *golangsdk.ServiceClient) (*volumes.Volume, error) { | ||
volumeName := tools.RandomString("ACPTTEST", 16) | ||
volumeDescription := tools.RandomString("ACPTTEST-DESC", 16) | ||
t.Logf("Attempting to create volume: %s", volumeName) | ||
|
||
createOpts := volumes.CreateOpts{ | ||
Size: 1, | ||
Name: volumeName, | ||
Description: volumeDescription, | ||
AvailabilityZone: clients.EnvOS.GetEnv("AVAILABILITY_ZONE"), | ||
} | ||
|
||
volume, err := volumes.Create(client, createOpts) | ||
if err != nil { | ||
return volume, err | ||
} | ||
|
||
err = volumes.WaitForStatus(client, volume.ID, "available", 60) | ||
if err != nil { | ||
return volume, err | ||
} | ||
|
||
tools.PrintResource(t, volume) | ||
th.AssertEquals(t, volume.Name, volumeName) | ||
th.AssertEquals(t, volume.Description, volumeDescription) | ||
th.AssertEquals(t, volume.Size, 1) | ||
|
||
t.Logf("Successfully created volume: %s", volume.ID) | ||
|
||
return volume, nil | ||
} | ||
|
||
// CreateVolumeWithType will create a volume of the given volume type | ||
// with a random name and size of 1GB. An error will be returned if | ||
// the volume was unable to be created. | ||
func CreateVolumeWithType(t *testing.T, client *golangsdk.ServiceClient, vt *volumetypes.VolumeType) (*volumes.Volume, error) { | ||
volumeName := tools.RandomString("ACPTTEST", 16) | ||
volumeDescription := tools.RandomString("ACPTTEST-DESC", 16) | ||
t.Logf("Attempting to create volume: %s", volumeName) | ||
|
||
createOpts := volumes.CreateOpts{ | ||
Size: 1, | ||
Name: volumeName, | ||
Description: volumeDescription, | ||
VolumeType: vt.Name, | ||
} | ||
|
||
volume, err := volumes.Create(client, createOpts) | ||
if err != nil { | ||
return volume, err | ||
} | ||
|
||
err = volumes.WaitForStatus(client, volume.ID, "available", 60) | ||
if err != nil { | ||
return volume, err | ||
} | ||
|
||
tools.PrintResource(t, volume) | ||
th.AssertEquals(t, volume.Name, volumeName) | ||
th.AssertEquals(t, volume.Description, volumeDescription) | ||
th.AssertEquals(t, volume.Size, 1) | ||
th.AssertEquals(t, volume.VolumeType, vt.Name) | ||
|
||
t.Logf("Successfully created volume: %s", volume.ID) | ||
|
||
return volume, nil | ||
} | ||
|
||
// DeleteSnapshot will delete a snapshot. A fatal error will occur if the | ||
// snapshot failed to be deleted. | ||
func DeleteSnapshot(t *testing.T, client *golangsdk.ServiceClient, snapshot *snapshots.Snapshot) { | ||
err := snapshots.Delete(client, snapshot.ID) | ||
if err != nil { | ||
t.Fatalf("Unable to delete snapshot %s: %+v", snapshot.ID, err) | ||
} | ||
|
||
// Volumes can't be deleted until their snapshots have been, | ||
// so block until the snapshot as been deleted. | ||
err = tools.WaitFor(func() (bool, error) { | ||
_, err := snapshots.Get(client, snapshot.ID) | ||
if err != nil { | ||
return true, nil | ||
} | ||
|
||
return false, nil | ||
}) | ||
if err != nil { | ||
t.Fatalf("Error waiting for snapshot to delete: %v", err) | ||
} | ||
|
||
t.Logf("Deleted snapshot: %s", snapshot.ID) | ||
} | ||
|
||
// DeleteVolume will delete a volume. A fatal error will occur if the volume | ||
// failed to be deleted. This works best when used as a deferred function. | ||
func DeleteVolume(t *testing.T, client *golangsdk.ServiceClient, volume *volumes.Volume) { | ||
t.Logf("Attempting to delete volume: %s", volume.ID) | ||
|
||
err := volumes.Delete(client, volumes.DeleteOpts{ | ||
VolumeId: volume.ID, | ||
}) | ||
if err != nil { | ||
t.Fatalf("Unable to delete volume %s: %v", volume.ID, err) | ||
} | ||
|
||
// VolumeTypes can't be deleted until their volumes have been, | ||
// so block until the volume is deleted. | ||
err = tools.WaitFor(func() (bool, error) { | ||
_, err := volumes.Get(client, volume.ID) | ||
if err != nil { | ||
return true, nil | ||
} | ||
|
||
return false, nil | ||
}) | ||
if err != nil { | ||
t.Fatalf("Error waiting for volume to delete: %v", err) | ||
} | ||
|
||
t.Logf("Successfully deleted volume: %s", volume.ID) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this request fails by timeout
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cannot make request images.ListDetail: server no response.
hard to fix, still trying.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cannot fix now, do it in another PR.
because API discarded and not working.