]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: Add UI for disabling ACL authentication
authorTiago Melo <tmelo@suse.com>
Tue, 12 Feb 2019 14:08:33 +0000 (14:08 +0000)
committerTiago Melo <tmelo@suse.com>
Thu, 28 Feb 2019 09:42:21 +0000 (09:42 +0000)
Fixes: http://tracker.ceph.com/issues/38218
Signed-off-by: Tiago Melo <tmelo@suse.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-form/iscsi-target-form.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-form/iscsi-target-form.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-form/iscsi-target-form.component.ts
src/pybind/mgr/dashboard/frontend/src/locale/messages.xlf

index 6c3b33634067924425e3e03d06fc9a8542a07aa0..1b59f3d93220b699b23f55f4153c761ab44e931f 100644 (file)
           </div>
         </div>
 
-        <!-- Initiators -->
+        <!-- acl_enabled -->
         <div class="form-group">
+          <div class="col-sm-offset-3 col-sm-9">
+            <div class="checkbox checkbox-primary">
+              <input type="checkbox"
+                     formControlName="acl_enabled"
+                     name="acl_enabled"
+                     id="acl_enabled">
+              <label for="acl_enabled"
+                     i18n>ACL authentication</label>
+            </div>
+
+            <hr />
+          </div>
+        </div>
+
+        <!-- Initiators -->
+        <div class="form-group"
+             *ngIf="targetForm.getValue('acl_enabled')">
           <label class="control-label col-sm-3"
                  for="initiators"
                  i18n>Initiators</label>
 
         <!-- Groups -->
         <div class="form-group"
+             *ngIf="targetForm.getValue('acl_enabled')"
              [ngClass]="{'has-error': targetForm.showError('groups', formDir)}">
           <label class="control-label col-sm-3"
                  for="initiators"
index adc769758883d39edffc956fa888cc82b89562b1..5ee56d2b4f8e39e165aaa24ff3120e0217f12db9 100644 (file)
@@ -174,6 +174,7 @@ describe('IscsiTargetFormComponent', () => {
       disks: [],
       groups: [],
       initiators: [],
+      acl_enabled: false,
       portals: [],
       target_controls: {},
       target_iqn: component.targetForm.value.target_iqn
@@ -218,7 +219,7 @@ describe('IscsiTargetFormComponent', () => {
 
   describe('should test initiators', () => {
     beforeEach(() => {
-      component.targetForm.patchValue({ disks: ['rbd/disk_1'] });
+      component.targetForm.patchValue({ disks: ['rbd/disk_1'], acl_enabled: true });
       component.addGroup().patchValue({ name: 'group_1' });
       component.onImageSelection({ option: { name: 'rbd/disk_1', selected: true } });
 
@@ -317,7 +318,7 @@ describe('IscsiTargetFormComponent', () => {
 
   describe('should submit request', () => {
     beforeEach(() => {
-      component.targetForm.patchValue({ disks: ['rbd/disk_1'] });
+      component.targetForm.patchValue({ disks: ['rbd/disk_1'], acl_enabled: true });
       component.onImageSelection({ option: { name: 'rbd/disk_1', selected: true } });
       component.portals.setValue(['node1:192.168.100.201', 'node2:192.168.100.202']);
       component.addInitiator().patchValue({
@@ -358,7 +359,8 @@ describe('IscsiTargetFormComponent', () => {
           { host: 'node2', ip: '192.168.100.202' }
         ],
         target_controls: {},
-        target_iqn: component.target_iqn
+        target_iqn: component.target_iqn,
+        acl_enabled: true
       });
     });
 
@@ -389,6 +391,27 @@ describe('IscsiTargetFormComponent', () => {
           { host: 'node2', ip: '192.168.100.202' }
         ],
         target_controls: {},
+        target_iqn: component.targetForm.value.target_iqn,
+        acl_enabled: true
+      });
+    });
+
+    it('should call create with acl_enabled disabled', () => {
+      component.targetForm.patchValue({ acl_enabled: false });
+      component.submit();
+
+      const req = httpTesting.expectOne('api/iscsi/target');
+      expect(req.request.method).toBe('POST');
+      expect(req.request.body).toEqual({
+        clients: [],
+        disks: [{ backstore: 'backstore:1', controls: {}, image: 'disk_1', pool: 'rbd' }],
+        groups: [],
+        acl_enabled: false,
+        portals: [
+          { host: 'node1', ip: '192.168.100.201' },
+          { host: 'node2', ip: '192.168.100.202' }
+        ],
+        target_controls: {},
         target_iqn: component.targetForm.value.target_iqn
       });
     });
index a765d499d53bca21cfc73fed82c4821fb201d341..e16dddac8cdeeb909f145fe362975259bff98adb 100644 (file)
@@ -159,14 +159,16 @@ export class IscsiTargetFormComponent implements OnInit {
       }),
       disks: new FormControl([]),
       initiators: new FormArray([]),
-      groups: new FormArray([])
+      groups: new FormArray([]),
+      acl_enabled: new FormControl(false)
     });
   }
 
   resolveModel(res) {
     this.targetForm.patchValue({
       target_iqn: res.target_iqn,
-      target_controls: res.target_controls
+      target_controls: res.target_controls,
+      acl_enabled: res.acl_enabled
     });
 
     const portals = [];
@@ -509,6 +511,7 @@ export class IscsiTargetFormComponent implements OnInit {
     const request = {
       target_iqn: this.targetForm.getValue('target_iqn'),
       target_controls: this.targetForm.getValue('target_controls'),
+      acl_enabled: this.targetForm.getValue('acl_enabled'),
       portals: [],
       disks: [],
       clients: [],
@@ -537,47 +540,51 @@ export class IscsiTargetFormComponent implements OnInit {
     });
 
     // Clients
-    formValue.initiators.forEach((initiator) => {
-      if (!initiator.auth.user) {
-        initiator.auth.user = null;
-      }
-      if (!initiator.auth.password) {
-        initiator.auth.password = null;
-      }
-      if (!initiator.auth.mutual_user) {
-        initiator.auth.mutual_user = null;
-      }
-      if (!initiator.auth.mutual_password) {
-        initiator.auth.mutual_password = null;
-      }
-
-      const newLuns = [];
-      initiator.luns.forEach((lun) => {
-        const imageSplit = lun.split('/');
-        newLuns.push({
-          pool: imageSplit[0],
-          image: imageSplit[1]
+    if (request.acl_enabled) {
+      formValue.initiators.forEach((initiator) => {
+        if (!initiator.auth.user) {
+          initiator.auth.user = null;
+        }
+        if (!initiator.auth.password) {
+          initiator.auth.password = null;
+        }
+        if (!initiator.auth.mutual_user) {
+          initiator.auth.mutual_user = null;
+        }
+        if (!initiator.auth.mutual_password) {
+          initiator.auth.mutual_password = null;
+        }
+
+        const newLuns = [];
+        initiator.luns.forEach((lun) => {
+          const imageSplit = lun.split('/');
+          newLuns.push({
+            pool: imageSplit[0],
+            image: imageSplit[1]
+          });
         });
-      });
 
-      initiator.luns = newLuns;
-    });
-    request.clients = formValue.initiators;
+        initiator.luns = newLuns;
+      });
+      request.clients = formValue.initiators;
+    }
 
     // Groups
-    formValue.groups.forEach((group) => {
-      const newDisks = [];
-      group.disks.forEach((disk) => {
-        const imageSplit = disk.split('/');
-        newDisks.push({
-          pool: imageSplit[0],
-          image: imageSplit[1]
+    if (request.acl_enabled) {
+      formValue.groups.forEach((group) => {
+        const newDisks = [];
+        group.disks.forEach((disk) => {
+          const imageSplit = disk.split('/');
+          newDisks.push({
+            pool: imageSplit[0],
+            image: imageSplit[1]
+          });
         });
-      });
 
-      group.disks = newDisks;
-    });
-    request.groups = formValue.groups;
+        group.disks = newDisks;
+      });
+      request.groups = formValue.groups;
+    }
 
     let wrapTask;
     if (this.isEdit) {
index 06120545c4526da043222c550f9d9e0014ab9f42..f5bccffb58cee8be0112e990add975722e8bbf9d 100644 (file)
         </context-group>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">346</context>
+          <context context-type="linenumber">363</context>
         </context-group>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">484</context>
+          <context context-type="linenumber">502</context>
         </context-group>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi/iscsi.component.html</context>
         </context-group>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">549</context>
+          <context context-type="linenumber">567</context>
         </context-group>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/rbd-form/rbd-form.component.html</context>
         </context-group>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">214</context>
+          <context context-type="linenumber">231</context>
         </context-group>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">236</context>
+          <context context-type="linenumber">253</context>
         </context-group>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">271</context>
+          <context context-type="linenumber">288</context>
         </context-group>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">296</context>
+          <context context-type="linenumber">313</context>
         </context-group>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">331</context>
+          <context context-type="linenumber">348</context>
         </context-group>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-discovery-modal/iscsi-target-discovery-modal.component.html</context>
         </context-group>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">218</context>
+          <context context-type="linenumber">235</context>
         </context-group>
       </trans-unit><trans-unit id="47d1bfe4f5b3f292e1202dfe691195b10cb99500" datatype="html">
         <source>An IQN has the following notation &apos;iqn.$year-$month.$reversedAddress:$definedName&apos;</source>
         </context-group>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">376</context>
+          <context context-type="linenumber">393</context>
+        </context-group>
+        <context-group purpose="location">
+          <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
+          <context context-type="linenumber">529</context>
         </context-group>
+      </trans-unit><trans-unit id="66c5fb27f52e75b70ca4b670b9b15a2a51cf9543" datatype="html">
+        <source>ACL authentication</source>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">511</context>
+          <context context-type="linenumber">184</context>
         </context-group>
       </trans-unit><trans-unit id="f494bd31f095f6dcc656ce87ec2dcf07a2e9b30c" datatype="html">
         <source>Initiators</source>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">179</context>
+          <context context-type="linenumber">196</context>
         </context-group>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">442</context>
+          <context context-type="linenumber">460</context>
         </context-group>
       </trans-unit><trans-unit id="e98239d8a6be1100119ff4b5630c822b82786740" datatype="html">
         <source>Initiator</source>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">186</context>
+          <context context-type="linenumber">203</context>
         </context-group>
       </trans-unit><trans-unit id="f2c5059d8cda15d8d03e2cce30f2d139623d9a91" datatype="html">
         <source>Client IQN</source>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">199</context>
+          <context context-type="linenumber">216</context>
         </context-group>
       </trans-unit><trans-unit id="107d5aabce23d900f0a80e6ddc1c10e29aa0bed8" datatype="html">
         <source>Initiator IQN needs to be unique.</source>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">210</context>
+          <context context-type="linenumber">227</context>
         </context-group>
       </trans-unit><trans-unit id="e08a77594f3d89311cdf6da5090044270909c194" datatype="html">
         <source>User</source>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">228</context>
+          <context context-type="linenumber">245</context>
         </context-group>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-discovery-modal/iscsi-target-discovery-modal.component.html</context>
                         can only contain letters, &apos;.&apos;, &apos;@&apos;, &apos;-&apos;, &apos;_&apos; or &apos;:&apos;.</source>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">240</context>
+          <context context-type="linenumber">257</context>
         </context-group>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">300</context>
+          <context context-type="linenumber">317</context>
         </context-group>
       </trans-unit><trans-unit id="c32ef07f8803a223a83ed17024b38e8d82292407" datatype="html">
         <source>Password</source>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">250</context>
+          <context context-type="linenumber">267</context>
         </context-group>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-discovery-modal/iscsi-target-discovery-modal.component.html</context>
                         and can only contain letters, &apos;@&apos;, &apos;-&apos; or &apos;_&apos;.</source>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">275</context>
+          <context context-type="linenumber">292</context>
         </context-group>
       </trans-unit><trans-unit id="ff40391de7a1944ea95091e4045cc34c4979b736" datatype="html">
         <source>Mutual User</source>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">286</context>
+          <context context-type="linenumber">303</context>
         </context-group>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-discovery-modal/iscsi-target-discovery-modal.component.html</context>
         <source>Mutual Password</source>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">310</context>
+          <context context-type="linenumber">327</context>
         </context-group>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-discovery-modal/iscsi-target-discovery-modal.component.html</context>
                         can only contain letters, &apos;@&apos;, &apos;-&apos; or &apos;_&apos;.</source>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">335</context>
+          <context context-type="linenumber">352</context>
         </context-group>
       </trans-unit><trans-unit id="5d1878d5fc761cbe9614bfd87047a740c82a6951" datatype="html">
         <source>Initiator belongs to a group. Images will be configure in the group.</source>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">366</context>
+          <context context-type="linenumber">383</context>
         </context-group>
       </trans-unit><trans-unit id="c0de67b9d97fafbf200f9451e8388ee8128a56ac" datatype="html">
         <source>No items added.</source>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">389</context>
+          <context context-type="linenumber">406</context>
         </context-group>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">526</context>
+          <context context-type="linenumber">544</context>
         </context-group>
       </trans-unit><trans-unit id="d565e47726158e428ecdc952fc9233b9b7d7f049" datatype="html">
         <source>Add initiator</source>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">394</context>
+          <context context-type="linenumber">411</context>
         </context-group>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">470</context>
+          <context context-type="linenumber">488</context>
         </context-group>
       </trans-unit><trans-unit id="c22ba03540aa3217da059f45e7eab138b51a96e2" datatype="html">
         <source>Groups</source>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">408</context>
+          <context context-type="linenumber">426</context>
         </context-group>
       </trans-unit><trans-unit id="4c90059afafb7e160384d9f512797c95bb95c6dc" datatype="html">
         <source>Group</source>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">415</context>
+          <context context-type="linenumber">433</context>
         </context-group>
       </trans-unit><trans-unit id="cff1428d10d59d14e45edec3c735a27b5482db59" datatype="html">
         <source>Name</source>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">427</context>
+          <context context-type="linenumber">445</context>
         </context-group>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/rbd-form/rbd-form.component.html</context>
         <source>Add group</source>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">531</context>
+          <context context-type="linenumber">549</context>
         </context-group>
       </trans-unit><trans-unit id="71c77bb8cecdf11ec3eead24dd1ba506573fa9cd" datatype="html">
         <source>Submit</source>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-form/iscsi-target-form.component.html</context>
-          <context context-type="linenumber">544</context>
+          <context context-type="linenumber">562</context>
         </context-group>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/iscsi-target-discovery-modal/iscsi-target-discovery-modal.component.html</context>