Update the controllerfs API to support fs creation/deletion
This commit adds support for creating and deleting a controller
filesystem. At the moment, only the creation of the controller
fs 'ceph-float' is allowed, used to establish ceph-specific
storage on controllers for Rook Ceph support.
The states below were introduced:
- 'drbd_fs_creating_in_progress': Status when creation is in
progress. The standby controller must be locked when using
the fs command.
- 'drbd_fs_creating_on_unlock': Status when using the create fs
command after bootstrap and before the first unlock of
controller-0.
- 'drbd_fs_deleting_in_progress': Status when deletion is in
progress. The standby controller must be locked when using
the fs command.
- 'drbd_fs_update_error': Status that indicates that there was a
failure in creation/deletion, with the possibility of retry
to be successful.
* A new alarm was added to FM for controller-fs: 800.105.
Test Plan:
PASS: AIO-SX / AIO-DX / Standard -> fresh install with Ceph Bare
Metal using designer build with topic changes + Check that
there is no interference or errors.
PASS: AIO-DX -> Standby controller locked and ceph-rook as
storage-backend + controller-fs add ceph-float=<size> +
checking if everything is created correctly: lv, drbd and
SM services.
PASS: AIO-DX -> After bootstrap, add ceph-rook as storage backend
+ use controller-fs add ceph=<size> + check if controller_fs
went to creation state on unlock + continue installation and
check if after unlock controller-1 if everything is created
correctly.
PASS: AIO-DX -> with the ceph filesystem created, modify (resize)
the new filesystem and some of the default ones, checking
that is working properly.
PASS: AIO-DX -> Lock/unlock + swact tests.
PASS: AIO-DX -> Standby controller locked + controllerfs-delete
ceph + checking if everything is deleted correctly: lv, drbd
and SM services.
PASS: Force operation to go to the state "drbd_fs_update_error" +
Check if the alarm 800.105 is raised + retry the command that
failed + Verify that the execution was successful and the
alarm was cleared.
Depends-On: https://review.opendev.org/c/starlingx/stx-puppet/+/919078
Story: 2011117
Task: 50073
Change-Id: I57dd9669ad8cddea81ec0692cd11435dae27dce4
Co-Authored-By: Robert Church <robert.church@windriver.com>
Signed-off-by: Gabriel de Araújo Cabral <gabriel.cabral@windriver.com>
This commit is contained in:
committed by
Gabriel de Araújo Cabral
parent
3fb62edce5
commit
9cc41b9f20
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2020 Wind River Systems, Inc.
|
||||
# Copyright (c) 2020,2024 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
@@ -24,6 +24,13 @@ NEW_SIZE = 20
|
||||
UPDATED_CONTROLLER_FS['size'] = NEW_SIZE
|
||||
SYSTEM_UUID = "11111111-2222-3333-4444-5555-000000000000"
|
||||
|
||||
CREATED_CONTROLLER_FS = {
|
||||
'name': 'cfs2',
|
||||
'size': 10,
|
||||
}
|
||||
|
||||
DELETED_CONTROLLER_FS = copy.deepcopy(CONTROLLER_FS)
|
||||
|
||||
fixtures = {
|
||||
'/v1/controller_fs':
|
||||
{
|
||||
@@ -31,6 +38,10 @@ fixtures = {
|
||||
{},
|
||||
{"controller_fs": [CONTROLLER_FS]},
|
||||
),
|
||||
'POST': (
|
||||
{},
|
||||
CREATED_CONTROLLER_FS,
|
||||
),
|
||||
},
|
||||
'/v1/controller_fs/%s' % CONTROLLER_FS['uuid']:
|
||||
{
|
||||
@@ -42,6 +53,10 @@ fixtures = {
|
||||
{},
|
||||
UPDATED_CONTROLLER_FS,
|
||||
),
|
||||
'DELETE': (
|
||||
{},
|
||||
None,
|
||||
),
|
||||
},
|
||||
'/v1/isystems/%s/controller_fs/update_many' % SYSTEM_UUID:
|
||||
{
|
||||
@@ -121,3 +136,18 @@ class ControllerFsManagerTest(testtools.TestCase):
|
||||
# Since update_many is just a PUT, we don't expect any output from it, so we can't
|
||||
# do a proper asert here. We just check if the request made is the one we expected.
|
||||
self.assertEqual(self.api.calls, expect)
|
||||
|
||||
def test_controller_fs_create(self):
|
||||
self.mgr.create(**CREATED_CONTROLLER_FS)
|
||||
expect = [
|
||||
('POST', '/v1/controller_fs', {}, CREATED_CONTROLLER_FS),
|
||||
]
|
||||
self.assertEqual(self.api.calls, expect)
|
||||
|
||||
def test_controller_fs_delete(self):
|
||||
controller_fs = self.mgr.delete(CONTROLLER_FS['uuid'])
|
||||
expect = [
|
||||
('DELETE', '/v1/controller_fs/%s' % CONTROLLER_FS['uuid'], {}, None),
|
||||
]
|
||||
self.assertEqual(self.api.calls, expect)
|
||||
self.assertTrue(controller_fs is None)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2013-2020 Wind River Systems, Inc.
|
||||
# Copyright (c) 2013-2020,2024 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
@@ -12,14 +12,25 @@ from cgtsclient.common import utils
|
||||
from cgtsclient import exc
|
||||
|
||||
|
||||
def _find_fs(cc, name):
|
||||
fs_list = cc.controller_fs.list()
|
||||
for fs in fs_list:
|
||||
if fs.name == name:
|
||||
break
|
||||
def _find_fs(cc, name_or_uuid):
|
||||
if name_or_uuid.isdigit():
|
||||
try:
|
||||
fs = cc.controller_fs.get(name_or_uuid)
|
||||
except exc.HTTPNotFound:
|
||||
raise exc.CommandError('Filesystem not found by uuid: %s'
|
||||
% name_or_uuid)
|
||||
else:
|
||||
return fs
|
||||
else:
|
||||
raise exc.CommandError('Filesystem "%s" not found' % name)
|
||||
return fs
|
||||
fs_list = cc.controller_fs.list()
|
||||
for fs in fs_list:
|
||||
if fs.name == name_or_uuid:
|
||||
return fs
|
||||
if fs.uuid == name_or_uuid:
|
||||
return fs
|
||||
else:
|
||||
raise exc.CommandError('Filesystem not found by name or '
|
||||
'uuid: %s' % name_or_uuid)
|
||||
|
||||
|
||||
def _print_controller_fs_show(controller_fs):
|
||||
@@ -69,13 +80,13 @@ def do_controllerfs_modify(cc, args):
|
||||
_print_controllerfs_list(cc, args)
|
||||
|
||||
|
||||
@utils.arg('name',
|
||||
metavar='<name>',
|
||||
help='Name of the filesystem [REQUIRED]')
|
||||
@utils.arg('fsnameoruuid',
|
||||
metavar='<fs name or uuid>',
|
||||
help="Name or UUID of filesystem [REQUIRED]")
|
||||
def do_controllerfs_show(cc, args):
|
||||
"""Show details of a controller filesystem"""
|
||||
|
||||
controller_fs = _find_fs(cc, args.name)
|
||||
controller_fs = _find_fs(cc, args.fsnameoruuid)
|
||||
_print_controller_fs_show(controller_fs)
|
||||
|
||||
|
||||
@@ -104,3 +115,47 @@ def _print_controllerfs_list(cc, args):
|
||||
def do_controllerfs_list(cc, args):
|
||||
"""Show list of controller filesystems"""
|
||||
_print_controllerfs_list(cc, args)
|
||||
|
||||
|
||||
@utils.arg('fsnameoruuid',
|
||||
metavar='<fs name or uuid>',
|
||||
help="Name or UUID of filesystem [REQUIRED]")
|
||||
def do_controllerfs_delete(cc, args):
|
||||
"""Delete a controller filesystem."""
|
||||
|
||||
controller_fs = _find_fs(cc, args.fsnameoruuid)
|
||||
|
||||
try:
|
||||
cc.controller_fs.delete(controller_fs.uuid)
|
||||
except exc.HTTPNotFound:
|
||||
raise exc.CommandError('Filesystem delete failed: '
|
||||
'name %s' % (args.name))
|
||||
setattr(args, 'column', None)
|
||||
setattr(args, 'format', None)
|
||||
_print_controllerfs_list(cc, args)
|
||||
|
||||
|
||||
@utils.arg('name',
|
||||
metavar='<fs name=size>',
|
||||
nargs=1,
|
||||
action='append',
|
||||
help="Name of the Filesystem [REQUIRED]")
|
||||
def do_controllerfs_add(cc, args):
|
||||
"""Add a controller filesystem"""
|
||||
fields = {}
|
||||
for attr in args.name[0]:
|
||||
try:
|
||||
fs_name, size = attr.split("=", 1)
|
||||
|
||||
fields['name'] = fs_name
|
||||
fields['size'] = size
|
||||
except ValueError:
|
||||
raise exc.CommandError('Filesystem creation attributes must be '
|
||||
'FS_NAME=SIZE not "%s"' % attr)
|
||||
try:
|
||||
fs = cc.controller_fs.create(**fields)
|
||||
except exc.HTTPNotFound:
|
||||
raise exc.CommandError('Failed to create filesystem: fields %s' %
|
||||
(fields))
|
||||
|
||||
_print_controller_fs_show(fs)
|
||||
|
||||
Reference in New Issue
Block a user