]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.ts
import ceph quincy 17.2.6
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / block / rbd-form / rbd-form.component.ts
index 4fa71646215fafe9f6603309d04818892c97651b..b9e3add709cf8f3bf35db988e5b88b03ce5a365c 100644 (file)
@@ -67,6 +67,7 @@ export class RbdFormComponent extends CdForm implements OnInit {
   }>(1);
 
   pool: string;
+  peerConfigured = false;
 
   advancedEnabled = false;
 
@@ -193,11 +194,11 @@ export class RbdFormComponent extends CdForm implements OnInit {
             return acc;
           }, {})
         ),
-        mirroring: new FormControl(false),
+        mirroring: new FormControl(''),
         schedule: new FormControl('', {
           validators: [Validators.pattern(/^([0-9]+)d|([0-9]+)h|([0-9]+)m$/)] // check schedule interval to be in format - 1d or 1h or 1m
         }),
-        mirroringMode: new FormControl(this.mirroringOptions[0]),
+        mirroringMode: new FormControl(''),
         stripingUnit: new FormControl(this.defaultStripingUnit),
         stripingCount: new FormControl(this.defaultStripingCount, {
           updateOn: 'blur'
@@ -257,6 +258,16 @@ export class RbdFormComponent extends CdForm implements OnInit {
   setMirrorMode() {
     this.mirroring = !this.mirroring;
     this.setExclusiveLock();
+    this.checkPeersConfigured();
+  }
+
+  checkPeersConfigured(poolname?: string) {
+    const poolName = poolname ? poolname : this.rbdForm.get('pool').value;
+    this.rbdMirroringService.getPeerForPool(poolName).subscribe((resp: any) => {
+      if (resp.length > 0) {
+        this.peerConfigured = true;
+      }
+    });
   }
 
   setPoolMirrorMode() {
@@ -274,10 +285,6 @@ export class RbdFormComponent extends CdForm implements OnInit {
           this.mirroring = false;
           this.rbdForm.get('mirroring').setValue(this.mirroring);
           this.rbdForm.get('mirroring').disable();
-        } else if (this.mode !== this.rbdFormMode.editing) {
-          this.rbdForm.get('mirroring').enable();
-          this.mirroring = true;
-          this.rbdForm.get('mirroring').setValue(this.mirroring);
         }
       });
     }
@@ -319,6 +326,7 @@ export class RbdFormComponent extends CdForm implements OnInit {
           this.snapName = decodeURIComponent(params.snap);
         }
         promises['rbd'] = this.rbdService.get(imageSpec);
+        this.checkPeersConfigured(imageSpec.poolName);
       });
     } else {
       // New image
@@ -636,6 +644,7 @@ export class RbdFormComponent extends CdForm implements OnInit {
     request.name = this.rbdForm.getValue('name');
     request.schedule_interval = this.rbdForm.getValue('schedule');
     request.size = this.formatter.toBytes(this.rbdForm.getValue('size'));
+
     if (this.poolMirrorMode === 'image') {
       request.mirror_mode = this.rbdForm.getValue('mirroringMode');
     }
@@ -690,18 +699,17 @@ export class RbdFormComponent extends CdForm implements OnInit {
       }
     });
     request.enable_mirror = this.rbdForm.getValue('mirroring');
-    if (this.poolMirrorMode === 'image') {
-      if (request.enable_mirror) {
+    if (request.enable_mirror) {
+      if (this.rbdForm.getValue('mirroringMode') === 'journal') {
+        request.features.push('journaling');
+      }
+      if (this.poolMirrorMode === 'image') {
         request.mirror_mode = this.rbdForm.getValue('mirroringMode');
       }
     } else {
-      if (request.enable_mirror) {
-        request.features.push('journaling');
-      } else {
-        const index = request.features.indexOf('journaling', 0);
-        if (index > -1) {
-          request.features.splice(index, 1);
-        }
+      const index = request.features.indexOf('journaling', 0);
+      if (index > -1) {
+        request.features.splice(index, 1);
       }
     }
     request.configuration = this.getDirtyConfigurationValues();