]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: adapt to create_osds parameters change 31928/head
authorKiefer Chang <kiefer.chang@suse.com>
Fri, 29 Nov 2019 08:15:20 +0000 (16:15 +0800)
committerKiefer Chang <kiefer.chang@suse.com>
Mon, 2 Dec 2019 04:36:13 +0000 (12:36 +0800)
Parameters of `create_osds` are changed after PR:
https://github.com/ceph/ceph/pull/30262.
Adapt dashboard backend to the change. Also a new test for creating OSDs
is added in backend QA.

Fixes: https://tracker.ceph.com/issues/43074
Signed-off-by: Kiefer Chang <kiefer.chang@suse.com>
qa/tasks/mgr/dashboard/test_orchestrator.py
src/pybind/mgr/dashboard/controllers/orchestrator.py
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-creation-preview-modal/osd-creation-preview-modal.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-form/osd-form.component.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/api/orchestrator.service.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/api/orchestrator.service.ts
src/pybind/mgr/dashboard/services/orchestrator.py

index cfa4f9cba75ca29ee531d3b94f8790185f7ea910..348bde14b720f561656476e12d9a15ddf6e9f77d 100644 (file)
@@ -52,11 +52,12 @@ test_data = {
 
 class OrchestratorControllerTest(DashboardTestCase):
 
-    AUTH_ROLES = ['read-only']
+    AUTH_ROLES = ['cluster-manager']
 
     URL_STATUS = '/api/orchestrator/status'
     URL_INVENTORY = '/api/orchestrator/inventory'
     URL_SERVICE = '/api/orchestrator/service'
+    URL_OSD = '/api/orchestrator/osd'
 
 
     @property
@@ -154,3 +155,33 @@ class OrchestratorControllerTest(DashboardTestCase):
         resp_services = sorted(data, key=sorting_key)
         for test, resp in zip(test_services, resp_services):
             self._validate_service(test, resp)
+
+    def test_create_osds(self):
+        data = {
+            'drive_group': {
+                'host_pattern': '*',
+                'data_devices': {
+                    'vendor': 'abc',
+                    'model': 'cba',
+                    'rotational': True,
+                    'size': '4 TB'
+                },
+                'wal_devices': {
+                    'vendor': 'def',
+                    'model': 'fed',
+                    'rotational': False,
+                    'size': '1 TB'
+                },
+                'db_devices': {
+                    'vendor': 'ghi',
+                    'model': 'ihg',
+                    'rotational': False,
+                    'size': '512 GB'
+                },
+                'wal_slots': 5,
+                'db_slots': 5,
+                'encrypted': True
+            }
+        }
+        self._post(self.URL_OSD, data)
+        self.assertStatus(201)
index 3ddfb2bc118858cfd2baf9142d6970f54c1d4635..f38ac90a87e07aa3e0f2449267261d4b140741a9 100644 (file)
@@ -102,9 +102,9 @@ class OrchestratorService(RESTController):
 class OrchestratorOsd(RESTController):
 
     @raise_if_no_orchestrator
-    def create(self, drive_group, all_hosts=None):
+    def create(self, drive_group):
         orch = OrchClient.instance()
         try:
-            orch.osds.create(DriveGroupSpec.from_json(drive_group), all_hosts)
+            orch.osds.create(DriveGroupSpec.from_json(drive_group))
         except (ValueError, TypeError, DriveGroupValidationError) as e:
             raise DashboardException(e, component='osd')
index 82b14ae4795eb9a3646cb3b091080dcce691cae8..703ce037a138f51814c5fe984165a38393f715a5 100644 (file)
@@ -17,9 +17,6 @@ export class OsdCreationPreviewModalComponent implements OnInit {
   @Input()
   driveGroup: DriveGroup;
 
-  @Input()
-  allHosts: string[];
-
   @Output()
   submitAction = new EventEmitter();
 
@@ -43,7 +40,7 @@ export class OsdCreationPreviewModalComponent implements OnInit {
   }
 
   onSubmit() {
-    this.orchService.osdCreate(this.driveGroup.spec, this.allHosts).subscribe(
+    this.orchService.osdCreate(this.driveGroup.spec).subscribe(
       undefined,
       () => {
         this.formGroup.setErrors({ cdSubmitButton: true });
index 0bc01793db5a7b0f6dde3a756bfe07e494ff4327..9265d35383ebf82574dac8244500c03c42664b12 100644 (file)
@@ -223,17 +223,9 @@ export class OsdFormComponent implements OnInit {
   }
 
   submit() {
-    let allHosts = [];
-    if (this.hostname === '') {
-      // wildcard * to match all hosts, provide hosts we can see
-      allHosts = _.sortedUniq(_.map(this.allDevices, 'hostname').sort());
-    } else {
-      allHosts = [this.hostname];
-    }
     const options: ModalOptions = {
       initialState: {
-        driveGroup: this.driveGroup,
-        allHosts: allHosts
+        driveGroup: this.driveGroup
       }
     };
     const modalRef = this.bsModalService.show(OsdCreationPreviewModalComponent, options);
index 06d87a17706aa5a2058899f2d85f6c4b19e30424..f7d81d3f68ff434b1173c826556553061fa46882 100644 (file)
@@ -62,10 +62,9 @@ describe('OrchestratorService', () => {
     const data = {
       drive_group: {
         host_pattern: '*'
-      },
-      all_hosts: ['a', 'b']
+      }
     };
-    service.osdCreate(data['drive_group'], data['all_hosts']).subscribe();
+    service.osdCreate(data['drive_group']).subscribe();
     const req = httpTesting.expectOne(service.osdURL);
     expect(req.request.method).toBe('POST');
     expect(req.request.body).toEqual(data);
index b3bbfc5db257aca72f6150bccde1978dc8f23f99..dbe70addea350ed4e7ae341b56674a094ff9d0cb 100644 (file)
@@ -49,13 +49,10 @@ export class OrchestratorService {
     return this.http.get(this.serviceURL, options);
   }
 
-  osdCreate(driveGroup: {}, all_hosts: string[]) {
+  osdCreate(driveGroup: {}) {
     const request = {
       drive_group: driveGroup
     };
-    if (!_.isEmpty(all_hosts)) {
-      request['all_hosts'] = all_hosts;
-    }
     return this.http.post(this.osdURL, request, { observe: 'response' });
   }
 }
index dfadfeb04d3b4c1909d98e329e4fb25e2269fb66..2e215adbf6116dd9c4b92d9dccd2847e957a0b9f 100644 (file)
@@ -89,8 +89,8 @@ class ServiceManager(ResourceManager):
 class OsdManager(ResourceManager):
 
     @wait_api_result
-    def create(self, drive_group, all_hosts=None):
-        return self.api.create_osds(drive_group, all_hosts)
+    def create(self, drive_group):
+        return self.api.create_osds(drive_group)
 
 
 class OrchClient(object):