]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: mirror site name and bootstrap service methods
authorJason Dillaman <dillaman@redhat.com>
Tue, 22 Oct 2019 17:57:58 +0000 (13:57 -0400)
committerJason Dillaman <dillaman@redhat.com>
Thu, 5 Dec 2019 14:32:42 +0000 (09:32 -0500)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd-mirroring.service.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd-mirroring.service.ts

index cc4b7d31c65e3bbc797262486d664123c6da0560..03f6b9d6557d3292cf730d8d26a8ba068e548e80 100644 (file)
@@ -89,6 +89,39 @@ describe('RbdMirroringService', () => {
     expect(req.request.body).toEqual(request);
   });
 
+  it('should get site name', () => {
+    service.getSiteName().subscribe();
+
+    const req = httpTesting.expectOne('api/block/mirroring/site_name');
+    expect(req.request.method).toBe('GET');
+  });
+
+  it('should set site name', () => {
+    service.setSiteName('site-a').subscribe();
+
+    const req = httpTesting.expectOne('api/block/mirroring/site_name');
+    expect(req.request.method).toBe('PUT');
+    expect(req.request.body).toEqual({ site_name: 'site-a' });
+  });
+
+  it('should create bootstrap token', () => {
+    service.createBootstrapToken('poolName').subscribe();
+
+    const req = httpTesting.expectOne('api/block/mirroring/pool/poolName/bootstrap/token');
+    expect(req.request.method).toBe('POST');
+  });
+
+  it('should import bootstrap token', () => {
+    service.importBootstrapToken('poolName', 'rx', 'token-1234').subscribe();
+
+    const req = httpTesting.expectOne('api/block/mirroring/pool/poolName/bootstrap/peer');
+    expect(req.request.method).toBe('POST');
+    expect(req.request.body).toEqual({
+      direction: 'rx',
+      token: 'token-1234'
+    });
+  });
+
   it('should get peer config', () => {
     service.getPeer('poolName', 'peerUUID').subscribe();
 
index 2f3626c2259fcdb34250c7a0a229db4656126f41..0dd04e9798e990ddafc2f5e51318b8b4fb3f7246 100644 (file)
@@ -3,8 +3,10 @@ import { Injectable, NgZone } from '@angular/core';
 
 import { BehaviorSubject, Subscription } from 'rxjs';
 
+import { cdEncode, cdEncodeNot } from '../decorators/cd-encode';
 import { ApiModule } from './api.module';
 
+@cdEncode
 @Injectable({
   providedIn: ApiModule
 })
@@ -60,6 +62,32 @@ export class RbdMirroringService {
     return this.http.put(`api/block/mirroring/pool/${poolName}`, request, { observe: 'response' });
   }
 
+  getSiteName() {
+    return this.http.get(`api/block/mirroring/site_name`);
+  }
+
+  setSiteName(@cdEncodeNot siteName) {
+    return this.http.put(
+      `api/block/mirroring/site_name`,
+      { site_name: siteName },
+      { observe: 'response' }
+    );
+  }
+
+  createBootstrapToken(poolName) {
+    return this.http.post(`api/block/mirroring/pool/${poolName}/bootstrap/token`, {});
+  }
+
+  importBootstrapToken(poolName, @cdEncodeNot direction, @cdEncodeNot token) {
+    const request = {
+      direction: direction,
+      token: token
+    };
+    return this.http.post(`api/block/mirroring/pool/${poolName}/bootstrap/peer`, request, {
+      observe: 'response'
+    });
+  }
+
   getPeer(poolName, peerUUID) {
     return this.http.get(`api/block/mirroring/pool/${poolName}/peer/${peerUUID}`);
   }