Search is not available for this dataset
repo
stringlengths
2
152
file
stringlengths
15
239
code
stringlengths
0
58.4M
file_length
int64
0
58.4M
avg_line_length
float64
0
1.81M
max_line_length
int64
0
12.7M
extension_type
stringclasses
364 values
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/modal.service.spec.ts
import { Component } from '@angular/core'; import { fakeAsync, TestBed, tick } from '@angular/core/testing'; import { NgbActiveModal, NgbModal, NgbModalModule } from '@ng-bootstrap/ng-bootstrap'; import { configureTestBed } from '~/testing/unit-test-helper'; import { ModalService } from './modal.service'; @Component...
1,673
26.9
98
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/modal.service.ts
import { Injectable } from '@angular/core'; import { NgbModal, NgbModalOptions, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; @Injectable({ providedIn: 'root' }) export class ModalService { constructor(private modal: NgbModal) {} show(component: any, initialState?: any, options?: NgbModalOptions): NgbModalR...
620
20.413793
84
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/module-status-guard.service.spec.ts
import { HttpClient } from '@angular/common/http'; import { Component, NgZone } from '@angular/core'; import { fakeAsync, TestBed, tick } from '@angular/core/testing'; import { ActivatedRouteSnapshot, Router, Routes } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; import { of as...
3,375
31.776699
105
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/module-status-guard.service.ts
import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, Router } from '@angular/router'; import { of as observableOf } from 'rxjs'; import { catchError, map } from 'rxjs/operators'; import { MgrModuleService } from ...
3,456
31.92381
97
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/motd-notification.service.spec.ts
import { HttpClientTestingModule } from '@angular/common/http/testing'; import { TestBed } from '@angular/core/testing'; import { Motd } from '~/app/shared/api/motd.service'; import { configureTestBed } from '~/testing/unit-test-helper'; import { MotdNotificationService } from './motd-notification.service'; describe(...
3,620
29.686441
93
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/motd-notification.service.ts
import { Injectable, OnDestroy } from '@angular/core'; import * as _ from 'lodash'; import { BehaviorSubject, EMPTY, Observable, of, Subscription } from 'rxjs'; import { catchError, delay, mergeMap, repeat, tap } from 'rxjs/operators'; import { Motd, MotdService } from '~/app/shared/api/motd.service'; import { whenPa...
2,756
31.435294
97
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/ngzone-scheduler.service.ts
import { Injectable, NgZone } from '@angular/core'; import { asyncScheduler, SchedulerLike, Subscription } from 'rxjs'; abstract class NgZoneScheduler implements SchedulerLike { protected scheduler = asyncScheduler; constructor(protected zone: NgZone) {} abstract schedule(...args: any[]): Subscription; now...
1,124
21.959184
98
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/no-sso-guard.service.spec.ts
import { Component, NgZone } from '@angular/core'; import { fakeAsync, TestBed, tick } from '@angular/core/testing'; import { Routes } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; import { DashboardUserDeniedError } from '~/app/core/error/error'; import { configureTestBed } fr...
1,629
31.6
81
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/no-sso-guard.service.ts
import { Injectable } from '@angular/core'; import { CanActivate, CanActivateChild } from '@angular/router'; import { DashboardUserDeniedError } from '~/app/core/error/error'; import { AuthStorageService } from './auth-storage.service'; /** * This service checks if a route can be activated if the user has not * bee...
744
24.689655
73
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/notification.service.spec.ts
import { HttpClientTestingModule } from '@angular/common/http/testing'; import { fakeAsync, TestBed, tick } from '@angular/core/testing'; import _ from 'lodash'; import { ToastrService } from 'ngx-toastr'; import { configureTestBed } from '~/testing/unit-test-helper'; import { RbdService } from '../api/rbd.service'; ...
9,478
32.143357
98
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/notification.service.ts
import { Injectable } from '@angular/core'; import _ from 'lodash'; import { IndividualConfig, ToastrService } from 'ngx-toastr'; import { BehaviorSubject, Subject } from 'rxjs'; import { NotificationType } from '../enum/notification-type.enum'; import { CdNotification, CdNotificationConfig } from '../models/cd-notif...
7,101
28.840336
97
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/number-formatter.service.spec.ts
import { TestBed } from '@angular/core/testing'; import { NumberFormatterService } from './number-formatter.service'; describe('FormatToService', () => { let service: NumberFormatterService; beforeEach(() => { TestBed.configureTestingModule({}); service = TestBed.inject(NumberFormatterService); }); ...
396
22.352941
68
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/number-formatter.service.ts
import { Injectable } from '@angular/core'; import { FormatterService } from './formatter.service'; @Injectable({ providedIn: 'root' }) export class NumberFormatterService { readonly bytesLabels = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']; readonly bytesPerSecondLabels = [ 'B/s', 'KiB...
1,775
24.73913
100
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/password-policy.service.spec.ts
import { HttpClientTestingModule } from '@angular/common/http/testing'; import { TestBed } from '@angular/core/testing'; import { of as observableOf } from 'rxjs'; import { configureTestBed } from '~/testing/unit-test-helper'; import { SettingsService } from '../api/settings.service'; import { SharedModule } from '.....
7,678
35.741627
80
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/password-policy.service.ts
import { Injectable } from '@angular/core'; import _ from 'lodash'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; import { SettingsService } from '../api/settings.service'; import { CdPwdPolicySettings } from '../models/cd-pwd-policy-settings'; @Injectable({ providedIn: 'root' }) export ...
2,436
35.924242
116
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-alert-formatter.spec.ts
import { HttpClientTestingModule } from '@angular/common/http/testing'; import { TestBed } from '@angular/core/testing'; import { ToastrModule } from 'ngx-toastr'; import { configureTestBed, PrometheusHelper } from '~/testing/unit-test-helper'; import { NotificationType } from '../enum/notification-type.enum'; import...
3,223
32.583333
92
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-alert-formatter.ts
import { Injectable } from '@angular/core'; import _ from 'lodash'; import { Icons } from '../enum/icons.enum'; import { NotificationType } from '../enum/notification-type.enum'; import { CdNotificationConfig } from '../models/cd-notification'; import { AlertmanagerAlert, AlertmanagerNotificationAlert, Promethe...
2,418
31.253333
102
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-alert.service.spec.ts
import { HttpClientTestingModule } from '@angular/common/http/testing'; import { TestBed } from '@angular/core/testing'; import { ToastrModule } from 'ngx-toastr'; import { Observable, of } from 'rxjs'; import { configureTestBed, PrometheusHelper } from '~/testing/unit-test-helper'; import { PrometheusService } from ...
7,446
33.637209
112
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-alert.service.ts
import { Injectable } from '@angular/core'; import _ from 'lodash'; import { PrometheusService } from '../api/prometheus.service'; import { AlertmanagerAlert, PrometheusCustomAlert, PrometheusRule } from '../models/prometheus-alerts'; import { PrometheusAlertFormatter } from './prometheus-alert-formatter'; @In...
3,510
29.530435
100
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-notification.service.spec.ts
import { HttpClientTestingModule } from '@angular/common/http/testing'; import { fakeAsync, TestBed, tick } from '@angular/core/testing'; import { ToastrModule, ToastrService } from 'ngx-toastr'; import { of, throwError } from 'rxjs'; import { configureTestBed, PrometheusHelper } from '~/testing/unit-test-helper'; im...
8,087
34.473684
100
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-notification.service.ts
import { Injectable } from '@angular/core'; import _ from 'lodash'; import { PrometheusService } from '../api/prometheus.service'; import { CdNotificationConfig } from '../models/cd-notification'; import { AlertmanagerNotification } from '../models/prometheus-alerts'; import { PrometheusAlertFormatter } from './prome...
1,601
29.807692
94
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-silence-matcher.service.spec.ts
import { TestBed } from '@angular/core/testing'; import { configureTestBed, PrometheusHelper } from '~/testing/unit-test-helper'; import { PrometheusRule } from '../models/prometheus-alerts'; import { SharedModule } from '../shared.module'; import { PrometheusSilenceMatcherService } from './prometheus-silence-matcher....
4,134
29.858209
98
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-silence-matcher.service.ts
import { Injectable } from '@angular/core'; import _ from 'lodash'; import { AlertmanagerSilenceMatcher, AlertmanagerSilenceMatcherMatch } from '../models/alertmanager-silence'; import { PrometheusRule } from '../models/prometheus-alerts'; @Injectable({ providedIn: 'root' }) export class PrometheusSilenceMatch...
2,264
28.802632
99
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/rbd-configuration.service.spec.ts
import { TestBed } from '@angular/core/testing'; import { configureTestBed } from '~/testing/unit-test-helper'; import { RbdConfigurationType } from '../models/configuration'; import { RbdConfigurationService } from './rbd-configuration.service'; describe('RbdConfigurationService', () => { let service: RbdConfigura...
1,435
30.217391
78
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/rbd-configuration.service.ts
import { Injectable } from '@angular/core'; import { RbdConfigurationExtraField, RbdConfigurationSection, RbdConfigurationType } from '../models/configuration'; /** * Define here which options should be made available under which section heading. * The display name and description needs to be added manually a...
5,021
33.634483
95
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/refresh-interval.service.spec.ts
import { NgZone } from '@angular/core'; import { fakeAsync, TestBed, tick } from '@angular/core/testing'; import { configureTestBed } from '~/testing/unit-test-helper'; import { RefreshIntervalService } from './refresh-interval.service'; describe('RefreshIntervalService', () => { let service: RefreshIntervalService...
1,482
26.981132
112
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/refresh-interval.service.ts
import { Injectable, NgZone, OnDestroy } from '@angular/core'; import { BehaviorSubject, interval, Subscription } from 'rxjs'; @Injectable({ providedIn: 'root' }) export class RefreshIntervalService implements OnDestroy { private intervalTime: number; // Observable sources private intervalDataSource = new Beh...
1,320
27.106383
95
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/summary.service.spec.ts
import { HttpClient } from '@angular/common/http'; import { fakeAsync, TestBed, tick } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { of as observableOf, Subscriber, Subscription } from 'rxjs'; import { configureTestBed } from '~/testing/unit-test-helper'; import...
4,982
26.683333
90
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/summary.service.ts
import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import _ from 'lodash'; import { BehaviorSubject, Observable, Subscription } from 'rxjs'; import { filter, first } from 'rxjs/operators'; import { ExecutingTask } from '../models/executing-task'; import { Summary } from '.....
2,702
29.033333
95
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-list.service.spec.ts
import { HttpClientTestingModule } from '@angular/common/http/testing'; import { TestBed } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { of } from 'rxjs'; import { configureTestBed, expectItemTasks } from '~/testing/unit-test-helper'; import { RbdService } from ...
4,288
31.007463
91
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-list.service.ts
import { Injectable, OnDestroy } from '@angular/core'; import { Observable, Subscription } from 'rxjs'; import { ExecutingTask } from '../models/executing-task'; import { Summary } from '../models/summary.model'; import { SummaryService } from './summary.service'; import { TaskMessageService } from './task-message.se...
3,835
33.25
95
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-manager.service.spec.ts
import { fakeAsync, TestBed, tick } from '@angular/core/testing'; import _ from 'lodash'; import { BehaviorSubject } from 'rxjs'; import { configureTestBed } from '~/testing/unit-test-helper'; import { SummaryService } from './summary.service'; import { TaskManagerService } from './task-manager.service'; const summa...
2,188
28.986301
94
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-manager.service.ts
import { Injectable } from '@angular/core'; import _ from 'lodash'; import { ExecutingTask } from '../models/executing-task'; import { FinishedTask } from '../models/finished-task'; import { Task } from '../models/task'; import { SummaryService } from './summary.service'; class TaskSubscription { name: string; m...
1,914
30.916667
98
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-message.service.spec.ts
import { HttpClientTestingModule } from '@angular/common/http/testing'; import { TestBed } from '@angular/core/testing'; import _ from 'lodash'; import { configureTestBed } from '~/testing/unit-test-helper'; import { RbdService } from '../api/rbd.service'; import { FinishedTask } from '../models/finished-task'; impor...
10,908
33.853035
106
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-message.service.ts
import { Injectable } from '@angular/core'; import _ from 'lodash'; import { Components } from '../enum/components.enum'; import { FinishedTask } from '../models/finished-task'; import { ImageSpec } from '../models/image-spec'; import { Task } from '../models/task'; export class TaskMessageOperation { running: stri...
14,692
31.434879
100
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-wrapper.service.spec.ts
import { HttpClientTestingModule } from '@angular/common/http/testing'; import { inject, TestBed } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { ToastrModule } from 'ngx-toastr'; import { Observable } from 'rxjs'; import { configureTestBed } from '~/testing/unit...
3,677
36.151515
98
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-wrapper.service.ts
import { Injectable } from '@angular/core'; import { Observable, Subscriber } from 'rxjs'; import { NotificationType } from '../enum/notification-type.enum'; import { CdNotificationConfig } from '../models/cd-notification'; import { ExecutingTask } from '../models/executing-task'; import { FinishedTask } from '../mod...
2,140
30.028986
85
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/telemetry-notification.service.spec.ts
import { TestBed } from '@angular/core/testing'; import { configureTestBed } from '~/testing/unit-test-helper'; import { TelemetryNotificationService } from './telemetry-notification.service'; describe('TelemetryNotificationService', () => { let service: TelemetryNotificationService; configureTestBed({ provi...
967
27.470588
80
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/telemetry-notification.service.ts
import { EventEmitter, Injectable, Output } from '@angular/core'; @Injectable({ providedIn: 'root' }) export class TelemetryNotificationService { visible = false; @Output() update: EventEmitter<boolean> = new EventEmitter<boolean>(); setVisibility(visible: boolean) { this.visible = visible; this.up...
346
19.411765
65
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/text-to-download.service.spec.ts
import { TestBed } from '@angular/core/testing'; import { configureTestBed } from '~/testing/unit-test-helper'; import { TextToDownloadService } from './text-to-download.service'; describe('TextToDownloadService', () => { let service: TextToDownloadService; configureTestBed({ providers: [TextToDownloadServic...
489
22.333333
67
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/text-to-download.service.ts
import { Injectable } from '@angular/core'; import { saveAs } from 'file-saver'; @Injectable({ providedIn: 'root' }) export class TextToDownloadService { download(downloadText: string, filename?: string) { saveAs(new Blob([downloadText]), filename); } }
266
19.538462
53
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/time-diff.service.spec.ts
import { TestBed } from '@angular/core/testing'; import { configureTestBed } from '~/testing/unit-test-helper'; import { TimeDiffService } from './time-diff.service'; describe('TimeDiffService', () => { let service: TimeDiffService; const baseTime = new Date('2022-02-22T00:00:00'); configureTestBed({ provi...
2,689
36.361111
98
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/time-diff.service.ts
import { Injectable } from '@angular/core'; import _ from 'lodash'; @Injectable({ providedIn: 'root' }) export class TimeDiffService { calculateDuration(startDate: Date, endDate: Date): string { const startTime = +startDate; const endTime = +endDate; const duration = this.getDuration(Math.abs(startTim...
1,732
29.946429
87
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/timer.service.spec.ts
import { fakeAsync, TestBed, tick } from '@angular/core/testing'; import { of, Subscription } from 'rxjs'; import { configureTestBed } from '~/testing/unit-test-helper'; import { TimerService } from './timer.service'; describe('TimerService', () => { let service: TimerService; let subs: Subscription; let recei...
2,017
28.246377
92
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/timer.service.ts
import { Injectable } from '@angular/core'; import { Observable, timer } from 'rxjs'; import { observeOn, shareReplay, switchMap } from 'rxjs/operators'; import { whenPageVisible } from '../rxjs/operators/page-visibilty.operator'; import { NgZoneSchedulerService } from './ngzone-scheduler.service'; @Injectable({ p...
890
28.7
76
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/url-builder.service.spec.ts
import { URLVerbs } from '../constants/app.constants'; import { URLBuilderService } from './url-builder.service'; describe('URLBuilderService', () => { const BASE = 'pool'; const urlBuilder = new URLBuilderService(BASE); it('get base', () => { expect(urlBuilder.base).toBe(BASE); }); it('build absolute ...
1,115
28.368421
94
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/url-builder.service.ts
import { Location } from '@angular/common'; import { URLVerbs } from '../constants/app.constants'; export class URLBuilderService { constructor(readonly base: string) {} private static concatURLSegments(segments: string[]): string { return segments.reduce(Location.joinWithSlash); } static buildURL(absol...
1,491
28.254902
90
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/wizard-steps.service.spec.ts
import { TestBed } from '@angular/core/testing'; import { WizardStepsService } from './wizard-steps.service'; describe('WizardStepsService', () => { let service: WizardStepsService; beforeEach(() => { TestBed.configureTestingModule({}); service = TestBed.inject(WizardStepsService); }); it('should be...
383
21.588235
60
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/services/wizard-steps.service.ts
import { Injectable } from '@angular/core'; import { BehaviorSubject, Observable } from 'rxjs'; import { WizardStepModel } from '~/app/shared/models/wizard-steps'; const initialStep = [{ stepIndex: 1, isComplete: false }]; @Injectable({ providedIn: 'root' }) export class WizardStepsService { steps$: BehaviorSub...
1,590
25.966102
94
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/environments/environment.tpl.ts
// The file contents for the current environment will overwrite these during build. // The build system defaults to the dev environment which uses `environment.ts`, but if you do // `ng build --env=prod` then `environment.prod.ts` will be used instead. // The list of which env maps to which file can be found in `.angul...
458
40.727273
94
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/testing/activated-route-stub.ts
import { ActivatedRoute } from '@angular/router'; import { ReplaySubject } from 'rxjs'; /** * An ActivateRoute test double with a `params` observable. * Use the `setParams()` method to add the next `params` value. */ export class ActivatedRouteStub extends ActivatedRoute { // Use a ReplaySubject to share previou...
746
26.666667
66
ts
null
ceph-main/src/pybind/mgr/dashboard/frontend/src/testing/unit-test-helper.ts
import { DebugElement, Type } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { AbstractControl } from '@angular/forms'; import { By } from '@angular/platform-browser'; import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing'; import { NgbM...
20,814
29.342566
105
ts
null
ceph-main/src/pybind/mgr/dashboard/model/__init__.py
# -*- coding: utf-8 -*-
24
11.5
23
py
null
ceph-main/src/pybind/mgr/dashboard/plugins/__init__.py
# -*- coding: utf-8 -*- import abc from .pluggy import HookimplMarker, HookspecMarker, PluginManager class Interface(object, metaclass=abc.ABCMeta): pass class Mixin(object): pass class DashboardPluginManager(object): def __init__(self, project_name): self.__pm = PluginManager(project_name) ...
2,420
32.625
78
py
null
ceph-main/src/pybind/mgr/dashboard/plugins/debug.py
# -*- coding: utf-8 -*- import json from enum import Enum from typing import no_type_check from . import PLUGIN_MANAGER as PM from . import interfaces as I # noqa: E741,N812 from .plugin import SimplePlugin as SP class Actions(Enum): ENABLE = 'enable' DISABLE = 'disable' STATUS = 'status' @PM.add_pl...
2,872
29.242105
100
py
null
ceph-main/src/pybind/mgr/dashboard/plugins/feature_toggles.py
# -*- coding: utf-8 -*- from enum import Enum from typing import List, Optional, Set, no_type_check import cherrypy from mgr_module import CLICommand, Option from ..controllers.cephfs import CephFS from ..controllers.iscsi import Iscsi, IscsiTarget from ..controllers.nfs import NFSGaneshaExports, NFSGaneshaUi from ....
5,576
33.85625
84
py
null
ceph-main/src/pybind/mgr/dashboard/plugins/interfaces.py
# -*- coding: utf-8 -*- from . import PLUGIN_MANAGER as PM # pylint: disable=cyclic-import from . import Interface, Mixin class CanMgr(Mixin): from .. import mgr mgr = mgr # type: ignore class CanCherrypy(Mixin): import cherrypy request = cherrypy.request response = cherrypy.response @PM.ad...
1,580
18.518519
70
py
null
ceph-main/src/pybind/mgr/dashboard/plugins/lru_cache.py
# -*- coding: utf-8 -*- """ This is a minimal implementation of lru_cache function. Based on Python 3 functools and backports.functools_lru_cache. """ from collections import OrderedDict from functools import wraps from threading import RLock def lru_cache(maxsize=128, typed=False): if typed is not False: ...
1,307
28.727273
69
py
null
ceph-main/src/pybind/mgr/dashboard/plugins/motd.py
# -*- coding: utf-8 -*- import hashlib import json from enum import Enum from typing import Dict, NamedTuple, Optional from ceph.utils import datetime_now, datetime_to_str, parse_timedelta, str_to_datetime from mgr_module import CLICommand from . import PLUGIN_MANAGER as PM from .plugin import SimplePlugin as SP c...
3,212
31.454545
86
py
null
ceph-main/src/pybind/mgr/dashboard/plugins/pluggy.py
# -*- coding: utf-8 -*- """ The MIT License (MIT) Copyright (c) 2015 holger krekel (rather uses bitbucket/hpk42) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including wit...
3,898
32.324786
78
py
null
ceph-main/src/pybind/mgr/dashboard/plugins/plugin.py
from typing import no_type_check from mgr_module import Command, Option from . import PLUGIN_MANAGER as PM from . import interfaces as I # noqa: E741,N812 class SimplePlugin(I.CanMgr, I.HasOptions, I.HasCommands): """ Helper class that provides simplified creation of plugins: - Default Mixins/Inter...
1,253
31.153846
82
py
null
ceph-main/src/pybind/mgr/dashboard/plugins/ttl_cache.py
""" This is a minimal implementation of TTL-ed lru_cache function. Based on Python 3 functools and backports.functools_lru_cache. """ from collections import OrderedDict from functools import wraps from threading import RLock from time import time from typing import Any, Dict try: from typing import Tuple except...
3,379
28.391304
94
py
null
ceph-main/src/pybind/mgr/dashboard/services/__init__.py
# -*- coding: utf-8 -*-
24
11.5
23
py
null
ceph-main/src/pybind/mgr/dashboard/services/_paginate.py
from typing import Any, Dict, List from ..exceptions import DashboardException class ListPaginator: # pylint: disable=W0102 def __init__(self, offset: int, limit: int, sort: str, search: str, input_list: List[Any], default_sort: str, searchable_params: List[str] = [], sortab...
2,314
31.152778
85
py
null
ceph-main/src/pybind/mgr/dashboard/services/access_control.py
# -*- coding: utf-8 -*- # pylint: disable=too-many-arguments,too-many-return-statements # pylint: disable=too-many-branches, too-many-locals, too-many-statements import errno import json import logging import re import threading import time from datetime import datetime, timedelta from string import ascii_lowercase, a...
33,170
34.176034
96
py
null
ceph-main/src/pybind/mgr/dashboard/services/auth.py
# -*- coding: utf-8 -*- import json import logging import os import threading import time import uuid from base64 import b64encode import cherrypy import jwt from .. import mgr from .access_control import LocalAuthenticator, UserDoesNotExist cherrypy.config.update({ 'response.headers.server': 'Ceph-Dashboard', ...
7,172
32.362791
96
py
null
ceph-main/src/pybind/mgr/dashboard/services/ceph_service.py
# -*- coding: utf-8 -*- import json import logging import rados from mgr_module import CommandResult from mgr_util import get_most_recent_rate, get_time_series_rates, name_to_config_section from .. import mgr try: from typing import Any, Dict, Optional, Union except ImportError: pass # For typing only log...
24,245
41.462347
161
py
null
ceph-main/src/pybind/mgr/dashboard/services/cephfs.py
# -*- coding: utf-8 -*- import datetime import logging import os from contextlib import contextmanager import cephfs from .. import mgr logger = logging.getLogger('cephfs') class CephFS(object): @classmethod def list_filesystems(cls): fsmap = mgr.get("fs_map") return [{'id': fs['id'], 'nam...
9,108
33.634981
93
py
null
ceph-main/src/pybind/mgr/dashboard/services/cluster.py
# -*- coding: utf-8 -*- from enum import Enum from typing import NamedTuple from .. import mgr class ClusterCapacity(NamedTuple): total_avail_bytes: int total_bytes: int total_used_raw_bytes: int class ClusterModel: class Status(Enum): INSTALLED = 0 POST_INSTALLED = 1 status: ...
1,394
26.9
98
py
null
ceph-main/src/pybind/mgr/dashboard/services/exception.py
# -*- coding: utf-8 -*- import json import logging from contextlib import contextmanager import cephfs import cherrypy import rados import rbd from orchestrator import OrchestratorError from ..exceptions import DashboardException, ViewCacheNoDataException from ..rest_client import RequestException from ..services.ce...
3,912
28.421053
92
py
null
ceph-main/src/pybind/mgr/dashboard/services/iscsi_cli.py
# -*- coding: utf-8 -*- import errno import json from typing import Optional from mgr_module import CLICheckNonemptyFileInput, CLIReadCommand, CLIWriteCommand from ..rest_client import RequestException from .iscsi_client import IscsiClient from .iscsi_config import InvalidServiceUrl, IscsiGatewayAlreadyExists, \ ...
1,895
31.135593
87
py
null
ceph-main/src/pybind/mgr/dashboard/services/iscsi_client.py
# -*- coding: utf-8 -*- # pylint: disable=too-many-public-methods import json import logging from requests.auth import HTTPBasicAuth try: from urlparse import urlparse except ImportError: from urllib.parse import urlparse from ..rest_client import RestClient from ..settings import Settings from .iscsi_confi...
10,116
38.061776
100
py
null
ceph-main/src/pybind/mgr/dashboard/services/iscsi_config.py
# -*- coding: utf-8 -*- import json try: from urlparse import urlparse except ImportError: from urllib.parse import urlparse from .. import mgr class IscsiGatewayAlreadyExists(Exception): def __init__(self, gateway_name): super(IscsiGatewayAlreadyExists, self).__init__( "iSCSI gatew...
3,919
34
98
py
null
ceph-main/src/pybind/mgr/dashboard/services/orchestrator.py
# -*- coding: utf-8 -*- import logging from functools import wraps from typing import Any, Dict, List, Optional, Tuple from ceph.deployment.service_spec import ServiceSpec from orchestrator import DaemonDescription, DeviceLightLoc, HostSpec, \ InventoryFilter, OrchestratorClientMixin, OrchestratorError, OrchResul...
9,674
33.430605
97
py
null
ceph-main/src/pybind/mgr/dashboard/services/osd.py
# -*- coding: utf-8 -*- from enum import Enum class OsdDeploymentOptions(str, Enum): COST_CAPACITY = 'cost_capacity' THROUGHPUT = 'throughput_optimized' IOPS = 'iops_optimized' class HostStorageSummary: def __init__(self, name: str, title=None, desc=None, available=False, capacity=0...
692
25.653846
74
py
null
ceph-main/src/pybind/mgr/dashboard/services/progress.py
# -*- coding: utf-8 -*- ''' Progress Mgr Module Helper This python module implements helper methods to retrieve the executing and completed tasks tacked by the progress mgr module using the same structure of dashboard tasks ''' import logging from datetime import datetime from .. import mgr from . import rbd # pyl...
3,309
34.978261
92
py
null
ceph-main/src/pybind/mgr/dashboard/services/rbd.py
# -*- coding: utf-8 -*- # pylint: disable=unused-argument import errno import json import math from enum import IntEnum import cherrypy import rados import rbd from .. import mgr from ..exceptions import DashboardException from ..plugins.ttl_cache import ttl_cache, ttl_cache_invalidator from ._paginate import ListPag...
30,452
38.19305
166
py
null
ceph-main/src/pybind/mgr/dashboard/services/rgw_client.py
# -*- coding: utf-8 -*- # pylint: disable=C0302 # pylint: disable=too-many-branches # pylint: disable=too-many-lines import ipaddress import json import logging import os import re import xml.etree.ElementTree as ET # noqa: N814 from subprocess import SubprocessError from mgr_util import build_url from .. import mg...
72,846
46.581319
211
py
null
ceph-main/src/pybind/mgr/dashboard/services/settings.py
# -*- coding: utf-8 -*- from contextlib import contextmanager import cherrypy class SettingsService: @contextmanager # pylint: disable=no-self-argument def attribute_handler(name): """ :type name: str|dict[str, str] :rtype: str|dict[str, str] """ if isinstance(name...
782
24.258065
89
py
null
ceph-main/src/pybind/mgr/dashboard/services/sso.py
# -*- coding: utf-8 -*- # pylint: disable=too-many-return-statements,too-many-branches import errno import json import logging import os import threading import warnings from urllib import parse from .. import mgr from ..tools import prepare_url_prefix logger = logging.getLogger('sso') try: from onelogin.saml2....
9,765
32.217687
99
py
null
ceph-main/src/pybind/mgr/dashboard/services/tcmu_service.py
from mgr_util import get_most_recent_rate from dashboard.services.ceph_service import CephService from .. import mgr try: from typing import Dict except ImportError: pass # Just for type checking SERVICE_TYPE = 'tcmu-runner' class TcmuService(object): # pylint: disable=too-many-nested-blocks # p...
4,535
38.789474
90
py
null
ceph-main/src/pybind/mgr/dashboard/tests/__init__.py
# -*- coding: utf-8 -*- # pylint: disable=too-many-arguments import contextlib import json import logging import threading import time from typing import Any, Dict, List, Optional from unittest import mock from unittest.mock import Mock import cherrypy from cherrypy._cptools import HandlerWrapperTool from cherrypy.te...
13,890
34.436224
100
py
null
ceph-main/src/pybind/mgr/dashboard/tests/helper.py
# -*- coding: utf-8 -*- try: from typing import Any, Dict except ImportError: pass def update_dict(data, update_data): # type: (Dict[Any, Any], Dict[Any, Any]) -> Dict[Any] """ Update a dictionary recursively. Eases doing so by providing the option to separate the key to be updated by dot charac...
1,534
26.410714
100
py
null
ceph-main/src/pybind/mgr/dashboard/tests/test_access_control.py
# -*- coding: utf-8 -*- # pylint: disable=dangerous-default-value,too-many-public-methods import errno import json import tempfile import time import unittest from datetime import datetime, timedelta from mgr_module import ERROR_MSG_EMPTY_INPUT_FILE from .. import mgr from ..security import Permission, Scope from .....
38,042
42.677382
100
py
null
ceph-main/src/pybind/mgr/dashboard/tests/test_api_auditing.py
# -*- coding: utf-8 -*- import json import re try: import mock except ImportError: import unittest.mock as mock from .. import mgr from ..controllers import RESTController, Router from ..tests import ControllerTestCase, KVStoreMockMixin # pylint: disable=W0613 @Router('/foo', secure=False) class FooResourc...
2,970
30.946237
74
py
null
ceph-main/src/pybind/mgr/dashboard/tests/test_auth.py
import unittest from unittest.mock import Mock, patch from .. import mgr from ..controllers.auth import Auth from ..services.auth import JwtManager from ..tests import ControllerTestCase mgr.get_module_option.return_value = JwtManager.JWT_TOKEN_TTL mgr.get_store.return_value = 'jwt_secret' mgr.ACCESS_CTRL_DB = Mock()...
2,200
31.850746
92
py
null
ceph-main/src/pybind/mgr/dashboard/tests/test_cache.py
import unittest from ..plugins.ttl_cache import CacheManager, TTLCache class TTLCacheTest(unittest.TestCase): def test_get(self): ref = 'testcache' cache = TTLCache(ref, 30) with self.assertRaises(KeyError): val = cache['foo'] cache['foo'] = 'var' val = cache[...
1,416
27.918367
54
py
null
ceph-main/src/pybind/mgr/dashboard/tests/test_ceph_service.py
# -*- coding: utf-8 -*- # pylint: disable=dangerous-default-value,too-many-public-methods import logging import unittest from contextlib import contextmanager from unittest import mock import pytest from ..services.ceph_service import CephService class CephServiceTest(unittest.TestCase): pools = [{ 'po...
6,852
39.311765
100
py
null
ceph-main/src/pybind/mgr/dashboard/tests/test_ceph_users.py
import unittest.mock as mock from jsonschema import validate from ..controllers.ceph_users import CephUser, create_form from ..tests import ControllerTestCase auth_dump_mock = {"auth_dump": [ {"entity": "client.admin", "key": "RANDOMFi7NwMARAA7RdGqdav+BEEFDEAD0x00g==", "caps": {"mds": "allow *", ...
1,769
32.396226
90
py
null
ceph-main/src/pybind/mgr/dashboard/tests/test_cephfs.py
# -*- coding: utf-8 -*- from collections import defaultdict try: from mock import Mock except ImportError: from unittest.mock import patch, Mock from ..controllers.cephfs import CephFS from ..tests import ControllerTestCase class MetaDataMock(object): def get(self, _x, _y): return 'bar' def ge...
1,193
26.767442
73
py
null
ceph-main/src/pybind/mgr/dashboard/tests/test_cluster_upgrade.py
from ..controllers.cluster import ClusterUpgrade from ..tests import ControllerTestCase, patch_orch from ..tools import NotificationQueue, TaskManager class ClusterUpgradeControllerTest(ControllerTestCase): URL_CLUSTER_UPGRADE = '/api/cluster/upgrade' @classmethod def setup_server(cls): Notificat...
2,307
36.225806
93
py
null
ceph-main/src/pybind/mgr/dashboard/tests/test_controllers.py
# -*- coding: utf-8 -*- from ..controllers import APIRouter, BaseController, Endpoint, RESTController, Router from ..tests import ControllerTestCase @Router("/btest/{key}", base_url="/ui", secure=False) class BTest(BaseController): @Endpoint() def test1(self, key, opt=1): return {'key': key, 'opt': o...
6,390
32.460733
85
py
null
ceph-main/src/pybind/mgr/dashboard/tests/test_crud.py
# pylint: disable=C0102 import json from typing import NamedTuple import pytest from jsonschema import validate from ..controllers._crud import ArrayHorizontalContainer, \ ArrayVerticalContainer, Form, FormField, HorizontalContainer, SecretStr, \ VerticalContainer, serialize def assertObjectEquals(a, b): ...
2,606
36.782609
91
py
null
ceph-main/src/pybind/mgr/dashboard/tests/test_daemon.py
# -*- coding: utf-8 -*- from ..controllers._version import APIVersion from ..controllers.daemon import Daemon from ..tests import ControllerTestCase, patch_orch class DaemonTest(ControllerTestCase): URL_DAEMON = '/api/daemon' @classmethod def setup_server(cls): cls.setup_controllers([Daemon]) ...
1,345
31.047619
97
py
null
ceph-main/src/pybind/mgr/dashboard/tests/test_docs.py
# # -*- coding: utf-8 -*- import unittest from ..api.doc import SchemaType from ..controllers import ENDPOINT_MAP, APIDoc, APIRouter, Endpoint, EndpointDoc, RESTController from ..controllers._version import APIVersion from ..controllers.docs import Docs from ..tests import ControllerTestCase # Dummy controller and ...
8,653
34.908714
98
py
null
ceph-main/src/pybind/mgr/dashboard/tests/test_erasure_code_profile.py
# -*- coding: utf-8 -*- from .. import mgr from ..controllers.erasure_code_profile import ErasureCodeProfile from ..tests import ControllerTestCase class ErasureCodeProfileTest(ControllerTestCase): @classmethod def setup_server(cls): mgr.get.side_effect = lambda key: { 'osd_map': { ...
837
26.933333
65
py
null
ceph-main/src/pybind/mgr/dashboard/tests/test_exceptions.py
# -*- coding: utf-8 -*- import time import rados from ..controllers import Endpoint, RESTController, Router, Task from ..services.ceph_service import SendCommandError from ..services.exception import handle_rados_error, \ handle_send_command_error, serialize_dashboard_exception from ..tests import ControllerTest...
4,523
27.099379
86
py
null
ceph-main/src/pybind/mgr/dashboard/tests/test_feature_toggles.py
# -*- coding: utf-8 -*- import unittest try: from mock import Mock, patch except ImportError: from unittest.mock import Mock, patch from ..plugins.feature_toggles import Actions, Features, FeatureToggles from ..tests import KVStoreMockMixin class SettingsTest(unittest.TestCase, KVStoreMockMixin): @clas...
2,082
31.046154
89
py
null
ceph-main/src/pybind/mgr/dashboard/tests/test_grafana.py
import json import unittest try: from mock import patch except ImportError: from unittest.mock import patch from requests import RequestException from ..controllers.grafana import Grafana from ..grafana import GrafanaRestClient from ..settings import Settings from ..tests import ControllerTestCase, KVStoreMo...
4,870
35.350746
99
py
null
ceph-main/src/pybind/mgr/dashboard/tests/test_home.py
import logging import os try: import mock except ImportError: import unittest.mock as mock from .. import mgr from ..controllers.home import HomeController, LanguageMixin from ..tests import ControllerTestCase, FakeFsMixin logger = logging.getLogger() class HomeTest(ControllerTestCase, FakeFsMixin): @...
2,839
37.378378
79
py