From: Jason Dillaman Date: Tue, 22 Oct 2019 17:57:58 +0000 (-0400) Subject: mgr/dashboard: mirror site name and bootstrap service methods X-Git-Tag: v15.1.0~633^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ae677f1c3ea69de89c673430cd27c53e6ff5cae2;p=ceph.git mgr/dashboard: mirror site name and bootstrap service methods Signed-off-by: Jason Dillaman --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd-mirroring.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd-mirroring.service.spec.ts index cc4b7d31c65e..03f6b9d6557d 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd-mirroring.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd-mirroring.service.spec.ts @@ -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(); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd-mirroring.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd-mirroring.service.ts index 2f3626c2259f..0dd04e9798e9 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd-mirroring.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd-mirroring.service.ts @@ -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}`); }