cloud-certification-team team mailing list archive
-
cloud-certification-team team
-
Mailing list archive
-
Message #00009
[Merge] lp:~jeffmarcom/cloud-testing/storage_delete_volume_tests into lp:cloud-testing/cloudbox
Jeff Marcom has proposed merging lp:~jeffmarcom/cloud-testing/storage_delete_volume_tests into lp:cloud-testing/cloudbox.
Requested reviews:
Cloud Certification (cloud-certification-team)
For more details, see:
https://code.launchpad.net/~jeffmarcom/cloud-testing/storage_delete_volume_tests/+merge/175337
This mr adds several volume service delete tasks.
Output from deletion attempt:
jeff@skywalker:~/cloud_development/cloudbox$ ./scripts/storage_cli_test --service cinder volume --delete --name test
Attempting to delete storage volume: test
+--------------------------------------+----------+--------------+------+-------------+----------+-------------+
| ID | Status | Display Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+----------+--------------+------+-------------+----------+-------------+
| c98986a1-27ca-4d43-a779-d021d92008a9 | deleting | test | 1 | None | | |
+--------------------------------------+----------+--------------+------+-------------+----------+-------------+
test volume status: deleting
jeff@skywalker:~/cloud_development/cloudbox$ echo $?
0
--
https://code.launchpad.net/~jeffmarcom/cloud-testing/storage_delete_volume_tests/+merge/175337
Your team Cloud Certification is requested to review the proposed merge of lp:~jeffmarcom/cloud-testing/storage_delete_volume_tests into lp:cloud-testing/cloudbox.
=== modified file 'cloudbox/openstack/api.py'
--- cloudbox/openstack/api.py 2013-07-15 15:48:08 +0000
+++ cloudbox/openstack/api.py 2013-07-17 16:54:27 +0000
@@ -43,6 +43,7 @@
"list_tenants": ["tenants", "GET"]},
"Volume": {
"create": ["volumes", "POST"],
+ "delete": ["volumes", "DELETE"],
"list_volumes": ["volumes", "GET"]},
"Compute": {
"create_server": ["servers", "POST"],
=== modified file 'cloudbox/openstack/component/storage.py'
--- cloudbox/openstack/component/storage.py 2013-06-18 16:00:46 +0000
+++ cloudbox/openstack/component/storage.py 2013-07-17 16:54:27 +0000
@@ -64,6 +64,13 @@
def list_volumes(cls, service_name="cinder"):
return openstack_cli(service_name).execute("list")
+ @classmethod
+ def delete(cls, name, service_name="cinder"):
+ command = "delete"
+ if service_name == "nova":
+ command = "volume-delete"
+ return openstack_cli(service_name).execute(" ".join((command, name)))
+
class BlockStorageAPI(StorageBase):
@@ -92,3 +99,23 @@
params = json.dumps(meta_data)
volume_data = openstack_api("storage").request("create", params)
return volume_data
+
+ @classmethod
+ def delete(cls, name):
+ volumes = cls.list_volumes()["volumes"]
+ id = ""
+ for volume in volumes:
+ try:
+ if volume["display_name"] == name:
+ id = volume["id"]
+ except (KeyError, IndexError):
+ logging.error("Failed parsing volume names")
+ return 1
+
+ if id == "":
+ logging.error("Failed finding volume name: {}".format(name))
+ return
+
+ api_obj = openstack_api("storage")
+ api_obj.page_tac = "/" + id
+ return api_obj.request("delete")
=== added file 'extras/whitelists/folsom_cleanup_compute.whitelist'
--- extras/whitelists/folsom_cleanup_compute.whitelist 1970-01-01 00:00:00 +0000
+++ extras/whitelists/folsom_cleanup_compute.whitelist 2013-07-17 16:54:27 +0000
@@ -0,0 +1,16 @@
+environment
+module
+package
+uname
+lsb
+dpkg
+__info__
+lspci_attachment
+modprobe_attachment
+modules_attachment
+__networking__
+networking/detect
+__folsom_remote__
+openstack/service_info
+__folsom_local_nova__
+nova/delete_flavors/local
=== added file 'extras/whitelists/folsom_cleanup_image.whitelist'
--- extras/whitelists/folsom_cleanup_image.whitelist 1970-01-01 00:00:00 +0000
+++ extras/whitelists/folsom_cleanup_image.whitelist 2013-07-17 16:54:27 +0000
@@ -0,0 +1,16 @@
+environment
+module
+package
+uname
+lsb
+dpkg
+__info__
+lspci_attachment
+modprobe_attachment
+modules_attachment
+__networking__
+networking/detect
+__folsom_remote__
+openstack/service_info
+__folsom_local_glance__
+glance/remove_image/local
=== removed file 'extras/whitelists/folsom_cleanup_local.whitelist'
--- extras/whitelists/folsom_cleanup_local.whitelist 2013-07-15 20:31:49 +0000
+++ extras/whitelists/folsom_cleanup_local.whitelist 1970-01-01 00:00:00 +0000
@@ -1,18 +0,0 @@
-environment
-module
-package
-uname
-lsb
-dpkg
-__info__
-lspci_attachment
-modprobe_attachment
-modules_attachment
-__networking__
-networking/detect
-__folsom_remote__
-openstack/service_info
-__folsom_local_glance__
-glance/remove_image/local
-__folsom_local_nova__
-nova/delete_flavors/local
=== added file 'extras/whitelists/folsom_cleanup_storage.whitelist'
--- extras/whitelists/folsom_cleanup_storage.whitelist 1970-01-01 00:00:00 +0000
+++ extras/whitelists/folsom_cleanup_storage.whitelist 2013-07-17 16:54:27 +0000
@@ -0,0 +1,17 @@
+environment
+module
+package
+uname
+lsb
+dpkg
+__info__
+lspci_attachment
+modprobe_attachment
+modules_attachment
+__networking__
+networking/detect
+__folsom_remote__
+openstack/service_info
+__folsom_local_volume__
+volume/delete_block_storage/local
+cinder/delete_block_storage/local
=== modified file 'jobs/folsom_local_volume.txt.in'
--- jobs/folsom_local_volume.txt.in 2013-06-18 18:49:37 +0000
+++ jobs/folsom_local_volume.txt.in 2013-07-17 16:54:27 +0000
@@ -1,14 +1,27 @@
plugin: shell
name: volume/create_block_storage/local
-command: storage_cli_test --service=nova create-volume
+command: storage_cli_test --service=nova volume --create
depends: openstack/check_service/nova-volume
_description:
Creates a block storage volume using nova-volume cli
plugin: shell
name: cinder/create_block_storage/local
-command: storage_cli_test --service=cinder create-volume
+command: storage_cli_test --service=cinder volume --create
depends: openstack/check_service/cinder
_description:
Creates a block storage volume using cinder cli
+plugin: shell
+name: volume/delete_block_storage/local
+command: storage_cli_test --service=nova volume --delete
+depends: openstack/check_service/nova-volume
+_description:
+ Deletes a block storage volume using nova-volume cli
+
+plugin: shell
+name: cinder/delete_block_storage/local
+command: storage_cli_test --service=cinder volume --delete
+depends: openstack/check_service/cinder
+_description:
+ Deletes a block storage volume using cinder cli
=== modified file 'jobs/folsom_remote.txt.in'
--- jobs/folsom_remote.txt.in 2013-07-15 20:31:49 +0000
+++ jobs/folsom_remote.txt.in 2013-07-17 16:54:27 +0000
@@ -126,18 +126,32 @@
plugin: shell
name: volume/create_block_storage/remote
-command: storage_api_test create-volume
+command: storage_api_test volume --create
depends: openstack/check_service/nova-volume
_description:
Creates a single block storage volume in the deployed openstack environment via volume api
plugin: shell
name: cinder/create_block_storage/remote
-command: storage_api_test create-volume
-depends: openstack/check_service/cinder
-_description:
- Creates a single block storage volume in the deployed openstack environment via volume api
-
+command: storage_api_test volume --create
+depends: openstack/check_service/cinder
+_description:
+ Creates a single block storage volume in the deployed openstack environment via cinder api
+
+plugin: shell
+name: volume/delete_block_storage/remote
+command: storage_api_test volume --delete
+depends: openstack/check_service/nova-volume
+_description:
+ Removes a single block storage volume in the deployed openstack environment via volume api
+
+plugin: shell
+name: cinder/delete_block_storage/remote
+command: storage_api_test volume --delete
+depends: openstack/check_service/cinder
+_description:
+ Removes a single block storage volume in the deployed openstack environment via cinder api
+
plugin: shell
name: nova/compute_benchmark/remote
command: nova_api_test compute-benchmark --start
=== modified file 'scripts/storage_api_test'
--- scripts/storage_api_test 2013-06-18 18:49:37 +0000
+++ scripts/storage_api_test 2013-07-17 16:54:27 +0000
@@ -45,6 +45,9 @@
volume_type = openstack_config.Volume["volume_type"]
availability_zone = openstack_config.Volume["availability_zone"]
+ if args.name != "":
+ display_name = args.name
+
test = BlockStorageAPI(
size=size,
snapshot_id=snapshot_id,
@@ -55,25 +58,51 @@
availability_zone=availability_zone)
exit_code = 5
- volume_info = test.create()
- logging.debug(volume_info)
- id = volume_info["volume"]["id"]
- for i in range(0, VOLUME_POLLING_REPEAT):
- time.sleep(VOLUME_POLLING_INTERVAL)
- print(test.list_volumes())
- # Get status of volume creation
- status = test.volume_detail(id)["volume"]["status"]
- # Check for errors
- if status == "available":
- exit_code = 0
- print("Volume created successfully")
- sys.exit(exit_code)
- elif status == "error":
- print("Failed creating volume")
- sys.exit(exit_code)
-
- print("Timeout exceeded...")
- print("Volume status: %s" % status)
+
+ if args.create:
+ volume_info = test.create()
+ logging.debug(volume_info)
+ id = volume_info["volume"]["id"]
+ for i in range(0, VOLUME_POLLING_REPEAT):
+ time.sleep(VOLUME_POLLING_INTERVAL)
+ print(test.list_volumes())
+ # Get status of volume creation
+ status = test.volume_detail(id)["volume"]["status"]
+ # Check for errors
+ if status == "available":
+ exit_code = 0
+ print("Volume created successfully")
+ sys.exit(exit_code)
+ elif status == "error":
+ print("Failed creating volume")
+ sys.exit(exit_code)
+
+ print("Timeout exceeded...")
+ print("Volume status: %s" % status)
+
+ if args.delete:
+ print("Attempting to remove volume: ", display_name)
+ print(test.delete(display_name))
+ for i in range(0, VOLUME_POLLING_REPEAT):
+ volumes = test.list_volumes()
+ status = "not available"
+ if type(volumes) == dict:
+ for entry in volumes["volumes"]:
+ print(entry)
+ try:
+ if entry["display_name"] == display_name:
+ status = entry["status"]
+ break
+ except KeyError:
+ continue
+
+ print(display_name, " status: ", status)
+ if status == "not available":
+ exit_code = 0
+ break
+ time.sleep(VOLUME_POLLING_INTERVAL * 5)
+
+
sys.exit(exit_code)
@@ -82,9 +111,13 @@
subparsers = cli_parser.add_subparsers()
volume_test_parser = subparsers.add_parser(
- 'create-volume', help=("create storage volume"))
+ 'volume', help=("Storage volume test"))
+ volume_test_parser.add_argument('--create', action="store_true")
+ volume_test_parser.add_argument('--delete', action="store_true")
volume_test_parser.add_argument('--debug', action="store_true")
+ volume_test_parser.add_argument(
+ '--name', type=str, default="", action="store")
volume_test_parser.set_defaults(func=volume_test)
=== modified file 'scripts/storage_cli_test'
--- scripts/storage_cli_test 2013-06-18 18:49:37 +0000
+++ scripts/storage_cli_test 2013-07-17 16:54:27 +0000
@@ -37,30 +37,6 @@
VOLUME_POLLING_REPEAT = 5
-def check_storage_status(type):
-
- if type == "volume":
- status = "failed"
- for i in range(0, VOLUME_POLLING_REPEAT):
- time.sleep(VOLUME_POLLING_INTERVAL)
-
- # Get status of volume creation
- volumes = json.loads(openstack_cli.format_to_json(
- BlockStorageCLI.list_volumes()))
- status = volumes[str(len(volumes.keys()) - 1)]["Status"]
- # Check for errors
- if status == "available":
- print("Volume created successfully")
- return
- elif status == "error":
- print("Failed creating volume")
- return 1
-
- print("Timeout exceeded...")
- print("Volume status: %s" % status)
- return 1
-
-
def volume_test(args):
size = openstack_config.Volume["size"]
snapshot_id = openstack_config.Volume["snapshot_id"]
@@ -70,6 +46,9 @@
volume_type = openstack_config.Volume["volume_type"]
availability_zone = openstack_config.Volume["availability_zone"]
+ if args.name != "":
+ display_name = args.name
+
test = BlockStorageCLI(
size=size,
snapshot_id=snapshot_id,
@@ -80,9 +59,64 @@
availability_zone=availability_zone)
exit_code = 5
- returncode, output = test.create(args.service)
- if returncode == 0:
- exit_code = check_storage_status("volume")
+ if args.create:
+ print("Attempting to create storage volume: ", display_name)
+ returncode, output = test.create(args.service)
+ if returncode == 0:
+ status = "failed"
+ for i in range(0, VOLUME_POLLING_REPEAT):
+ time.sleep(VOLUME_POLLING_INTERVAL)
+
+ # Get status of volume creation
+ volumes = json.loads(openstack_cli.format_to_json(
+ BlockStorageCLI.list_volumes()))
+ status = volumes[str(len(volumes.keys()) - 1)]["Status"]
+
+ # Check for errors
+ if status == "available":
+ print("Volume created successfully")
+ sys.exit(5)
+ elif status == "error":
+ print("Failed creating volume")
+ sys.exit(3)
+ else:
+ sys.exit(7)
+
+ if args.delete:
+ print("Attempting to delete storage volume: ", display_name)
+ returncode, output = test.delete(display_name, args.service)
+ if returncode == 0:
+ status = "not available"
+ for i in range(0, VOLUME_POLLING_REPEAT):
+ volumes = json.loads(openstack_cli.format_to_json(
+ BlockStorageCLI.list_volumes()))
+
+ # Grab latest created volume in pool
+ try:
+ latest_volume = volumes[str(len(volumes.keys()) - 1)]
+ except KeyError:
+ # Zero volumes found we'll simply exit with success
+ sys.exit()
+
+ # Check current status of volume deletion
+ if display_name in latest_volume.values():
+ try:
+ status = latest_volume["Status"]
+ except (KeyError, TypeError):
+ print("Failed parsing volume data")
+ sys.exit(9)
+ else:
+ print("Volume succesfully deleted")
+ sys.exit()
+
+ print(display_name, "volume status: ", status)
+ time.sleep(VOLUME_POLLING_INTERVAL * 5)
+ else:
+ sys.exit()
+
+ print("Timeout exceeded...")
+ print("Volume status: %s" % status)
+
sys.exit(exit_code)
@@ -91,11 +125,15 @@
subparsers = cli_parser.add_subparsers()
volume_test_parser = subparsers.add_parser(
- 'create-volume', help=("create storage volume"))
+ 'volume', help=("storage volume test"))
cli_parser.add_argument(
'--service', type=str, default="cinder",
help=("Specify openstack service to perform action"))
+ volume_test_parser.add_argument('--create', action="store_true")
+ volume_test_parser.add_argument('--delete', action="store_true")
+ volume_test_parser.add_argument(
+ '--name', type=str, default="", action="store")
volume_test_parser.add_argument('--debug', action="store_true")
volume_test_parser.set_defaults(func=volume_test)
Follow ups