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
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)
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')
@Input()
driveGroup: DriveGroup;
- @Input()
- allHosts: string[];
-
@Output()
submitAction = new EventEmitter();
}
onSubmit() {
- this.orchService.osdCreate(this.driveGroup.spec, this.allHosts).subscribe(
+ this.orchService.osdCreate(this.driveGroup.spec).subscribe(
undefined,
() => {
this.formGroup.setErrors({ cdSubmitButton: true });
}
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);
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);
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' });
}
}
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):