logger = logging.getLogger(__name__)
RBD_SCHEMA = ([{
- "status": (int, 'Status of the image'),
"value": ([str], ''),
"pool_name": (str, 'pool name')
}])
for i, image in enumerate(images):
pool = image['pool']
if pool not in pool_result:
- pool_result[pool] = {'status': 1, 'value': [], 'pool_name': image['pool']}
+ pool_result[pool] = {'value': [], 'pool_name': image['pool']}
pool_result[pool]['value'].append(image)
images[i]['configuration'] = RbdConfiguration(
};
const RBD_LIST: any[] = [
- { status: 0, value: [], pool_name: 'ganesha' },
+ { value: [], pool_name: 'ganesha' },
{
- status: 0,
value: [
{
size: 96636764160,
httpTesting.expectOne('ui-api/iscsi/settings').flush(SETTINGS);
httpTesting.expectOne('ui-api/iscsi/portals').flush(PORTALS);
httpTesting.expectOne('ui-api/iscsi/version').flush(VERSION);
- httpTesting.expectOne('api/block/image').flush(RBD_LIST);
+ httpTesting.expectOne('api/block/image?offset=0&limit=-1').flush(RBD_LIST);
httpTesting.expectOne('api/iscsi/target').flush(LIST_TARGET);
httpTesting.verify();
});
import { CdForm } from '~/app/shared/forms/cd-form';
import { CdFormGroup } from '~/app/shared/forms/cd-form-group';
import { CdValidators } from '~/app/shared/forms/cd-validators';
+import { CdTableFetchDataContext } from '~/app/shared/models/cd-table-fetch-data-context';
import { FinishedTask } from '~/app/shared/models/finished-task';
import { ModalService } from '~/app/shared/services/modal.service';
import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service';
}
ngOnInit() {
+ const rbdListContext = new CdTableFetchDataContext(() => {});
+ /* limit -1 to specify all images */
+ rbdListContext.pageInfo.limit = -1;
const promises: any[] = [
this.iscsiService.listTargets(),
- this.rbdService.list({ offset: 0, limit: 5 }),
+ /* tslint:disable:no-empty */
+ this.rbdService.list(rbdListContext.toParams()),
this.iscsiService.portals(),
this.iscsiService.settings(),
this.iscsiService.version()
selectionType="single"
[hasDetails]="true"
[status]="tableStatus"
- [autoReload]="5000"
+ [autoReload]="-1"
(fetchData)="taskListService.fetch($event)"
(setExpandedRow)="setExpandedRow($event)"
(updateSelection)="updateSelection($event)">
import { BehaviorSubject, of } from 'rxjs';
import { RbdService } from '~/app/shared/api/rbd.service';
-import { TableStatusViewCache } from '~/app/shared/classes/table-status-view-cache';
import { TableActionsComponent } from '~/app/shared/datatable/table-actions/table-actions.component';
-import { ViewCacheStatus } from '~/app/shared/enum/view-cache-status.enum';
import { ExecutingTask } from '~/app/shared/models/executing-task';
import { SummaryService } from '~/app/shared/services/summary.service';
import { TaskListService } from '~/app/shared/services/task-list.service';
spyOn(component.table, 'reset');
summaryService['summaryDataSource'].error(undefined);
expect(component.table.reset).toHaveBeenCalled();
- expect(component.tableStatus).toEqual(
- new TableStatusViewCache(ViewCacheStatus.ValueException)
- );
});
});
});
it('should display N/A for Provisioned & Total Provisioned columns if disk usage is null', () => {
- rbdServiceListSpy.and.callFake(() => of([{ pool_name: 'rbd', status: 1, value: images }]));
+ rbdServiceListSpy.and.callFake(() => of([{ pool_name: 'rbd', value: images }]));
fixture.detectChanges();
const spanWithoutFastDiff = fixture.debugElement.nativeElement.querySelectorAll(
'.datatable-body-cell-label span'
component.images = images;
refresh({ executing_tasks: [], finished_tasks: [] });
- rbdServiceListSpy.and.callFake(() => of([{ pool_name: 'rbd', status: 1, value: images }]));
+ rbdServiceListSpy.and.callFake(() => of([{ pool_name: 'rbd', value: images }]));
fixture.detectChanges();
const spanWithFastDiff = fixture.debugElement.nativeElement.querySelectorAll(
addImage('c');
component.images = images;
refresh({ executing_tasks: [], finished_tasks: [] });
- spyOn(rbdService, 'list').and.callFake(() =>
- of([{ pool_name: 'rbd', status: 1, value: images }])
- );
+ spyOn(rbdService, 'list').and.callFake(() => of([{ pool_name: 'rbd', value: images }]));
fixture.detectChanges();
});
import { ActionLabelsI18n } from '~/app/shared/constants/app.constants';
import { TableComponent } from '~/app/shared/datatable/table/table.component';
import { Icons } from '~/app/shared/enum/icons.enum';
-import { ViewCacheStatus } from '~/app/shared/enum/view-cache-status.enum';
import { CdTableAction } from '~/app/shared/models/cd-table-action';
import { CdTableColumn } from '~/app/shared/models/cd-table-column';
import { CdTableFetchDataContext } from '~/app/shared/models/cd-table-fetch-data-context';
onFetchError() {
this.table.reset(); // Disable loading indicator.
- this.tableStatus = new TableStatusViewCache(ViewCacheStatus.ValueException);
}
getRbdImages(context: CdTableFetchDataContext = null) {
return false;
}
}
-
-/*
- for pool in pools
- for namespace in namespaces
- refs = get_image_refs
- for ref in refs:
- get_data(ref)
-
-@ttl_cache(5)
-def get_refs();
- joint_refs = []
- for pool in pools
- for namespace in namespaces
- refs = get_image_refs
- for ref in refs:
- joint_refs.append(ref)
- return joint_refs
-
-sort(joint_refs)
- for ref in joint_refs[offset:offset+limit]:
-get_data(ref)
-
-*/
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
+import { CdTableFetchDataContext } from '~/app/shared/models/cd-table-fetch-data-context';
import { configureTestBed } from '~/testing/unit-test-helper';
import { ImageSpec } from '../models/image-spec';
import { RbdConfigurationService } from '../services/rbd-configuration.service';
});
it('should call list', () => {
- service.list().subscribe();
- const req = httpTesting.expectOne('api/block/image');
+ /* tslint:disable:no-empty */
+ const context = new CdTableFetchDataContext(() => {});
+ service.list(context.toParams()).subscribe();
+ const req = httpTesting.expectOne('api/block/image?offset=0&limit=10');
expect(req.request.method).toBe('GET');
});
[rowClass]="getRowClass()"
[headerHeight]="header ? 'auto' : 0"
[footerHeight]="footer ? 'auto' : 0"
- [count]="count"
- [externalPaging]="serverSide"
+ [count]="count"
+ [externalPaging]="serverSide"
[limit]="userConfig.limit > 0 ? userConfig.limit : undefined"
[offset]="userConfig.offset >= 0 ? userConfig.offset : 0"
(page)="changePage($event)"
import { CdTableColumnFilter } from '~/app/shared/models/cd-table-column-filter';
import { CdTableColumnFiltersChange } from '~/app/shared/models/cd-table-column-filters-change';
import { CdTableFetchDataContext } from '~/app/shared/models/cd-table-fetch-data-context';
+import { PageInfo } from '~/app/shared/models/cd-table-paging';
import { CdTableSelection } from '~/app/shared/models/cd-table-selection';
import { CdUserConfig } from '~/app/shared/models/cd-user-config';
import { TimerService } from '~/app/shared/services/timer.service';
-import { PageInfo } from '../../models/cd-table-paging';
@Component({
selector: 'cd-table',
providedIn: 'root'
})
export class CdTableServerSideService {
+ /* tslint:disable:no-empty */
constructor() {}
static getCount(resp: HttpResponse<any>): number {
name: pool_name
schema:
type: string
+ - default: 0
+ description: offset
+ in: query
+ name: offset
+ schema:
+ type: integer
+ - default: 5
+ description: limit
+ in: query
+ name: limit
+ schema:
+ type: integer
responses:
'200':
content:
pool_name:
description: pool name
type: string
- status:
- description: Status of the image
- type: integer
value:
description: ''
items:
type: array
type: object
required:
- - status
- value
- pool_name
type: array
from .. import mgr
from ..exceptions import DashboardException
-from ..tools import ViewCache
from .ceph_service import CephService
try:
rbd_inst = rbd.RBD()
for pool in pool_names:
with mgr.rados.open_ioctx(pool) as ioctx:
- result = []
if namespace:
namespaces = [namespace]
else:
def rbd_pool_list(cls, pool_names: List[str], namespace=None, offset=0, limit=0):
offset = int(offset)
limit = int(limit)
- if limit < 0:
+ # let's use -1 to denotate we want ALL images for now. Iscsi currently gathers
+ # all images therefore, we need this.
+ if limit < -1:
return []
refs = cls._rbd_pool_image_refs(pool_names, namespace)
# transform to list so that we can count
for i in refs:
image_refs.append(i)
-
+
result = []
- for image_ref in sorted(image_refs, key=lambda v: v['name'])[offset:offset+limit]:
+ end = offset + limit
+ if limit == -1:
+ end = len(image_refs)
+ for image_ref in sorted(image_refs, key=lambda v: v['name'])[offset:end]:
with mgr.rados.open_ioctx(image_ref['pool']) as ioctx:
ioctx.set_namespace(image_ref['namespace'])
try:
'namespace': ''
}
- rbd_pool_list = RbdService.rbd_pool_list('test_pool')
- self.assertEqual(rbd_pool_list, (0, [{
+ rbd_pool_list = RbdService.rbd_pool_list(['test_pool'], offset=0, limit=5)
+ self.assertEqual(rbd_pool_list, ([{
'id': '3c1a5ee60a88',
'unique_id': 'test_pool/3c1a5ee60a88',
'name': 'test_rbd',
'source': 'REMOVING',
'deletion_time': '{}Z'.format(time.isoformat()),
'deferment_end_time': '{}Z'.format(time.isoformat()),
+ 'pool': 'test_pool',
'pool_name': 'test_pool',
'namespace': ''
- }]))
+ }], 1))
def test_valid_interval(self):
test_cases = [