From b3234b5b2748008f36bd78fa638083f1c27872c4 Mon Sep 17 00:00:00 2001 From: Tiago Melo Date: Thu, 14 Feb 2019 16:47:01 +0000 Subject: [PATCH] mgr/dashboard: Improve RBD form Remove pools with '/' in the name and add RBD name validation. Fixes: http://tracker.ceph.com/issues/38303 Signed-off-by: Tiago Melo --- .../block/rbd-form/rbd-form.component.html | 9 ++- .../ceph/block/rbd-form/rbd-form.component.ts | 20 +++--- .../frontend/src/locale/messages.xlf | 64 ++++++++++--------- 3 files changed, 52 insertions(+), 41 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.html index 5a0ef4ef0cd9d..63df157673ea0 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.html @@ -50,6 +50,10 @@ *ngIf="rbdForm.showError('name', formDir, 'required')"> This field is required. + + '/' and '@' are not allowed. + @@ -206,8 +210,7 @@
- Advanced... @@ -317,4 +320,4 @@
- + \ No newline at end of file diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.ts index 9abc9d73a78ee..3739d0eda62e7 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.ts @@ -163,7 +163,7 @@ export class RbdFormComponent implements OnInit { { parent: new FormControl(''), name: new FormControl('', { - validators: [Validators.required] + validators: [Validators.required, Validators.pattern(/^[^@/]+?$/)] }), pool: new FormControl(null, { validators: [Validators.required] @@ -243,14 +243,16 @@ export class RbdFormComponent implements OnInit { const dataPools = []; for (const pool of resp) { if (_.indexOf(pool.application_metadata, 'rbd') !== -1) { - if (pool.type === 'replicated') { - pools.push(pool); - dataPools.push(pool); - } else if ( - pool.type === 'erasure' && - pool.flags_names.indexOf('ec_overwrites') !== -1 - ) { - dataPools.push(pool); + if (!pool.pool_name.includes('/')) { + if (pool.type === 'replicated') { + pools.push(pool); + dataPools.push(pool); + } else if ( + pool.type === 'erasure' && + pool.flags_names.indexOf('ec_overwrites') !== -1 + ) { + dataPools.push(pool); + } } } } diff --git a/src/pybind/mgr/dashboard/frontend/src/locale/messages.xlf b/src/pybind/mgr/dashboard/frontend/src/locale/messages.xlf index ac024409677d1..dca9a30e71240 100644 --- a/src/pybind/mgr/dashboard/frontend/src/locale/messages.xlf +++ b/src/pybind/mgr/dashboard/frontend/src/locale/messages.xlf @@ -248,7 +248,7 @@ app/ceph/block/rbd-form/rbd-form.component.html - 315 + 318 app/ceph/cluster/configuration/configuration-form/configuration-form.component.html @@ -505,15 +505,15 @@ app/ceph/block/rbd-form/rbd-form.component.html - 93 + 97 app/ceph/block/rbd-form/rbd-form.component.html - 153 + 157 app/ceph/block/rbd-form/rbd-form.component.html - 177 + 181 app/ceph/cluster/osd/osd-recv-speed-modal/osd-recv-speed-modal.component.html @@ -1010,15 +1010,21 @@ app/ceph/block/rbd-form/rbd-form.component.html 22 + + '/' and '@' are not allowed. + + app/ceph/block/rbd-form/rbd-form.component.html + 55 + Loading... app/ceph/block/rbd-form/rbd-form.component.html - 81 + 85 app/ceph/block/rbd-form/rbd-form.component.html - 141 + 145 app/ceph/nfs/nfs-form/nfs-form.component.html @@ -1080,37 +1086,37 @@ -- No rbd pools available -- app/ceph/block/rbd-form/rbd-form.component.html - 84 + 88 -- Select a pool -- app/ceph/block/rbd-form/rbd-form.component.html - 87 + 91 Use a dedicated data pool app/ceph/block/rbd-form/rbd-form.component.html - 107 + 111 Data pool app/ceph/block/rbd-form/rbd-form.component.html - 118 + 122 Dedicated pool that stores the object-data of the RBD. app/ceph/block/rbd-form/rbd-form.component.html - 122 + 126 -- No data pools available -- app/ceph/block/rbd-form/rbd-form.component.html - 144 + 148 app/ceph/nfs/nfs-form/nfs-form.component.html @@ -1120,7 +1126,7 @@ Size app/ceph/block/rbd-form/rbd-form.component.html - 162 + 166 app/ceph/block/rbd-details/rbd-details.component.html @@ -1130,19 +1136,19 @@ e.g., 10GiB app/ceph/block/rbd-form/rbd-form.component.html - 172 + 176 You have to increase the size. app/ceph/block/rbd-form/rbd-form.component.html - 180 + 184 Features app/ceph/block/rbd-form/rbd-form.component.html - 190 + 194 app/ceph/block/rbd-details/rbd-details.component.html @@ -1152,25 +1158,25 @@ Advanced... app/ceph/block/rbd-form/rbd-form.component.html - 213 + 216 Advanced app/ceph/block/rbd-form/rbd-form.component.html - 219 + 222 Striping app/ceph/block/rbd-form/rbd-form.component.html - 222 + 225 Object size app/ceph/block/rbd-form/rbd-form.component.html - 229 + 232 app/ceph/block/rbd-details/rbd-details.component.html @@ -1180,55 +1186,55 @@ Stripe unit app/ceph/block/rbd-form/rbd-form.component.html - 246 + 249 -- Select stripe unit -- app/ceph/block/rbd-form/rbd-form.component.html - 257 + 260 This field is required because stripe count is defined! app/ceph/block/rbd-form/rbd-form.component.html - 263 + 266 Stripe unit is greater than object size. app/ceph/block/rbd-form/rbd-form.component.html - 266 + 269 Stripe count app/ceph/block/rbd-form/rbd-form.component.html - 275 + 278 This field is required because stripe unit is defined! app/ceph/block/rbd-form/rbd-form.component.html - 288 + 291 Stripe count must be greater than 0. app/ceph/block/rbd-form/rbd-form.component.html - 291 + 294 RBD app/ceph/block/rbd-form/rbd-form.component.html - 310 + 313 {VAR_SELECT, select, editing {Update} cloning {Clone} copying {Copy} other {Create} } app/ceph/block/rbd-form/rbd-form.component.html - 310 + 313 Trash -- 2.39.5