repo
stringlengths 1
152
⌀ | file
stringlengths 15
205
| code
stringlengths 0
41.6M
| file_length
int64 0
41.6M
| avg_line_length
float64 0
1.81M
| max_line_length
int64 0
12.7M
| extension_type
stringclasses 90
values |
---|---|---|---|---|---|---|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-system-user/rgw-system-user.component.html
|
<cd-modal [modalRef]="activeModal">
<ng-container i18n="form title"
class="modal-title">Create System User</ng-container>
<ng-container class="modal-content">
<form name="multisiteSystemUserForm"
#formDir="ngForm"
[formGroup]="multisiteSystemUserForm"
novalidate>
<div class="modal-body">
<div class="form-group row">
<label class="cd-col-form-label required"
for="userName"
i18n>User Name</label>
<div class="cd-col-form-input">
<input class="form-control"
type="text"
placeholder="User name..."
id="userName"
name="userName"
formControlName="userName">
<span class="invalid-feedback"
*ngIf="multisiteSystemUserForm.showError('userName', formDir, 'required')"
i18n>This field is required.</span>
<span class="invalid-feedback"
*ngIf="multisiteSystemUserForm.showError('userName', formDir, 'uniqueName')"
i18n>The chosen realm name is already in use.</span>
</div>
</div>
</div>
<div class="modal-footer">
<cd-form-button-panel (submitActionEvent)="submit()"
[form]="multisiteSystemUserForm"></cd-form-button-panel>
</div>
</form>
</ng-container>
</cd-modal>
| 1,465 | 37.578947 | 94 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-capability-modal/rgw-user-capability-modal.component.html
|
<cd-modal [modalRef]="activeModal">
<ng-container i18n="form title"
class="modal-title">{{ action | titlecase }} {{ resource | upperFirst }}</ng-container>
<ng-container class="modal-content">
<form #frm="ngForm"
[formGroup]="formGroup"
novalidate>
<div class="modal-body">
<!-- Type -->
<div class="form-group row">
<label class="cd-col-form-label"
[ngClass]="{'required': !editing}"
for="type"
i18n>Type</label>
<div class="cd-col-form-input">
<input id="type"
class="form-control"
type="text"
*ngIf="editing"
[readonly]="true"
formControlName="type">
<select id="type"
class="form-select"
formControlName="type"
*ngIf="!editing"
autofocus>
<option i18n
*ngIf="types !== null"
[ngValue]="null">-- Select a type --</option>
<option *ngFor="let type of types"
[value]="type">{{ type }}</option>
</select>
<span class="invalid-feedback"
*ngIf="formGroup.showError('type', frm, 'required')"
i18n>This field is required.</span>
</div>
</div>
<!-- Permission -->
<div class="form-group row">
<label class="cd-col-form-label required"
for="perm"
i18n>Permission</label>
<div class="cd-col-form-input">
<select id="perm"
class="form-select"
formControlName="perm">
<option i18n
[ngValue]="null">-- Select a permission --</option>
<option *ngFor="let perm of ['read', 'write', '*']"
[value]="perm">
{{ perm }}
</option>
</select>
<span class="invalid-feedback"
*ngIf="formGroup.showError('perm', frm, 'required')"
i18n>This field is required.</span>
</div>
</div>
</div>
<div class="modal-footer">
<cd-form-button-panel (submitActionEvent)="onSubmit()"
[form]="formGroup"
[submitText]="(action | titlecase) + ' ' + (resource | upperFirst)"></cd-form-button-panel>
</div>
</form>
</ng-container>
</cd-modal>
| 2,605 | 35.704225 | 121 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-details/rgw-user-details.component.html
|
<ng-container *ngIf="selection">
<div *ngIf="user">
<div *ngIf="keys.length">
<legend i18n>Keys</legend>
<div>
<cd-table [data]="keys"
[columns]="keysColumns"
columnMode="flex"
selectionType="multi"
forceIdentifier="true"
(updateSelection)="updateKeysSelection($event)">
<div class="table-actions">
<div class="btn-group"
dropdown>
<button type="button"
class="btn btn-accent"
[disabled]="!keysSelection.hasSingleSelection"
(click)="showKeyModal()">
<i [ngClass]="[icons.show]"></i>
<ng-container i18n>Show</ng-container>
</button>
</div>
</div>
</cd-table>
</div>
</div>
<legend i18n>Details</legend>
<table class="table table-striped table-bordered">
<tbody>
<tr>
<td i18n
class="bold w-25">Tenant</td>
<td class="w-75">{{ user.tenant }}</td>
</tr>
<tr>
<td i18n
class="bold w-25">User ID</td>
<td class="w-75">{{ user.user_id }}</td>
</tr>
<tr>
<td i18n
class="bold w-25">Username</td>
<td class="w-75">{{ user.uid }}</td>
</tr>
<tr>
<td i18n
class="bold">Full name</td>
<td>{{ user.display_name }}</td>
</tr>
<tr *ngIf="user.email?.length">
<td i18n
class="bold">Email address</td>
<td>{{ user.email }}</td>
</tr>
<tr>
<td i18n
class="bold">Suspended</td>
<td>{{ user.suspended | booleanText }}</td>
</tr>
<tr>
<td i18n
class="bold">System</td>
<td>{{ user.system === 'true' | booleanText }}</td>
</tr>
<tr>
<td i18n
class="bold">Maximum buckets</td>
<td>{{ user.max_buckets | map:maxBucketsMap }}</td>
</tr>
<tr *ngIf="user.subusers && user.subusers.length">
<td i18n
class="bold">Subusers</td>
<td>
<div *ngFor="let subuser of user.subusers">
{{ subuser.id }} ({{ subuser.permissions }})
</div>
</td>
</tr>
<tr *ngIf="user.caps && user.caps.length">
<td i18n
class="bold">Capabilities</td>
<td>
<div *ngFor="let cap of user.caps">
{{ cap.type }} ({{ cap.perm }})
</div>
</td>
</tr>
<tr *ngIf="user.mfa_ids?.length">
<td i18n
class="bold">MFAs(Id)</td>
<td>{{ user.mfa_ids | join}}</td>
</tr>
</tbody>
</table>
<!-- User quota -->
<div *ngIf="user.user_quota">
<legend i18n>User quota</legend>
<table class="table table-striped table-bordered">
<tbody>
<tr>
<td i18n
class="bold w-25">Enabled</td>
<td class="w-75">{{ user.user_quota.enabled | booleanText }}</td>
</tr>
<tr>
<td i18n
class="bold">Maximum size</td>
<td *ngIf="!user.user_quota.enabled">-</td>
<td *ngIf="user.user_quota.enabled && user.user_quota.max_size <= -1"
i18n>Unlimited</td>
<td *ngIf="user.user_quota.enabled && user.user_quota.max_size > -1">
{{ user.user_quota.max_size | dimlessBinary }}
</td>
</tr>
<tr>
<td i18n
class="bold">Maximum objects</td>
<td *ngIf="!user.user_quota.enabled">-</td>
<td *ngIf="user.user_quota.enabled && user.user_quota.max_objects <= -1"
i18n>Unlimited</td>
<td *ngIf="user.user_quota.enabled && user.user_quota.max_objects > -1">
{{ user.user_quota.max_objects }}
</td>
</tr>
</tbody>
</table>
</div>
<!-- Bucket quota -->
<div *ngIf="user.bucket_quota">
<legend i18n>Bucket quota</legend>
<table class="table table-striped table-bordered">
<tbody>
<tr>
<td i18n
class="bold w-25">Enabled</td>
<td class="w-75">{{ user.bucket_quota.enabled | booleanText }}</td>
</tr>
<tr>
<td i18n
class="bold">Maximum size</td>
<td *ngIf="!user.bucket_quota.enabled">-</td>
<td *ngIf="user.bucket_quota.enabled && user.bucket_quota.max_size <= -1"
i18n>Unlimited</td>
<td *ngIf="user.bucket_quota.enabled && user.bucket_quota.max_size > -1">
{{ user.bucket_quota.max_size | dimlessBinary }}
</td>
</tr>
<tr>
<td i18n
class="bold">Maximum objects</td>
<td *ngIf="!user.bucket_quota.enabled">-</td>
<td *ngIf="user.bucket_quota.enabled && user.bucket_quota.max_objects <= -1"
i18n>Unlimited</td>
<td *ngIf="user.bucket_quota.enabled && user.bucket_quota.max_objects > -1">
{{ user.bucket_quota.max_objects }}
</td>
</tr>
</tbody>
</table>
</div>
</div>
</ng-container>
| 5,489 | 32.072289 | 88 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.html
|
<div class="cd-col-form"
*cdFormLoading="loading">
<form #frm="ngForm"
[formGroup]="userForm"
novalidate>
<div class="card">
<div i18n="form title"
class="card-header">{{ action | titlecase }} {{ resource | upperFirst }}</div>
<div class="card-body">
<!-- User ID -->
<div class="form-group row">
<label class="cd-col-form-label"
[ngClass]="{'required': !editing}"
for="user_id"
i18n>User ID</label>
<div class="cd-col-form-input">
<input id="user_id"
class="form-control"
type="text"
formControlName="user_id"
[readonly]="editing">
<span class="invalid-feedback"
*ngIf="userForm.showError('user_id', frm, 'required')"
i18n>This field is required.</span>
<span class="invalid-feedback"
*ngIf="userForm.showError('user_id', frm, 'pattern')"
i18n>The value is not valid.</span>
<span class="invalid-feedback"
*ngIf="!userForm.getValue('show_tenant') && userForm.showError('user_id', frm, 'notUnique')"
i18n>The chosen user ID is already in use.</span>
</div>
</div>
<!-- Show Tenant -->
<div class="form-group row">
<div class="cd-col-form-offset">
<div class="custom-control custom-checkbox">
<input class="custom-control-input"
id="show_tenant"
type="checkbox"
(click)="updateFieldsWhenTenanted()"
formControlName="show_tenant"
[readonly]="true">
<label class="custom-control-label"
for="show_tenant"
i18n>Show Tenant</label>
</div>
</div>
</div>
<!-- Tenant -->
<div class="form-group row"
*ngIf="userForm.getValue('show_tenant')">
<label class="cd-col-form-label"
for="tenant"
i18n>Tenant</label>
<div class="cd-col-form-input">
<input id="tenant"
class="form-control"
type="text"
formControlName="tenant"
[readonly]="editing"
autofocus>
<span class="invalid-feedback"
*ngIf="userForm.showError('tenant', frm, 'pattern')"
i18n>The value is not valid.</span>
<span class="invalid-feedback"
*ngIf="userForm.showError('tenant', frm, 'notUnique')"
i18n>The chosen user ID exists in this tenant.</span>
</div>
</div>
<!-- Full name -->
<div class="form-group row">
<label class="cd-col-form-label"
[ngClass]="{'required': !editing}"
for="display_name"
i18n>Full name</label>
<div class="cd-col-form-input">
<input id="display_name"
class="form-control"
type="text"
formControlName="display_name">
<span class="invalid-feedback"
*ngIf="userForm.showError('display_name', frm, 'pattern')"
i18n>The value is not valid.</span>
<span class="invalid-feedback"
*ngIf="userForm.showError('display_name', frm, 'required')"
i18n>This field is required.</span>
</div>
</div>
<!-- Email address -->
<div class="form-group row">
<label class="cd-col-form-label"
for="email"
i18n>Email address</label>
<div class="cd-col-form-input">
<input id="email"
class="form-control"
type="text"
formControlName="email">
<span class="invalid-feedback"
*ngIf="userForm.showError('email', frm, 'email')"
i18n>This is not a valid email address.</span>
<span class="invalid-feedback"
*ngIf="userForm.showError('email', frm, 'notUnique')"
i18n>The chosen email address is already in use.</span>
</div>
</div>
<!-- Max. buckets -->
<div class="form-group row">
<label class="cd-col-form-label"
for="max_buckets_mode"
i18n>Max. buckets</label>
<div class="cd-col-form-input">
<select class="form-select"
formControlName="max_buckets_mode"
name="max_buckets_mode"
id="max_buckets_mode"
(change)="onMaxBucketsModeChange($event.target.value)">
<option i18n
value="-1">Disabled</option>
<option i18n
value="0">Unlimited</option>
<option i18n
value="1">Custom</option>
</select>
</div>
</div>
<div *ngIf="1 == userForm.get('max_buckets_mode').value"
class="form-group row">
<label class="cd-col-form-label"></label>
<div class="cd-col-form-input">
<input id="max_buckets"
class="form-control"
type="number"
formControlName="max_buckets"
min="1">
<span class="invalid-feedback"
*ngIf="userForm.showError('max_buckets', frm, 'required')"
i18n>This field is required.</span>
<span class="invalid-feedback"
*ngIf="userForm.showError('max_buckets', frm, 'min')"
i18n>The entered value must be >= 1.</span>
</div>
</div>
<!-- Suspended -->
<div class="form-group row">
<div class="cd-col-form-offset">
<div class="custom-control custom-checkbox">
<input class="custom-control-input"
id="suspended"
type="checkbox"
formControlName="suspended">
<label class="custom-control-label"
for="suspended"
i18n>Suspended</label>
<cd-helper i18n>Suspending the user disables the user and subuser.</cd-helper>
</div>
</div>
</div>
<!-- S3 key -->
<fieldset *ngIf="!editing">
<legend i18n>S3 key</legend>
<!-- Auto-generate key -->
<div class="form-group row">
<div class="cd-col-form-offset">
<div class="custom-control custom-checkbox">
<input class="custom-control-input"
id="generate_key"
type="checkbox"
formControlName="generate_key">
<label class="custom-control-label"
for="generate_key"
i18n>Auto-generate key</label>
</div>
</div>
</div>
<!-- Access key -->
<div class="form-group row"
*ngIf="!editing && !userForm.getValue('generate_key')">
<label class="cd-col-form-label required"
for="access_key"
i18n>Access key</label>
<div class="cd-col-form-input">
<div class="input-group">
<input id="access_key"
class="form-control"
type="password"
formControlName="access_key">
<button type="button"
class="btn btn-light"
cdPasswordButton="access_key">
</button>
<cd-copy-2-clipboard-button source="access_key">
</cd-copy-2-clipboard-button>
</div>
<span class="invalid-feedback"
*ngIf="userForm.showError('access_key', frm, 'required')"
i18n>This field is required.</span>
</div>
</div>
<!-- Secret key -->
<div class="form-group row"
*ngIf="!editing && !userForm.getValue('generate_key')">
<label class="cd-col-form-label required"
for="secret_key"
i18n>Secret key</label>
<div class="cd-col-form-input">
<div class="input-group">
<input id="secret_key"
class="form-control"
type="password"
formControlName="secret_key">
<button type="button"
class="btn btn-light"
cdPasswordButton="secret_key">
</button>
<cd-copy-2-clipboard-button source="secret_key">
</cd-copy-2-clipboard-button>
</div>
<span class="invalid-feedback"
*ngIf="userForm.showError('secret_key', frm, 'required')"
i18n>This field is required.</span>
</div>
</div>
</fieldset>
<!-- Subusers -->
<fieldset *ngIf="editing">
<legend i18n>Subusers</legend>
<div class="row">
<div class="cd-col-form-offset">
<span *ngIf="subusers.length === 0"
class="no-border">
<span class="form-text text-muted"
i18n>There are no subusers.</span>
</span>
<span *ngFor="let subuser of subusers; let i=index;">
<div class="input-group">
<span class="input-group-text">
<i class="{{ icons.user }}"></i>
</span>
<input type="text"
class="cd-form-control"
value="{{ subuser.id }}"
readonly>
<span class="input-group-text">
<i class="{{ icons.share }}"></i>
</span>
<input type="text"
class="cd-form-control"
value="{{ ('full-control' === subuser.permissions) ? 'full' : subuser.permissions }}"
readonly>
<button type="button"
class="btn btn-light tc_showSubuserButton"
i18n-ngbTooltip
ngbTooltip="Edit"
(click)="showSubuserModal(i)">
<i [ngClass]="[icons.edit]"></i>
</button>
<button type="button"
class="btn btn-light tc_deleteSubuserButton"
i18n-ngbTooltip
ngbTooltip="Delete"
(click)="deleteSubuser(i)">
<i [ngClass]="[icons.destroy]"></i>
</button>
</div>
<span class="form-text text-muted"></span>
</span>
<div class="row my-2">
<div class="col-12">
<button type="button"
class="btn btn-light float-end tc_addSubuserButton"
(click)="showSubuserModal()">
<i [ngClass]="[icons.add]"></i>
<ng-container i18n>{{ actionLabels.CREATE | titlecase }}
{{ subuserLabel | upperFirst }}</ng-container>
</button>
</div>
</div>
<span class="help-block"></span>
</div>
</div>
</fieldset>
<!-- Keys -->
<fieldset *ngIf="editing">
<legend i18n>Keys</legend>
<!-- S3 keys -->
<div class="form-group row">
<label class="cd-col-form-label"
i18n>S3</label>
<div class="cd-col-form-input">
<span *ngIf="s3Keys.length === 0"
class="no-border">
<span class="form-text text-muted"
i18n>There are no keys.</span>
</span>
<span *ngFor="let key of s3Keys; let i=index;">
<div class="input-group">
<div class="input-group-text">
<i class="{{ icons.key }}"></i>
</div>
<input type="text"
class="cd-form-control"
value="{{ key.user }}"
readonly>
<button type="button"
class="btn btn-light tc_showS3KeyButton"
i18n-ngbTooltip
ngbTooltip="Show"
(click)="showS3KeyModal(i)">
<i [ngClass]="[icons.show]"></i>
</button>
<button type="button"
class="btn btn-light tc_deleteS3KeyButton"
i18n-ngbTooltip
ngbTooltip="Delete"
(click)="deleteS3Key(i)">
<i [ngClass]="[icons.destroy]"></i>
</button>
</div>
<span class="form-text text-muted"></span>
</span>
<div class="row my-2">
<div class="col-12">
<button type="button"
class="btn btn-light float-end tc_addS3KeyButton"
(click)="showS3KeyModal()">
<i [ngClass]="[icons.add]"></i>
<ng-container i18n>{{ actionLabels.CREATE | titlecase }}
{{ s3keyLabel | upperFirst }}</ng-container>
</button>
</div>
</div>
<span class="help-block"></span>
</div>
<hr>
</div>
<!-- Swift keys -->
<div class="form-group row">
<label class="cd-col-form-label"
i18n>Swift</label>
<div class="cd-col-form-input">
<span *ngIf="swiftKeys.length === 0"
class="no-border">
<span class="form-text text-muted"
i18n>There are no keys.</span>
</span>
<span *ngFor="let key of swiftKeys; let i=index;">
<div class="input-group">
<span class="input-group-text">
<i class="{{ icons.key }}"></i>
</span>
<input type="text"
class="cd-form-control"
value="{{ key.user }}"
readonly>
<button type="button"
class="btn btn-light tc_showSwiftKeyButton"
i18n-ngbTooltip
ngbTooltip="Show"
(click)="showSwiftKeyModal(i)">
<i [ngClass]="[icons.show]"></i>
</button>
</div>
<span class="form-text text-muted"></span>
</span>
</div>
</div>
</fieldset>
<!-- Capabilities -->
<fieldset *ngIf="editing">
<legend i18n>Capabilities</legend>
<div class="form-group row">
<div class="cd-col-form-offset">
<span *ngIf="capabilities.length === 0"
class="no-border">
<span class="form-text text-muted"
i18n>There are no capabilities.</span>
</span>
<span *ngFor="let cap of capabilities; let i=index;">
<div class="input-group">
<div class="input-group-text">
<i class="{{ icons.share }}"></i>
</div>
<input type="text"
class="cd-form-control"
value="{{ cap.type }}:{{ cap.perm }}"
readonly>
<button type="button"
class="btn btn-light tc_editCapButton"
i18n-ngbTooltip
ngbTooltip="Edit"
(click)="showCapabilityModal(i)">
<i [ngClass]="[icons.edit]"></i>
</button>
<button type="button"
class="btn btn-light tc_deleteCapButton"
i18n-ngbTooltip
ngbTooltip="Delete"
(click)="deleteCapability(i)">
<i [ngClass]="[icons.destroy]"></i>
</button>
</div>
<span class="form-text text-muted"></span>
</span>
<div class="row my-2">
<div class="col-12">
<button type="button"
class="btn btn-light float-end tc_addCapButton"
[disabled]="capabilities | pipeFunction:hasAllCapabilities"
i18n-ngbTooltip
ngbTooltip="All capabilities are already added."
[disableTooltip]="!(capabilities | pipeFunction:hasAllCapabilities)"
triggers="pointerenter:pointerleave"
(click)="showCapabilityModal()">
<i [ngClass]="[icons.add]"></i>
<ng-container i18n>{{ actionLabels.ADD | titlecase }}
{{ capabilityLabel | upperFirst }}</ng-container>
</button>
</div>
</div>
<span class="help-block"></span>
</div>
</div>
</fieldset>
<!-- User quota -->
<fieldset>
<legend i18n>User quota</legend>
<!-- Enabled -->
<div class="form-group row">
<div class="cd-col-form-offset">
<div class="custom-control custom-checkbox">
<input class="custom-control-input"
id="user_quota_enabled"
type="checkbox"
formControlName="user_quota_enabled">
<label class="custom-control-label"
for="user_quota_enabled"
i18n>Enabled</label>
</div>
</div>
</div>
<!-- Unlimited size -->
<div class="form-group row"
*ngIf="userForm.controls.user_quota_enabled.value">
<div class="cd-col-form-offset">
<div class="custom-control custom-checkbox">
<input class="custom-control-input"
id="user_quota_max_size_unlimited"
type="checkbox"
formControlName="user_quota_max_size_unlimited">
<label class="custom-control-label"
for="user_quota_max_size_unlimited"
i18n>Unlimited size</label>
</div>
</div>
</div>
<!-- Maximum size -->
<div class="form-group row"
*ngIf="userForm.controls.user_quota_enabled.value && !userForm.getValue('user_quota_max_size_unlimited')">
<label class="cd-col-form-label required"
for="user_quota_max_size"
i18n>Max. size</label>
<div class="cd-col-form-input">
<input id="user_quota_max_size"
class="form-control"
type="text"
formControlName="user_quota_max_size"
cdDimlessBinary>
<span class="invalid-feedback"
*ngIf="userForm.showError('user_quota_max_size', frm, 'required')"
i18n>This field is required.</span>
<span class="invalid-feedback"
*ngIf="userForm.showError('user_quota_max_size', frm, 'quotaMaxSize')"
i18n>The value is not valid.</span>
</div>
</div>
<!-- Unlimited objects -->
<div class="form-group row"
*ngIf="userForm.controls.user_quota_enabled.value">
<div class="cd-col-form-offset">
<div class="custom-control custom-checkbox">
<input class="custom-control-input"
id="user_quota_max_objects_unlimited"
type="checkbox"
formControlName="user_quota_max_objects_unlimited">
<label class="custom-control-label"
for="user_quota_max_objects_unlimited"
i18n>Unlimited objects</label>
</div>
</div>
</div>
<!-- Maximum objects -->
<div class="form-group row"
*ngIf="userForm.controls.user_quota_enabled.value && !userForm.getValue('user_quota_max_objects_unlimited')">
<label class="cd-col-form-label required"
for="user_quota_max_objects"
i18n>Max. objects</label>
<div class="cd-col-form-input">
<input id="user_quota_max_objects"
class="form-control"
type="number"
formControlName="user_quota_max_objects"
min="0">
<span class="invalid-feedback"
*ngIf="userForm.showError('user_quota_max_objects', frm, 'required')"
i18n>This field is required.</span>
<span class="invalid-feedback"
*ngIf="userForm.showError('user_quota_max_objects', frm, 'min')"
i18n>The entered value must be >= 0.</span>
</div>
</div>
</fieldset>
<!-- Bucket quota -->
<fieldset>
<legend i18n>Bucket quota</legend>
<!-- Enabled -->
<div class="form-group row">
<div class="cd-col-form-offset">
<div class="custom-control custom-checkbox">
<input class="custom-control-input"
id="bucket_quota_enabled"
type="checkbox"
formControlName="bucket_quota_enabled">
<label class="custom-control-label"
for="bucket_quota_enabled"
i18n>Enabled</label>
</div>
</div>
</div>
<!-- Unlimited size -->
<div class="form-group row"
*ngIf="userForm.controls.bucket_quota_enabled.value">
<div class="cd-col-form-offset">
<div class="custom-control custom-checkbox">
<input class="custom-control-input"
id="bucket_quota_max_size_unlimited"
type="checkbox"
formControlName="bucket_quota_max_size_unlimited">
<label class="custom-control-label"
for="bucket_quota_max_size_unlimited"
i18n>Unlimited size</label>
</div>
</div>
</div>
<!-- Maximum size -->
<div class="form-group row"
*ngIf="userForm.controls.bucket_quota_enabled.value && !userForm.getValue('bucket_quota_max_size_unlimited')">
<label class="cd-col-form-label required"
for="bucket_quota_max_size"
i18n>Max. size</label>
<div class="cd-col-form-input">
<input id="bucket_quota_max_size"
class="form-control"
type="text"
formControlName="bucket_quota_max_size"
cdDimlessBinary>
<span class="invalid-feedback"
*ngIf="userForm.showError('bucket_quota_max_size', frm, 'required')"
i18n>This field is required.</span>
<span class="invalid-feedback"
*ngIf="userForm.showError('bucket_quota_max_size', frm, 'quotaMaxSize')"
i18n>The value is not valid.</span>
</div>
</div>
<!-- Unlimited objects -->
<div class="form-group row"
*ngIf="userForm.controls.bucket_quota_enabled.value">
<div class="cd-col-form-offset">
<div class="custom-control custom-checkbox">
<input class="custom-control-input"
id="bucket_quota_max_objects_unlimited"
type="checkbox"
formControlName="bucket_quota_max_objects_unlimited">
<label class="custom-control-label"
for="bucket_quota_max_objects_unlimited"
i18n>Unlimited objects</label>
</div>
</div>
</div>
<!-- Maximum objects -->
<div class="form-group row"
*ngIf="userForm.controls.bucket_quota_enabled.value && !userForm.getValue('bucket_quota_max_objects_unlimited')">
<label class="cd-col-form-label required"
for="bucket_quota_max_objects"
i18n>Max. objects</label>
<div class="cd-col-form-input">
<input id="bucket_quota_max_objects"
class="form-control"
type="number"
formControlName="bucket_quota_max_objects"
min="0">
<span class="invalid-feedback"
*ngIf="userForm.showError('bucket_quota_max_objects', frm, 'required')"
i18n>This field is required.</span>
<span class="invalid-feedback"
*ngIf="userForm.showError('bucket_quota_max_objects', frm, 'min')"
i18n>The entered value must be >= 0.</span>
</div>
</div>
</fieldset>
</div>
<div class="card-footer">
<cd-form-button-panel (submitActionEvent)="onSubmit()"
[form]="userForm"
[submitText]="(action | titlecase) + ' ' + (resource | upperFirst)"
wrappingClass="text-right"></cd-form-button-panel>
</div>
</div>
</form>
</div>
| 26,814 | 40.190476 | 128 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-list/rgw-user-list.component.html
|
<cd-rgw-user-tabs></cd-rgw-user-tabs>
<cd-table #table
[autoReload]="false"
[data]="users"
[columns]="columns"
columnMode="flex"
selectionType="multiClick"
[hasDetails]="true"
(setExpandedRow)="setExpandedRow($event)"
(updateSelection)="updateSelection($event)"
identifier="uid"
(fetchData)="getUserList($event)"
[status]="tableStatus">
<cd-table-actions class="table-actions"
[permission]="permission"
[selection]="selection"
[tableActions]="tableActions">
</cd-table-actions>
<cd-rgw-user-details cdTableDetail
[selection]="expandedRow">
</cd-rgw-user-details>
</cd-table>
<ng-template #userSizeTpl
let-row="row">
<cd-usage-bar *ngIf="row.user_quota.max_size > 0 && row.user_quota.enabled; else noSizeQuota"
[total]="row.user_quota.max_size"
[used]="row.stats.size_actual">
</cd-usage-bar>
<ng-template #noSizeQuota
i18n>No Limit</ng-template>
</ng-template>
<ng-template #userObjectTpl
let-row="row">
<cd-usage-bar *ngIf="row.user_quota.max_objects > 0 && row.user_quota.enabled; else noObjectQuota"
[total]="row.user_quota.max_objects"
[used]="row.stats.num_objects"
[isBinary]="false">
</cd-usage-bar>
<ng-template #noObjectQuota
i18n>No Limit</ng-template>
</ng-template>
| 1,532 | 31.617021 | 100 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-s3-key-modal/rgw-user-s3-key-modal.component.html
|
<cd-modal [modalRef]="activeModal">
<ng-container i18n="form title"
class="modal-title">{{ action | titlecase }} {{ resource | upperFirst }}</ng-container>
<ng-container class="modal-content">
<form #frm="ngForm"
[formGroup]="formGroup"
novalidate>
<div class="modal-body">
<!-- Username -->
<div class="form-group row">
<label class="cd-col-form-label"
[ngClass]="{'required': !viewing}"
for="user"
i18n>Username</label>
<div class="cd-col-form-input">
<input id="user"
class="form-control"
type="text"
*ngIf="viewing"
[readonly]="true"
formControlName="user">
<select id="user"
class="form-control"
formControlName="user"
*ngIf="!viewing"
autofocus>
<option i18n
*ngIf="userCandidates !== null"
[ngValue]="null">-- Select a username --</option>
<option *ngFor="let userCandidate of userCandidates"
[value]="userCandidate">{{ userCandidate }}</option>
</select>
<span class="invalid-feedback"
*ngIf="formGroup.showError('user', frm, 'required')"
i18n>This field is required.</span>
</div>
</div>
<!-- Auto-generate key -->
<div class="form-group row"
*ngIf="!viewing">
<div class="cd-col-form-offset">
<div class="custom-control custom-checkbox">
<input class="custom-control-input"
id="generate_key"
type="checkbox"
formControlName="generate_key">
<label class="custom-control-label"
for="generate_key"
i18n>Auto-generate key</label>
</div>
</div>
</div>
<!-- Access key -->
<div class="form-group row"
*ngIf="!formGroup.getValue('generate_key')">
<label class="cd-col-form-label"
[ngClass]="{'required': !viewing}"
for="access_key"
i18n>Access key</label>
<div class="cd-col-form-input">
<div class="input-group">
<input id="access_key"
class="form-control"
type="password"
[readonly]="viewing"
formControlName="access_key">
<button type="button"
class="btn btn-light"
cdPasswordButton="access_key">
</button>
<cd-copy-2-clipboard-button source="access_key">
</cd-copy-2-clipboard-button>
</div>
<span class="invalid-feedback"
*ngIf="formGroup.showError('access_key', frm, 'required')"
i18n>This field is required.</span>
</div>
</div>
<!-- Secret key -->
<div class="form-group row"
*ngIf="!formGroup.getValue('generate_key')">
<label class="cd-col-form-label"
[ngClass]="{'required': !viewing}"
for="secret_key"
i18n>Secret key</label>
<div class="cd-col-form-input">
<div class="input-group">
<input id="secret_key"
class="form-control"
type="password"
[readonly]="viewing"
formControlName="secret_key">
<button type="button"
class="btn btn-light"
cdPasswordButton="secret_key">
</button>
<cd-copy-2-clipboard-button source="secret_key">
</cd-copy-2-clipboard-button>
</div>
<span class="invalid-feedback"
*ngIf="formGroup.showError('secret_key', frm, 'required')"
i18n>This field is required.</span>
</div>
</div>
</div>
<div class="modal-footer">
<cd-form-button-panel (submitActionEvent)="onSubmit()"
[form]="formGroup"
[submitText]="(action | titlecase) + ' ' + (resource | upperFirst)"
[showSubmit]="!viewing"></cd-form-button-panel>
</div>
</form>
</ng-container>
</cd-modal>
| 4,615 | 36.836066 | 103 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-subuser-modal/rgw-user-subuser-modal.component.html
|
<cd-modal [modalRef]="bsModalRef">
<ng-container i18n="form title"
class="modal-title">{{ action | titlecase }} {{ resource | upperFirst }}</ng-container>
<ng-container class="modal-content">
<form #frm="ngForm"
[formGroup]="formGroup"
novalidate>
<div class="modal-body">
<!-- Username -->
<div class="form-group row">
<label class="cd-col-form-label"
for="uid"
i18n>Username</label>
<div class="cd-col-form-input">
<input id="uid"
class="form-control"
type="text"
formControlName="uid"
[readonly]="true">
</div>
</div>
<!-- Subuser -->
<div class="form-group row">
<label class="cd-col-form-label"
[ngClass]="{'required': !editing}"
for="subuid"
i18n>Subuser</label>
<div class="cd-col-form-input">
<input id="subuid"
class="form-control"
type="text"
formControlName="subuid"
[readonly]="editing"
autofocus>
<span class="invalid-feedback"
*ngIf="formGroup.showError('subuid', frm, 'required')"
i18n>This field is required.</span>
<span class="invalid-feedback"
*ngIf="formGroup.showError('subuid', frm, 'subuserIdExists')"
i18n>The chosen subuser ID is already in use.</span>
</div>
</div>
<!-- Permission -->
<div class="form-group row">
<label class="cd-col-form-label required"
for="perm"
i18n>Permission</label>
<div class="cd-col-form-input">
<select id="perm"
class="form-select"
formControlName="perm">
<option i18n
[ngValue]="null">-- Select a permission --</option>
<option *ngFor="let perm of ['read', 'write']"
[value]="perm">
{{ perm }}
</option>
<option i18n
value="read-write">read, write</option>
<option i18n
value="full-control">full</option>
</select>
<span class="invalid-feedback"
*ngIf="formGroup.showError('perm', frm, 'required')"
i18n>This field is required.</span>
</div>
</div>
<!-- Swift key -->
<fieldset *ngIf="!editing">
<legend i18n>Swift key</legend>
<!-- Auto-generate key -->
<div class="form-group row">
<div class="cd-col-form-offset">
<div class="custom-control custom-checkbox">
<input class="custom-control-input"
id="generate_secret"
type="checkbox"
formControlName="generate_secret">
<label class="custom-control-label"
for="generate_secret"
i18n>Auto-generate secret</label>
</div>
</div>
</div>
<!-- Secret key -->
<div class="form-group row"
*ngIf="!editing && !formGroup.getValue('generate_secret')">
<label class="cd-col-form-label required"
for="secret_key"
i18n>Secret key</label>
<div class="cd-col-form-input">
<div class="input-group">
<input id="secret_key"
class="form-control"
type="password"
formControlName="secret_key">
<button type="button"
class="btn btn-light"
cdPasswordButton="secret_key">
</button>
<cd-copy-2-clipboard-button source="secret_key">
</cd-copy-2-clipboard-button>
</div>
<span class="invalid-feedback"
*ngIf="formGroup.showError('secret_key', frm, 'required')"
i18n>This field is required.</span>
</div>
</div>
</fieldset>
</div>
<div class="modal-footer">
<cd-form-button-panel (submitActionEvent)="onSubmit()"
[form]="formGroup"
[submitText]="(action | titlecase) + ' ' + (resource | upperFirst)"></cd-form-button-panel>
</div>
</form>
</ng-container>
</cd-modal>
| 4,714 | 36.125984 | 121 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-swift-key-modal/rgw-user-swift-key-modal.component.html
|
<cd-modal [modalRef]="activeModal">
<ng-container i18n="form title"
class="modal-title">{{ action | titlecase }} {{ resource | upperFirst }}</ng-container>
<ng-container class="modal-content">
<div class="modal-body">
<form novalidate>
<!-- Username -->
<div class="form-group row">
<label class="cd-col-form-label"
for="user"
i18n>Username</label>
<div class="cd-col-form-input">
<input id="user"
name="user"
class="form-control"
type="text"
[readonly]="true"
[(ngModel)]="user">
</div>
</div>
<!-- Secret key -->
<div class="form-group row">
<label class="cd-col-form-label"
for="secret_key"
i18n>Secret key</label>
<div class="cd-col-form-input">
<div class="input-group">
<input id="secret_key"
name="secret_key"
class="form-control"
type="password"
[(ngModel)]="secret_key"
[readonly]="true">
<button type="button"
class="btn btn-light"
cdPasswordButton="secret_key">
</button>
<cd-copy-2-clipboard-button source="secret_key">
</cd-copy-2-clipboard-button>
</div>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<cd-back-button (backAction)="activeModal.close()"></cd-back-button>
</div>
</ng-container>
</cd-modal>
| 1,714 | 31.358491 | 103 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-tabs/rgw-user-tabs.component.html
|
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link"
routerLink="/rgw/user"
routerLinkActive="active"
ariaCurrentWhenActive="page"
[routerLinkActiveOptions]="{exact: true}"
i18n>Users</a>
</li>
<li class="nav-item">
<a class="nav-link"
routerLink="/rgw/roles"
routerLinkActive="active"
ariaCurrentWhenActive="page"
[routerLinkActiveOptions]="{exact: true}"
i18n>Roles</a>
</li>
</ul>
| 485 | 24.578947 | 48 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/device-list/device-list.component.html
|
<cd-table *ngIf="hostname || osdId !== null"
[data]="devices"
[columns]="columns"></cd-table>
<cd-alert-panel type="warning"
*ngIf="hostname === '' && osdId === null"
i18n>Neither hostname nor OSD ID given</cd-alert-panel>
<ng-template #deviceLocation
let-value="value">
<ng-container *ngFor="let location of value">
<cd-label *ngIf="location.host === hostname"
[value]="location.dev"></cd-label>
</ng-container>
</ng-template>
<ng-template #daemonName
let-value="value">
<ng-container [ngTemplateOutlet]="osdId !== null ? osdIdDaemon : readableDaemons"
[ngTemplateOutletContext]="{daemons: value}">
</ng-container>
</ng-template>
<ng-template #osdIdDaemon
let-daemons="daemons">
<ng-container *ngFor="let daemon of daemons">
<cd-label *ngIf="daemon.includes(osdId)"
[value]="daemon"></cd-label>
</ng-container>
</ng-template>
<ng-template #readableDaemons
let-daemons="daemons">
<ng-container *ngFor="let daemon of daemons">
<cd-label class="me-1"
[value]="daemon"></cd-label>
</ng-container>
</ng-template>
<ng-template #lifeExpectancy
let-value="value">
<span *ngIf="!value.life_expectancy_enabled"
i18n>{{ "" | notAvailable }}</span>
<span *ngIf="value.min && !value.max">> {{value.min | i18nPlural: translationMapping}}</span>
<span *ngIf="value.max && !value.min">< {{value.max | i18nPlural: translationMapping}}</span>
<span *ngIf="value.max && value.min">{{value.min}} to {{value.max | i18nPlural: translationMapping}}</span>
</ng-template>
<ng-template #lifeExpectancyTimestamp
let-value="value">
{{value}}
</ng-template>
| 1,779 | 31.962963 | 109 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/feedback/feedback.component.html
|
<cd-modal [modalRef]="activeModal">
<div class="modal-title"
i18n>Report an issue</div>
<div class="modal-content">
<form name="feedbackForm"
[formGroup]="feedbackForm"
#formDir="ngForm">
<div class="modal-body">
<cd-alert-panel *ngIf="!isFeedbackEnabled"
type="error"
i18n>Feedback module is not enabled. Please enable it from <a (click)="redirect()">Cluster-> Manager Modules.</a>
</cd-alert-panel>
<!-- api_key -->
<div class="form-group row mt-3"
*ngIf="!isAPIKeySet">
<label class="cd-col-form-label required"
for="api_key"
i18n>Ceph Tracker API Key</label>
<div class="cd-col-form-input">
<input id="api_key"
type="password"
formControlName="api_key"
class="form-control"
placeholder="Add Ceph tracker API key">
<span class="invalid-feedback"
*ngIf="feedbackForm.showError('api_key', formDir, 'required')"
i18n>Ceph Tracker API key is required.</span>
<span class="invalid-feedback"
*ngIf="feedbackForm.showError('api_key', formDir, 'invalidApiKey')"
i18n>Ceph Tracker API key is invalid.</span>
</div>
</div>
<!-- project -->
<div class="form-group row">
<label class="cd-col-form-label required"
for="project"
i18n>Project name</label>
<div class="cd-col-form-input">
<select class="form-control"
id="project"
formControlName="project">
<option ngValue=""
i18n>-- Select a project --</option>
<option *ngFor="let projectName of project"
[value]="projectName">{{ projectName }}</option>
</select>
<span class="invalid-feedback"
*ngIf="feedbackForm.showError('project', formDir, 'required')"
i18n>Project name is required.</span>
</div>
</div>
<!-- tracker -->
<div class="form-group row">
<label class="cd-col-form-label required"
for="tracker"
i18n>Tracker</label>
<div class="cd-col-form-input">
<select class="form-control"
id="tracker"
formControlName="tracker">
<option ngValue=""
i18n>-- Select a tracker --</option>
<option *ngFor="let trackerName of tracker"
[value]="trackerName">{{ trackerName }}</option>
</select>
<span class="invalid-feedback"
*ngIf="feedbackForm.showError('tracker', formDir, 'required')"
i18n>Tracker name is required.</span>
</div>
</div>
<!-- subject -->
<div class="form-group row">
<label class="cd-col-form-label required"
for="subject"
i18n>Subject</label>
<div class="cd-col-form-input">
<input id="subject"
type="text"
formControlName="subject"
class="form-control"
placeholder="Add issue title">
<span class="invalid-feedback"
*ngIf="feedbackForm.showError('subject', formDir, 'required')"
i18n>Subject is required.</span>
</div>
</div>
<!-- description -->
<div class="form-group row">
<label class="cd-col-form-label required"
for="description"
i18n>Description</label>
<div class="cd-col-form-input">
<textarea id="description"
type="text"
formControlName="description"
class="form-control"
placeholder="Add issue description">
</textarea>
<span class="invalid-feedback"
*ngIf="feedbackForm.showError('description', formDir, 'required')"
i18n>Description is required.</span>
</div>
</div>
</div>
<div class="modal-footer">
<cd-form-button-panel (submitActionEvent)="onSubmit()"
[form]="feedbackForm"
[submitText]="actionLabels.SUBMIT"
wrappingClass="text-right">
</cd-form-button-panel>
</div>
</form>
</div>
</cd-modal>
| 4,717 | 37.991736 | 137 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/smart-list/smart-list.component.html
|
<ng-container *ngIf="!loading; else isLoading">
<cd-alert-panel *ngIf="error"
type="error"
i18n>Failed to retrieve SMART data.</cd-alert-panel>
<cd-alert-panel *ngIf="incompatible"
type="warning"
i18n>The data received has the JSON format version 2.x and is currently incompatible with the
dashboard.</cd-alert-panel>
<ng-container *ngIf="!error && !incompatible">
<cd-alert-panel *ngIf="data | pipeFunction:isEmpty"
type="info"
i18n>No SMART data available.</cd-alert-panel>
<ng-container *ngIf="!(data | pipeFunction:isEmpty)">
<nav ngbNav
#nav="ngbNav"
class="nav-tabs">
<ng-container ngbNavItem
*ngFor="let device of data | keyvalue">
<a ngbNavLink>{{ device.value.device }} ({{ device.value.identifier }})</a>
<ng-template ngbNavContent>
<ng-container *ngIf="device.value.error; else noError">
<cd-alert-panel id="alert-error"
type="warning">{{ device.value.userMessage }}</cd-alert-panel>
</ng-container>
<ng-template #noError>
<cd-alert-panel *ngIf="device.value.info?.smart_status | pipeFunction:isEmpty; else hasSmartStatus"
id="alert-self-test-unknown"
size="slim"
type="warning"
i18n-title
title="SMART overall-health self-assessment test result"
i18n>unknown</cd-alert-panel>
<ng-template #hasSmartStatus>
<!-- HDD/NVMe self test -->
<ng-container *ngIf="device.value.info.smart_status.passed; else selfTestFailed">
<cd-alert-panel id="alert-self-test-passed"
size="slim"
type="info"
i18n-title
title="SMART overall-health self-assessment test result"
i18n>passed</cd-alert-panel>
</ng-container>
<ng-template #selfTestFailed>
<cd-alert-panel id="alert-self-test-failed"
size="slim"
type="warning"
i18n-title
title="SMART overall-health self-assessment test result"
i18n>failed</cd-alert-panel>
</ng-template>
</ng-template>
</ng-template>
<ng-container *ngIf="!(device.value.info | pipeFunction:isEmpty) || !(device.value.smart | pipeFunction:isEmpty)">
<nav ngbNav
#innerNav="ngbNav"
class="nav-tabs">
<li [ngbNavItem]="1">
<a ngbNavLink
i18n>Device Information</a>
<ng-template ngbNavContent>
<cd-table-key-value *ngIf="!(device.value.info | pipeFunction:isEmpty)"
[renderObjects]="true"
[data]="device.value.info"></cd-table-key-value>
<cd-alert-panel *ngIf="device.value.info | pipeFunction:isEmpty"
id="alert-device-info-unavailable"
type="info"
i18n>No device information available for this device.</cd-alert-panel>
</ng-template>
</li>
<li [ngbNavItem]="2">
<a ngbNavLink
i18n>SMART</a>
<ng-template ngbNavContent>
<cd-table *ngIf="device.value.smart?.attributes"
[data]="device.value.smart.attributes.table"
updateSelectionOnRefresh="never"
[columns]="smartDataColumns"></cd-table>
<cd-table-key-value *ngIf="device.value.smart?.scsi_error_counter_log"
[renderObjects]="true"
[data]="device.value.smart"
updateSelectionOnRefresh="never"></cd-table-key-value>
<cd-table-key-value *ngIf="device.value.smart?.nvmeData"
[renderObjects]="true"
[data]="device.value.smart.nvmeData"
updateSelectionOnRefresh="never"></cd-table-key-value>
<cd-alert-panel *ngIf="!device.value.smart?.attributes && !device.value.smart?.nvmeData && !device.value.smart?.scsi_error_counter_log"
id="alert-device-smart-data-unavailable"
type="info"
i18n>No SMART data available for this device.</cd-alert-panel>
</ng-template>
</li>
</nav>
<div [ngbNavOutlet]="innerNav"></div>
</ng-container>
</ng-template>
</ng-container>
</nav>
<div [ngbNavOutlet]="nav"></div>
</ng-container>
</ng-container>
</ng-container>
<ng-template #isLoading>
<cd-loading-panel i18n>SMART data is loading.</cd-loading-panel>
</ng-template>
| 5,596 | 49.423423 | 155 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/core/auth/login-password-form/login-password-form.component.html
|
<div>
<h2 i18n>Please set a new password.</h2>
<h4 i18n>You will be redirected to the login page afterwards.</h4>
<form #frm="ngForm"
[formGroup]="userForm"
novalidate>
<!-- Old password -->
<div class="form-group has-feedback">
<div class="input-group">
<input class="form-control"
type="password"
placeholder="Old password..."
id="oldpassword"
formControlName="oldpassword"
autocomplete="new-password"
autofocus>
<button class="btn btn-outline-light btn-password"
cdPasswordButton="oldpassword">
</button>
</div>
<span class="invalid-feedback"
*ngIf="userForm.showError('oldpassword', frm, 'required')"
i18n>This field is required.</span>
<span class="invalid-feedback"
*ngIf="userForm.showError('oldpassword', frm, 'notmatch')"
i18n>The old and new passwords must be different.</span>
</div>
<!-- New password -->
<div class="form-group has-feedback">
<div class="input-group">
<input class="form-control"
type="password"
placeholder="New password..."
id="newpassword"
autocomplete="new-password"
formControlName="newpassword">
<button type="button"
class="btn btn-outline-light btn-password"
cdPasswordButton="newpassword">
</button>
</div>
<div class="password-strength-level">
<div class="{{ passwordStrengthLevelClass }}"
data-toggle="tooltip"
title="{{ passwordValuation }}">
</div>
</div>
<span class="invalid-feedback"
*ngIf="userForm.showError('newpassword', frm, 'required')"
i18n>This field is required.</span>
<span class="invalid-feedback"
*ngIf="userForm.showError('newpassword', frm, 'notmatch')"
i18n>The old and new passwords must be different.</span>
<span class="invalid-feedback"
*ngIf="userForm.showError('newpassword', frm, 'passwordPolicy')">
{{ passwordValuation }}
</span>
</div>
<!-- Confirm new password -->
<div class="form-group has-feedback">
<div class="input-group">
<input class="form-control"
type="password"
autocomplete="new-password"
placeholder="Confirm new password..."
id="confirmnewpassword"
formControlName="confirmnewpassword">
<button class="btn btn-outline-light btn-password"
cdPasswordButton="confirmnewpassword">
</button>
</div>
<span class="invalid-feedback"
*ngIf="userForm.showError('confirmnewpassword', frm, 'required')"
i18n>This field is required.</span>
<span class="invalid-feedback"
*ngIf="userForm.showError('confirmnewpassword', frm, 'match')"
i18n>Password confirmation doesn't match the new password.</span>
</div>
<cd-form-button-panel (submitActionEvent)="onSubmit()"
(backActionEvent)="onCancel()"
[form]="userForm"
[disabled]="userForm.invalid"
[submitText]="(action | titlecase) + ' ' + (resource | upperFirst)"
wrappingClass="text-right"></cd-form-button-panel>
</form>
</div>
| 3,523 | 38.155556 | 93 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/core/auth/login/login.component.html
|
<div class="container"
*ngIf="isLoginActive">
<h1 class="sr-only">Ceph login</h1>
<form name="loginForm"
(ngSubmit)="login()"
#loginForm="ngForm"
novalidate>
<!-- Username -->
<div class="form-group has-feedback d-flex flex-column py-3">
<label class="placeholder ps-3"
for="username"
i18n>Username</label>
<input id="username"
name="username"
[(ngModel)]="model.username"
#username="ngModel"
type="text"
[attr.aria-invalid]="username.invalid"
aria-labelledby="username"
class="form-control ps-3"
required
autofocus>
<div class="invalid-feedback ps-3"
*ngIf="(loginForm.submitted || username.dirty) && username.invalid"
i18n>Username is required</div>
</div>
<!-- Password -->
<div class="form-group has-feedback"
id="password-div">
<div class="input-group d-flex flex-nowrap">
<div class="d-flex flex-column flex-grow-1 py-3">
<label class="placeholder ps-3"
for="password"
i18n>Password</label>
<input id="password"
name="password"
[(ngModel)]="model.password"
#password="ngModel"
type="password"
[attr.aria-invalid]="password.invalid"
aria-labelledby="password"
class="form-control ps-3"
required>
<div class="invalid-feedback ps-3"
*ngIf="(loginForm.submitted || password.dirty) && password.invalid"
i18n>Password is required</div>
</div>
<span class="form-group-append">
<button type="button"
class="btn btn-outline-light btn-password h-100 px-4"
cdPasswordButton="password"
aria-label="toggle-password">
</button>
</span>
</div>
</div>
<input type="submit"
class="btn btn-accent px-5 py-2"
[disabled]="loginForm.invalid"
value="Log in"
i18n-value>
</form>
</div>
| 2,219 | 32.134328 | 82 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-details/role-details.component.html
|
<ng-container *ngIf="selection">
<cd-table [data]="scopes_permissions"
[columns]="columns"
columnMode="flex"
[toolHeader]="false"
[autoReload]="false"
[autoSave]="false"
[footer]="false"
[limit]="0">
</cd-table>
</ng-container>
| 316 | 25.416667 | 39 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-form/role-form.component.html
|
<div class="cd-col-form"
*cdFormLoading="loading">
<form name="roleForm"
#formDir="ngForm"
[formGroup]="roleForm"
novalidate>
<div class="card">
<div i18n="form title"
class="card-header">{{ action | titlecase }} {{ resource | upperFirst }}</div>
<div class="card-body">
<!-- Name -->
<div class="form-group row">
<label class="cd-col-form-label"
[ngClass]="{'required': mode !== roleFormMode.editing}"
for="name"
i18n>Name</label>
<div class="cd-col-form-input">
<input class="form-control"
type="text"
i18n-placeholder
placeholder="Name..."
id="name"
name="name"
formControlName="name"
autofocus>
<span class="invalid-feedback"
*ngIf="roleForm.showError('name', formDir, 'required')"
i18n>This field is required.</span>
<span class="invalid-feedback"
*ngIf="roleForm.showError('name', formDir, 'notUnique')"
i18n>The chosen name is already in use.</span>
</div>
</div>
<!-- Description -->
<div class="form-group row">
<label i18n
class="cd-col-form-label"
for="description">Description</label>
<div class="cd-col-form-input">
<input class="form-control"
type="text"
i18n-placeholder
placeholder="Description..."
id="description"
name="description"
formControlName="description">
</div>
</div>
<!-- Permissions -->
<div class="form-group row">
<label i18n
class="cd-col-form-label">Permissions</label>
<div class="cd-col-form-input">
<cd-table [data]="scopes_permissions"
[columns]="columns"
columnMode="flex"
[toolHeader]="false"
[autoReload]="false"
[autoSave]="false"
[footer]="false"
[limit]="0">
</cd-table>
</div>
</div>
</div>
<div class="card-footer">
<cd-form-button-panel (submitActionEvent)="submit()"
[form]="roleForm"
[submitText]="(action | titlecase) + ' ' + (resource | upperFirst)"
wrappingClass="text-right"></cd-form-button-panel>
</div>
</div>
</form>
</div>
<ng-template #cellScopeCheckboxTpl
let-column="column"
let-row="row"
let-value="value">
<div class="custom-control custom-checkbox">
<input class="custom-control-input"
id="scope_{{ row.scope }}"
type="checkbox"
[checked]="isRowChecked(row.scope)"
(change)="onClickCellCheckbox(row.scope, column.prop, $event)">
<label class="datatable-permissions-scope-cell-label custom-control-label"
for="scope_{{ row.scope }}">{{ value }}</label>
</div>
</ng-template>
<ng-template #cellPermissionCheckboxTpl
let-column="column"
let-row="row"
let-value="value">
<div class="custom-control custom-checkbox">
<input class="custom-control-input"
type="checkbox"
[checked]="value"
[id]="row.scope + '-' + column.prop"
(change)="onClickCellCheckbox(row.scope, column.prop, $event)">
<label class="custom-control-label"
[for]="row.scope + '-' + column.prop"></label>
</div>
</ng-template>
<ng-template #headerPermissionCheckboxTpl
let-column="column">
<div class="custom-control custom-checkbox">
<input class="custom-control-input"
id="header_{{ column.prop }}"
type="checkbox"
[checked]="isHeaderChecked(column.prop)"
(change)="onClickHeaderCheckbox(column.prop, $event)">
<label class="datatable-permissions-header-cell-label custom-control-label"
for="header_{{ column.prop }}">{{ column.name }}</label>
</div>
</ng-template>
| 4,381 | 34.918033 | 97 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-list/role-list.component.html
|
<cd-user-tabs></cd-user-tabs>
<cd-table [data]="roles"
columnMode="flex"
[columns]="columns"
identifier="name"
selectionType="single"
[hasDetails]="true"
(setExpandedRow)="setExpandedRow($event)"
(fetchData)="getRoles()"
(updateSelection)="updateSelection($event)">
<cd-table-actions class="table-actions"
[permission]="permission"
[selection]="selection"
[tableActions]="tableActions">
</cd-table-actions>
<cd-role-details cdTableDetail
[selection]="expandedRow"
[scopes]="scopes">
</cd-role-details>
</cd-table>
| 701 | 30.909091 | 54 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-form/user-form.component.html
|
<div class="cd-col-form"
*cdFormLoading="loading">
<form name="userForm"
#formDir="ngForm"
[formGroup]="userForm"
novalidate>
<div class="card">
<div i18n="form title"
class="card-header">{{ action | titlecase }} {{ resource | upperFirst }}</div>
<div class="card-body">
<!-- Username -->
<div class="form-group row">
<label class="cd-col-form-label"
[ngClass]="{'required': mode !== userFormMode.editing}"
for="username"
i18n>Username</label>
<div class="cd-col-form-input">
<input class="form-control"
type="text"
placeholder="Username..."
id="username"
name="username"
formControlName="username"
autocomplete="off"
autofocus>
<span class="invalid-feedback"
*ngIf="userForm.showError('username', formDir, 'required')"
i18n>This field is required.</span>
<span class="invalid-feedback"
*ngIf="userForm.showError('username', formDir, 'notUnique')"
i18n>The username already exists.</span>
</div>
</div>
<!-- Password -->
<div class="form-group row"
*ngIf="!authStorageService.isSSO()">
<label class="cd-col-form-label"
for="password">
<ng-container i18n>Password</ng-container>
<cd-helper *ngIf="passwordPolicyHelpText.length > 0"
class="text-pre-wrap"
html="{{ passwordPolicyHelpText }}">
</cd-helper>
</label>
<div class="cd-col-form-input">
<div class="input-group">
<input class="form-control"
type="password"
placeholder="Password..."
id="password"
name="password"
autocomplete="new-password"
formControlName="password">
<button type="button"
class="btn btn-light"
cdPasswordButton="password">
</button>
</div>
<div class="password-strength-level">
<div class="{{ passwordStrengthLevelClass }}"
data-toggle="tooltip"
title="{{ passwordValuation }}">
</div>
</div>
<span class="invalid-feedback"
*ngIf="userForm.showError('password', formDir, 'required')"
i18n>This field is required.</span>
<span class="invalid-feedback"
*ngIf="userForm.showError('password', formDir, 'passwordPolicy')">
{{ passwordValuation }}
</span>
</div>
</div>
<!-- Confirm password -->
<div class="form-group row"
*ngIf="!authStorageService.isSSO()">
<label i18n
class="cd-col-form-label"
for="confirmpassword">Confirm password</label>
<div class="cd-col-form-input">
<div class="input-group">
<input class="form-control"
type="password"
placeholder="Confirm password..."
id="confirmpassword"
name="confirmpassword"
autocomplete="new-password"
formControlName="confirmpassword">
<button type="button"
class="btn btn-light"
cdPasswordButton="confirmpassword">
</button>
<span class="invalid-feedback"
*ngIf="userForm.showError('confirmpassword', formDir, 'match')"
i18n>Password confirmation doesn't match the password.</span>
</div>
<span class="invalid-feedback"
*ngIf="userForm.showError('confirmpassword', formDir, 'required')"
i18n>This field is required.</span>
</div>
</div>
<!-- Password expiration date -->
<div class="form-group row"
*ngIf="!authStorageService.isSSO()">
<label class="cd-col-form-label"
[ngClass]="{'required': pwdExpirationSettings.pwdExpirationSpan > 0}"
for="pwdExpirationDate">
<ng-container i18n>Password expiration date</ng-container>
<cd-helper class="text-pre-wrap"
*ngIf="pwdExpirationSettings.pwdExpirationSpan == 0">
<p>
The Dashboard setting defining the expiration interval of
passwords is currently set to <strong>0</strong>. This means
if a date is set, the user password will only expire once.
</p>
<p>
Consider configuring the Dashboard setting
<a routerLink="/mgr-modules/edit/dashboard"
class="alert-link">USER_PWD_EXPIRATION_SPAN</a>
in order to let passwords expire periodically.
</p>
</cd-helper>
</label>
<div class="cd-col-form-input">
<div class="input-group">
<input class="form-control"
i18n-placeholder
placeholder="Password expiration date..."
id="pwdExpirationDate"
name="pwdExpirationDate"
formControlName="pwdExpirationDate"
[ngbPopover]="popContent"
triggers="manual"
#p="ngbPopover"
(click)="p.open()"
(keypress)="p.close()">
<button type="button"
class="btn btn-light"
(click)="clearExpirationDate()">
<i class="icon-prepend {{ icons.destroy }}"></i>
</button>
<span class="invalid-feedback"
*ngIf="userForm.showError('pwdExpirationDate', formDir, 'required')"
i18n>This field is required.</span>
</div>
</div>
</div>
<!-- Name -->
<div class="form-group row">
<label i18n
class="cd-col-form-label"
for="name">Full name</label>
<div class="cd-col-form-input">
<input class="form-control"
type="text"
placeholder="Full name..."
id="name"
name="name"
formControlName="name">
</div>
</div>
<!-- Email -->
<div class="form-group row">
<label i18n
class="cd-col-form-label"
for="email">Email</label>
<div class="cd-col-form-input">
<input class="form-control"
type="email"
placeholder="Email..."
id="email"
name="email"
formControlName="email">
<span class="invalid-feedback"
*ngIf="userForm.showError('email', formDir, 'email')"
i18n>Invalid email.</span>
</div>
</div>
<!-- Roles -->
<div class="form-group row">
<label class="cd-col-form-label"
i18n>Roles</label>
<div class="cd-col-form-input">
<span class="no-border full-height"
*ngIf="allRoles">
<cd-select-badges [data]="userForm.controls.roles.value"
[options]="allRoles"
[messages]="messages"></cd-select-badges>
</span>
</div>
</div>
<!-- Enabled -->
<div class="form-group row"
*ngIf="!isCurrentUser()">
<div class="cd-col-form-offset">
<div class="custom-control custom-checkbox">
<input type="checkbox"
class="custom-control-input"
id="enabled"
name="enabled"
formControlName="enabled">
<label class="custom-control-label"
for="enabled"
i18n>Enabled</label>
</div>
</div>
</div>
<!-- Force change password -->
<div class="form-group row"
*ngIf="!isCurrentUser() && !authStorageService.isSSO()">
<div class="cd-col-form-offset">
<div class="custom-control custom-checkbox">
<input type="checkbox"
class="custom-control-input"
id="pwdUpdateRequired"
name="pwdUpdateRequired"
formControlName="pwdUpdateRequired">
<label class="custom-control-label"
for="pwdUpdateRequired"
i18n>User must change password at next logon</label>
</div>
</div>
</div>
</div>
<div class="card-footer">
<cd-form-button-panel (submitActionEvent)="submit()"
[form]="userForm"
[submitText]="(action | titlecase) + ' ' + (resource | upperFirst)"
wrappingClass="text-right"></cd-form-button-panel>
</div>
</div>
</form>
</div>
<ng-template #removeSelfUserReadUpdatePermissionTpl>
<p><strong i18n>You are about to remove "user read / update" permissions from your own user.</strong></p>
<br>
<p i18n>If you continue, you will no longer be able to add or remove roles from any user.</p>
<ng-container i18n>Are you sure you want to continue?</ng-container>
</ng-template>
<ng-template #popContent>
<cd-date-time-picker [control]="userForm.get('pwdExpirationDate')"
[hasTime]="false"></cd-date-time-picker>
</ng-template>
| 10,135 | 38.286822 | 107 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-list/user-list.component.html
|
<cd-user-tabs></cd-user-tabs>
<cd-table [data]="users"
columnMode="flex"
[columns]="columns"
identifier="username"
selectionType="single"
(fetchData)="getUsers()"
(updateSelection)="updateSelection($event)">
<cd-table-actions class="table-actions"
[permission]="permission"
[selection]="selection"
[tableActions]="tableActions">
</cd-table-actions>
</cd-table>
<ng-template #userRolesTpl
let-value="value">
<span *ngFor="let role of value; last as isLast">
{{ role }}{{ !isLast ? ", " : "" }}
</span>
</ng-template>
<ng-template #warningTpl
let-column="column"
let-value="value"
let-row="row">
<div [class.border-danger]="row.remainingDays < this.expirationDangerAlert"
[class.border-warning]="row.remainingDays < this.expirationWarningAlert && row.remainingDays >= this.expirationDangerAlert"
class="border-margin">
<div class="warning-content"> {{ value }} </div>
</div>
</ng-template>
<ng-template #durationTpl
let-column="column"
let-value="value"
let-row="row">
<i *ngIf="row.remainingDays < this.expirationWarningAlert"
i18n-title
title="User's password is about to expire"
[class.icon-danger-color]="row.remainingDays < this.expirationDangerAlert"
[class.icon-warning-color]="row.remainingDays < this.expirationWarningAlert && row.remainingDays >= this.expirationDangerAlert"
class="{{ icons.warning }}"></i>
<span title="{{ value | cdDate }}">{{ row.remainingTimeWithoutSeconds / 1000 | duration }}</span>
</ng-template>
| 1,707 | 35.340426 | 132 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-password-form/user-password-form.component.html
|
<div class="cd-col-form">
<form #frm="ngForm"
[formGroup]="userForm"
novalidate>
<div class="card">
<div i18n="form title"
class="card-header">{{ action | titlecase }} {{ resource | upperFirst }}</div>
<div class="card-body">
<!-- Old password -->
<div class="form-group row">
<label class="cd-col-form-label required"
for="oldpassword"
i18n>Old password</label>
<div class="cd-col-form-input">
<div class="input-group">
<input class="form-control"
type="password"
placeholder="Old password..."
id="oldpassword"
formControlName="oldpassword"
autocomplete="new-password"
autofocus>
<button class="btn btn-light"
cdPasswordButton="oldpassword">
</button>
</div>
<span class="invalid-feedback"
*ngIf="userForm.showError('oldpassword', frm, 'required')"
i18n>This field is required.</span>
<span class="invalid-feedback"
*ngIf="userForm.showError('oldpassword', frm, 'notmatch')"
i18n>The old and new passwords must be different.</span>
</div>
</div>
<!-- New password -->
<div class="form-group row">
<label class="cd-col-form-label"
for="newpassword">
<span class="required"
i18n>New password</span>
<cd-helper *ngIf="passwordPolicyHelpText.length > 0"
class="text-pre-wrap"
html="{{ passwordPolicyHelpText }}">
</cd-helper>
</label>
<div class="cd-col-form-input">
<div class="input-group">
<input class="form-control"
type="password"
placeholder="Password..."
id="newpassword"
autocomplete="new-password"
formControlName="newpassword">
<button type="button"
class="btn btn-light"
cdPasswordButton="newpassword">
</button>
</div>
<div class="password-strength-level">
<div class="{{ passwordStrengthLevelClass }}"
data-toggle="tooltip"
title="{{ passwordValuation }}">
</div>
</div>
<span class="invalid-feedback"
*ngIf="userForm.showError('newpassword', frm, 'required')"
i18n>This field is required.</span>
<span class="invalid-feedback"
*ngIf="userForm.showError('newpassword', frm, 'notmatch')"
i18n>The old and new passwords must be different.</span>
<span class="invalid-feedback"
*ngIf="userForm.showError('newpassword', frm, 'passwordPolicy')">
{{ passwordValuation }}
</span>
</div>
</div>
<!-- Confirm new password -->
<div class="form-group row">
<label class="cd-col-form-label required"
for="confirmnewpassword"
i18n>Confirm new password</label>
<div class="cd-col-form-input">
<div class="input-group">
<input class="form-control"
type="password"
autocomplete="new-password"
placeholder="Confirm new password..."
id="confirmnewpassword"
formControlName="confirmnewpassword">
<button class="btn btn-light"
cdPasswordButton="confirmnewpassword">
</button>
</div>
<span class="invalid-feedback"
*ngIf="userForm.showError('confirmnewpassword', frm, 'required')"
i18n>This field is required.</span>
<span class="invalid-feedback"
*ngIf="userForm.showError('confirmnewpassword', frm, 'match')"
i18n>Password confirmation doesn't match the new password.</span>
</div>
</div>
</div>
<div class="card-footer">
<cd-form-button-panel (submitActionEvent)="onSubmit()"
[form]="userForm"
[submitText]="(action | titlecase) + ' ' + (resource | upperFirst)"
wrappingClass="text-right"></cd-form-button-panel>
</div>
</div>
</form>
</div>
| 4,719 | 39.689655 | 97 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-tabs/user-tabs.component.html
|
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link"
routerLink="/user-management/users"
routerLinkActive="active"
ariaCurrentWhenActive="page"
[routerLinkActiveOptions]="{exact: true}"
i18n>Users</a>
</li>
<li class="nav-item">
<a class="nav-link"
routerLink="/user-management/roles"
routerLinkActive="active"
ariaCurrentWhenActive="page"
[routerLinkActiveOptions]="{exact: true}"
i18n>Roles</a>
</li>
</ul>
| 510 | 25.894737 | 48 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/core/context/context.component.html
|
<ng-container *ngIf="{ ftMap: featureToggleMap$ | async, daemons: rgwDaemonService.daemons$ | async, selectedDaemon: rgwDaemonService.selectedDaemon$ | async } as data">
<ng-container *ngIf="data.ftMap && data.ftMap.rgw && permissions.rgw.read && isRgwRoute && data.daemons.length > 1">
<div class="cd-context-bar pt-3 pb-3">
<span class="me-1"
i18n>Selected Object Gateway:</span>
<div ngbDropdown
placement="bottom-left"
class="d-inline-block ms-2">
<button ngbDropdownToggle
class="btn btn-outline-info ctx-bar-selected-rgw-daemon"
i18n-title
title="Select Object Gateway">
{{ data.selectedDaemon.id }} ( {{ data.selectedDaemon.zonegroup_name }} )
</button>
<div ngbDropdownMenu>
<ng-container *ngFor="let daemon of data.daemons">
<button ngbDropdownItem
class="ctx-bar-available-rgw-daemon"
(click)="onDaemonSelection(daemon)">
{{ daemon.id }} ( {{ daemon.zonegroup_name }} )
</button>
</ng-container>
</div>
</div>
</div>
</ng-container>
</ng-container>
| 1,211 | 42.285714 | 169 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/core/error/error.component.html
|
<head>
<title>Error Page</title>
<base target="_blank">
</head>
<div class="container h-75">
<div class="row h-100 justify-content-center align-items-center">
<div class="blank-page">
<div *ngIf="header && message; else elseBlock">
<i [ngClass]="icon"
class="mx-auto d-block"></i>
<div class="mt-4 text-center">
<h3><b>{{ header }}</b></h3>
<h4 class="mt-3"
*ngIf="header !== message">{{ message }}</h4>
<h4 *ngIf="section"
i18n>Please consult the <a href="{{ docUrl }}">documentation</a> on how to configure and enable
the {{ sectionInfo }} management functionality.
</h4>
</div>
</div>
<div class="mt-4">
<div class="text-center"
*ngIf="(buttonName && buttonRoute) || uiConfig; else dashboardButton">
<button class="btn btn-primary ms-1"
[routerLink]="buttonRoute"
*ngIf="!uiConfig; else configureButtonTpl"
i18n>{{ buttonName }}</button>
<button class="btn btn-light ms-1"
[routerLink]="secondaryButtonRoute"
*ngIf="secondaryButtonName && secondaryButtonRoute"
i18n>{{ secondaryButtonName }}</button>
</div>
</div>
</div>
</div>
</div>
<ng-template #configureButtonTpl>
<button class="btn btn-primary"
(click)="doConfigure()"
[attr.title]="buttonTitle"
*ngIf="uiConfig"
i18n>{{ buttonName }}</button>
</ng-template>
<ng-template #elseBlock>
<i class="fa fa-exclamation-triangle mx-auto d-block text-danger"></i>
<div class="mt-4 text-center">
<h3 i18n><b>Page not Found</b></h3>
<h4 class="mt-4"
i18n>Sorry, we couldn’t find what you were looking for.
The page you requested may have been changed or moved.</h4>
</div>
</ng-template>
<ng-template #dashboardButton>
<div class="mt-4 text-center">
<button class="btn btn-primary"
[routerLink]="'/dashboard'"
i18n>Go To Dashboard</button>
</div>
</ng-template>
| 2,147 | 30.588235 | 109 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/core/layouts/blank-layout/blank-layout.component.html
|
<router-outlet></router-outlet>
| 32 | 15.5 | 31 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/core/layouts/login-layout/login-layout.component.html
|
<main class="login full-height">
<header>
<nav class="navbar p-4">
<a class="navbar-brand"></a>
<div class="form-inline">
<cd-language-selector></cd-language-selector>
</div>
</nav>
</header>
<section>
<div class="container">
<div class="row full-height">
<div class="col-sm-12 col-md-6 d-sm-block login-form">
<router-outlet></router-outlet>
</div>
<div class="col-sm-12 col-md-6 d-sm-block branding-info">
<img src="assets/Ceph_Ceph_Logo_with_text_white.svg"
alt="Ceph"
class="img-fluid pb-3">
<ul class="list-inline">
<li class="list-inline-item p-3"
*ngFor="let docItem of docItems">
<cd-doc section="{{ docItem.section }}"
docText="{{ docItem.text }}"
noSubscribe="true"
i18n-docText></cd-doc>
</li>
</ul>
<cd-custom-login-banner></cd-custom-login-banner>
</div>
</div>
</div>
</section>
</main>
| 1,095 | 30.314286 | 65 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/core/layouts/workbench-layout/workbench-layout.component.html
|
<block-ui>
<cd-navigation>
<div class="container-fluid h-100"
[ngClass]="{'dashboard': (router.url == '/dashboard' || router.url == '/dashboard_3')}">
<cd-context></cd-context>
<cd-breadcrumbs></cd-breadcrumbs>
<router-outlet></router-outlet>
</div>
</cd-navigation>
</block-ui>
| 316 | 27.818182 | 97 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/about/about.component.html
|
<div class="about-container">
<div class="modal-header">
<button type="button"
class="btn-close float-end"
aria-label="Close"
(click)="activeModal.close()">
</button>
</div>
<div class="modal-body">
<img src="assets/Ceph_Ceph_Logo_with_text_red_white.svg"
class="ceph-logo"
alt="{{ projectConstants.organization }}">
<h3>
<strong>{{ projectConstants.projectName }}</strong>
</h3>
<div class="product-versions">
<strong>Version</strong>
<br>
{{ versionNumber }}
{{ versionHash }}
<br>
{{ versionName }}
</div>
<br>
<dl>
<dt>Ceph Manager</dt>
<dd>{{ hostAddr }}</dd>
<dt>User</dt>
<dd>{{ modalVariables.user }}</dd>
<dt>User Role</dt>
<dd>{{ modalVariables.role }}</dd>
<dt>Browser</dt>
<dd>{{ modalVariables.browserName }}</dd>
<dt>Browser Version</dt>
<dd>{{ modalVariables.browserVersion }}</dd>
<dt>Browser OS</dt>
<dd>{{ modalVariables.browserOS }}</dd>
</dl>
</div>
<div class="modal-footer">
<div class="text-left">
{{ projectConstants.copyright }}
{{ projectConstants.license }}
</div>
</div>
</div>
| 1,246 | 25.531915 | 60 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/administration/administration.component.html
|
<div ngbDropdown
placement="bottom-right"
*ngIf="userPermission.read">
<a ngbDropdownToggle
class="dropdown-toggle"
i18n-title
title="Dashboard Settings"
role="button">
<i [ngClass]="[icons.deepCheck]"></i>
<span i18n
class="d-md-none">Dashboard Settings</span>
</a>
<div ngbDropdownMenu>
<button ngbDropdownItem
*ngIf="userPermission.read"
routerLink="/user-management"
i18n>User management</button>
<button ngbDropdownItem
*ngIf="configOptPermission.read"
routerLink="/telemetry"
i18n>Telemetry configuration</button>
</div>
</div>
| 670 | 26.958333 | 53 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/api-docs/api-docs.component.html
|
<div id="swagger-ui"
class="apiDocs"></div>
| 50 | 11.75 | 27 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/breadcrumbs/breadcrumbs.component.html
|
<ol *ngIf="crumbs.length"
class="breadcrumb">
<li *ngFor="let crumb of crumbs; let last = last"
[ngClass]="{ 'active': last && finished }"
class="breadcrumb-item">
<a *ngIf="!last && crumb.path !== null"
[routerLink]="crumb.path"
preserveFragment>{{ crumb.text }}</a>
<span *ngIf="last || crumb.path === null">{{ crumb.text }}</span>
</li>
</ol>
| 388 | 31.416667 | 69 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.html
|
<div ngbDropdown
placement="bottom-right">
<a ngbDropdownToggle
i18n-title
title="Help"
role="button">
<i [ngClass]="[icons.questionCircle]"></i>
<span i18n
class="d-md-none">Help</span>
</a>
<div ngbDropdownMenu>
<a ngbDropdownItem
class="text-capitalize"
[ngClass]="{'disabled': !docsUrl}"
href="{{ docsUrl }}"
target="_blank"
i18n>documentation</a>
<button ngbDropdownItem
routerLink="/api-docs"
target="_blank"
i18n>API</button>
<button ngbDropdownItem
(click)="openAboutModal()"
i18n>About</button>
<button ngbDropdownItem
(click)="openFeedbackModal()"
i18n>Report an issue...</button>
</div>
</div>
| 786 | 25.233333 | 46 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/identity/identity.component.html
|
<div ngbDropdown
placement="bottom-right">
<a ngbDropdownToggle
i18n-title
title="Logged in user"
role="button">
<i [ngClass]="[icons.user]"></i>
<span i18n
class="d-md-none">Logged in user</span>
</a>
<div ngbDropdownMenu>
<button ngbDropdownItem
disabled
i18n>Signed in as <strong>{{ username }}</strong></button>
<hr class="dropdown-divider" />
<button ngbDropdownItem
*ngIf="!sso"
routerLink="/user-profile/edit">
<i [ngClass]="[icons.lock]"></i>
<span i18n>Change password</span>
</button>
<button ngbDropdownItem
(click)="logout()">
<i [ngClass]="[icons.signOut]"></i>
<span i18n>Sign out</span>
</button>
</div>
</div>
| 780 | 25.931034 | 70 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.html
|
<div class="cd-navbar-main">
<cd-pwd-expiration-notification></cd-pwd-expiration-notification>
<cd-telemetry-notification></cd-telemetry-notification>
<cd-motd></cd-motd>
<cd-notifications-sidebar></cd-notifications-sidebar>
<div class="cd-navbar-top">
<nav class="navbar navbar-expand-md navbar-dark cd-navbar-brand">
<button class="btn btn-link py-0 ms-3"
(click)="showMenuSidebar = !showMenuSidebar"
aria-label="toggle sidebar visibility">
<i class="fa fa-bars fa-2x"
aria-hidden="true"></i>
</button>
<a class="navbar-brand ms-2"
href="#">
<img src="assets/Ceph_Ceph_Logo_with_text_white.svg"
alt="Ceph" />
</a>
<button type="button"
class="navbar-toggler"
(click)="toggleRightSidebar()">
<span i18n
class="sr-only">Toggle navigation</span>
<span class="">
<i class="fa fa-navicon fa-lg"></i>
</span>
</button>
<div class="collapse navbar-collapse"
[ngClass]="{'show': rightSidebarOpen}">
<ul class="nav navbar-nav cd-navbar-utility my-2 my-md-0">
<ng-container *ngTemplateOutlet="cd_utilities"> </ng-container>
</ul>
</div>
</nav>
</div>
<div class="wrapper">
<!-- Content -->
<nav id="sidebar"
[ngClass]="{'active': !showMenuSidebar}">
<ngx-simplebar [options]="simplebar">
<ul class="list-unstyled components cd-navbar-primary">
<ng-container *ngTemplateOutlet="cd_menu"> </ng-container>
</ul>
</ngx-simplebar>
</nav>
<!-- Page Content -->
<div id="content"
[ngClass]="{'active': !showMenuSidebar}">
<ng-content></ng-content>
</div>
</div>
<ng-template #cd_utilities>
<li class="nav-item">
<cd-language-selector class="cd-navbar"></cd-language-selector>
</li>
<li class="nav-item">
<cd-notifications class="cd-navbar"
(click)="toggleRightSidebar()"></cd-notifications>
</li>
<li class="nav-item">
<cd-dashboard-help class="cd-navbar"></cd-dashboard-help>
</li>
<li class="nav-item">
<cd-administration class="cd-navbar"></cd-administration>
</li>
<li class="nav-item">
<cd-identity class="cd-navbar"></cd-identity>
</li>
</ng-template>
<ng-template #cd_menu>
<ng-container *ngIf="enabledFeature$ | async as enabledFeature">
<!-- Dashboard -->
<li routerLinkActive="active"
class="nav-item tc_menuitem_dashboard">
<a routerLink="/dashboard"
class="nav-link">
<span i18n>Dashboard</span>
<i [ngClass]="[icons.health]"
[ngStyle]="summaryData?.health_status | healthColor"></i>
</a>
</li>
<!-- Cluster -->
<li routerLinkActive="active"
class="nav-item tc_menuitem_cluster"
*ngIf="permissions.hosts.read || permissions.monitor.read ||
permissions.osd.read || permissions.configOpt.read ||
permissions.log.read || permissions.prometheus.read">
<a (click)="toggleSubMenu('cluster')"
class="nav-link dropdown-toggle"
[attr.aria-expanded]="displayedSubMenu === 'cluster'"
aria-controls="cluster-nav"
role="button">
<ng-container i18n>Cluster</ng-container>
</a>
<ul class="list-unstyled"
id="cluster-nav"
[ngbCollapse]="displayedSubMenu !== 'cluster'">
<li routerLinkActive="active"
class="tc_submenuitem tc_submenuitem_hosts"
*ngIf="permissions.hosts.read">
<a i18n
routerLink="/hosts">Hosts</a>
</li>
<li routerLinkActive="active"
class="tc_submenuitem tc_submenuitem_cluster_inventory"
*ngIf="permissions.hosts.read">
<a i18n
routerLink="/inventory">Physical Disks</a>
</li>
<li routerLinkActive="active"
class="tc_submenuitem tc_submenuitem_cluster_monitor"
*ngIf="permissions.monitor.read">
<a i18n
routerLink="/monitor/">Monitors</a>
</li>
<li routerLinkActive="active"
class="tc_submenuitem tc_submenuitem_cluster_services"
*ngIf="permissions.hosts.read">
<a i18n
routerLink="/services/">Services</a>
</li>
<li routerLinkActive="active"
class="tc_submenuitem tc_submenuitem_osds"
*ngIf="permissions.osd.read">
<a i18n
routerLink="/osd">OSDs</a>
</li>
<li routerLinkActive="active"
class="tc_submenuitem tc_submenuitem_configuration"
*ngIf="permissions.configOpt.read">
<a i18n
routerLink="/configuration">Configuration</a>
</li>
<li routerLinkActive="active"
class="tc_submenuitem tc_submenuitem_crush"
*ngIf="permissions.osd.read">
<a i18n
routerLink="/crush-map">CRUSH map</a>
</li>
<li routerLinkActive="active"
class="tc_submenuitem tc_submenuitem_modules"
*ngIf="permissions.configOpt.read">
<a i18n
routerLink="/mgr-modules">Manager Modules</a>
</li>
<li routerLinkActive="active"
class="tc_submenuitem tc_submenuitem_users"
*ngIf="permissions.configOpt.read">
<a i18n
routerLink="/ceph-users">Ceph Users</a>
</li>
<li routerLinkActive="active"
class="tc_submenuitem tc_submenuitem_log"
*ngIf="permissions.log.read">
<a i18n
routerLink="/logs">Logs</a>
</li>
<li routerLinkActive="active"
class="tc_submenuitem tc_submenuitem_monitoring"
*ngIf="permissions.prometheus.read">
<a routerLink="/monitoring">
<ng-container i18n>Alerts</ng-container>
<small *ngIf="prometheusAlertService.activeCriticalAlerts > 0"
class="badge badge-danger ms-1">{{ prometheusAlertService.activeCriticalAlerts }}</small>
<small *ngIf="prometheusAlertService.activeWarningAlerts > 0"
class="badge badge-warning ms-1">{{ prometheusAlertService.activeWarningAlerts }}</small>
</a>
</li>
<li routerLinkActive="active"
class="tc_submenuitem tc_submenuitem_upgrade"
*ngIf="permissions.configOpt.read">
<a i18n
routerLink="/upgrade">Upgrade</a>
</li>
</ul>
</li>
<!-- Pools -->
<li routerLinkActive="active"
class="nav-item tc_menuitem_pool"
*ngIf="permissions.pool.read">
<a class="nav-link"
i18n
routerLink="/pool">Pools</a>
</li>
<!-- Block -->
<li routerLinkActive="active"
class="nav-item tc_menuitem_block"
*ngIf="(permissions.rbdImage.read || permissions.rbdMirroring.read || permissions.iscsi.read) &&
(enabledFeature.rbd || enabledFeature.mirroring || enabledFeature.iscsi)">
<a class="nav-link dropdown-toggle"
(click)="toggleSubMenu('block')"
[attr.aria-expanded]="displayedSubMenu === 'block'"
aria-controls="block-nav"
role="button"
[ngStyle]="blockHealthColor()">
<ng-container i18n>Block</ng-container>
</a>
<ul class="list-unstyled"
id="block-nav"
[ngbCollapse]="displayedSubMenu !== 'block'">
<li routerLinkActive="active"
class="tc_submenuitem tc_submenuitem_block_images"
*ngIf="permissions.rbdImage.read && enabledFeature.rbd">
<a i18n
routerLink="/block/rbd">Images</a>
</li>
<li routerLinkActive="active"
class="tc_submenuitem tc_submenuitem_block_mirroring"
*ngIf="permissions.rbdMirroring.read && enabledFeature.mirroring">
<a routerLink="/block/mirroring">
<ng-container i18n>Mirroring</ng-container>
<small *ngIf="summaryData?.rbd_mirroring?.warnings !== 0"
class="badge badge-warning">{{ summaryData?.rbd_mirroring?.warnings }}</small>
<small *ngIf="summaryData?.rbd_mirroring?.errors !== 0"
class="badge badge-danger">{{ summaryData?.rbd_mirroring?.errors }}</small>
</a>
</li>
<li routerLinkActive="active"
class="tc_submenuitem tc_submenuitem_block_iscsi"
*ngIf="permissions.iscsi.read && enabledFeature.iscsi">
<a i18n
routerLink="/block/iscsi">iSCSI</a>
</li>
</ul>
</li>
<!-- NFS -->
<li routerLinkActive="active"
class="nav-item tc_menuitem_nfs"
*ngIf="permissions.nfs.read && enabledFeature.nfs">
<a i18n
class="nav-link"
routerLink="/nfs">NFS</a>
</li>
<!-- Filesystem -->
<li routerLinkActive="active"
class="nav-item tc_menuitem_cephfs"
*ngIf="permissions.cephfs.read && enabledFeature.cephfs">
<a i18n
class="nav-link"
routerLink="/cephfs">File Systems</a>
</li>
<!-- Object Gateway -->
<li routerLinkActive="active"
class="nav-item tc_menuitem_rgw"
*ngIf="permissions.rgw.read && enabledFeature.rgw">
<a class="nav-link dropdown-toggle"
(click)="toggleSubMenu('rgw')"
[attr.aria-expanded]="displayedSubMenu === 'rgw'"
aria-controls="gateway-nav"
role="button">
<ng-container i18n>Object Gateway</ng-container>
</a>
<ul class="list-unstyled"
id="gateway-nav"
[ngbCollapse]="displayedSubMenu !== 'rgw'">
<li routerLinkActive="active"
class="tc_submenuitem tc_submenuitem_rgw_daemons">
<a i18n
routerLink="/rgw/daemon">Gateways</a>
</li>
<li routerLinkActive="active"
class="tc_submenuitem tc_submenuitem_rgw_users">
<a i18n
routerLink="/rgw/user">Users</a>
</li>
<li routerLinkActive="active"
class="tc_submenuitem tc_submenuitem_rgw_buckets">
<a i18n
routerLink="/rgw/bucket">Buckets</a>
</li>
<li routerLinkActive="active"
class="tc_submenuitem tc_submenuitem_rgw_buckets">
<a i18n
routerLink="/rgw/multisite">Multisite</a>
</li>
</ul>
</li>
</ng-container>
</ng-template>
</div>
| 10,990 | 35.88255 | 110 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/notifications/notifications.component.html
|
<a i18n-title
title="Tasks and Notifications"
[ngClass]="{ 'running': hasRunningTasks }"
(click)="toggleSidebar()">
<i [ngClass]="[icons.bell]"></i>
<span class="dot"
*ngIf="hasNotifications">
</span>
<span class="d-md-none"
i18n>Tasks and Notifications</span>
</a>
| 299 | 24 | 45 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/components/alert-panel/alert-panel.component.html
|
<ngb-alert type="{{ bootstrapClass }}"
[dismissible]="dismissible"
(closed)="onClose()"
[ngClass]="spacingClass">
<table>
<ng-container *ngIf="size === 'normal'; else slim">
<tr>
<td *ngIf="showIcon"
rowspan="2"
class="alert-panel-icon">
<i [ngClass]="[icons.large3x]"
class="alert-{{ bootstrapClass }} {{ typeIcon }}"
aria-hidden="true"></i>
</td>
<td *ngIf="showTitle"
class="alert-panel-title">{{ title }}</td>
</tr>
<tr>
<td class="alert-panel-text">
<ng-container *ngTemplateOutlet="content"></ng-container>
</td>
</tr>
</ng-container>
<ng-template #slim>
<tr>
<td *ngIf="showIcon"
class="alert-panel-icon">
<i class="alert-{{ bootstrapClass }} {{ typeIcon }}"
aria-hidden="true"></i>
</td>
<td *ngIf="showTitle"
class="alert-panel-title">{{ title }}</td>
<td class="alert-panel-text">
<ng-container *ngTemplateOutlet="content"></ng-container>
</td>
</tr>
</ng-template>
</table>
</ngb-alert>
<ng-template #content>
<ng-content></ng-content>
</ng-template>
| 1,273 | 27.954545 | 67 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/components/back-button/back-button.component.html
|
<button class="btn btn-light tc_backButton"
aria-label="Back"
(click)="back()"
type="button">
{{ name }}
</button>
| 141 | 19.285714 | 43 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/components/cd-label/cd-label.component.html
|
<span *ngIf="!key; else key_value"
class="badge badge-{{value}}"
ngClass="{{value | colorClassFromText}}">
{{ value }}
</span>
<ng-template #key_value>
<span class="badge badge-background-primary badge-{{key}}-{{value}}">
{{ key }}: {{ value }}
</span>
</ng-template>
| 295 | 23.666667 | 71 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/components/config-option/config-option.component.html
|
<div [formGroup]="optionsFormGroup">
<div *ngFor="let option of options; let last = last">
<div class="form-group row pt-2"
*ngIf="option.type === 'bool'">
<label class="cd-col-form-label"
[for]="option.name">
<b>{{ option.text }}</b>
<br>
<span class="text-muted">
{{ option.desc }}
<cd-helper *ngIf="option.long_desc">
{{ option.long_desc }}</cd-helper>
</span>
</label>
<div class="cd-col-form-input">
<div class="custom-control custom-checkbox">
<input class="custom-control-input"
type="checkbox"
[id]="option.name"
[formControlName]="option.name">
<label class="custom-control-label"
[for]="option.name"></label>
</div>
</div>
</div>
<div class="form-group row pt-2"
*ngIf="option.type !== 'bool'">
<label class="cd-col-form-label"
[for]="option.name">{{ option.text }}
<br>
<span class="text-muted">
{{ option.desc }}
<cd-helper *ngIf="option.long_desc">
{{ option.long_desc }}</cd-helper>
</span>
</label>
<div class="cd-col-form-input">
<div class="input-group">
<input class="form-control"
[type]="option.additionalTypeInfo.inputType"
[id]="option.name"
[placeholder]="option.additionalTypeInfo.humanReadable"
[formControlName]="option.name"
[step]="getStep(option.type, optionsForm.getValue(option.name))">
<button class="btn btn-light"
type="button"
data-toggle="button"
title="Remove the custom configuration value. The default configuration will be inherited and used instead."
(click)="resetValue(option.name)"
i18n-title
*ngIf="optionsFormShowReset">
<i [ngClass]="[icons.erase]"
aria-hidden="true"></i>
</button>
</div>
<span class="invalid-feedback"
*ngIf="optionsForm.showError(option.name, optionsFormDir, 'pattern')">
{{ option.additionalTypeInfo.patternHelpText }}</span>
<span class="invalid-feedback"
*ngIf="optionsForm.showError(option.name, optionsFormDir, 'invalidUuid')">
{{ option.additionalTypeInfo.patternHelpText }}</span>
<span class="invalid-feedback"
*ngIf="optionsForm.showError(option.name, optionsFormDir, 'max')"
i18n>The entered value is too high! It must not be greater than {{ option.maxValue }}.</span>
<span class="invalid-feedback"
*ngIf="optionsForm.showError(option.name, optionsFormDir, 'min')"
i18n>The entered value is too low! It must not be lower than {{ option.minValue }}.</span>
</div>
</div>
<hr *ngIf="!last"
class="my-2">
</div>
</div>
| 3,046 | 39.092105 | 126 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/components/confirmation-modal/confirmation-modal.component.html
|
<cd-modal (hide)="cancel()">
<ng-container class="modal-title">
<span class="text-warning"
*ngIf="warning">
<i class="fa fa-exclamation-triangle fa-1x"></i>
</span>{{ titleText }}</ng-container>
<ng-container class="modal-content">
<form name="confirmationForm"
#formDir="ngForm"
[formGroup]="confirmationForm"
novalidate>
<div class="modal-body">
<ng-container *ngTemplateOutlet="bodyTpl; context: bodyContext"></ng-container>
<p *ngIf="description">
{{description}}
</p>
</div>
<div class="modal-footer">
<cd-form-button-panel (submitActionEvent)="onSubmit(confirmationForm.value)"
(backActionEvent)="boundCancel()"
[form]="confirmationForm"
[submitText]="buttonText"
[showCancel]="showCancel"
[showSubmit]="showSubmit"></cd-form-button-panel>
</div>
</form>
</ng-container>
</cd-modal>
| 1,073 | 36.034483 | 87 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/components/copy2clipboard-button/copy2clipboard-button.component.html
|
<button (click)="onClick()"
type="button"
class="btn btn-light"
i18n-title
title="Copy to Clipboard">
<i [ngClass]="[icons.clipboard]"></i>
</button>
| 184 | 22.125 | 39 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/components/critical-confirmation-modal/critical-confirmation-modal.component.html
|
<cd-modal #modal
[modalRef]="activeModal">
<ng-container class="modal-title">
<ng-container *ngTemplateOutlet="deletionHeading"></ng-container>
</ng-container>
<ng-container class="modal-content">
<form name="deletionForm"
#formDir="ngForm"
[formGroup]="deletionForm"
novalidate>
<div class="modal-body">
<ng-container *ngTemplateOutlet="bodyTemplate; context: bodyContext"></ng-container>
<div class="question">
<span *ngIf="itemNames; else noNames">
<p *ngIf="itemNames.length === 1; else manyNames"
i18n>Are you sure that you want to {{ actionDescription | lowercase }} <strong>{{ itemNames[0] }}</strong>?</p>
<ng-template #manyNames>
<p i18n>Are you sure that you want to {{ actionDescription | lowercase }} the selected items?</p>
<ul>
<li *ngFor="let itemName of itemNames"><strong>{{ itemName }}</strong></li>
</ul>
</ng-template >
</span>
<ng-template #noNames>
<p i18n>Are you sure that you want to {{ actionDescription | lowercase }} the selected {{ itemDescription }}?</p>
</ng-template>
<ng-container *ngTemplateOutlet="childFormGroupTemplate; context:{form:deletionForm}"></ng-container>
<div class="form-group">
<div class="custom-control custom-checkbox">
<input type="checkbox"
class="custom-control-input"
name="confirmation"
id="confirmation"
formControlName="confirmation"
autofocus>
<label class="custom-control-label"
for="confirmation"
i18n>Yes, I am sure.</label>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<cd-form-button-panel (submitActionEvent)="callSubmitAction()"
[form]="deletionForm"
[submitText]="(actionDescription | titlecase) + ' ' + itemDescription"></cd-form-button-panel>
</div>
</form>
</ng-container>
</cd-modal>
<ng-template #deletionHeading>
{{ actionDescription | titlecase }} {{ itemDescription }}
</ng-template>
| 2,340 | 40.803571 | 126 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/components/custom-login-banner/custom-login-banner.component.html
|
<p class="login-text"
*ngIf="bannerText$ | async as bannerText">{{ bannerText }}</p>
| 88 | 28.666667 | 65 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/components/date-time-picker/date-time-picker.component.html
|
<div class="d-flex justify-content-center">
<ngb-datepicker #dp
[(ngModel)]="date"
[minDate]="minDate"
(ngModelChange)="onModelChange()"></ngb-datepicker>
</div>
<div class="d-flex justify-content-center"
*ngIf="hasTime">
<ngb-timepicker [seconds]="hasSeconds"
[(ngModel)]="time"
(ngModelChange)="onModelChange()"></ngb-timepicker>
</div>
| 439 | 30.428571 | 69 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/components/doc/doc.component.html
|
<a href="{{ docUrl }}"
target="_blank">{{ docText }}</a>
| 60 | 19.333333 | 36 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/components/download-button/download-button.component.html
|
<div ngbDropdown
placement="bottom-right">
<button type="button"
[title]="title"
class="btn btn-light dropdown-toggle-split"
ngbDropdownToggle>
<i [ngClass]="[icons.download]"></i>
</button>
<div ngbDropdownMenu>
<button ngbDropdownItem
(click)="download('json')"
*ngIf="objectItem">
<i [ngClass]="[icons.json]"></i>
<span>JSON</span>
</button>
<button ngbDropdownItem
(click)="download()"
*ngIf="textItem">
<i [ngClass]="[icons.text]"></i>
<span>Text</span>
</button>
</div>
</div>
| 618 | 24.791667 | 53 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/components/form-button-panel/form-button-panel.component.html
|
<div [class]="wrappingClass">
<cd-back-button *ngIf="showCancel"
class="m-2"
(backAction)="backAction()"
[name]="cancelText"></cd-back-button>
<cd-submit-button *ngIf="showSubmit"
(submitAction)="submitAction()"
[disabled]="disabled"
[form]="form"
[ariaLabel]="submitText"
data-cy="submitBtn">{{ submitText }}</cd-submit-button>
</div>
| 494 | 37.076923 | 75 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/components/form-modal/form-modal.component.html
|
<cd-modal [modalRef]="activeModal">
<ng-container *ngIf="titleText"
class="modal-title">
{{ titleText }}
</ng-container>
<ng-container class="modal-content">
<form [formGroup]="formGroup"
#formDir="ngForm"
novalidate>
<div class="modal-body">
<p *ngIf="message">{{ message }}</p>
<ng-container *ngFor="let field of fields">
<div class="form-group row cd-{{field.name}}-form-group">
<label *ngIf="field.label"
class="cd-col-form-label"
[ngClass]="{'required': field?.required === true}"
[for]="field.name">
{{ field.label }}
</label>
<div [ngClass]="{'cd-col-form-input': field.label, 'col-sm-12': !field.label}">
<input *ngIf="['text', 'number'].includes(field.type)"
[type]="field.type"
class="form-control"
[id]="field.name"
[name]="field.name"
[formControlName]="field.name">
<input *ngIf="field.type === 'binary'"
type="text"
class="form-control"
[id]="field.name"
[name]="field.name"
[formControlName]="field.name"
cdDimlessBinary>
<select *ngIf="field.type === 'select'"
class="form-select"
[id]="field.name"
[formControlName]="field.name">
<option *ngIf="field?.typeConfig?.placeholder"
[ngValue]="null">
{{ field?.typeConfig?.placeholder }}
</option>
<option *ngFor="let option of field?.typeConfig?.options"
[value]="option.value">
{{ option.text }}
</option>
</select>
<cd-select-badges *ngIf="field.type === 'select-badges'"
[id]="field.name"
[data]="field.value"
[customBadges]="field?.typeConfig?.customBadges"
[options]="field?.typeConfig?.options"
[messages]="field?.typeConfig?.messages">
</cd-select-badges>
<span *ngIf="formGroup.showError(field.name, formDir)"
class="invalid-feedback">
{{ getError(field) }}
</span>
</div>
</div>
</ng-container>
</div>
<div class="modal-footer">
<cd-form-button-panel (submitActionEvent)="onSubmitForm(formGroup.value)"
[form]="formGroup"
[submitText]="submitButtonText"></cd-form-button-panel>
</div>
</form>
</ng-container>
</cd-modal>
| 2,956 | 41.242857 | 91 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/components/grafana/grafana.component.html
|
<!-- Embed dashboard -->
<cd-loading-panel *ngIf="loading && grafanaExist"
i18n>Loading panel data...</cd-loading-panel>
<cd-alert-panel type="info"
*ngIf="!grafanaExist"
i18n>Please consult the <cd-doc section="grafana"></cd-doc> on
how to configure and enable the monitoring functionality.</cd-alert-panel>
<cd-alert-panel type="info"
*ngIf="!dashboardExist"
i18n>Grafana Dashboard doesn't exist. Please refer to
<cd-doc section="grafana"></cd-doc> on how to add dashboards to Grafana.</cd-alert-panel>
<ng-container *ngIf="grafanaExist && dashboardExist">
<div class="row mb-3">
<div class="col-lg-5 d-flex">
<div class="col-md-3 timepicker">
<label for="timepicker"
class="mt-2"
i18n>Grafana Time Picker</label>
</div>
<div class="col-sm-4">
<select id="timepicker"
name="timepicker"
class="form-select"
[(ngModel)]="time"
(ngModelChange)="onTimepickerChange($event)">
<option *ngFor="let key of grafanaTimes"
[ngValue]="key.value">{{ key.name }}
</option>
</select>
</div>
<div class="col-sm-1">
<button class="btn btn-light ms-3"
i18n-title
title="Reset Settings"
(click)="reset()">
<i [ngClass]="[icons.undo]"></i>
</button>
</div>
<div class="col-sm-1">
<button class="btn btn-light ms-3"
i18n-title
title="Show hidden information"
(click)="showMessage = !showMessage">
<i [ngClass]="[icons.infoCircle, icons.large]"></i>
</button>
</div>
</div>
</div>
<div class="row">
<div class="col my-2"
*ngIf="showMessage">
<cd-alert-panel type="info"
class="mb-3"
*ngIf="showMessage"
dismissible="true"
(dismissed)="showMessage = false"
i18n>If no embedded Grafana Dashboard appeared below, please follow <a [href]="grafanaSrc"
target="_blank"
noopener
noreferrer>this link </a> to check if Grafana is reachable and there are no HTTPS certificate issues. You may need to reload this page after accepting any Browser certificate exceptions</cd-alert-panel>
</div>
</div>
<div class="row">
<div class="col">
<div class="grafana-container">
<iframe #iframe
id="iframe"
[src]="grafanaSrc"
class="grafana"
[ngClass]="panelStyle"
frameborder="0"
scrolling="no"
[title]="title"
i18n-title>
</iframe>
</div>
</div>
</div>
</ng-container>
| 2,955 | 33.776471 | 224 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/components/helper/helper.component.html
|
<ng-template #popoverTpl>
<div [class]="class"
[innerHtml]="html">
</div>
<ng-content></ng-content>
</ng-template>
<i [ngClass]="iconClass ? iconClass : [icons.questionCircle]"
aria-hidden="true"
[ngbPopover]="popoverTpl"
(click)="$event.preventDefault();">
</i>
| 285 | 22.833333 | 61 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/components/language-selector/language-selector.component.html
|
<div ngbDropdown
display="dynamic"
placement="bottom-right">
<a ngbDropdownToggle
i18n-title
id="toggle-language-button"
title="Select a Language"
role="button">
{{ allLanguages[selectedLanguage] }}
</a>
<div ngbDropdownMenu
role="listbox"
aria-labelledby="toggle-language-button">
<ng-container *ngFor="let lang of supportedLanguages | keyvalue">
<button ngbDropdownItem
role="option"
(click)="changeLanguage(lang.key)">
{{ lang.value }}
</button>
</ng-container>
</div>
</div>
| 591 | 24.73913 | 69 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/components/loading-panel/loading-panel.component.html
|
<ngb-alert type="info"
[dismissible]="false">
<strong>
<i [ngClass]="[icons.spinner, icons.spin]"
aria-hidden="true"
class="me-2"></i>
</strong>
<ng-content></ng-content>
</ngb-alert>
| 219 | 21 | 46 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/components/modal/modal.component.html
|
<div [ngClass]="pageURL ? 'modal' : ''">
<div [ngClass]="pageURL ? 'modal-dialog' : ''">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title float-start">
<ng-content select=".modal-title"></ng-content>
</h4>
<button type="button"
class="btn-close float-end"
aria-label="Close"
(click)="close()">
</button>
</div>
<ng-content select=".modal-content"></ng-content>
</div>
</div>
</div>
| 532 | 27.052632 | 57 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/components/motd/motd.component.html
|
<cd-alert-panel *ngIf="motd"
size="slim"
[showTitle]="false"
[type]="motd.severity"
[dismissible]="motd.severity !== 'danger'"
(dismissed)="onDismissed()">
<span [innerHTML]="motd.message | sanitizeHtml"></span>
</cd-alert-panel>
| 312 | 33.777778 | 58 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/components/notifications-sidebar/notifications-sidebar.component.html
|
<ng-template #tasksTpl>
<!-- Executing -->
<div *ngFor="let executingTask of executingTasks; trackBy:trackByFn">
<div class="card tc_task border-0">
<div class="row no-gutters">
<div class="col-md-2 text-center">
<span [ngClass]="[icons.stack, icons.large2x]"
class="text-info">
<i [ngClass]="[icons.stack2x, icons.circle]"></i>
<i [ngClass]="[icons.stack1x, icons.spinner, icons.spin, icons.inverse]"></i>
</span>
</div>
<div class="col-md-9">
<div class="card-body p-1">
<h6 class="card-title bold">{{ executingTask.description }}</h6>
<div class="mb-1">
<ngb-progressbar type="info"
[value]="executingTask?.progress"
[striped]="true"
[animated]="true"></ngb-progressbar>
</div>
<p class="card-text text-muted">
<small class="date float-start">
{{ executingTask.begin_time | cdDate }}
</small>
<span class="float-end">
{{ executingTask.progress || 0 }} %
</span>
</p>
</div>
</div>
</div>
</div>
<hr>
</div>
</ng-template>
<ng-template #notificationsTpl>
<ng-container *ngIf="notifications.length > 0">
<button type="button"
class="btn btn-light btn-block"
(click)="removeAll(); $event.stopPropagation()">
<i [ngClass]="[icons.trash]"
aria-hidden="true"></i>
<ng-container i18n>Clear notifications</ng-container>
</button>
<hr>
<div *ngFor="let notification of notifications; let i = index"
[ngClass]="notification.borderClass">
<div class="card tc_notification border-0">
<div class="row no-gutters">
<div class="col-md-2 text-center">
<span [ngClass]="[icons.stack, icons.large2x, notification.textClass]">
<i [ngClass]="[icons.circle, icons.stack2x]"></i>
<i [ngClass]="[icons.stack1x, icons.inverse, notification.iconClass]"></i>
</span>
</div>
<div class="col-md-10">
<div class="card-body p-1">
<button class="btn btn-link float-end mt-0 pt-0"
title="Remove notification"
i18n-title
(click)="remove(i); $event.stopPropagation()">
<i [ngClass]="[icons.trash]"></i>
</button>
<button *ngIf="notification.application === 'Prometheus' && notification.type !== 2 && !notification.alertSilenced"
class="btn btn-link float-end text-muted mute m-0 p-0"
title="Silence Alert"
i18n-title
(click)="silence(notification)">
<i [ngClass]="[icons.mute]"></i>
</button>
<button *ngIf="notification.application === 'Prometheus' && notification.type !== 2 && notification.alertSilenced"
class="btn btn-link float-end text-muted mute m-0 p-0"
title="Expire Silence"
i18n-title
(click)="expire(notification)">
<i [ngClass]="[icons.bell]"></i>
</button>
<h6 class="card-title bold">{{ notification.title }}</h6>
<p class="card-text"
[innerHtml]="notification.message"></p>
<p class="card-text text-muted">
<ng-container *ngIf="notification.duration">
<small>
<ng-container i18n>Duration:</ng-container> {{ notification.duration | duration }}
</small>
<br>
</ng-container>
<small class="date"
[title]="notification.timestamp | cdDate">{{ notification.timestamp | relativeDate }}</small>
<i class="float-end custom-icon"
[ngClass]="[notification.applicationClass]"
[title]="notification.application"></i>
</p>
</div>
</div>
</div>
</div>
<hr>
</div>
</ng-container>
</ng-template>
<ng-template #emptyTpl>
<div *ngIf="notifications.length === 0 && executingTasks.length === 0">
<div class="message text-center"
i18n>There are no notifications.</div>
</div>
</ng-template>
<div class="card"
(clickOutside)="closeSidebar()"
[clickOutsideEnabled]="isSidebarOpened">
<div class="card-header">
<ng-container i18n>Tasks and Notifications</ng-container>
<button class="btn-close float-end"
tabindex="-1"
type="button"
title="close"
(click)="closeSidebar()">
</button>
</div>
<ngx-simplebar [options]="simplebar">
<div class="card-body">
<ng-container *ngTemplateOutlet="tasksTpl"></ng-container>
<ng-container *ngTemplateOutlet="notificationsTpl"></ng-container>
<ng-container *ngTemplateOutlet="emptyTpl"></ng-container>
</div>
</ngx-simplebar>
</div>
| 5,251 | 35.22069 | 129 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/components/orchestrator-doc-panel/orchestrator-doc-panel.component.html
|
<cd-alert-panel *ngIf="missingFeatures; else elseBlock"
type="info"
i18n>The feature is not supported in the current Orchestrator.</cd-alert-panel>
<ng-template #elseBlock>
<cd-alert-panel type="info"
i18n>Orchestrator is not available.
Please consult the <cd-doc section="orch"></cd-doc> on how to configure and
enable the functionality.</cd-alert-panel>
</ng-template>
| 432 | 38.363636 | 95 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/components/pwd-expiration-notification/pwd-expiration-notification.component.html
|
<cd-alert-panel class="no-margin-bottom"
[type]="alertType"
*ngIf="displayNotification"
[showTitle]="false"
size="slim"
[dismissible]="alertType !== 'danger'"
(dismissed)="onDismissed()">
<div *ngIf="expirationDays === 0"
i18n>Your password will expire in <strong>less than 1</strong> day. Click
<a routerLink="/user-profile/edit"
class="alert-link">here</a> to change it now.</div>
<div *ngIf="expirationDays > 0"
i18n>Your password will expire in <strong>{{ expirationDays }}</strong> day(s). Click
<a routerLink="/user-profile/edit"
class="alert-link">here</a> to change it now.</div>
</cd-alert-panel>
| 738 | 42.470588 | 92 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/components/refresh-selector/refresh-selector.component.html
|
<div class="container-fluid">
<div class="row">
<form>
<div class="col-sm-1 d-flex float-end">
<label for="refreshInterval"
class="col-form-label my-0 mx-2 float-end"
i18n>Refresh</label>
<select id="refreshInterval"
name="refreshInterval"
class="form-select float-end"
(change)="changeRefreshInterval($event.target.value)"
[(ngModel)]="selectedInterval">
<option *ngFor="let key of intervalKeys"
[value]="intervalList[key]">{{ key }}</option>
</select>
</div>
</form>
</div>
</div>
| 653 | 31.7 | 69 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/components/select-badges/select-badges.component.html
|
<cd-select #cdSelect
[data]="data"
[options]="options"
[messages]="messages"
[selectionLimit]="selectionLimit"
[customBadges]="customBadges"
[customBadgeValidators]="customBadgeValidators"
elemClass="me-2 select-menu-edit"
(selection)="selection.emit($event)">
<i [ngClass]="[icons.edit]"></i>
</cd-select>
<span *ngFor="let dataItem of data">
<span class="badge badge-dark me-2">
<span class="me-2">{{ dataItem }}</span>
<a class="badge-remove"
(click)="cdSelect.removeItem(dataItem)">
<i [ngClass]="[icons.destroy]"
aria-hidden="true"></i>
</a>
</span>
</span>
| 692 | 29.130435 | 58 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/components/select/select.component.html
|
<ng-template #popTemplate>
<form name="form"
#formDir="ngForm"
[formGroup]="form"
novalidate>
<div>
<input type="text"
formControlName="filter"
i18n-placeholder
[placeholder]="messages.filter"
(keyup)="$event.keyCode === 13 ? selectOption() : updateFilter()"
class="form-control text-center" />
<ng-container *ngFor="let error of Object.keys(messages.customValidations)">
<span class="invalid-feedback text-center d-block"
*ngIf="form.showError('filter', formDir) && filter.hasError(error)">
{{ messages.customValidations[error] }}
</span>
</ng-container>
</div>
</form>
<div *ngFor="let option of filteredOptions"
class="select-menu-item"
[ngClass]="{'help-block disabled': (data.length === selectionLimit || !option.enabled) && !option.selected}"
(click)="triggerSelection(option)">
<div class="select-menu-item-icon">
<i [ngClass]="[icons.check]"
aria-hidden="true"
*ngIf="option.selected"></i>
</div>
<div class="select-menu-item-content">
{{ option.name }}
<ng-container *ngIf="option.description">
<br>
<small class="form-text text-muted">
{{ option.description }}
</small>
</ng-container>
</div>
</div>
<div *ngIf="isCreatable()"
class="select-menu-item"
(click)="addCustomOption()">
<div class="select-menu-item-icon">
<i [ngClass]="[icons.tag]"
aria-hidden="true"></i>
</div>
<div class="select-menu-item-content">
{{ messages.add }} '{{ filter.value }}'
</div>
</div>
<div class="is-invalid"
*ngIf="data.length === selectionLimit">
<span class="form-text text-muted text-center text-warning"
[ngbTooltip]="messages.selectionLimit.tooltip"
*ngIf="data.length === selectionLimit">
{{ messages.selectionLimit.text }}
</span>
</div>
</ng-template>
<a class="select-menu-edit float-start"
[ngClass]="elemClass"
[ngbPopover]="popTemplate"
data-testid="select-menu-edit"
*ngIf="customBadges || options.length > 0">
<ng-content></ng-content>
</a>
<span class="form-text text-muted float-start"
*ngIf="data.length === 0 && !(!customBadges && options.length === 0)">
{{ messages.empty }}
</span>
<span class="form-text text-muted float-start"
*ngIf="!customBadges && options.length === 0">
{{ messages.noOptions }}
</span>
| 2,565 | 31.075 | 115 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/components/sparkline/sparkline.component.html
|
<div class="chart-container"
[ngStyle]="style">
<canvas baseChart
#sparkCanvas
[labels]="labels"
[datasets]="datasets"
[options]="options"
[colors]="colors"
[chartType]="'line'">
</canvas>
<div class="chartjs-tooltip"
#sparkTooltip>
<table></table>
</div>
</div>
| 347 | 20.75 | 31 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/components/submit-button/submit-button.component.html
|
<button [type]="type"
class="btn btn-accent tc_submitButton"
[ngClass]="btnClass"
[disabled]="loading || disabled"
(click)="submit($event)"
[attr.aria-label]="ariaLabel">
<ng-content></ng-content>
<span *ngIf="loading">
<i [ngClass]="[icons.spinner, icons.spin]"></i>
</span>
</button>
| 336 | 27.083333 | 51 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/components/telemetry-notification/telemetry-notification.component.html
|
<cd-alert-panel *ngIf="displayNotification"
class="no-margin-bottom"
[showTitle]="false"
size="slim"
[type]="notificationSeverity"
[dismissible]="notificationSeverity !== 'danger'"
(dismissed)="onDismissed()">
<div i18n>The Ceph community needs your help to continue improving: please
<a routerLink="/telemetry"
class="btn activate-button alert-link activate-text">Activate</a> the
<a href="https://docs.ceph.com/en/latest/mgr/telemetry/">Telemetry</a> module.</div>
</cd-alert-panel>
| 596 | 44.923077 | 86 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/components/usage-bar/usage-bar.component.html
|
<ng-template #usageTooltipTpl>
<table>
<tr>
<td class="text-left">Used: </td>
<td class="text-right"><strong> {{ isBinary ? (used | dimlessBinary) : (used | dimless) }}</strong></td>
</tr>
<tr *ngIf="calculatePerc">
<td class="text-left">Free: </td>
<td class="'text-right"><strong>{{ isBinary ? (total - used | dimlessBinary) : (total - used | dimless) }}</strong></td>
</tr>
</table>
</ng-template>
<div class="progress"
data-placement="left"
[ngbTooltip]="usageTooltipTpl">
<div class="progress-bar bg-info"
[ngClass]="{'bg-warning': usedPercentage/100 >= warningThreshold, 'bg-danger': usedPercentage/100 >= errorThreshold}"
role="progressbar"
[attr.aria-label]="{ title }"
i18n-aria-label="The title of this usage bar is { title }"
[style.width]="usedPercentage + '%'">
<span>{{ usedPercentage | number: '1.0-' + decimals }}%</span>
</div>
<div class="progress-bar bg-freespace"
role="progressbar"
[attr.aria-label]="{ title }"
i18n-aria-label="The title of this usage bar is { title }"
[style.width]="freePercentage + '%'">
</div>
</div>
| 1,184 | 36.03125 | 126 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/components/wizard/wizard.component.html
|
<div class="card-body">
<div class="row m-7">
<nav class="col">
<ul class="nav nav-pills flex-column"
*ngFor="let step of steps | async; let i = index;">
<li class="nav-item">
<a class="nav-link"
(click)="onStepClick(step)"
[ngClass]="{active: currentStep.stepIndex === step.stepIndex}">
<span class="circle-step"
[ngClass]="{active: currentStep.stepIndex === step.stepIndex}"
i18n>{{ step.stepIndex }}</span>
<span i18n>{{ stepsTitle[i] }}</span>
</a>
</li>
</ul>
</nav>
</div>
</div>
| 642 | 31.15 | 80 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/crud-table/crud-table.component.html
|
<ul class="nav nav-tabs"
*ngIf="tabs">
<li class="nav-item"
*ngFor="let tab of tabs; keyvalue">
<a class="nav-link"
[routerLink]="tab.url"
routerLinkActive="active"
ariaCurrentWhenActive="page"
[routerLinkActiveOptions]="{exact: true}"
i18n>{{tab.name}}</a>
</li>
</ul>
<ng-container *ngIf="meta">
<cd-table
[data]="data$ | async"
[columns]="meta.table.columns"
[columnMode]="meta.table.columnMode"
(setExpandedRow)="setExpandedRow($event)"
[hasDetails]="meta.detail_columns.length > 0"
[selectionType]="meta.table.selectionType"
(updateSelection)="updateSelection($event)"
[toolHeader]="meta.table.toolHeader">
<div class="table-actions btn-toolbar">
<cd-table-actions [permission]="permission"
[selection]="selection"
class="btn-group"
id="crud-table-actions"
[tableActions]="meta.actions">
</cd-table-actions>
</div>
<ng-container *ngIf="expandedRow && meta.detail_columns.length > 0"
cdTableDetail>
<table class="table table-striped table-bordered">
<tbody>
<tr *ngFor="let column of meta.detail_columns">
<td i18n
class="bold">{{ column }}</td>
<td> {{ expandedRow[column] }} </td>
</tr>
</tbody>
</table>
</ng-container>
</cd-table>
</ng-container>
<ng-template #badgeDictTpl
let-value="value">
<span *ngFor="let instance of value | keyvalue; last as isLast">
<span class="badge badge-background-primary" >{{ instance.key }}: {{ instance.value }}</span>
<ng-container *ngIf="!isLast"> </ng-container>
</span>
</ng-template>
<ng-template #dateTpl
let-value="value">
<span>{{ value | cdDate }}</span>
</ng-template>
<ng-template #durationTpl
let-value="value">
<span>{{ value | duration }}</span>
</ng-template>
<ng-template #exportDataModalTpl>
<div class="d-flex flex-column align-items-center w-100 gap-3">
<textarea readonly
class="form-control w-100 bg-light height-400"
id="authExportArea">{{ modalState.authExportData }}</textarea>
<cd-copy-2-clipboard-button class="align-self-end"
source="authExportArea">
</cd-copy-2-clipboard-button>
</div>
</ng-template>
| 2,449 | 30.818182 | 97 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-actions/table-actions.component.html
|
<div class="btn-group">
<ng-container *ngIf="currentAction">
<button type="button"
title="{{ useDisableDesc(currentAction) }}"
class="btn btn-{{btnColor}}"
[ngClass]="{'disabled': disableSelectionAction(currentAction)}"
(click)="useClickAction(currentAction)"
[disabled]="disableSelectionAction(currentAction)"
[routerLink]="useRouterLink(currentAction)"
[attr.aria-label]="currentAction.name"
[preserveFragment]="currentAction.preserveFragment ? '' : null">
<i [ngClass]="[currentAction.icon]"></i>
<span class="action-label">{{ currentAction.name }}</span>
</button>
</ng-container>
<div class="btn-group"
ngbDropdown
role="group"
*ngIf="dropDownActions.length > 1"
aria-label="Button group with nested dropdown">
<button aria-label="dropdown-menu-toggle"
class="btn btn-{{btnColor}} dropdown-toggle-split"
ngbDropdownToggle>
<ng-container *ngIf="dropDownOnly">{{ dropDownOnly }} </ng-container>
<span *ngIf="!dropDownOnly"
class="sr-only"></span>
</button>
<div class="dropdown-menu"
ngbDropdownMenu>
<ng-container *ngFor="let action of dropDownActions">
<button ngbDropdownItem
class="{{ toClassName(action) }}"
title="{{ useDisableDesc(action) }}"
(click)="useClickAction(action)"
[routerLink]="useRouterLink(action)"
[preserveFragment]="action.preserveFragment ? '' : null"
[disabled]="disableSelectionAction(action)"
[attr.aria-label]="action.name">
<i [ngClass]="[action.icon, 'action-icon']"></i>
<span>{{ action.name }}</span>
</button>
</ng-container>
</div>
</div>
</div>
| 1,869 | 39.652174 | 76 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-key-value/table-key-value.component.html
|
<div class="table-scroller">
<cd-table #table
[data]="tableData"
[columns]="columns"
columnMode="flex"
[toolHeader]="false"
[autoReload]="autoReload"
[customCss]="customCss"
[autoSave]="false"
[header]="false"
[footer]="false"
[limit]="0">
</cd-table>
</div>
| 383 | 24.6 | 37 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-pagination/table-pagination.component.html
|
<nav class="pagination"
aria-label="Pagination"
i18n-aria-label>
<button
class="pagination__btn pagination__btn_first"
aria-label="Go to first page"
i18n-aria-label
[disabled]="!canPrevious()"
(click)="selectPage(1)"
>
<i class="fa fa-angle-double-left"
aria-hidden="true"></i>
</button>
<button
class="pagination__btn pagination__btn_prev"
aria-label="Go to previous page"
i18n-aria-label
[disabled]="!canPrevious()"
(click)="prevPage()"
>
<i class="fa fa-angle-left"
aria-hidden="true"></i>
</button>
<div class="pagination__pages">
<input
#pageNumber
class="pagination__page_input"
aria-label="Current page"
i18n-aria-label
type="number"
min="1"
[max]="totalPages"
[value]="page"
(input)="selectPage(pageNumber.valueAsNumber)"
/>
<span aria-hidden="true"> of {{ totalPages }} </span>
</div>
<button
class="pagination__btn pagination__btn_next"
aria-label="Go to next page"
i18n-aria-label
(click)="nextPage()"
[disabled]="!canNext()"
>
<i class="fa fa-angle-right"
aria-hidden="true"></i>
</button>
<button
class="pagination__btn pagination__btn_last"
aria-label="Go to last page"
i18n-aria-label
[disabled]="!canNext()"
(click)="selectPage(totalPages)"
>
<i class="fa fa-angle-double-right"
aria-hidden="true"></i>
</button>
</nav>
| 1,464 | 23.830508 | 57 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.html
|
<div class="dataTables_wrapper">
<div *ngIf="onlyActionHeader"
class="dataTables_header clearfix">
<div class="cd-datatable-actions">
<ng-content select=".only-table-actions"></ng-content>
</div>
</div>
<div class="dataTables_header clearfix"
*ngIf="toolHeader">
<!-- actions -->
<div class="cd-datatable-actions">
<ng-content select=".table-actions"></ng-content>
</div>
<!-- end actions -->
<!-- column filters -->
<div *ngIf="columnFilters.length !== 0"
class="btn-group widget-toolbar">
<div ngbDropdown
placement="bottom-right"
class="tc_filter_name">
<button ngbDropdownToggle
class="btn btn-light"
title="Filter">
<i [ngClass]="[icons.large, icons.filter]"></i>
{{ selectedFilter.column.name }}
</button>
<div ngbDropdownMenu>
<ng-container *ngFor="let filter of columnFilters">
<button ngbDropdownItem
(click)="onSelectFilter(filter); false">{{ filter.column.name }}</button>
</ng-container>
</div>
</div>
<div ngbDropdown
placement="bottom-right"
class="tc_filter_option">
<button ngbDropdownToggle
class="btn btn-light"
[class.disabled]="selectedFilter.options.length === 0">
{{ selectedFilter.value ? selectedFilter.value.formatted: 'Any' }}
</button>
<div ngbDropdownMenu>
<ng-container *ngFor="let option of selectedFilter.options">
<button ngbDropdownItem
(click)="onChangeFilter(selectedFilter, option); false">
{{ option.formatted }}
<i *ngIf="selectedFilter.value !== undefined && (selectedFilter.value.raw === option.raw)"
[ngClass]="[icons.check]"></i>
</button>
</ng-container>
</div>
</div>
</div>
<!-- end column filters -->
<!-- search -->
<div class="input-group search"
*ngIf="searchField">
<span class="input-group-text">
<i [ngClass]="[icons.search]"></i>
</span>
<input aria-label="search"
class="form-control"
type="text"
[(ngModel)]="search"
(keyup)="updateFilter()">
<button type="button"
class="btn btn-light"
title="Clear"
(click)="onClearSearch()">
<i class="icon-prepend {{ icons.destroy }}"></i>
</button>
</div>
<!-- end search -->
<!-- pagination limit -->
<div class="input-group dataTables_paginate"
*ngIf="limit">
<input aria-label="table pagination"
class="form-control"
type="number"
min="1"
max="9999"
[value]="userConfig.limit"
(click)="setLimit($event)"
(keyup)="setLimit($event)"
(blur)="setLimit($event)">
</div>
<!-- end pagination limit-->
<!-- show hide columns -->
<div class="widget-toolbar">
<div ngbDropdown
autoClose="outside"
class="tc_menuitem">
<button ngbDropdownToggle
class="btn btn-light tc_columnBtn"
title="toggle columns">
<i [ngClass]="[icons.large, icons.table]"></i>
</button>
<div ngbDropdownMenu>
<ng-container *ngFor="let column of columns">
<button ngbDropdownItem
*ngIf="column.name !== ''"
(click)="toggleColumn(column); false;">
<div class="custom-control custom-checkbox py-0">
<input class="custom-control-input"
type="checkbox"
[name]="column.prop"
id="{{ column.prop }}{{ tableName }}"
[checked]="!column.isHidden">
<label class="custom-control-label"
for="{{ column.prop }}{{ tableName }}">{{ column.name }}</label>
</div>
</button>
</ng-container>
</div>
</div>
</div>
<!-- end show hide columns -->
<!-- refresh button -->
<div class="widget-toolbar tc_refreshBtn"
*ngIf="fetchData.observers.length > 0">
<button type="button"
[class]="'btn btn-' + status.type"
[ngbTooltip]="status.msg"
(click)="refreshBtn()"
title="Refresh">
<i [ngClass]="[icons.large, icons.refresh]"
[class.fa-spin]="updating || loadingIndicator"></i>
</button>
</div>
<!-- end refresh button -->
</div>
<div class="dataTables_header clearfix"
*ngIf="toolHeader && columnFiltered">
<!-- filter chips for column filters -->
<div class="filter-chips">
<span *ngFor="let filter of columnFilters">
<span *ngIf="filter.value"
class="badge badge-info me-2">
<span class="me-2">{{ filter.column.name }}: {{ filter.value.formatted }}</span>
<a class="badge-remove"
(click)="onChangeFilter(filter); false">
<i [ngClass]="[icons.destroy]"
aria-hidden="true"></i>
</a>
</span>
</span>
<a class="tc_clearSelections"
href=""
(click)="onClearFilters(); false">
<ng-container i18n>Clear filters</ng-container>
</a>
</div>
<!-- end filter chips for column filters -->
</div>
<ngx-datatable #table
class="bootstrap cd-datatable"
[cssClasses]="paginationClasses"
[selectionType]="selectionType"
[selected]="selection.selected"
(select)="onSelect($event)"
[sorts]="userConfig.sorts"
(sort)="changeSorting($event)"
[columns]="tableColumns"
[columnMode]="columnMode"
[rows]="rows"
[rowClass]="getRowClass()"
[headerHeight]="header ? 'auto' : 0"
[footerHeight]="footer ? 'auto' : 0"
[count]="count"
[externalPaging]="serverSide"
[externalSorting]="serverSide"
[limit]="userConfig.limit > 0 ? userConfig.limit : undefined"
[offset]="userConfig.offset >= 0 ? userConfig.offset : 0"
(page)="changePage($event)"
[loadingIndicator]="loadingIndicator"
[rowIdentity]="rowIdentity()"
[rowHeight]="'auto'">
<!-- Row Selection Template-->
<ng-template #rowSelectionTpl
let-value="value"
let-isSelected="isSelected"
ngx-datatable-cell-template>
<input type="checkbox"
[attr.aria-label]="isSelected ? 'selected' : 'select'"
[checked]="isSelected"
class="cd-datatable-checkbox" />
</ng-template>
<!-- Row Detail Template -->
<ngx-datatable-row-detail rowHeight="auto"
#detailRow>
<ng-template let-row="row"
let-expanded="expanded"
ngx-datatable-row-detail-template>
<!-- Table Details -->
<ng-content select="[cdTableDetail]"></ng-content>
</ng-template>
</ngx-datatable-row-detail>
<ngx-datatable-footer>
<ng-template ngx-datatable-footer-template
let-rowCount="rowCount"
let-pageSize="pageSize"
let-selectedCount="selectedCount"
let-curPage="curPage"
let-offset="offset"
let-isVisible="isVisible">
<div class="page-count">
<span *ngIf="selectionType">
{{ selectedCount }} <ng-container i18n="X selected">selected</ng-container> /
</span>
<!-- rowCount might have different semantics with or without serverSide.
We treat serverSide (backend-driven tables) as a specific case.
-->
<span *ngIf="!serverSide else serverSideTpl">
<span *ngIf="rowCount != data?.length">
{{ rowCount }} <ng-container i18n="X found">found</ng-container> /
</span>
{{ data?.length || 0 }} <ng-container i18n="X total">total</ng-container>
</span>
<ng-template #serverSideTpl>
{{ data?.length || 0 }} <ng-container i18n="X found">found</ng-container> /
{{ rowCount }} <ng-container i18n="X total">total</ng-container>
</ng-template>
</div>
<cd-table-pagination [page]="curPage"
[size]="pageSize"
[count]="rowCount"
[hidden]="!((rowCount / pageSize) > 1)"
(pageChange)="table.onFooterPage($event)"></cd-table-pagination>
</ng-template>
</ngx-datatable-footer>
</ngx-datatable>
</div>
<!-- cell templates that can be accessed from outside -->
<ng-template #tableCellBoldTpl
let-value="value">
<strong>{{ value }}</strong>
</ng-template>
<ng-template #sparklineTpl
let-row="row"
let-value="value">
<cd-sparkline [data]="value"
[isBinary]="row.cdIsBinary"></cd-sparkline>
</ng-template>
<ng-template #routerLinkTpl
let-row="row"
let-value="value">
<a [routerLink]="[row.cdLink]"
[queryParams]="row.cdParams">{{ value }}</a>
</ng-template>
<ng-template #checkIconTpl
let-value="value">
<i [ngClass]="[icons.check]"
[hidden]="!(value | boolean)"></i>
</ng-template>
<ng-template #perSecondTpl
let-row="row"
let-value="value">
{{ value | dimless }} /s
</ng-template>
<ng-template #executingTpl
let-column="column"
let-row="row"
let-value="value">
<i [ngClass]="[icons.spinner, icons.spin]"
*ngIf="row.cdExecuting"></i>
<span [ngClass]="column?.customTemplateConfig?.valueClass">
{{ value }}
</span>
<span *ngIf="row.cdExecuting"
[ngClass]="column?.customTemplateConfig?.executingClass ? column.customTemplateConfig.executingClass : 'text-muted italic'">({{ row.cdExecuting }})</span>
</ng-template>
<ng-template #classAddingTpl
let-value="value">
<span class="{{ value | pipeFunction:useCustomClass:this }}">{{ value }}</span>
</ng-template>
<ng-template #badgeTpl
let-column="column"
let-value="value">
<span *ngFor="let item of (value | array); last as last">
<span class="badge"
[ngClass]="(column?.customTemplateConfig?.map && column?.customTemplateConfig?.map[item]?.class) ? column.customTemplateConfig.map[item].class : (column?.customTemplateConfig?.class ? column.customTemplateConfig.class : 'badge-primary')"
*ngIf="(column?.customTemplateConfig?.map && column?.customTemplateConfig?.map[item]?.value) ? column.customTemplateConfig.map[item].value : column?.customTemplateConfig?.prefix ? column.customTemplateConfig.prefix + item : item">
{{ (column?.customTemplateConfig?.map && column?.customTemplateConfig?.map[item]?.value) ? column.customTemplateConfig.map[item].value : column?.customTemplateConfig?.prefix ? column.customTemplateConfig.prefix + item : item }}
</span>
<span *ngIf="!last"> </span>
</span>
</ng-template>
<ng-template #mapTpl
let-column="column"
let-value="value">
<span>{{ value | map:column?.customTemplateConfig }}</span>
</ng-template>
<ng-template #truncateTpl
let-column="column"
let-value="value">
<span data-toggle="tooltip"
[title]="value">{{ value | truncate:column?.customTemplateConfig?.length:column?.customTemplateConfig?.omission }}</span>
</ng-template>
<ng-template #rowDetailsTpl
let-row="row"
let-isExpanded="expanded"
ngx-datatable-cell-template>
<a href="javascript:void(0)"
[class.expand-collapse-icon-right]="!isExpanded"
[class.expand-collapse-icon-down]="isExpanded"
class="expand-collapse-icon tc_expand-collapse"
title="Expand/Collapse Row"
i18n-title
(click)="toggleExpandRow(row, isExpanded, $event)">
</a>
</ng-template>
<ng-template #timeAgoTpl
let-value="value">
<span data-toggle="tooltip"
[title]="value | cdDate">{{ value | relativeDate }}</span>
</ng-template>
| 12,585 | 35.80117 | 247 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/forms/crud-form/crud-form.component.html
|
<div class="cd-col-form">
<div class="card pb-0"
*ngIf="formUISchema$ | async as formUISchema">
<div i18n="form title"
class="card-header">{{ formUISchema.title }}</div>
<form *ngIf="formUISchema.uiSchema"
[formGroup]="form"
(ngSubmit)="submit(model, formUISchema.taskInfo)">
<div class="card-body position-relative">
<formly-form [form]="form"
[fields]="formUISchema.controlSchema"
[model]="model"
[options]="{formState: formUISchema.uiSchema}"></formly-form>
</div>
<div class="card-footer">
<cd-form-button-panel (submitActionEvent)="submit(model, formUISchema.taskInfo)"
[form]="formDir"
[submitText]="formUISchema.title"
[disabled]="!form.valid"
wrappingClass="text-right"></cd-form-button-panel>
</div>
</form>
</div>
</div>
| 1,007 | 37.769231 | 88 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/forms/crud-form/formly-array-type/formly-array-type.component.html
|
<div class="mb-3">
<legend *ngIf="props.label"
class="cd-header mt-1"
i18n>{{ props.label }}</legend>
<p *ngIf="props.description"
i18n>{{ props.description }}</p>
<div *ngFor="let field of field.fieldGroup; let i = index"
class="d-flex">
<formly-field class="col"
[field]="field"></formly-field>
<div class="action-btn">
<button class="btn btn-light ms-1"
type="button"
(click)="addWrapper()">
<i [ngClass]="icons.add"></i>
</button>
<button class="btn btn-light ms-1"
type="button"
(click)="remove(i)"
*ngIf="field.props.removable !== false">
<i [ngClass]="icons.trash"></i>
</button>
</div>
</div>
<div *ngIf="field.fieldGroup.length === 0"
class="text-right">
<button class="btn btn-light"
type="button"
(click)="addWrapper()"
i18n>
<i [ngClass]="icons.add"></i>
Add {{ props.label }}
</button>
</div>
<span class="invalid-feedback"
role="alert"
*ngIf="showError && formControl.errors">
<formly-validation-message [field]="field"></formly-validation-message>
</span>
</div>
| 1,251 | 28.116279 | 75 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/forms/crud-form/formly-file-type/formly-file-type.component.html
|
<input type="file"
[formControl]="formControl"
[formlyAttributes]="field"
/>
| 98 | 18.8 | 34 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/forms/crud-form/formly-input-type/formly-input-type.component.html
|
<input [formControl]="formControl"
[formlyAttributes]="field"
class="form-control col-form-input"/>
| 114 | 27.75 | 44 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/forms/crud-form/formly-input-wrapper/formly-input-wrapper.component.html
|
<ng-template #labelTemplate>
<div class="d-flex align-items-center">
<label *ngIf="props.label && props.hideLabel !== true"
[attr.for]="id"
class="form-label">
{{ props.label }}
<span *ngIf="props.required && props.hideRequiredMarker !== true"
aria-hidden="true">*</span>
<cd-helper *ngIf="helper">
<span [innerHTML]="helper"></span>
</cd-helper>
</label>
</div>
</ng-template>
<div class="mb-3"
[class.form-floating]="props.labelPosition === 'floating'"
[class.has-error]="showError">
<ng-container *ngIf="props.labelPosition !== 'floating'">
<ng-container [ngTemplateOutlet]="labelTemplate"></ng-container>
</ng-container>
<ng-container #fieldComponent></ng-container>
<ng-container *ngIf="props.labelPosition === 'floating'">
<ng-container [ngTemplateOutlet]="labelTemplate"></ng-container>
</ng-container>
<div *ngIf="showError"
class="invalid-feedback"
[style.display]="'block'">
<formly-validation-message [field]="field"></formly-validation-message>
</div>
<small *ngIf="props.description"
class="form-text text-muted">{{ props.description }}</small>
</div>
| 1,209 | 30.842105 | 75 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/forms/crud-form/formly-object-type/formly-object-type.component.html
|
<div class="mb-3">
<legend *ngIf="props.label"
class="cd-col-form-label"
i18n>{{ props.label }}</legend>
<p *ngIf="props.description"
i18n>{{ props.description }}</p>
<div class="alert alert-danger"
role="alert"
*ngIf="showError && formControl.errors">
<formly-validation-message [field]="field"></formly-validation-message>
</div>
<div [ngClass]="inputClass">
<formly-field *ngFor="let f of field.fieldGroup"
[field]="f"
class="flex-grow-1"></formly-field>
</div>
</div>
| 567 | 30.555556 | 75 |
html
|
null |
ceph-main/src/pybind/mgr/dashboard/frontend/src/app/shared/forms/crud-form/formly-textarea-type/formly-textarea-type.component.html
|
<textarea #textArea
[formControl]="formControl"
[cols]="props.cols"
[rows]="props.rows"
class="form-control"
[class.is-invalid]="showError"
[formlyAttributes]="field"
(change)="onChange()">
</textarea>
| 272 | 26.3 | 40 |
html
|
null |
ceph-main/src/pybind/mgr/rook/generate_rook_ceph_client.sh
|
#!/bin/sh
set -e
script_location="$(dirname "$(readlink -f "$0")")"
cd "$script_location"
rm -rf rook_client
cp -r ./rook-client-python/rook_client .
rm -rf rook_client/cassandra
rm -rf rook_client/edgefs
rm -rf rook_client/tests
| 235 | 14.733333 | 50 |
sh
|
null |
ceph-main/src/rbd_fuse/rbd-fuse.cc
|
/*
* rbd-fuse
*/
#include "include/int_types.h"
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <getopt.h>
#include <assert.h>
#include <string>
#include <mutex>
#include <limits.h>
#if defined(__FreeBSD__)
#include <sys/param.h>
#endif
#include "include/compat.h"
#include "include/rbd/librbd.h"
#include "include/ceph_assert.h"
#include "common/ceph_argparse.h"
#include "common/ceph_context.h"
#include "include/ceph_fuse.h"
#include "global/global_init.h"
#include "global/global_context.h"
static int gotrados = 0;
char *pool_name;
char *nspace_name;
char *mount_image_name;
rados_t cluster;
rados_ioctx_t ioctx;
std::mutex readdir_lock;
struct rbd_stat {
u_char valid;
rbd_image_info_t rbd_info;
};
struct rbd_options {
char *pool_name;
char *nspace_name;
char *image_name;
};
struct rbd_image {
char *image_name;
struct rbd_image *next;
};
struct rbd_image_data {
struct rbd_image *images;
rbd_image_spec_t *image_specs;
size_t image_spec_count;
};
struct rbd_image_data rbd_image_data;
struct rbd_openimage {
char *image_name;
rbd_image_t image;
struct rbd_stat rbd_stat;
};
#define MAX_RBD_IMAGES 128
struct rbd_openimage opentbl[MAX_RBD_IMAGES];
struct rbd_options rbd_options = {(char*) "rbd", (char*) "", NULL};
#define rbdsize(fd) opentbl[fd].rbd_stat.rbd_info.size
#define rbdblksize(fd) opentbl[fd].rbd_stat.rbd_info.obj_size
#define rbdblkcnt(fd) opentbl[fd].rbd_stat.rbd_info.num_objs
uint64_t imagesize = 1024ULL * 1024 * 1024;
uint64_t imageorder = 22ULL;
uint64_t imagefeatures = 1ULL;
// Minimize calls to rbd_list: marks bracketing of opendir/<ops>/releasedir
int in_opendir;
/* prototypes */
int connect_to_cluster(rados_t *pcluster);
void enumerate_images(struct rbd_image_data *data);
int open_rbd_image(const char *image_name);
int find_openrbd(const char *path);
void simple_err(const char *msg, int err);
void
enumerate_images(struct rbd_image_data *data)
{
struct rbd_image **head = &data->images;
struct rbd_image *im, *next;
int ret;
if (*head != NULL) {
for (im = *head; im != NULL;) {
next = im->next;
free(im);
im = next;
}
*head = NULL;
rbd_image_spec_list_cleanup(data->image_specs,
data->image_spec_count);
free(data->image_specs);
data->image_specs = NULL;
data->image_spec_count = 0;
}
while (true) {
ret = rbd_list2(ioctx, data->image_specs,
&data->image_spec_count);
if (ret == -ERANGE) {
data->image_specs = static_cast<rbd_image_spec_t *>(
realloc(data->image_specs,
sizeof(rbd_image_spec_t) * data->image_spec_count));
} else if (ret < 0) {
simple_err("Failed to list images", ret);
} else {
break;
}
}
if (*nspace_name != '\0') {
fprintf(stderr, "pool/namespace %s/%s: ", pool_name, nspace_name);
} else {
fprintf(stderr, "pool %s: ", pool_name);
}
for (size_t idx = 0; idx < data->image_spec_count; ++idx) {
if ((mount_image_name == NULL) ||
((strlen(mount_image_name) > 0) &&
(strcmp(data->image_specs[idx].name, mount_image_name) == 0))) {
fprintf(stderr, "%s, ", data->image_specs[idx].name);
im = static_cast<rbd_image*>(malloc(sizeof(*im)));
im->image_name = data->image_specs[idx].name;
im->next = *head;
*head = im;
}
}
fprintf(stderr, "\n");
}
int
find_openrbd(const char *path)
{
int i;
/* find in opentbl[] entry if already open */
for (i = 0; i < MAX_RBD_IMAGES; i++) {
if ((opentbl[i].image_name != NULL) &&
(strcmp(opentbl[i].image_name, path) == 0)) {
return i;
}
}
return -1;
}
int
open_rbd_image(const char *image_name)
{
struct rbd_image *im;
struct rbd_openimage *rbd = NULL;
int fd;
if (image_name == (char *)NULL)
return -1;
// relies on caller to keep rbd_image_data up to date
for (im = rbd_image_data.images; im != NULL; im = im->next) {
if (strcmp(im->image_name, image_name) == 0) {
break;
}
}
if (im == NULL)
return -1;
/* find in opentbl[] entry if already open */
if ((fd = find_openrbd(image_name)) != -1) {
rbd = &opentbl[fd];
} else {
int i;
// allocate an opentbl[] and open the image
for (i = 0; i < MAX_RBD_IMAGES; i++) {
if (opentbl[i].image == NULL) {
fd = i;
rbd = &opentbl[fd];
rbd->image_name = strdup(image_name);
break;
}
}
if (i == MAX_RBD_IMAGES || !rbd)
return -1;
int ret = rbd_open(ioctx, rbd->image_name, &(rbd->image), NULL);
if (ret < 0) {
simple_err("open_rbd_image: can't open: ", ret);
return ret;
}
}
rbd_stat(rbd->image, &(rbd->rbd_stat.rbd_info),
sizeof(rbd_image_info_t));
rbd->rbd_stat.valid = 1;
return fd;
}
static void
iter_images(void *cookie,
void (*iter)(void *cookie, const char *image))
{
struct rbd_image *im;
readdir_lock.lock();
for (im = rbd_image_data.images; im != NULL; im = im->next)
iter(cookie, im->image_name);
readdir_lock.unlock();
}
static void count_images_cb(void *cookie, const char *image)
{
(*((unsigned int *)cookie))++;
}
static int count_images(void)
{
unsigned int count = 0;
readdir_lock.lock();
enumerate_images(&rbd_image_data);
readdir_lock.unlock();
iter_images(&count, count_images_cb);
return count;
}
extern "C" {
static int rbdfs_getattr(const char *path, struct stat *stbuf
#if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 0)
, struct fuse_file_info *fi
#endif
)
{
int fd;
time_t now;
if (!gotrados)
return -ENXIO;
if (path[0] == 0)
return -ENOENT;
memset(stbuf, 0, sizeof(struct stat));
if (strcmp(path, "/") == 0) {
now = time(NULL);
stbuf->st_mode = S_IFDIR + 0755;
stbuf->st_nlink = 2+count_images();
stbuf->st_uid = getuid();
stbuf->st_gid = getgid();
stbuf->st_size = 1024;
stbuf->st_blksize = 1024;
stbuf->st_blocks = 1;
stbuf->st_atime = now;
stbuf->st_mtime = now;
stbuf->st_ctime = now;
return 0;
}
if (!in_opendir) {
readdir_lock.lock();
enumerate_images(&rbd_image_data);
readdir_lock.unlock();
}
fd = open_rbd_image(path + 1);
if (fd < 0)
return -ENOENT;
now = time(NULL);
stbuf->st_mode = S_IFREG | 0666;
stbuf->st_nlink = 1;
stbuf->st_uid = getuid();
stbuf->st_gid = getgid();
stbuf->st_size = rbdsize(fd);
stbuf->st_blksize = rbdblksize(fd);
stbuf->st_blocks = rbdblkcnt(fd);
stbuf->st_atime = now;
stbuf->st_mtime = now;
stbuf->st_ctime = now;
return 0;
}
static int rbdfs_open(const char *path, struct fuse_file_info *fi)
{
int fd;
if (!gotrados)
return -ENXIO;
if (path[0] == 0)
return -ENOENT;
readdir_lock.lock();
enumerate_images(&rbd_image_data);
readdir_lock.unlock();
fd = open_rbd_image(path + 1);
if (fd < 0)
return -ENOENT;
fi->fh = fd;
return 0;
}
static int rbdfs_read(const char *path, char *buf, size_t size,
off_t offset, struct fuse_file_info *fi)
{
size_t numread;
struct rbd_openimage *rbd;
if (!gotrados)
return -ENXIO;
rbd = &opentbl[fi->fh];
numread = 0;
while (size > 0) {
ssize_t ret;
ret = rbd_read(rbd->image, offset, size, buf);
if (ret <= 0)
break;
buf += ret;
size -= ret;
offset += ret;
numread += ret;
}
return numread;
}
static int rbdfs_write(const char *path, const char *buf, size_t size,
off_t offset, struct fuse_file_info *fi)
{
size_t numwritten;
struct rbd_openimage *rbd;
if (!gotrados)
return -ENXIO;
rbd = &opentbl[fi->fh];
numwritten = 0;
while (size > 0) {
ssize_t ret;
if ((size_t)(offset + size) > rbdsize(fi->fh)) {
int r;
fprintf(stderr, "rbdfs_write resizing %s to 0x%" PRIxMAX "\n",
path, offset+size);
r = rbd_resize(rbd->image, offset+size);
if (r < 0)
return r;
r = rbd_stat(rbd->image, &(rbd->rbd_stat.rbd_info),
sizeof(rbd_image_info_t));
if (r < 0)
return r;
}
ret = rbd_write(rbd->image, offset, size, buf);
if (ret < 0)
break;
buf += ret;
size -= ret;
offset += ret;
numwritten += ret;
}
return numwritten;
}
static void rbdfs_statfs_image_cb(void *num, const char *image)
{
int fd;
((uint64_t *)num)[0]++;
fd = open_rbd_image(image);
if (fd >= 0)
((uint64_t *)num)[1] += rbdsize(fd);
}
static int rbdfs_statfs(const char *path, struct statvfs *buf)
{
uint64_t num[2];
if (!gotrados)
return -ENXIO;
num[0] = 1;
num[1] = 0;
readdir_lock.lock();
enumerate_images(&rbd_image_data);
readdir_lock.unlock();
iter_images(num, rbdfs_statfs_image_cb);
#define RBDFS_BSIZE 4096
buf->f_bsize = RBDFS_BSIZE;
buf->f_frsize = RBDFS_BSIZE;
buf->f_blocks = num[1] / RBDFS_BSIZE;
buf->f_bfree = 0;
buf->f_bavail = 0;
buf->f_files = num[0];
buf->f_ffree = 0;
buf->f_favail = 0;
buf->f_fsid = 0;
buf->f_flag = 0;
buf->f_namemax = PATH_MAX;
return 0;
}
static int rbdfs_fsync(const char *path, int datasync,
struct fuse_file_info *fi)
{
if (!gotrados)
return -ENXIO;
rbd_flush(opentbl[fi->fh].image);
return 0;
}
static int rbdfs_opendir(const char *path, struct fuse_file_info *fi)
{
// only one directory, so global "in_opendir" flag should be fine
readdir_lock.lock();
in_opendir++;
enumerate_images(&rbd_image_data);
readdir_lock.unlock();
return 0;
}
struct rbdfs_readdir_info {
void *buf;
fuse_fill_dir_t filler;
};
static void rbdfs_readdir_cb(void *_info, const char *name)
{
struct rbdfs_readdir_info *info = (struct rbdfs_readdir_info*) _info;
filler_compat(info->filler, info->buf, name, NULL, 0);
}
static int rbdfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *fi
#if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 0)
, enum fuse_readdir_flags
#endif
)
{
struct rbdfs_readdir_info info = { buf, filler };
if (!gotrados)
return -ENXIO;
if (!in_opendir)
fprintf(stderr, "in readdir, but not inside opendir?\n");
if (strcmp(path, "/") != 0)
return -ENOENT;
filler_compat(filler, buf, ".", NULL, 0);
filler_compat(filler, buf, "..", NULL, 0);
iter_images(&info, rbdfs_readdir_cb);
return 0;
}
static int rbdfs_releasedir(const char *path, struct fuse_file_info *fi)
{
// see opendir comments
readdir_lock.lock();
in_opendir--;
readdir_lock.unlock();
return 0;
}
void *
rbdfs_init(struct fuse_conn_info *conn
#if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 0)
, struct fuse_config *cfg
#endif
)
{
int ret;
// init cannot fail, so if we fail here, gotrados remains at 0,
// causing other operations to fail immediately with ENXIO
ret = connect_to_cluster(&cluster);
if (ret < 0)
exit(90);
pool_name = rbd_options.pool_name;
nspace_name = rbd_options.nspace_name;
mount_image_name = rbd_options.image_name;
ret = rados_ioctx_create(cluster, pool_name, &ioctx);
if (ret < 0)
exit(91);
#if FUSE_VERSION >= FUSE_MAKE_VERSION(2, 8) && FUSE_VERSION < FUSE_MAKE_VERSION(3, 0)
conn->want |= FUSE_CAP_BIG_WRITES;
#endif
rados_ioctx_set_namespace(ioctx, nspace_name);
gotrados = 1;
// init's return value shows up in fuse_context.private_data,
// also to void (*destroy)(void *); useful?
return NULL;
}
void
rbdfs_destroy(void *unused)
{
if (!gotrados)
return;
for (int i = 0; i < MAX_RBD_IMAGES; ++i) {
if (opentbl[i].image) {
rbd_close(opentbl[i].image);
opentbl[i].image = NULL;
}
}
rados_ioctx_destroy(ioctx);
rados_shutdown(cluster);
}
int
rbdfs_checkname(const char *checkname)
{
const char *extra[] = {"@", "/"};
std::string strCheckName(checkname);
if (strCheckName.empty())
return -EINVAL;
unsigned int sz = sizeof(extra) / sizeof(const char*);
for (unsigned int i = 0; i < sz; i++)
{
std::string ex(extra[i]);
if (std::string::npos != strCheckName.find(ex))
return -EINVAL;
}
return 0;
}
// return -errno on error. fi->fh is not set until open time
int
rbdfs_create(const char *path, mode_t mode, struct fuse_file_info *fi)
{
int r;
int order = imageorder;
r = rbdfs_checkname(path+1);
if (r != 0)
{
return r;
}
r = rbd_create2(ioctx, path+1, imagesize, imagefeatures, &order);
return r;
}
int
rbdfs_rename(const char *path, const char *destname
#if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 0)
, unsigned int flags
#endif
)
{
int r;
r = rbdfs_checkname(destname+1);
if (r != 0)
{
return r;
}
if (strcmp(path, "/") == 0)
return -EINVAL;
return rbd_rename(ioctx, path+1, destname+1);
}
int
rbdfs_utimens(const char *path, const struct timespec tv[2]
#if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 0)
, struct fuse_file_info *fi
#endif
)
{
// called on create; not relevant
return 0;
}
int
rbdfs_unlink(const char *path)
{
int fd = find_openrbd(path+1);
if (fd != -1) {
struct rbd_openimage *rbd = &opentbl[fd];
rbd_close(rbd->image);
rbd->image = 0;
free(rbd->image_name);
rbd->rbd_stat.valid = 0;
}
return rbd_remove(ioctx, path+1);
}
int
rbdfs_truncate(const char *path, off_t size
#if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 0)
, struct fuse_file_info *fi
#endif
)
{
int fd;
int r;
struct rbd_openimage *rbd;
if ((fd = open_rbd_image(path+1)) < 0)
return -ENOENT;
rbd = &opentbl[fd];
fprintf(stderr, "truncate %s to %" PRIdMAX " (0x%" PRIxMAX ")\n",
path, size, size);
r = rbd_resize(rbd->image, size);
if (r < 0)
return r;
r = rbd_stat(rbd->image, &(rbd->rbd_stat.rbd_info),
sizeof(rbd_image_info_t));
if (r < 0)
return r;
return 0;
}
/**
* set an xattr on path, with name/value, length size.
* Presumably flags are from Linux, as in XATTR_CREATE or
* XATTR_REPLACE (both "set", but fail if exist vs fail if not exist.
*
* We accept xattrs only on the root node.
*
* All values converted with strtoull, so can be expressed in any base
*/
struct rbdfuse_attr {
char *attrname;
uint64_t *attrvalp;
} attrs[] = {
{ (char*) "user.rbdfuse.imagesize", &imagesize },
{ (char*) "user.rbdfuse.imageorder", &imageorder },
{ (char*) "user.rbdfuse.imagefeatures", &imagefeatures },
{ NULL, NULL }
};
int
rbdfs_setxattr(const char *path, const char *name, const char *value,
size_t size,
int flags
#if defined(DARWIN)
,uint32_t pos
#endif
)
{
struct rbdfuse_attr *ap;
if (strcmp(path, "/") != 0)
return -EINVAL;
for (ap = attrs; ap->attrname != NULL; ap++) {
if (strcmp(name, ap->attrname) == 0) {
*ap->attrvalp = strtoull(value, NULL, 0);
fprintf(stderr, "rbd-fuse: %s set to 0x%" PRIx64 "\n",
ap->attrname, *ap->attrvalp);
return 0;
}
}
return -EINVAL;
}
int
rbdfs_getxattr(const char *path, const char *name, char *value,
size_t size
#if defined(DARWIN)
,uint32_t position
#endif
)
{
struct rbdfuse_attr *ap;
char buf[128];
// allow gets on other files; ls likes to ask for things like
// security.*
for (ap = attrs; ap->attrname != NULL; ap++) {
if (strcmp(name, ap->attrname) == 0) {
sprintf(buf, "%" PRIu64, *ap->attrvalp);
if (value != NULL && size >= strlen(buf))
strcpy(value, buf);
fprintf(stderr, "rbd-fuse: get %s\n", ap->attrname);
return (strlen(buf));
}
}
return 0;
}
int
rbdfs_listxattr(const char *path, char *list, size_t len)
{
struct rbdfuse_attr *ap;
size_t required_len = 0;
if (strcmp(path, "/") != 0)
return -EINVAL;
for (ap = attrs; ap->attrname != NULL; ap++)
required_len += strlen(ap->attrname) + 1;
if (len >= required_len) {
for (ap = attrs; ap->attrname != NULL; ap++) {
sprintf(list, "%s", ap->attrname);
list += strlen(ap->attrname) + 1;
}
}
return required_len;
}
const static struct fuse_operations rbdfs_oper = {
getattr: rbdfs_getattr,
readlink: 0,
#if FUSE_VERSION < FUSE_MAKE_VERSION(3, 0)
getdir: 0,
#endif
mknod: 0,
mkdir: 0,
unlink: rbdfs_unlink,
rmdir: 0,
symlink: 0,
rename: rbdfs_rename,
link: 0,
chmod: 0,
chown: 0,
truncate: rbdfs_truncate,
#if FUSE_VERSION < FUSE_MAKE_VERSION(3, 0)
utime: 0,
#endif
open: rbdfs_open,
read: rbdfs_read,
write: rbdfs_write,
statfs: rbdfs_statfs,
flush: 0,
release: 0,
fsync: rbdfs_fsync,
setxattr: rbdfs_setxattr,
getxattr: rbdfs_getxattr,
listxattr: rbdfs_listxattr,
removexattr: 0,
opendir: rbdfs_opendir,
readdir: rbdfs_readdir,
releasedir: rbdfs_releasedir,
fsyncdir: 0,
init: rbdfs_init,
destroy: rbdfs_destroy,
access: 0,
create: rbdfs_create,
#if FUSE_VERSION < FUSE_MAKE_VERSION(3, 0)
ftruncate: 0,
fgetattr: 0,
#endif
lock: 0,
utimens: rbdfs_utimens,
/* skip unimplemented */
};
} /* extern "C" */
enum {
KEY_HELP,
KEY_VERSION,
KEY_RADOS_POOLNAME,
KEY_RADOS_POOLNAME_LONG,
KEY_RADOS_NSPACENAME,
KEY_RADOS_NSPACENAME_LONG,
KEY_RBD_IMAGENAME,
KEY_RBD_IMAGENAME_LONG
};
static struct fuse_opt rbdfs_opts[] = {
FUSE_OPT_KEY("-h", KEY_HELP),
FUSE_OPT_KEY("--help", KEY_HELP),
FUSE_OPT_KEY("-V", KEY_VERSION),
FUSE_OPT_KEY("--version", KEY_VERSION),
{"-p %s", offsetof(struct rbd_options, pool_name), KEY_RADOS_POOLNAME},
{"--poolname=%s", offsetof(struct rbd_options, pool_name),
KEY_RADOS_POOLNAME_LONG},
{"-s %s", offsetof(struct rbd_options, nspace_name), KEY_RADOS_NSPACENAME},
{"--namespace=%s", offsetof(struct rbd_options, nspace_name),
KEY_RADOS_NSPACENAME_LONG},
{"-r %s", offsetof(struct rbd_options, image_name), KEY_RBD_IMAGENAME},
{"--image=%s", offsetof(struct rbd_options, image_name),
KEY_RBD_IMAGENAME_LONG},
FUSE_OPT_END
};
static void usage(const char *progname)
{
fprintf(stderr,
"Usage: %s mountpoint [options]\n"
"\n"
"General options:\n"
" -h --help print help\n"
" -V --version print version\n"
" -c --conf ceph configuration file [/etc/ceph/ceph.conf]\n"
" -p --poolname rados pool name [rbd]\n"
" -s --namespace rados namespace name []\n"
" -r --image RBD image name\n"
"\n", progname);
}
static int rbdfs_opt_proc(void *data, const char *arg, int key,
struct fuse_args *outargs)
{
if (key == KEY_HELP) {
usage(outargs->argv[0]);
fuse_opt_add_arg(outargs, "-ho");
fuse_main(outargs->argc, outargs->argv, &rbdfs_oper, NULL);
exit(1);
}
if (key == KEY_VERSION) {
fuse_opt_add_arg(outargs, "--version");
fuse_main(outargs->argc, outargs->argv, &rbdfs_oper, NULL);
exit(0);
}
if (key == KEY_RADOS_POOLNAME) {
if (rbd_options.pool_name != NULL) {
free(rbd_options.pool_name);
rbd_options.pool_name = NULL;
}
rbd_options.pool_name = strdup(arg+2);
return 0;
}
if (key == KEY_RADOS_NSPACENAME) {
if (rbd_options.nspace_name != NULL) {
free(rbd_options.nspace_name);
rbd_options.nspace_name = NULL;
}
rbd_options.nspace_name = strdup(arg+2);
return 0;
}
if (key == KEY_RBD_IMAGENAME) {
if (rbd_options.image_name!= NULL) {
free(rbd_options.image_name);
rbd_options.image_name = NULL;
}
rbd_options.image_name = strdup(arg+2);
return 0;
}
return 1;
}
void
simple_err(const char *msg, int err)
{
fprintf(stderr, "%s: %s\n", msg, strerror(-err));
return;
}
int
connect_to_cluster(rados_t *pcluster)
{
int r;
global_init_postfork_start(g_ceph_context);
common_init_finish(g_ceph_context);
global_init_postfork_finish(g_ceph_context);
r = rados_create_with_context(pcluster, g_ceph_context);
if (r < 0) {
simple_err("Could not create cluster handle", r);
return r;
}
r = rados_connect(*pcluster);
if (r < 0) {
simple_err("Error connecting to cluster", r);
rados_shutdown(*pcluster);
return r;
}
return 0;
}
#define OPT_NOT_FOUND -1
int main(int argc, const char *argv[])
{
memset(&rbd_image_data, 0, sizeof(rbd_image_data));
// librados will filter out -r/-f/-d options from command-line
std::map<std::string, int> filter_options = {
{"-r", OPT_NOT_FOUND},
{"-f", OPT_NOT_FOUND},
{"-d", OPT_NOT_FOUND}};
std::set<std::string> require_arg_options = {"-r"};
std::vector<const char*> arg_vector;
for (auto idx = 0; idx < argc; ++idx) {
auto it = filter_options.find(argv[idx]);
if (it != filter_options.end()) {
it->second = idx;
}
arg_vector.push_back(argv[idx]);
}
auto cct = global_init(NULL, arg_vector, CEPH_ENTITY_TYPE_CLIENT,
CODE_ENVIRONMENT_DAEMON,
CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS);
g_ceph_context->_conf.set_val_or_die("pid_file", "");
g_ceph_context->_conf.set_val_or_die("daemonize", "true");
if (global_init_prefork(g_ceph_context) < 0) {
fprintf(stderr, "Failed to initialize librados\n");
exit(1);
}
for (auto& it : filter_options) {
if (it.second != OPT_NOT_FOUND) {
arg_vector.push_back(it.first.c_str());
if (require_arg_options.count(it.first) &&
it.second + 1 < argc) {
arg_vector.push_back(argv[it.second + 1]);
}
}
}
struct fuse_args args = FUSE_ARGS_INIT((int)arg_vector.size(),
(char**)&arg_vector.front());
if (fuse_opt_parse(&args, &rbd_options, rbdfs_opts,
rbdfs_opt_proc) == -1) {
exit(1);
}
return fuse_main(args.argc, args.argv, &rbdfs_oper, NULL);
}
| 21,241 | 20.944215 | 85 |
cc
|
null |
ceph-main/src/rbd_replay/ActionTypes.cc
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#include "rbd_replay/ActionTypes.h"
#include "include/ceph_assert.h"
#include "include/byteorder.h"
#include "include/stringify.h"
#include "common/Formatter.h"
#include <iostream>
#include <boost/variant.hpp>
namespace rbd_replay {
namespace action {
namespace {
bool byte_swap_required(__u8 version) {
#if defined(CEPH_LITTLE_ENDIAN)
return (version == 0);
#else
return false;
#endif
}
void decode_big_endian_string(std::string &str, bufferlist::const_iterator &it) {
using ceph::decode;
#if defined(CEPH_LITTLE_ENDIAN)
uint32_t length;
decode(length, it);
length = swab(length);
str.clear();
it.copy(length, str);
#else
ceph_abort();
#endif
}
class EncodeVisitor : public boost::static_visitor<void> {
public:
explicit EncodeVisitor(bufferlist &bl) : m_bl(bl) {
}
template <typename Action>
inline void operator()(const Action &action) const {
using ceph::encode;
encode(static_cast<uint8_t>(Action::ACTION_TYPE), m_bl);
action.encode(m_bl);
}
private:
bufferlist &m_bl;
};
class DecodeVisitor : public boost::static_visitor<void> {
public:
DecodeVisitor(__u8 version, bufferlist::const_iterator &iter)
: m_version(version), m_iter(iter) {
}
template <typename Action>
inline void operator()(Action &action) const {
action.decode(m_version, m_iter);
}
private:
__u8 m_version;
bufferlist::const_iterator &m_iter;
};
class DumpVisitor : public boost::static_visitor<void> {
public:
explicit DumpVisitor(Formatter *formatter) : m_formatter(formatter) {}
template <typename Action>
inline void operator()(const Action &action) const {
ActionType action_type = Action::ACTION_TYPE;
m_formatter->dump_string("action_type", stringify(action_type));
action.dump(m_formatter);
}
private:
ceph::Formatter *m_formatter;
};
} // anonymous namespace
void Dependency::encode(bufferlist &bl) const {
using ceph::encode;
encode(id, bl);
encode(time_delta, bl);
}
void Dependency::decode(bufferlist::const_iterator &it) {
decode(1, it);
}
void Dependency::decode(__u8 version, bufferlist::const_iterator &it) {
using ceph::decode;
decode(id, it);
decode(time_delta, it);
if (byte_swap_required(version)) {
id = swab(id);
time_delta = swab(time_delta);
}
}
void Dependency::dump(Formatter *f) const {
f->dump_unsigned("id", id);
f->dump_unsigned("time_delta", time_delta);
}
void Dependency::generate_test_instances(std::list<Dependency *> &o) {
o.push_back(new Dependency());
o.push_back(new Dependency(1, 123456789));
}
void ActionBase::encode(bufferlist &bl) const {
using ceph::encode;
encode(id, bl);
encode(thread_id, bl);
encode(dependencies, bl);
}
void ActionBase::decode(__u8 version, bufferlist::const_iterator &it) {
using ceph::decode;
decode(id, it);
decode(thread_id, it);
if (version == 0) {
uint32_t num_successors;
decode(num_successors, it);
uint32_t num_completion_successors;
decode(num_completion_successors, it);
}
if (byte_swap_required(version)) {
id = swab(id);
thread_id = swab(thread_id);
uint32_t dep_count;
decode(dep_count, it);
dep_count = swab(dep_count);
dependencies.resize(dep_count);
for (uint32_t i = 0; i < dep_count; ++i) {
dependencies[i].decode(0, it);
}
} else {
decode(dependencies, it);
}
}
void ActionBase::dump(Formatter *f) const {
f->dump_unsigned("id", id);
f->dump_unsigned("thread_id", thread_id);
f->open_array_section("dependencies");
for (size_t i = 0; i < dependencies.size(); ++i) {
f->open_object_section("dependency");
dependencies[i].dump(f);
f->close_section();
}
f->close_section();
}
void ImageActionBase::encode(bufferlist &bl) const {
using ceph::encode;
ActionBase::encode(bl);
encode(imagectx_id, bl);
}
void ImageActionBase::decode(__u8 version, bufferlist::const_iterator &it) {
using ceph::decode;
ActionBase::decode(version, it);
decode(imagectx_id, it);
if (byte_swap_required(version)) {
imagectx_id = swab(imagectx_id);
}
}
void ImageActionBase::dump(Formatter *f) const {
ActionBase::dump(f);
f->dump_unsigned("imagectx_id", imagectx_id);
}
void IoActionBase::encode(bufferlist &bl) const {
using ceph::encode;
ImageActionBase::encode(bl);
encode(offset, bl);
encode(length, bl);
}
void IoActionBase::decode(__u8 version, bufferlist::const_iterator &it) {
using ceph::decode;
ImageActionBase::decode(version, it);
decode(offset, it);
decode(length, it);
if (byte_swap_required(version)) {
offset = swab(offset);
length = swab(length);
}
}
void IoActionBase::dump(Formatter *f) const {
ImageActionBase::dump(f);
f->dump_unsigned("offset", offset);
f->dump_unsigned("length", length);
}
void OpenImageAction::encode(bufferlist &bl) const {
using ceph::encode;
ImageActionBase::encode(bl);
encode(name, bl);
encode(snap_name, bl);
encode(read_only, bl);
}
void OpenImageAction::decode(__u8 version, bufferlist::const_iterator &it) {
using ceph::decode;
ImageActionBase::decode(version, it);
if (byte_swap_required(version)) {
decode_big_endian_string(name, it);
decode_big_endian_string(snap_name, it);
} else {
decode(name, it);
decode(snap_name, it);
}
decode(read_only, it);
}
void OpenImageAction::dump(Formatter *f) const {
ImageActionBase::dump(f);
f->dump_string("name", name);
f->dump_string("snap_name", snap_name);
f->dump_bool("read_only", read_only);
}
void AioOpenImageAction::encode(bufferlist &bl) const {
using ceph::encode;
ImageActionBase::encode(bl);
encode(name, bl);
encode(snap_name, bl);
encode(read_only, bl);
}
void AioOpenImageAction::decode(__u8 version, bufferlist::const_iterator &it) {
using ceph::decode;
ImageActionBase::decode(version, it);
if (byte_swap_required(version)) {
decode_big_endian_string(name, it);
decode_big_endian_string(snap_name, it);
} else {
decode(name, it);
decode(snap_name, it);
}
decode(read_only, it);
}
void AioOpenImageAction::dump(Formatter *f) const {
ImageActionBase::dump(f);
f->dump_string("name", name);
f->dump_string("snap_name", snap_name);
f->dump_bool("read_only", read_only);
}
void UnknownAction::encode(bufferlist &bl) const {
ceph_abort();
}
void UnknownAction::decode(__u8 version, bufferlist::const_iterator &it) {
}
void UnknownAction::dump(Formatter *f) const {
}
void ActionEntry::encode(bufferlist &bl) const {
ENCODE_START(1, 1, bl);
boost::apply_visitor(EncodeVisitor(bl), action);
ENCODE_FINISH(bl);
}
void ActionEntry::decode(bufferlist::const_iterator &it) {
DECODE_START(1, it);
decode_versioned(struct_v, it);
DECODE_FINISH(it);
}
void ActionEntry::decode_unversioned(bufferlist::const_iterator &it) {
decode_versioned(0, it);
}
void ActionEntry::decode_versioned(__u8 version, bufferlist::const_iterator &it) {
using ceph::decode;
uint8_t action_type;
decode(action_type, it);
// select the correct action variant based upon the action_type
switch (action_type) {
case ACTION_TYPE_START_THREAD:
action = StartThreadAction();
break;
case ACTION_TYPE_STOP_THREAD:
action = StopThreadAction();
break;
case ACTION_TYPE_READ:
action = ReadAction();
break;
case ACTION_TYPE_WRITE:
action = WriteAction();
break;
case ACTION_TYPE_DISCARD:
action = DiscardAction();
break;
case ACTION_TYPE_AIO_READ:
action = AioReadAction();
break;
case ACTION_TYPE_AIO_WRITE:
action = AioWriteAction();
break;
case ACTION_TYPE_AIO_DISCARD:
action = AioDiscardAction();
break;
case ACTION_TYPE_OPEN_IMAGE:
action = OpenImageAction();
break;
case ACTION_TYPE_CLOSE_IMAGE:
action = CloseImageAction();
break;
case ACTION_TYPE_AIO_OPEN_IMAGE:
action = AioOpenImageAction();
break;
case ACTION_TYPE_AIO_CLOSE_IMAGE:
action = AioCloseImageAction();
break;
}
boost::apply_visitor(DecodeVisitor(version, it), action);
}
void ActionEntry::dump(Formatter *f) const {
boost::apply_visitor(DumpVisitor(f), action);
}
void ActionEntry::generate_test_instances(std::list<ActionEntry *> &o) {
Dependencies dependencies;
dependencies.push_back(Dependency(3, 123456789));
dependencies.push_back(Dependency(4, 234567890));
o.push_back(new ActionEntry(StartThreadAction()));
o.push_back(new ActionEntry(StartThreadAction(1, 123456789, dependencies)));
o.push_back(new ActionEntry(StopThreadAction()));
o.push_back(new ActionEntry(StopThreadAction(1, 123456789, dependencies)));
o.push_back(new ActionEntry(ReadAction()));
o.push_back(new ActionEntry(ReadAction(1, 123456789, dependencies, 3, 4, 5)));
o.push_back(new ActionEntry(WriteAction()));
o.push_back(new ActionEntry(WriteAction(1, 123456789, dependencies, 3, 4,
5)));
o.push_back(new ActionEntry(DiscardAction()));
o.push_back(new ActionEntry(DiscardAction(1, 123456789, dependencies, 3, 4,
5)));
o.push_back(new ActionEntry(AioReadAction()));
o.push_back(new ActionEntry(AioReadAction(1, 123456789, dependencies, 3, 4,
5)));
o.push_back(new ActionEntry(AioWriteAction()));
o.push_back(new ActionEntry(AioWriteAction(1, 123456789, dependencies, 3, 4,
5)));
o.push_back(new ActionEntry(AioDiscardAction()));
o.push_back(new ActionEntry(AioDiscardAction(1, 123456789, dependencies, 3, 4,
5)));
o.push_back(new ActionEntry(OpenImageAction()));
o.push_back(new ActionEntry(OpenImageAction(1, 123456789, dependencies, 3,
"image_name", "snap_name",
true)));
o.push_back(new ActionEntry(CloseImageAction()));
o.push_back(new ActionEntry(CloseImageAction(1, 123456789, dependencies, 3)));
o.push_back(new ActionEntry(AioOpenImageAction()));
o.push_back(new ActionEntry(AioOpenImageAction(1, 123456789, dependencies, 3,
"image_name", "snap_name",
true)));
o.push_back(new ActionEntry(AioCloseImageAction()));
o.push_back(new ActionEntry(AioCloseImageAction(1, 123456789, dependencies, 3)));
}
std::ostream &operator<<(std::ostream &out,
const ActionType &type) {
using namespace rbd_replay::action;
switch (type) {
case ACTION_TYPE_START_THREAD:
out << "StartThread";
break;
case ACTION_TYPE_STOP_THREAD:
out << "StopThread";
break;
case ACTION_TYPE_READ:
out << "Read";
break;
case ACTION_TYPE_WRITE:
out << "Write";
break;
case ACTION_TYPE_DISCARD:
out << "Discard";
break;
case ACTION_TYPE_AIO_READ:
out << "AioRead";
break;
case ACTION_TYPE_AIO_WRITE:
out << "AioWrite";
break;
case ACTION_TYPE_AIO_DISCARD:
out << "AioDiscard";
break;
case ACTION_TYPE_OPEN_IMAGE:
out << "OpenImage";
break;
case ACTION_TYPE_CLOSE_IMAGE:
out << "CloseImage";
break;
case ACTION_TYPE_AIO_OPEN_IMAGE:
out << "AioOpenImage";
break;
case ACTION_TYPE_AIO_CLOSE_IMAGE:
out << "AioCloseImage";
break;
default:
out << "Unknown (" << static_cast<uint32_t>(type) << ")";
break;
}
return out;
}
} // namespace action
} // namespace rbd_replay
| 11,577 | 25.800926 | 83 |
cc
|
null |
ceph-main/src/rbd_replay/ActionTypes.h
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#ifndef CEPH_RBD_REPLAY_ACTION_TYPES_H
#define CEPH_RBD_REPLAY_ACTION_TYPES_H
#include "include/int_types.h"
#include "include/buffer_fwd.h"
#include "include/encoding.h"
#include <iosfwd>
#include <list>
#include <string>
#include <vector>
#include <boost/variant/variant.hpp>
namespace ceph { class Formatter; }
namespace rbd_replay {
namespace action {
typedef uint64_t imagectx_id_t;
typedef uint64_t thread_id_t;
/// Even IDs are normal actions, odd IDs are completions.
typedef uint32_t action_id_t;
static const std::string BANNER("rbd-replay-trace");
/**
* Dependencies link actions to earlier actions or completions.
* If an action has a dependency \c d then it waits until \c d.time_delta
* nanoseconds after the action or completion with ID \c d.id has fired.
*/
struct Dependency {
/// ID of the action or completion to wait for.
action_id_t id;
/// Nanoseconds of delay to wait until after the action or completion fires.
uint64_t time_delta;
/**
* @param id ID of the action or completion to wait for.
* @param time_delta Nanoseconds of delay to wait after the action or
* completion fires.
*/
Dependency() : id(0), time_delta(0) {
}
Dependency(action_id_t id, uint64_t time_delta)
: id(id), time_delta(time_delta) {
}
void encode(bufferlist &bl) const;
void decode(bufferlist::const_iterator &it);
void decode(__u8 version, bufferlist::const_iterator &it);
void dump(Formatter *f) const;
static void generate_test_instances(std::list<Dependency *> &o);
};
WRITE_CLASS_ENCODER(Dependency);
typedef std::vector<Dependency> Dependencies;
enum ActionType {
ACTION_TYPE_START_THREAD = 0,
ACTION_TYPE_STOP_THREAD = 1,
ACTION_TYPE_READ = 2,
ACTION_TYPE_WRITE = 3,
ACTION_TYPE_AIO_READ = 4,
ACTION_TYPE_AIO_WRITE = 5,
ACTION_TYPE_OPEN_IMAGE = 6,
ACTION_TYPE_CLOSE_IMAGE = 7,
ACTION_TYPE_AIO_OPEN_IMAGE = 8,
ACTION_TYPE_AIO_CLOSE_IMAGE = 9,
ACTION_TYPE_DISCARD = 10,
ACTION_TYPE_AIO_DISCARD = 11
};
struct ActionBase {
action_id_t id;
thread_id_t thread_id;
Dependencies dependencies;
ActionBase() : id(0), thread_id(0) {
}
ActionBase(action_id_t id, thread_id_t thread_id,
const Dependencies &dependencies)
: id(id), thread_id(thread_id), dependencies(dependencies) {
}
void encode(bufferlist &bl) const;
void decode(__u8 version, bufferlist::const_iterator &it);
void dump(Formatter *f) const;
};
struct StartThreadAction : public ActionBase {
static const ActionType ACTION_TYPE = ACTION_TYPE_START_THREAD;
StartThreadAction() {
}
StartThreadAction(action_id_t id, thread_id_t thread_id,
const Dependencies &dependencies)
: ActionBase(id, thread_id, dependencies) {
}
};
struct StopThreadAction : public ActionBase {
static const ActionType ACTION_TYPE = ACTION_TYPE_STOP_THREAD;
StopThreadAction() {
}
StopThreadAction(action_id_t id, thread_id_t thread_id,
const Dependencies &dependencies)
: ActionBase(id, thread_id, dependencies) {
}
};
struct ImageActionBase : public ActionBase {
imagectx_id_t imagectx_id;
ImageActionBase() : imagectx_id(0) {
}
ImageActionBase(action_id_t id, thread_id_t thread_id,
const Dependencies &dependencies, imagectx_id_t imagectx_id)
: ActionBase(id, thread_id, dependencies), imagectx_id(imagectx_id) {
}
void encode(bufferlist &bl) const;
void decode(__u8 version, bufferlist::const_iterator &it);
void dump(Formatter *f) const;
};
struct IoActionBase : public ImageActionBase {
uint64_t offset;
uint64_t length;
IoActionBase() : offset(0), length(0) {
}
IoActionBase(action_id_t id, thread_id_t thread_id,
const Dependencies &dependencies, imagectx_id_t imagectx_id,
uint64_t offset, uint64_t length)
: ImageActionBase(id, thread_id, dependencies, imagectx_id),
offset(offset), length(length) {
}
void encode(bufferlist &bl) const;
void decode(__u8 version, bufferlist::const_iterator &it);
void dump(Formatter *f) const;
};
struct ReadAction : public IoActionBase {
static const ActionType ACTION_TYPE = ACTION_TYPE_READ;
ReadAction() {
}
ReadAction(action_id_t id, thread_id_t thread_id,
const Dependencies &dependencies, imagectx_id_t imagectx_id,
uint64_t offset, uint64_t length)
: IoActionBase(id, thread_id, dependencies, imagectx_id, offset, length) {
}
};
struct WriteAction : public IoActionBase {
static const ActionType ACTION_TYPE = ACTION_TYPE_WRITE;
WriteAction() {
}
WriteAction(action_id_t id, thread_id_t thread_id,
const Dependencies &dependencies, imagectx_id_t imagectx_id,
uint64_t offset, uint64_t length)
: IoActionBase(id, thread_id, dependencies, imagectx_id, offset, length) {
}
};
struct DiscardAction : public IoActionBase {
static const ActionType ACTION_TYPE = ACTION_TYPE_DISCARD;
DiscardAction() {
}
DiscardAction(action_id_t id, thread_id_t thread_id,
const Dependencies &dependencies, imagectx_id_t imagectx_id,
uint64_t offset, uint64_t length)
: IoActionBase(id, thread_id, dependencies, imagectx_id, offset, length) {
}
};
struct AioReadAction : public IoActionBase {
static const ActionType ACTION_TYPE = ACTION_TYPE_AIO_READ;
AioReadAction() {
}
AioReadAction(action_id_t id, thread_id_t thread_id,
const Dependencies &dependencies, imagectx_id_t imagectx_id,
uint64_t offset, uint64_t length)
: IoActionBase(id, thread_id, dependencies, imagectx_id, offset, length) {
}
};
struct AioWriteAction : public IoActionBase {
static const ActionType ACTION_TYPE = ACTION_TYPE_AIO_WRITE;
AioWriteAction() {
}
AioWriteAction(action_id_t id, thread_id_t thread_id,
const Dependencies &dependencies, imagectx_id_t imagectx_id,
uint64_t offset, uint64_t length)
: IoActionBase(id, thread_id, dependencies, imagectx_id, offset, length) {
}
};
struct AioDiscardAction : public IoActionBase {
static const ActionType ACTION_TYPE = ACTION_TYPE_AIO_DISCARD;
AioDiscardAction() {
}
AioDiscardAction(action_id_t id, thread_id_t thread_id,
const Dependencies &dependencies, imagectx_id_t imagectx_id,
uint64_t offset, uint64_t length)
: IoActionBase(id, thread_id, dependencies, imagectx_id, offset, length) {
}
};
struct OpenImageAction : public ImageActionBase {
static const ActionType ACTION_TYPE = ACTION_TYPE_OPEN_IMAGE;
std::string name;
std::string snap_name;
bool read_only;
OpenImageAction() : read_only(false) {
}
OpenImageAction(action_id_t id, thread_id_t thread_id,
const Dependencies &dependencies, imagectx_id_t imagectx_id,
const std::string &name, const std::string &snap_name,
bool read_only)
: ImageActionBase(id, thread_id, dependencies, imagectx_id),
name(name), snap_name(snap_name), read_only(read_only) {
}
void encode(bufferlist &bl) const;
void decode(__u8 version, bufferlist::const_iterator &it);
void dump(Formatter *f) const;
};
struct CloseImageAction : public ImageActionBase {
static const ActionType ACTION_TYPE = ACTION_TYPE_CLOSE_IMAGE;
CloseImageAction() {
}
CloseImageAction(action_id_t id, thread_id_t thread_id,
const Dependencies &dependencies, imagectx_id_t imagectx_id)
: ImageActionBase(id, thread_id, dependencies, imagectx_id) {
}
};
struct AioOpenImageAction : public ImageActionBase {
static const ActionType ACTION_TYPE = ACTION_TYPE_AIO_OPEN_IMAGE;
std::string name;
std::string snap_name;
bool read_only;
AioOpenImageAction() : read_only(false) {
}
AioOpenImageAction(action_id_t id, thread_id_t thread_id,
const Dependencies &dependencies, imagectx_id_t imagectx_id,
const std::string &name, const std::string &snap_name,
bool read_only)
: ImageActionBase(id, thread_id, dependencies, imagectx_id),
name(name), snap_name(snap_name), read_only(read_only) {
}
void encode(bufferlist &bl) const;
void decode(__u8 version, bufferlist::const_iterator &it);
void dump(Formatter *f) const;
};
struct AioCloseImageAction : public ImageActionBase {
static const ActionType ACTION_TYPE = ACTION_TYPE_AIO_CLOSE_IMAGE;
AioCloseImageAction() {
}
AioCloseImageAction(action_id_t id, thread_id_t thread_id,
const Dependencies &dependencies, imagectx_id_t imagectx_id)
: ImageActionBase(id, thread_id, dependencies, imagectx_id) {
}
};
struct UnknownAction {
static const ActionType ACTION_TYPE = static_cast<ActionType>(-1);
void encode(bufferlist &bl) const;
void decode(__u8 version, bufferlist::const_iterator &it);
void dump(Formatter *f) const;
};
typedef boost::variant<StartThreadAction,
StopThreadAction,
ReadAction,
WriteAction,
DiscardAction,
AioReadAction,
AioWriteAction,
AioDiscardAction,
OpenImageAction,
CloseImageAction,
AioOpenImageAction,
AioCloseImageAction,
UnknownAction> Action;
class ActionEntry {
public:
Action action;
ActionEntry() : action(UnknownAction()) {
}
ActionEntry(const Action &action) : action(action) {
}
void encode(bufferlist &bl) const;
void decode(bufferlist::const_iterator &it);
void decode_unversioned(bufferlist::const_iterator &it);
void dump(Formatter *f) const;
static void generate_test_instances(std::list<ActionEntry *> &o);
private:
void decode_versioned(__u8 version, bufferlist::const_iterator &it);
};
WRITE_CLASS_ENCODER(ActionEntry);
std::ostream &operator<<(std::ostream &out,
const rbd_replay::action::ActionType &type);
} // namespace action
} // namespace rbd_replay
#endif // CEPH_RBD_REPLAY_ACTION_TYPES_H
| 10,290 | 29.267647 | 79 |
h
|
null |
ceph-main/src/rbd_replay/BoundedBuffer.hpp
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#ifndef _INCLUDED_BOUNDED_BUFFER_HPP
#define _INCLUDED_BOUNDED_BUFFER_HPP
#include <boost/bind/bind.hpp>
#include <boost/circular_buffer.hpp>
#include <boost/thread/condition.hpp>
#include <boost/thread/mutex.hpp>
/**
Blocking, fixed-capacity, thread-safe FIFO queue useful for communicating between threads.
This code was taken from the Boost docs: http://www.boost.org/doc/libs/1_55_0/libs/circular_buffer/example/circular_buffer_bound_example.cpp
*/
template <class T>
class BoundedBuffer {
public:
typedef boost::circular_buffer<T> container_type;
typedef typename container_type::size_type size_type;
typedef typename container_type::value_type value_type;
typedef typename boost::call_traits<value_type>::param_type param_type;
explicit BoundedBuffer(size_type capacity) : m_unread(0), m_container(capacity) {
}
/**
Inserts an element into the queue.
Blocks if the queue is full.
*/
void push_front(typename boost::call_traits<value_type>::param_type item) {
// `param_type` represents the "best" way to pass a parameter of type `value_type` to a method.
boost::mutex::scoped_lock lock(m_mutex);
m_not_full.wait(lock, boost::bind(&BoundedBuffer<value_type>::is_not_full, this));
m_container.push_front(item);
++m_unread;
lock.unlock();
m_not_empty.notify_one();
}
/**
Removes an element from the queue.
Blocks if the queue is empty.
*/
void pop_back(value_type* pItem) {
boost::mutex::scoped_lock lock(m_mutex);
m_not_empty.wait(lock, boost::bind(&BoundedBuffer<value_type>::is_not_empty, this));
*pItem = m_container[--m_unread];
lock.unlock();
m_not_full.notify_one();
}
private:
BoundedBuffer(const BoundedBuffer&); // Disabled copy constructor.
BoundedBuffer& operator= (const BoundedBuffer&); // Disabled assign operator.
bool is_not_empty() const {
return m_unread > 0;
}
bool is_not_full() const {
return m_unread < m_container.capacity();
}
size_type m_unread;
container_type m_container;
boost::mutex m_mutex;
boost::condition m_not_empty;
boost::condition m_not_full;
};
#endif
| 2,248 | 30.236111 | 143 |
hpp
|
null |
ceph-main/src/rbd_replay/BufferReader.cc
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#include "rbd_replay/BufferReader.h"
#include "include/ceph_assert.h"
#include "include/intarith.h"
namespace rbd_replay {
BufferReader::BufferReader(int fd, size_t min_bytes, size_t max_bytes)
: m_fd(fd), m_min_bytes(min_bytes), m_max_bytes(max_bytes),
m_bl_it(m_bl.begin()), m_eof_reached(false) {
ceph_assert(m_min_bytes <= m_max_bytes);
}
int BufferReader::fetch(bufferlist::const_iterator **it) {
if (m_bl_it.get_remaining() < m_min_bytes) {
ssize_t bytes_to_read = round_up_to(m_max_bytes - m_bl_it.get_remaining(),
CEPH_PAGE_SIZE);
while (!m_eof_reached && bytes_to_read > 0) {
int r = m_bl.read_fd(m_fd, CEPH_PAGE_SIZE);
if (r < 0) {
return r;
}
if (r == 0) {
m_eof_reached = true;
}
ceph_assert(r <= bytes_to_read);
bytes_to_read -= r;
}
}
*it = &m_bl_it;
return 0;
}
} // namespace rbd_replay
| 1,026 | 26.026316 | 78 |
cc
|
null |
ceph-main/src/rbd_replay/BufferReader.h
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#ifndef CEPH_RBD_REPLAY_BUFFER_READER_H
#define CEPH_RBD_REPLAY_BUFFER_READER_H
#include "include/int_types.h"
#include "include/buffer.h"
namespace rbd_replay {
class BufferReader {
public:
static const size_t DEFAULT_MIN_BYTES = 1<<20;
static const size_t DEFAULT_MAX_BYTES = 1<<22;
BufferReader(int fd, size_t min_bytes = DEFAULT_MIN_BYTES,
size_t max_bytes = DEFAULT_MAX_BYTES);
int fetch(bufferlist::const_iterator **it);
private:
int m_fd;
size_t m_min_bytes;
size_t m_max_bytes;
bufferlist m_bl;
bufferlist::const_iterator m_bl_it;
bool m_eof_reached;
};
} // namespace rbd_replay
#endif // CEPH_RBD_REPLAY_BUFFER_READER_H
| 773 | 21.114286 | 70 |
h
|
null |
ceph-main/src/rbd_replay/ImageNameMap.cc
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2014 Adam Crume <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#include "ImageNameMap.hpp"
using namespace std;
using namespace rbd_replay;
bool ImageNameMap::parse_mapping(string mapping_string, Mapping *mapping) const {
string fields[2];
int field = 0;
for (size_t i = 0, n = mapping_string.length(); i < n; i++) {
char c = mapping_string[i];
switch (c) {
case '\\':
if (i != n - 1 && mapping_string[i + 1] == '=') {
i++;
fields[field].push_back('=');
} else {
fields[field].push_back('\\');
}
break;
case '=':
if (field == 1) {
return false;
}
field = 1;
break;
default:
fields[field].push_back(c);
}
}
if (field == 0) {
return false;
}
if (!mapping->first.parse(fields[0])) {
return false;
}
if (!mapping->second.parse(fields[1])) {
return false;
}
return true;
}
void ImageNameMap::add_mapping(const Mapping& mapping) {
m_map.insert(mapping);
}
rbd_loc ImageNameMap::map(const rbd_loc& name) const {
std::map<rbd_loc, rbd_loc>::const_iterator p(m_map.find(name));
if (p == m_map.end()) {
return name;
} else {
return p->second;
}
}
| 1,538 | 20.985714 | 81 |
cc
|
null |
ceph-main/src/rbd_replay/ImageNameMap.hpp
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2014 Adam Crume <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef _INCLUDED_RBD_REPLAY_IMAGENAMEMAP_HPP
#define _INCLUDED_RBD_REPLAY_IMAGENAMEMAP_HPP
#include <map>
#include <string>
#include "rbd_loc.hpp"
namespace rbd_replay {
/**
Maps image names.
*/
class ImageNameMap {
public:
typedef std::pair<rbd_loc, rbd_loc> Mapping;
/**
Parses a mapping.
If parsing fails, the contents of \c mapping are undefined.
@param[in] mapping_string string representation of the mapping
@param[out] mapping stores the parsed mapping
@retval true parsing was successful
*/
bool parse_mapping(std::string mapping_string, Mapping *mapping) const;
void add_mapping(const Mapping& mapping);
/**
Maps an image name.
If no mapping matches the name, it is returned unmodified.
*/
rbd_loc map(const rbd_loc& name) const;
private:
std::map<rbd_loc, rbd_loc> m_map;
};
}
#endif
| 1,287 | 22.418182 | 73 |
hpp
|
null |
ceph-main/src/rbd_replay/PendingIO.cc
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2014 Adam Crume <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#include "PendingIO.hpp"
#include "rbd_replay_debug.hpp"
#define dout_context g_ceph_context
using namespace rbd_replay;
extern "C"
void rbd_replay_pending_io_callback(librbd::completion_t cb, void *arg) {
PendingIO *io = static_cast<PendingIO*>(arg);
io->completed(cb);
}
PendingIO::PendingIO(action_id_t id,
ActionCtx &worker)
: m_id(id),
m_completion(new librbd::RBD::AioCompletion(this, rbd_replay_pending_io_callback)),
m_worker(worker) {
}
PendingIO::~PendingIO() {
m_completion->release();
}
void PendingIO::completed(librbd::completion_t cb) {
dout(ACTION_LEVEL) << "Completed pending IO #" << m_id << dendl;
ssize_t r = m_completion->get_return_value();
assertf(r >= 0, "id = %d, r = %d", m_id, r);
m_worker.remove_pending(shared_from_this());
}
| 1,220 | 26.133333 | 87 |
cc
|
null |
ceph-main/src/rbd_replay/PendingIO.hpp
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2014 Adam Crume <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef _INCLUDED_RBD_REPLAY_PENDINGIO_HPP
#define _INCLUDED_RBD_REPLAY_PENDINGIO_HPP
#include <boost/enable_shared_from_this.hpp>
#include "actions.hpp"
/// Do not call outside of rbd_replay::PendingIO.
extern "C"
void rbd_replay_pending_io_callback(librbd::completion_t cb, void *arg);
namespace rbd_replay {
/**
A PendingIO is an I/O operation that has been started but not completed.
*/
class PendingIO : public boost::enable_shared_from_this<PendingIO> {
public:
typedef boost::shared_ptr<PendingIO> ptr;
PendingIO(action_id_t id,
ActionCtx &worker);
~PendingIO();
action_id_t id() const {
return m_id;
}
ceph::bufferlist &bufferlist() {
return m_bl;
}
librbd::RBD::AioCompletion &completion() {
return *m_completion;
}
private:
void completed(librbd::completion_t cb);
friend void ::rbd_replay_pending_io_callback(librbd::completion_t cb, void *arg);
const action_id_t m_id;
ceph::bufferlist m_bl;
librbd::RBD::AioCompletion *m_completion;
ActionCtx &m_worker;
};
}
#endif
| 1,474 | 21.692308 | 83 |
hpp
|
null |
ceph-main/src/rbd_replay/Replayer.cc
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2014 Adam Crume <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#include "Replayer.hpp"
#include "common/errno.h"
#include "include/scope_guard.h"
#include "rbd_replay/ActionTypes.h"
#include "rbd_replay/BufferReader.h"
#include <boost/foreach.hpp>
#include <chrono>
#include <condition_variable>
#include <thread>
#include <fstream>
#include "global/global_context.h"
#include "rbd_replay_debug.hpp"
#define dout_context g_ceph_context
using std::cerr;
using std::cout;
using namespace rbd_replay;
namespace {
bool is_versioned_replay(BufferReader &buffer_reader) {
bufferlist::const_iterator *it;
int r = buffer_reader.fetch(&it);
if (r < 0) {
return false;
}
if (it->get_remaining() < action::BANNER.size()) {
return false;
}
std::string banner;
it->copy(action::BANNER.size(), banner);
bool versioned = (banner == action::BANNER);
if (!versioned) {
it->seek(0);
}
return versioned;
}
} // anonymous namespace
Worker::Worker(Replayer &replayer)
: m_replayer(replayer),
m_buffer(100),
m_done(false) {
}
void Worker::start() {
m_thread = std::make_shared<std::thread>(&Worker::run, this);
}
// Should only be called by StopThreadAction
void Worker::stop() {
m_done = true;
}
void Worker::join() {
m_thread->join();
}
void Worker::send(Action::ptr action) {
ceph_assert(action);
m_buffer.push_front(action);
}
void Worker::add_pending(PendingIO::ptr io) {
ceph_assert(io);
std::scoped_lock lock{m_pending_ios_mutex};
assertf(m_pending_ios.count(io->id()) == 0, "id = %d", io->id());
m_pending_ios[io->id()] = io;
}
void Worker::run() {
dout(THREAD_LEVEL) << "Worker thread started" << dendl;
while (!m_done) {
Action::ptr action;
m_buffer.pop_back(&action);
m_replayer.wait_for_actions(action->predecessors());
action->perform(*this);
m_replayer.set_action_complete(action->id());
}
{
std::unique_lock lock{m_pending_ios_mutex};
bool first_time = true;
while (!m_pending_ios.empty()) {
if (!first_time) {
dout(THREAD_LEVEL) << "Worker thread trying to stop, still waiting for " << m_pending_ios.size() << " pending IOs to complete:" << dendl;
std::pair<action_id_t, PendingIO::ptr> p;
BOOST_FOREACH(p, m_pending_ios) {
dout(THREAD_LEVEL) << "> " << p.first << dendl;
}
}
m_pending_ios_empty.wait_for(lock, std::chrono::seconds(1));
first_time = false;
}
}
dout(THREAD_LEVEL) << "Worker thread stopped" << dendl;
}
void Worker::remove_pending(PendingIO::ptr io) {
ceph_assert(io);
m_replayer.set_action_complete(io->id());
std::scoped_lock lock{m_pending_ios_mutex};
size_t num_erased = m_pending_ios.erase(io->id());
assertf(num_erased == 1, "id = %d", io->id());
if (m_pending_ios.empty()) {
m_pending_ios_empty.notify_all();
}
}
librbd::Image* Worker::get_image(imagectx_id_t imagectx_id) {
return m_replayer.get_image(imagectx_id);
}
void Worker::put_image(imagectx_id_t imagectx_id, librbd::Image* image) {
ceph_assert(image);
m_replayer.put_image(imagectx_id, image);
}
void Worker::erase_image(imagectx_id_t imagectx_id) {
m_replayer.erase_image(imagectx_id);
}
librbd::RBD* Worker::rbd() {
return m_replayer.get_rbd();
}
librados::IoCtx* Worker::ioctx() {
return m_replayer.get_ioctx();
}
void Worker::set_action_complete(action_id_t id) {
m_replayer.set_action_complete(id);
}
bool Worker::readonly() const {
return m_replayer.readonly();
}
rbd_loc Worker::map_image_name(std::string image_name, std::string snap_name) const {
return m_replayer.image_name_map().map(rbd_loc("", image_name, snap_name));
}
Replayer::Replayer(int num_action_trackers)
: m_rbd(NULL), m_ioctx(0),
m_latency_multiplier(1.0),
m_readonly(false), m_dump_perf_counters(false),
m_num_action_trackers(num_action_trackers),
m_action_trackers(new action_tracker_d[m_num_action_trackers]) {
assertf(num_action_trackers > 0, "num_action_trackers = %d", num_action_trackers);
}
Replayer::~Replayer() {
delete[] m_action_trackers;
}
Replayer::action_tracker_d &Replayer::tracker_for(action_id_t id) {
return m_action_trackers[id % m_num_action_trackers];
}
void Replayer::run(const std::string& replay_file) {
{
librados::Rados rados;
rados.init(NULL);
int r = rados.init_with_context(g_ceph_context);
if (r) {
cerr << "Failed to initialize RADOS: " << cpp_strerror(r) << std::endl;
goto out;
}
r = rados.connect();
if (r) {
cerr << "Failed to connect to cluster: " << cpp_strerror(r) << std::endl;
goto out;
}
if (m_pool_name.empty()) {
r = rados.conf_get("rbd_default_pool", m_pool_name);
if (r < 0) {
cerr << "Failed to retrieve default pool: " << cpp_strerror(r)
<< std::endl;
goto out;
}
}
m_ioctx = new librados::IoCtx();
{
r = rados.ioctx_create(m_pool_name.c_str(), *m_ioctx);
if (r) {
cerr << "Failed to open pool " << m_pool_name << ": "
<< cpp_strerror(r) << std::endl;
goto out2;
}
m_rbd = new librbd::RBD();
std::map<thread_id_t, Worker*> workers;
int fd = open(replay_file.c_str(), O_RDONLY|O_BINARY);
if (fd < 0) {
std::cerr << "Failed to open " << replay_file << ": "
<< cpp_strerror(errno) << std::endl;
exit(1);
}
auto close_fd = make_scope_guard([fd] { close(fd); });
BufferReader buffer_reader(fd);
bool versioned = is_versioned_replay(buffer_reader);
while (true) {
action::ActionEntry action_entry;
try {
bufferlist::const_iterator *it;
int r = buffer_reader.fetch(&it);
if (r < 0) {
std::cerr << "Failed to read from trace file: " << cpp_strerror(r)
<< std::endl;
exit(-r);
}
if (it->get_remaining() == 0) {
break;
}
if (versioned) {
action_entry.decode(*it);
} else {
action_entry.decode_unversioned(*it);
}
} catch (const buffer::error &err) {
std::cerr << "Failed to decode trace action: " << err.what() << std::endl;
exit(1);
}
Action::ptr action = Action::construct(action_entry);
if (!action) {
// unknown / unsupported action
continue;
}
if (action->is_start_thread()) {
Worker *worker = new Worker(*this);
workers[action->thread_id()] = worker;
worker->start();
} else {
workers[action->thread_id()]->send(action);
}
}
dout(THREAD_LEVEL) << "Waiting for workers to die" << dendl;
std::pair<thread_id_t, Worker*> w;
BOOST_FOREACH(w, workers) {
w.second->join();
delete w.second;
}
clear_images();
delete m_rbd;
m_rbd = NULL;
}
out2:
delete m_ioctx;
m_ioctx = NULL;
}
out:
;
}
librbd::Image* Replayer::get_image(imagectx_id_t imagectx_id) {
std::scoped_lock lock{m_images_mutex};
return m_images[imagectx_id];
}
void Replayer::put_image(imagectx_id_t imagectx_id, librbd::Image *image) {
ceph_assert(image);
std::unique_lock lock{m_images_mutex};
ceph_assert(m_images.count(imagectx_id) == 0);
m_images[imagectx_id] = image;
}
void Replayer::erase_image(imagectx_id_t imagectx_id) {
std::unique_lock lock{m_images_mutex};
librbd::Image* image = m_images[imagectx_id];
if (m_dump_perf_counters) {
std::string command = "perf dump";
cmdmap_t cmdmap;
JSONFormatter jf(true);
bufferlist out;
std::stringstream ss;
g_ceph_context->do_command(command, cmdmap, &jf, ss, &out);
jf.flush(cout);
cout << std::endl;
cout.flush();
}
delete image;
m_images.erase(imagectx_id);
}
void Replayer::set_action_complete(action_id_t id) {
dout(DEPGRAPH_LEVEL) << "ActionTracker::set_complete(" << id << ")" << dendl;
auto now = std::chrono::system_clock::now();
action_tracker_d &tracker = tracker_for(id);
std::unique_lock lock{tracker.mutex};
ceph_assert(tracker.actions.count(id) == 0);
tracker.actions[id] = now;
tracker.condition.notify_all();
}
bool Replayer::is_action_complete(action_id_t id) {
action_tracker_d &tracker = tracker_for(id);
std::shared_lock lock{tracker.mutex};
return tracker.actions.count(id) > 0;
}
void Replayer::wait_for_actions(const action::Dependencies &deps) {
auto release_time = std::chrono::time_point<std::chrono::system_clock>::min();
for(auto& dep : deps) {
dout(DEPGRAPH_LEVEL) << "Waiting for " << dep.id << dendl;
auto start_time = std::chrono::system_clock::now();
action_tracker_d &tracker = tracker_for(dep.id);
std::unique_lock lock{tracker.mutex};
bool first_time = true;
while (tracker.actions.count(dep.id) == 0) {
if (!first_time) {
dout(DEPGRAPH_LEVEL) << "Still waiting for " << dep.id << dendl;
}
tracker.condition.wait_for(lock, std::chrono::seconds(1));
first_time = false;
}
auto action_completed_time(tracker.actions[dep.id]);
lock.unlock();
auto end_time = std::chrono::system_clock::now();
auto micros = std::chrono::duration_cast<std::chrono::microseconds>(end_time - start_time).count();
dout(DEPGRAPH_LEVEL) << "Finished waiting for " << dep.id << " after " << micros << " microseconds" << dendl;
// Apparently the nanoseconds constructor is optional:
// http://www.boost.org/doc/libs/1_46_0/doc/html/date_time/details.html#compile_options
auto sub_release_time{action_completed_time +
std::chrono::microseconds{static_cast<long long>(dep.time_delta * m_latency_multiplier / 1000)}};
if (sub_release_time > release_time) {
release_time = sub_release_time;
}
}
if (release_time > std::chrono::system_clock::now()) {
auto sleep_for = release_time - std::chrono::system_clock::now();
dout(SLEEP_LEVEL) << "Sleeping for "
<< std::chrono::duration_cast<std::chrono::microseconds>(sleep_for).count()
<< " microseconds" << dendl;
std::this_thread::sleep_until(release_time);
}
}
void Replayer::clear_images() {
std::shared_lock lock{m_images_mutex};
if (m_dump_perf_counters && !m_images.empty()) {
std::string command = "perf dump";
cmdmap_t cmdmap;
JSONFormatter jf(true);
bufferlist out;
std::stringstream ss;
g_ceph_context->do_command(command, cmdmap, &jf, ss, &out);
jf.flush(cout);
cout << std::endl;
cout.flush();
}
for (auto& p : m_images) {
delete p.second;
}
m_images.clear();
}
void Replayer::set_latency_multiplier(float f) {
assertf(f >= 0, "f = %f", f);
m_latency_multiplier = f;
}
bool Replayer::readonly() const {
return m_readonly;
}
void Replayer::set_readonly(bool readonly) {
m_readonly = readonly;
}
std::string Replayer::pool_name() const {
return m_pool_name;
}
void Replayer::set_pool_name(std::string pool_name) {
m_pool_name = pool_name;
}
| 11,257 | 26.525672 | 138 |
cc
|
null |
ceph-main/src/rbd_replay/Replayer.hpp
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2014 Adam Crume <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef _INCLUDED_RBD_REPLAY_REPLAYER_HPP
#define _INCLUDED_RBD_REPLAY_REPLAYER_HPP
#include <chrono>
#include <mutex>
#include <thread>
#include <condition_variable>
#include "rbd_replay/ActionTypes.h"
#include "BoundedBuffer.hpp"
#include "ImageNameMap.hpp"
#include "PendingIO.hpp"
namespace rbd_replay {
class Replayer;
/**
Performs Actions within a single thread.
*/
class Worker : public ActionCtx {
public:
explicit Worker(Replayer &replayer);
void start();
/// Should only be called by StopThreadAction
void stop() override;
void join();
void send(Action::ptr action);
void add_pending(PendingIO::ptr io) override;
void remove_pending(PendingIO::ptr io) override;
librbd::Image* get_image(imagectx_id_t imagectx_id) override;
void put_image(imagectx_id_t imagectx_id, librbd::Image* image) override;
void erase_image(imagectx_id_t imagectx_id) override;
librbd::RBD* rbd() override;
librados::IoCtx* ioctx() override;
void set_action_complete(action_id_t id) override;
bool readonly() const override;
rbd_loc map_image_name(std::string image_name, std::string snap_name) const override;
private:
void run();
Replayer &m_replayer;
BoundedBuffer<Action::ptr> m_buffer;
std::shared_ptr<std::thread> m_thread;
std::map<action_id_t, PendingIO::ptr> m_pending_ios;
std::mutex m_pending_ios_mutex;
std::condition_variable_any m_pending_ios_empty;
bool m_done;
};
class Replayer {
public:
explicit Replayer(int num_action_trackers);
~Replayer();
void run(const std::string &replay_file);
librbd::RBD* get_rbd() {
return m_rbd;
}
librados::IoCtx* get_ioctx() {
return m_ioctx;
}
librbd::Image* get_image(imagectx_id_t imagectx_id);
void put_image(imagectx_id_t imagectx_id, librbd::Image *image);
void erase_image(imagectx_id_t imagectx_id);
void set_action_complete(action_id_t id);
bool is_action_complete(action_id_t id);
void wait_for_actions(const action::Dependencies &deps);
std::string pool_name() const;
void set_pool_name(std::string pool_name);
void set_latency_multiplier(float f);
bool readonly() const;
void set_readonly(bool readonly);
void set_image_name_map(const ImageNameMap &map) {
m_image_name_map = map;
}
void set_dump_perf_counters(bool dump_perf_counters) {
m_dump_perf_counters = dump_perf_counters;
}
const ImageNameMap &image_name_map() const {
return m_image_name_map;
}
private:
struct action_tracker_d {
/// Maps an action ID to the time the action completed
std::map<action_id_t, std::chrono::system_clock::time_point> actions;
std::shared_mutex mutex;
std::condition_variable_any condition;
};
void clear_images();
action_tracker_d &tracker_for(action_id_t id);
/// Disallow copying
Replayer(const Replayer& rhs);
/// Disallow assignment
const Replayer& operator=(const Replayer& rhs);
librbd::RBD* m_rbd;
librados::IoCtx* m_ioctx;
std::string m_pool_name;
float m_latency_multiplier;
bool m_readonly;
ImageNameMap m_image_name_map;
bool m_dump_perf_counters;
std::map<imagectx_id_t, librbd::Image*> m_images;
std::shared_mutex m_images_mutex;
/// Actions are hashed across the trackers by ID.
/// Number of trackers should probably be larger than the number of cores and prime.
/// Should definitely be odd.
const int m_num_action_trackers;
action_tracker_d* m_action_trackers;
};
}
#endif
| 3,876 | 22.077381 | 87 |
hpp
|
null |
ceph-main/src/rbd_replay/actions.cc
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2014 Adam Crume <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#include "actions.hpp"
#include <boost/foreach.hpp>
#include <cstdlib>
#include "PendingIO.hpp"
#include "rbd_replay_debug.hpp"
#define dout_context g_ceph_context
using std::cerr;
using namespace rbd_replay;
namespace {
std::string create_fake_data() {
char data[1 << 20]; // 1 MB
for (unsigned int i = 0; i < sizeof(data); i++) {
data[i] = (char) i;
}
return std::string(data, sizeof(data));
}
struct ConstructVisitor : public boost::static_visitor<Action::ptr> {
inline Action::ptr operator()(const action::StartThreadAction &action) const {
return Action::ptr(new StartThreadAction(action));
}
inline Action::ptr operator()(const action::StopThreadAction &action) const{
return Action::ptr(new StopThreadAction(action));
}
inline Action::ptr operator()(const action::ReadAction &action) const {
return Action::ptr(new ReadAction(action));
}
inline Action::ptr operator()(const action::AioReadAction &action) const {
return Action::ptr(new AioReadAction(action));
}
inline Action::ptr operator()(const action::WriteAction &action) const {
return Action::ptr(new WriteAction(action));
}
inline Action::ptr operator()(const action::AioWriteAction &action) const {
return Action::ptr(new AioWriteAction(action));
}
inline Action::ptr operator()(const action::DiscardAction &action) const {
return Action::ptr(new DiscardAction(action));
}
inline Action::ptr operator()(const action::AioDiscardAction &action) const {
return Action::ptr(new AioDiscardAction(action));
}
inline Action::ptr operator()(const action::OpenImageAction &action) const {
return Action::ptr(new OpenImageAction(action));
}
inline Action::ptr operator()(const action::CloseImageAction &action) const {
return Action::ptr(new CloseImageAction(action));
}
inline Action::ptr operator()(const action::AioOpenImageAction &action) const {
return Action::ptr(new AioOpenImageAction(action));
}
inline Action::ptr operator()(const action::AioCloseImageAction &action) const {
return Action::ptr(new AioCloseImageAction(action));
}
inline Action::ptr operator()(const action::UnknownAction &action) const {
return Action::ptr();
}
};
} // anonymous namespace
std::ostream& rbd_replay::operator<<(std::ostream& o, const Action& a) {
return a.dump(o);
}
Action::ptr Action::construct(const action::ActionEntry &action_entry) {
return boost::apply_visitor(ConstructVisitor(), action_entry.action);
}
void StartThreadAction::perform(ActionCtx &ctx) {
cerr << "StartThreadAction should never actually be performed" << std::endl;
exit(1);
}
void StopThreadAction::perform(ActionCtx &ctx) {
dout(ACTION_LEVEL) << "Performing " << *this << dendl;
ctx.stop();
}
void AioReadAction::perform(ActionCtx &worker) {
dout(ACTION_LEVEL) << "Performing " << *this << dendl;
librbd::Image *image = worker.get_image(m_action.imagectx_id);
ceph_assert(image);
PendingIO::ptr io(new PendingIO(pending_io_id(), worker));
worker.add_pending(io);
int r = image->aio_read(m_action.offset, m_action.length, io->bufferlist(), &io->completion());
assertf(r >= 0, "id = %d, r = %d", id(), r);
}
void ReadAction::perform(ActionCtx &worker) {
dout(ACTION_LEVEL) << "Performing " << *this << dendl;
librbd::Image *image = worker.get_image(m_action.imagectx_id);
PendingIO::ptr io(new PendingIO(pending_io_id(), worker));
worker.add_pending(io);
ssize_t r = image->read(m_action.offset, m_action.length, io->bufferlist());
assertf(r >= 0, "id = %d, r = %d", id(), r);
worker.remove_pending(io);
}
void AioWriteAction::perform(ActionCtx &worker) {
static const std::string fake_data(create_fake_data());
dout(ACTION_LEVEL) << "Performing " << *this << dendl;
librbd::Image *image = worker.get_image(m_action.imagectx_id);
PendingIO::ptr io(new PendingIO(pending_io_id(), worker));
uint64_t remaining = m_action.length;
while (remaining > 0) {
uint64_t n = std::min(remaining, (uint64_t)fake_data.length());
io->bufferlist().append(fake_data.data(), n);
remaining -= n;
}
worker.add_pending(io);
if (worker.readonly()) {
worker.remove_pending(io);
} else {
int r = image->aio_write(m_action.offset, m_action.length, io->bufferlist(), &io->completion());
assertf(r >= 0, "id = %d, r = %d", id(), r);
}
}
void WriteAction::perform(ActionCtx &worker) {
dout(ACTION_LEVEL) << "Performing " << *this << dendl;
librbd::Image *image = worker.get_image(m_action.imagectx_id);
PendingIO::ptr io(new PendingIO(pending_io_id(), worker));
worker.add_pending(io);
io->bufferlist().append_zero(m_action.length);
if (!worker.readonly()) {
ssize_t r = image->write(m_action.offset, m_action.length, io->bufferlist());
assertf(r >= 0, "id = %d, r = %d", id(), r);
}
worker.remove_pending(io);
}
void AioDiscardAction::perform(ActionCtx &worker) {
dout(ACTION_LEVEL) << "Performing " << *this << dendl;
librbd::Image *image = worker.get_image(m_action.imagectx_id);
PendingIO::ptr io(new PendingIO(pending_io_id(), worker));
worker.add_pending(io);
if (worker.readonly()) {
worker.remove_pending(io);
} else {
int r = image->aio_discard(m_action.offset, m_action.length, &io->completion());
assertf(r >= 0, "id = %d, r = %d", id(), r);
}
}
void DiscardAction::perform(ActionCtx &worker) {
dout(ACTION_LEVEL) << "Performing " << *this << dendl;
librbd::Image *image = worker.get_image(m_action.imagectx_id);
PendingIO::ptr io(new PendingIO(pending_io_id(), worker));
worker.add_pending(io);
if (!worker.readonly()) {
ssize_t r = image->discard(m_action.offset, m_action.length);
assertf(r >= 0, "id = %d, r = %d", id(), r);
}
worker.remove_pending(io);
}
void OpenImageAction::perform(ActionCtx &worker) {
dout(ACTION_LEVEL) << "Performing " << *this << dendl;
PendingIO::ptr io(new PendingIO(pending_io_id(), worker));
worker.add_pending(io);
librbd::Image *image = new librbd::Image();
librbd::RBD *rbd = worker.rbd();
rbd_loc name(worker.map_image_name(m_action.name, m_action.snap_name));
int r;
if (m_action.read_only || worker.readonly()) {
r = rbd->open_read_only(*worker.ioctx(), *image, name.image.c_str(), name.snap.c_str());
} else {
r = rbd->open(*worker.ioctx(), *image, name.image.c_str(), name.snap.c_str());
}
if (r) {
cerr << "Unable to open image '" << m_action.name
<< "' with snap '" << m_action.snap_name
<< "' (mapped to '" << name.str()
<< "') and readonly " << m_action.read_only
<< ": (" << -r << ") " << strerror(-r) << std::endl;
exit(1);
}
worker.put_image(m_action.imagectx_id, image);
worker.remove_pending(io);
}
void CloseImageAction::perform(ActionCtx &worker) {
dout(ACTION_LEVEL) << "Performing " << *this << dendl;
worker.erase_image(m_action.imagectx_id);
worker.set_action_complete(pending_io_id());
}
void AioOpenImageAction::perform(ActionCtx &worker) {
dout(ACTION_LEVEL) << "Performing " << *this << dendl;
// TODO: Make it async
PendingIO::ptr io(new PendingIO(pending_io_id(), worker));
worker.add_pending(io);
librbd::Image *image = new librbd::Image();
librbd::RBD *rbd = worker.rbd();
rbd_loc name(worker.map_image_name(m_action.name, m_action.snap_name));
int r;
if (m_action.read_only || worker.readonly()) {
r = rbd->open_read_only(*worker.ioctx(), *image, name.image.c_str(), name.snap.c_str());
} else {
r = rbd->open(*worker.ioctx(), *image, name.image.c_str(), name.snap.c_str());
}
if (r) {
cerr << "Unable to open image '" << m_action.name
<< "' with snap '" << m_action.snap_name
<< "' (mapped to '" << name.str()
<< "') and readonly " << m_action.read_only
<< ": (" << -r << ") " << strerror(-r) << std::endl;
exit(1);
}
worker.put_image(m_action.imagectx_id, image);
worker.remove_pending(io);
}
void AioCloseImageAction::perform(ActionCtx &worker) {
dout(ACTION_LEVEL) << "Performing " << *this << dendl;
// TODO: Make it async
worker.erase_image(m_action.imagectx_id);
worker.set_action_complete(pending_io_id());
}
| 8,538 | 33.01992 | 100 |
cc
|
null |
ceph-main/src/rbd_replay/actions.hpp
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2014 Adam Crume <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef _INCLUDED_RBD_REPLAY_ACTIONS_HPP
#define _INCLUDED_RBD_REPLAY_ACTIONS_HPP
#include <boost/shared_ptr.hpp>
#include "include/rbd/librbd.hpp"
#include "common/Formatter.h"
#include "rbd_replay/ActionTypes.h"
#include "rbd_loc.hpp"
#include <iostream>
// Stupid Doxygen requires this or else the typedef docs don't appear anywhere.
/// @file rbd_replay/actions.hpp
namespace rbd_replay {
typedef uint64_t imagectx_id_t;
typedef uint64_t thread_id_t;
/// Even IDs are normal actions, odd IDs are completions.
typedef uint32_t action_id_t;
class PendingIO;
/**
%Context through which an Action interacts with its environment.
*/
class ActionCtx {
public:
virtual ~ActionCtx() {
}
/**
Returns the image with the given ID.
The image must have been previously tracked with put_image(imagectx_id_t,librbd::Image*).
*/
virtual librbd::Image* get_image(imagectx_id_t imagectx_id) = 0;
/**
Tracks an image.
put_image(imagectx_id_t,librbd::Image*) must not have been called previously with the same ID,
and the image must not be NULL.
*/
virtual void put_image(imagectx_id_t imagectx_id, librbd::Image* image) = 0;
/**
Stops tracking an Image and release it.
This deletes the C++ object, not the image itself.
The image must have been previously tracked with put_image(imagectx_id_t,librbd::Image*).
*/
virtual void erase_image(imagectx_id_t imagectx_id) = 0;
virtual librbd::RBD* rbd() = 0;
virtual librados::IoCtx* ioctx() = 0;
virtual void add_pending(boost::shared_ptr<PendingIO> io) = 0;
virtual bool readonly() const = 0;
virtual void remove_pending(boost::shared_ptr<PendingIO> io) = 0;
virtual void set_action_complete(action_id_t id) = 0;
virtual void stop() = 0;
/**
Maps an image name from the name in the original trace to the name that should be used when replaying.
@param image_name name of the image in the original trace
@param snap_name name of the snap in the original trace
@return image name to replay against
*/
virtual rbd_loc map_image_name(std::string image_name, std::string snap_name) const = 0;
};
/**
Performs an %IO or a maintenance action such as starting or stopping a thread.
Actions are read from a replay file and scheduled by Replayer.
Corresponds to the IO class, except that Actions are executed by rbd-replay,
and IOs are used by rbd-replay-prep for processing the raw trace.
*/
class Action {
public:
typedef boost::shared_ptr<Action> ptr;
virtual ~Action() {
}
virtual void perform(ActionCtx &ctx) = 0;
/// Returns the ID of the completion corresponding to this action.
action_id_t pending_io_id() {
return id() + 1;
}
// There's probably a better way to do this, but oh well.
virtual bool is_start_thread() {
return false;
}
virtual action_id_t id() const = 0;
virtual thread_id_t thread_id() const = 0;
virtual const action::Dependencies& predecessors() const = 0;
virtual std::ostream& dump(std::ostream& o) const = 0;
static ptr construct(const action::ActionEntry &action_entry);
};
template <typename ActionType>
class TypedAction : public Action {
public:
explicit TypedAction(const ActionType &action) : m_action(action) {
}
action_id_t id() const override {
return m_action.id;
}
thread_id_t thread_id() const override {
return m_action.thread_id;
}
const action::Dependencies& predecessors() const override {
return m_action.dependencies;
}
std::ostream& dump(std::ostream& o) const override {
o << get_action_name() << ": ";
ceph::JSONFormatter formatter(false);
formatter.open_object_section("");
m_action.dump(&formatter);
formatter.close_section();
formatter.flush(o);
return o;
}
protected:
const ActionType m_action;
virtual const char *get_action_name() const = 0;
};
/// Writes human-readable debug information about the action to the stream.
/// @related Action
std::ostream& operator<<(std::ostream& o, const Action& a);
class StartThreadAction : public TypedAction<action::StartThreadAction> {
public:
explicit StartThreadAction(const action::StartThreadAction &action)
: TypedAction<action::StartThreadAction>(action) {
}
bool is_start_thread() override {
return true;
}
void perform(ActionCtx &ctx) override;
protected:
const char *get_action_name() const override {
return "StartThreadAction";
}
};
class StopThreadAction : public TypedAction<action::StopThreadAction> {
public:
explicit StopThreadAction(const action::StopThreadAction &action)
: TypedAction<action::StopThreadAction>(action) {
}
void perform(ActionCtx &ctx) override;
protected:
const char *get_action_name() const override {
return "StartThreadAction";
}
};
class AioReadAction : public TypedAction<action::AioReadAction> {
public:
explicit AioReadAction(const action::AioReadAction &action)
: TypedAction<action::AioReadAction>(action) {
}
void perform(ActionCtx &ctx) override;
protected:
const char *get_action_name() const override {
return "AioReadAction";
}
};
class ReadAction : public TypedAction<action::ReadAction> {
public:
explicit ReadAction(const action::ReadAction &action)
: TypedAction<action::ReadAction>(action) {
}
void perform(ActionCtx &ctx) override;
protected:
const char *get_action_name() const override {
return "ReadAction";
}
};
class AioWriteAction : public TypedAction<action::AioWriteAction> {
public:
explicit AioWriteAction(const action::AioWriteAction &action)
: TypedAction<action::AioWriteAction>(action) {
}
void perform(ActionCtx &ctx) override;
protected:
const char *get_action_name() const override {
return "AioWriteAction";
}
};
class WriteAction : public TypedAction<action::WriteAction> {
public:
explicit WriteAction(const action::WriteAction &action)
: TypedAction<action::WriteAction>(action) {
}
void perform(ActionCtx &ctx) override;
protected:
const char *get_action_name() const override {
return "WriteAction";
}
};
class AioDiscardAction : public TypedAction<action::AioDiscardAction> {
public:
explicit AioDiscardAction(const action::AioDiscardAction &action)
: TypedAction<action::AioDiscardAction>(action) {
}
void perform(ActionCtx &ctx) override;
protected:
const char *get_action_name() const override {
return "AioDiscardAction";
}
};
class DiscardAction : public TypedAction<action::DiscardAction> {
public:
explicit DiscardAction(const action::DiscardAction &action)
: TypedAction<action::DiscardAction>(action) {
}
void perform(ActionCtx &ctx) override;
protected:
const char *get_action_name() const override {
return "DiscardAction";
}
};
class OpenImageAction : public TypedAction<action::OpenImageAction> {
public:
explicit OpenImageAction(const action::OpenImageAction &action)
: TypedAction<action::OpenImageAction>(action) {
}
void perform(ActionCtx &ctx) override;
protected:
const char *get_action_name() const override {
return "OpenImageAction";
}
};
class CloseImageAction : public TypedAction<action::CloseImageAction> {
public:
explicit CloseImageAction(const action::CloseImageAction &action)
: TypedAction<action::CloseImageAction>(action) {
}
void perform(ActionCtx &ctx) override;
protected:
const char *get_action_name() const override {
return "CloseImageAction";
}
};
class AioOpenImageAction : public TypedAction<action::AioOpenImageAction> {
public:
explicit AioOpenImageAction(const action::AioOpenImageAction &action)
: TypedAction<action::AioOpenImageAction>(action) {
}
void perform(ActionCtx &ctx) override;
protected:
const char *get_action_name() const override {
return "AioOpenImageAction";
}
};
class AioCloseImageAction : public TypedAction<action::AioCloseImageAction> {
public:
explicit AioCloseImageAction(const action::AioCloseImageAction &action)
: TypedAction<action::AioCloseImageAction>(action) {
}
void perform(ActionCtx &ctx) override;
protected:
const char *get_action_name() const override {
return "AioCloseImageAction";
}
};
}
#endif
| 8,631 | 24.02029 | 107 |
hpp
|
null |
ceph-main/src/rbd_replay/ios.cc
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2014 Adam Crume <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
// This code assumes that IO IDs and timestamps are related monotonically.
// In other words, (a.id < b.id) == (a.timestamp < b.timestamp) for all IOs a and b.
#include "ios.hpp"
#include "rbd_replay/ActionTypes.h"
using namespace std;
using namespace rbd_replay;
namespace {
bool compare_dependencies_by_start_time(const action::Dependency &lhs,
const action::Dependency &rhs) {
return lhs.time_delta < rhs.time_delta;
}
action::Dependencies convert_dependencies(uint64_t start_time,
const io_set_t &deps) {
action::Dependencies action_deps;
action_deps.reserve(deps.size());
for (io_set_t::const_iterator it = deps.begin(); it != deps.end(); ++it) {
boost::shared_ptr<IO> io = *it;
uint64_t time_delta = 0;
if (start_time >= io->start_time()) {
time_delta = start_time - io->start_time();
}
action_deps.push_back(action::Dependency(io->ionum(), time_delta));
}
std::sort(action_deps.begin(), action_deps.end(),
compare_dependencies_by_start_time);
return action_deps;
}
} // anonymous namespace
void IO::write_debug_base(ostream& out, const string &type) const {
out << m_ionum << ": " << m_start_time / 1000000.0 << ": " << type << ", thread = " << m_thread_id << ", deps = {";
bool first = true;
for (io_set_t::iterator itr = m_dependencies.begin(), end = m_dependencies.end(); itr != end; ++itr) {
if (first) {
first = false;
} else {
out << ", ";
}
out << (*itr)->m_ionum << ": " << m_start_time - (*itr)->m_start_time;
}
out << "}";
}
ostream& operator<<(ostream &out, const IO::ptr &io) {
io->write_debug(out);
return out;
}
void StartThreadIO::encode(bufferlist &bl) const {
using ceph::encode;
action::Action action((action::StartThreadAction(
ionum(), thread_id(), convert_dependencies(start_time(), dependencies()))));
encode(action, bl);
}
void StartThreadIO::write_debug(std::ostream& out) const {
write_debug_base(out, "start thread");
}
void StopThreadIO::encode(bufferlist &bl) const {
using ceph::encode;
action::Action action((action::StopThreadAction(
ionum(), thread_id(), convert_dependencies(start_time(), dependencies()))));
encode(action, bl);
}
void StopThreadIO::write_debug(std::ostream& out) const {
write_debug_base(out, "stop thread");
}
void ReadIO::encode(bufferlist &bl) const {
using ceph::encode;
action::Action action((action::ReadAction(
ionum(), thread_id(), convert_dependencies(start_time(), dependencies()),
m_imagectx, m_offset, m_length)));
encode(action, bl);
}
void ReadIO::write_debug(std::ostream& out) const {
write_debug_base(out, "read");
out << ", imagectx=" << m_imagectx << ", offset=" << m_offset << ", length=" << m_length << "]";
}
void WriteIO::encode(bufferlist &bl) const {
using ceph::encode;
action::Action action((action::WriteAction(
ionum(), thread_id(), convert_dependencies(start_time(), dependencies()),
m_imagectx, m_offset, m_length)));
encode(action, bl);
}
void WriteIO::write_debug(std::ostream& out) const {
write_debug_base(out, "write");
out << ", imagectx=" << m_imagectx << ", offset=" << m_offset << ", length=" << m_length << "]";
}
void DiscardIO::encode(bufferlist &bl) const {
using ceph::encode;
action::Action action((action::DiscardAction(
ionum(), thread_id(), convert_dependencies(start_time(), dependencies()),
m_imagectx, m_offset, m_length)));
encode(action, bl);
}
void DiscardIO::write_debug(std::ostream& out) const {
write_debug_base(out, "discard");
out << ", imagectx=" << m_imagectx << ", offset=" << m_offset << ", length=" << m_length << "]";
}
void AioReadIO::encode(bufferlist &bl) const {
using ceph::encode;
action::Action action((action::AioReadAction(
ionum(), thread_id(), convert_dependencies(start_time(), dependencies()),
m_imagectx, m_offset, m_length)));
encode(action, bl);
}
void AioReadIO::write_debug(std::ostream& out) const {
write_debug_base(out, "aio read");
out << ", imagectx=" << m_imagectx << ", offset=" << m_offset << ", length=" << m_length << "]";
}
void AioWriteIO::encode(bufferlist &bl) const {
using ceph::encode;
action::Action action((action::AioWriteAction(
ionum(), thread_id(), convert_dependencies(start_time(), dependencies()),
m_imagectx, m_offset, m_length)));
encode(action, bl);
}
void AioWriteIO::write_debug(std::ostream& out) const {
write_debug_base(out, "aio write");
out << ", imagectx=" << m_imagectx << ", offset=" << m_offset << ", length=" << m_length << "]";
}
void AioDiscardIO::encode(bufferlist &bl) const {
using ceph::encode;
action::Action action((action::AioDiscardAction(
ionum(), thread_id(), convert_dependencies(start_time(), dependencies()),
m_imagectx, m_offset, m_length)));
encode(action, bl);
}
void AioDiscardIO::write_debug(std::ostream& out) const {
write_debug_base(out, "aio discard");
out << ", imagectx=" << m_imagectx << ", offset=" << m_offset << ", length=" << m_length << "]";
}
void OpenImageIO::encode(bufferlist &bl) const {
using ceph::encode;
action::Action action((action::OpenImageAction(
ionum(), thread_id(), convert_dependencies(start_time(), dependencies()),
m_imagectx, m_name, m_snap_name, m_readonly)));
encode(action, bl);
}
void OpenImageIO::write_debug(std::ostream& out) const {
write_debug_base(out, "open image");
out << ", imagectx=" << m_imagectx << ", name='" << m_name << "', snap_name='" << m_snap_name << "', readonly=" << m_readonly;
}
void CloseImageIO::encode(bufferlist &bl) const {
using ceph::encode;
action::Action action((action::CloseImageAction(
ionum(), thread_id(), convert_dependencies(start_time(), dependencies()),
m_imagectx)));
encode(action, bl);
}
void CloseImageIO::write_debug(std::ostream& out) const {
write_debug_base(out, "close image");
out << ", imagectx=" << m_imagectx;
}
void AioOpenImageIO::encode(bufferlist &bl) const {
using ceph::encode;
action::Action action((action::AioOpenImageAction(
ionum(), thread_id(), convert_dependencies(start_time(), dependencies()),
m_imagectx, m_name, m_snap_name, m_readonly)));
encode(action, bl);
}
void AioOpenImageIO::write_debug(std::ostream& out) const {
write_debug_base(out, "aio open image");
out << ", imagectx=" << m_imagectx << ", name='" << m_name << "', snap_name='" << m_snap_name << "', readonly=" << m_readonly;
}
void AioCloseImageIO::encode(bufferlist &bl) const {
using ceph::encode;
action::Action action((action::AioCloseImageAction(
ionum(), thread_id(), convert_dependencies(start_time(), dependencies()),
m_imagectx)));
encode(action, bl);
}
void AioCloseImageIO::write_debug(std::ostream& out) const {
write_debug_base(out, "aio close image");
out << ", imagectx=" << m_imagectx;
}
| 7,319 | 32.122172 | 128 |
cc
|
null |
ceph-main/src/rbd_replay/ios.hpp
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2014 Adam Crume <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef _INCLUDED_RBD_REPLAY_IOS_HPP
#define _INCLUDED_RBD_REPLAY_IOS_HPP
// This code assumes that IO IDs and timestamps are related monotonically.
// In other words, (a.id < b.id) == (a.timestamp < b.timestamp) for all IOs a and b.
#include "include/buffer_fwd.h"
#include <boost/enable_shared_from_this.hpp>
#include <boost/shared_ptr.hpp>
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include "actions.hpp"
namespace rbd_replay {
class IO;
typedef std::set<boost::shared_ptr<IO> > io_set_t;
typedef std::map<action_id_t, boost::shared_ptr<IO> > io_map_t;
/**
Used by rbd-replay-prep for processing the raw trace.
Corresponds to the Action class, except that Actions are executed by rbd-replay,
and IOs are used by rbd-replay-prep for processing the raw trace.
*/
class IO : public boost::enable_shared_from_this<IO> {
public:
typedef boost::shared_ptr<IO> ptr;
typedef std::vector<ptr> ptrs;
/**
@param ionum ID of this %IO
@param start_time time the %IO started, in nanoseconds
@param thread_id ID of the thread that issued the %IO
*/
IO(action_id_t ionum,
uint64_t start_time,
thread_id_t thread_id,
const io_set_t& deps)
: m_ionum(ionum),
m_start_time(start_time),
m_dependencies(deps),
m_thread_id(thread_id),
m_completed(false) {
}
virtual ~IO() {
}
uint64_t start_time() const {
return m_start_time;
}
io_set_t& dependencies() {
return m_dependencies;
}
const io_set_t& dependencies() const {
return m_dependencies;
}
virtual void encode(bufferlist &bl) const = 0;
void set_ionum(action_id_t ionum) {
m_ionum = ionum;
}
action_id_t ionum() const {
return m_ionum;
}
thread_id_t thread_id() const {
return m_thread_id;
}
virtual void write_debug(std::ostream& out) const = 0;
protected:
void write_debug_base(std::ostream& out, const std::string &iotype) const;
private:
action_id_t m_ionum;
uint64_t m_start_time;
io_set_t m_dependencies;
thread_id_t m_thread_id;
bool m_completed;
};
/// Used for dumping debug info.
/// @related IO
std::ostream& operator<<(std::ostream &out, const IO::ptr &io);
class StartThreadIO : public IO {
public:
StartThreadIO(action_id_t ionum,
uint64_t start_time,
thread_id_t thread_id)
: IO(ionum, start_time, thread_id, io_set_t()) {
}
void encode(bufferlist &bl) const override;
void write_debug(std::ostream& out) const override;
};
class StopThreadIO : public IO {
public:
StopThreadIO(action_id_t ionum,
uint64_t start_time,
thread_id_t thread_id,
const io_set_t& deps)
: IO(ionum, start_time, thread_id, deps) {
}
void encode(bufferlist &bl) const override;
void write_debug(std::ostream& out) const override;
};
class ReadIO : public IO {
public:
ReadIO(action_id_t ionum,
uint64_t start_time,
thread_id_t thread_id,
const io_set_t& deps,
imagectx_id_t imagectx,
uint64_t offset,
uint64_t length)
: IO(ionum, start_time, thread_id, deps),
m_imagectx(imagectx),
m_offset(offset),
m_length(length) {
}
void encode(bufferlist &bl) const override;
void write_debug(std::ostream& out) const override;
private:
imagectx_id_t m_imagectx;
uint64_t m_offset;
uint64_t m_length;
};
class WriteIO : public IO {
public:
WriteIO(action_id_t ionum,
uint64_t start_time,
thread_id_t thread_id,
const io_set_t& deps,
imagectx_id_t imagectx,
uint64_t offset,
uint64_t length)
: IO(ionum, start_time, thread_id, deps),
m_imagectx(imagectx),
m_offset(offset),
m_length(length) {
}
void encode(bufferlist &bl) const override;
void write_debug(std::ostream& out) const override;
private:
imagectx_id_t m_imagectx;
uint64_t m_offset;
uint64_t m_length;
};
class DiscardIO : public IO {
public:
DiscardIO(action_id_t ionum,
uint64_t start_time,
thread_id_t thread_id,
const io_set_t& deps,
imagectx_id_t imagectx,
uint64_t offset,
uint64_t length)
: IO(ionum, start_time, thread_id, deps),
m_imagectx(imagectx),
m_offset(offset),
m_length(length) {
}
void encode(bufferlist &bl) const override;
void write_debug(std::ostream& out) const override;
private:
imagectx_id_t m_imagectx;
uint64_t m_offset;
uint64_t m_length;
};
class AioReadIO : public IO {
public:
AioReadIO(action_id_t ionum,
uint64_t start_time,
thread_id_t thread_id,
const io_set_t& deps,
imagectx_id_t imagectx,
uint64_t offset,
uint64_t length)
: IO(ionum, start_time, thread_id, deps),
m_imagectx(imagectx),
m_offset(offset),
m_length(length) {
}
void encode(bufferlist &bl) const override;
void write_debug(std::ostream& out) const override;
private:
imagectx_id_t m_imagectx;
uint64_t m_offset;
uint64_t m_length;
};
class AioWriteIO : public IO {
public:
AioWriteIO(action_id_t ionum,
uint64_t start_time,
thread_id_t thread_id,
const io_set_t& deps,
imagectx_id_t imagectx,
uint64_t offset,
uint64_t length)
: IO(ionum, start_time, thread_id, deps),
m_imagectx(imagectx),
m_offset(offset),
m_length(length) {
}
void encode(bufferlist &bl) const override;
void write_debug(std::ostream& out) const override;
private:
imagectx_id_t m_imagectx;
uint64_t m_offset;
uint64_t m_length;
};
class AioDiscardIO : public IO {
public:
AioDiscardIO(action_id_t ionum,
uint64_t start_time,
thread_id_t thread_id,
const io_set_t& deps,
imagectx_id_t imagectx,
uint64_t offset,
uint64_t length)
: IO(ionum, start_time, thread_id, deps),
m_imagectx(imagectx),
m_offset(offset),
m_length(length) {
}
void encode(bufferlist &bl) const override;
void write_debug(std::ostream& out) const override;
private:
imagectx_id_t m_imagectx;
uint64_t m_offset;
uint64_t m_length;
};
class OpenImageIO : public IO {
public:
OpenImageIO(action_id_t ionum,
uint64_t start_time,
thread_id_t thread_id,
const io_set_t& deps,
imagectx_id_t imagectx,
const std::string& name,
const std::string& snap_name,
bool readonly)
: IO(ionum, start_time, thread_id, deps),
m_imagectx(imagectx),
m_name(name),
m_snap_name(snap_name),
m_readonly(readonly) {
}
void encode(bufferlist &bl) const override;
imagectx_id_t imagectx() const {
return m_imagectx;
}
void write_debug(std::ostream& out) const override;
private:
imagectx_id_t m_imagectx;
std::string m_name;
std::string m_snap_name;
bool m_readonly;
};
class CloseImageIO : public IO {
public:
CloseImageIO(action_id_t ionum,
uint64_t start_time,
thread_id_t thread_id,
const io_set_t& deps,
imagectx_id_t imagectx)
: IO(ionum, start_time, thread_id, deps),
m_imagectx(imagectx) {
}
void encode(bufferlist &bl) const override;
imagectx_id_t imagectx() const {
return m_imagectx;
}
void write_debug(std::ostream& out) const override;
private:
imagectx_id_t m_imagectx;
};
class AioOpenImageIO : public IO {
public:
AioOpenImageIO(action_id_t ionum,
uint64_t start_time,
thread_id_t thread_id,
const io_set_t& deps,
imagectx_id_t imagectx,
const std::string& name,
const std::string& snap_name,
bool readonly)
: IO(ionum, start_time, thread_id, deps),
m_imagectx(imagectx),
m_name(name),
m_snap_name(snap_name),
m_readonly(readonly) {
}
void encode(bufferlist &bl) const override;
imagectx_id_t imagectx() const {
return m_imagectx;
}
void write_debug(std::ostream& out) const override;
private:
imagectx_id_t m_imagectx;
std::string m_name;
std::string m_snap_name;
bool m_readonly;
};
class AioCloseImageIO : public IO {
public:
AioCloseImageIO(action_id_t ionum,
uint64_t start_time,
thread_id_t thread_id,
const io_set_t& deps,
imagectx_id_t imagectx)
: IO(ionum, start_time, thread_id, deps),
m_imagectx(imagectx) {
}
void encode(bufferlist &bl) const override;
imagectx_id_t imagectx() const {
return m_imagectx;
}
void write_debug(std::ostream& out) const override;
private:
imagectx_id_t m_imagectx;
};
}
#endif
| 8,880 | 21.09204 | 84 |
hpp
|
null |
ceph-main/src/rbd_replay/rbd-replay-prep.cc
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2014 Adam Crume <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
// This code assumes that IO IDs and timestamps are related monotonically.
// In other words, (a.id < b.id) == (a.timestamp < b.timestamp) for all IOs a and b.
#include "include/compat.h"
#include "common/errno.h"
#include "rbd_replay/ActionTypes.h"
#include <babeltrace/babeltrace.h>
#include <babeltrace/ctf/events.h>
#include <babeltrace/ctf/iterator.h>
#include <sys/types.h>
#include <fcntl.h>
#include <cstdlib>
#include <string>
#include <assert.h>
#include <fstream>
#include <set>
#include <boost/thread/thread.hpp>
#include <boost/scope_exit.hpp>
#include "ios.hpp"
using namespace std;
using namespace rbd_replay;
#define ASSERT_EXIT(check, str) \
if (!(check)) { \
std::cerr << str << std::endl; \
exit(1); \
}
class Thread {
public:
typedef boost::shared_ptr<Thread> ptr;
Thread(thread_id_t id,
uint64_t window)
: m_id(id),
m_window(window),
m_latest_io(IO::ptr()),
m_max_ts(0) {
}
void insert_ts(uint64_t ts) {
if (m_max_ts == 0 || ts > m_max_ts) {
m_max_ts = ts;
}
}
uint64_t max_ts() const {
return m_max_ts;
}
void issued_io(IO::ptr io, std::set<IO::ptr> *latest_ios) {
ceph_assert(io);
if (m_latest_io.get() != NULL) {
latest_ios->erase(m_latest_io);
}
m_latest_io = io;
latest_ios->insert(io);
}
thread_id_t id() const {
return m_id;
}
IO::ptr latest_io() {
return m_latest_io;
}
private:
thread_id_t m_id;
uint64_t m_window;
IO::ptr m_latest_io;
uint64_t m_max_ts;
};
class AnonymizedImage {
public:
void init(const string &image_name, int index) {
ceph_assert(m_image_name == "");
m_image_name = image_name;
ostringstream oss;
oss << "image" << index;
m_anonymized_image_name = oss.str();
}
string image_name() const {
return m_image_name;
}
pair<string, string> anonymize(string snap_name) {
if (snap_name == "") {
return pair<string, string>(m_anonymized_image_name, "");
}
string& anonymized_snap_name(m_snaps[snap_name]);
if (anonymized_snap_name == "") {
ostringstream oss;
oss << "snap" << m_snaps.size();
anonymized_snap_name = oss.str();
}
return pair<string, string>(m_anonymized_image_name, anonymized_snap_name);
}
private:
string m_image_name;
string m_anonymized_image_name;
map<string, string> m_snaps;
};
static void usage(const string &prog) {
std::stringstream str;
str << "Usage: " << prog << " ";
std::cout << str.str() << "[ --window <seconds> ] [ --anonymize ] [ --verbose ]" << std::endl
<< std::string(str.str().size(), ' ') << "<trace-input> <replay-output>" << endl;
}
__attribute__((noreturn)) static void usage_exit(const string &prog, const string &msg) {
cerr << msg << endl;
usage(prog);
exit(1);
}
class Processor {
public:
Processor()
: m_window(1000000000ULL), // 1 billion nanoseconds, i.e., one second
m_io_count(0),
m_anonymize(false),
m_verbose(false) {
}
void run(vector<string> args) {
string input_file_name;
string output_file_name;
bool got_input = false;
bool got_output = false;
for (int i = 1, nargs = args.size(); i < nargs; i++) {
const string& arg(args[i]);
if (arg == "--window") {
if (i == nargs - 1) {
usage_exit(args[0], "--window requires an argument");
}
m_window = (uint64_t)(1e9 * atof(args[++i].c_str()));
} else if (arg.compare(0, 9, "--window=") == 0) {
m_window = (uint64_t)(1e9 * atof(arg.c_str() + sizeof("--window=")));
} else if (arg == "--anonymize") {
m_anonymize = true;
} else if (arg == "--verbose") {
m_verbose = true;
} else if (arg == "-h" || arg == "--help") {
usage(args[0]);
exit(0);
} else if (arg.compare(0, 1, "-") == 0) {
usage_exit(args[0], "Unrecognized argument: " + arg);
} else if (!got_input) {
input_file_name = arg;
got_input = true;
} else if (!got_output) {
output_file_name = arg;
got_output = true;
} else {
usage_exit(args[0], "Too many arguments");
}
}
if (!got_output) {
usage_exit(args[0], "Not enough arguments");
}
struct bt_context *ctx = bt_context_create();
int trace_handle = bt_context_add_trace(ctx,
input_file_name.c_str(), // path
"ctf", // format
NULL, // packet_seek
NULL, // stream_list
NULL); // metadata
ASSERT_EXIT(trace_handle >= 0, "Error loading trace file");
uint64_t start_time_ns = bt_trace_handle_get_timestamp_begin(ctx, trace_handle, BT_CLOCK_REAL);
ASSERT_EXIT(start_time_ns != -1ULL,
"Error extracting creation time from trace");
struct bt_ctf_iter *itr = bt_ctf_iter_create(ctx,
NULL, // begin_pos
NULL); // end_pos
ceph_assert(itr);
struct bt_iter *bt_itr = bt_ctf_get_iter(itr);
int fd = open(output_file_name.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_BINARY, 0644);
ASSERT_EXIT(fd >= 0, "Error opening output file " << output_file_name <<
": " << cpp_strerror(errno));
BOOST_SCOPE_EXIT( (fd) ) {
close(fd);
} BOOST_SCOPE_EXIT_END;
write_banner(fd);
uint64_t trace_start = 0;
bool first = true;
while(true) {
struct bt_ctf_event *evt = bt_ctf_iter_read_event(itr);
if(!evt) {
break;
}
uint64_t ts = bt_ctf_get_timestamp(evt);
ASSERT_EXIT(ts != -1ULL, "Error extracting event timestamp");
if (first) {
trace_start = ts;
first = false;
}
ts -= trace_start;
ts += 4; // This is so we have room to insert two events (thread start and open image) at unique timestamps before whatever the first event is.
IO::ptrs ptrs;
process_event(ts, evt, &ptrs);
serialize_events(fd, ptrs);
int r = bt_iter_next(bt_itr);
ASSERT_EXIT(r == 0, "Error advancing event iterator");
}
bt_ctf_iter_destroy(itr);
insert_thread_stops(fd);
}
private:
void write_banner(int fd) {
bufferlist bl;
bl.append(rbd_replay::action::BANNER);
int r = bl.write_fd(fd);
ASSERT_EXIT(r >= 0, "Error writing to output file: " << cpp_strerror(r));
}
void serialize_events(int fd, const IO::ptrs &ptrs) {
for (IO::ptrs::const_iterator it = ptrs.begin(); it != ptrs.end(); ++it) {
IO::ptr io(*it);
bufferlist bl;
io->encode(bl);
int r = bl.write_fd(fd);
ASSERT_EXIT(r >= 0, "Error writing to output file: " << cpp_strerror(r));
if (m_verbose) {
io->write_debug(std::cout);
std::cout << std::endl;
}
}
}
void insert_thread_stops(int fd) {
IO::ptrs ios;
for (map<thread_id_t, Thread::ptr>::const_iterator itr = m_threads.begin(),
end = m_threads.end(); itr != end; ++itr) {
Thread::ptr thread(itr->second);
ios.push_back(IO::ptr(new StopThreadIO(next_id(), thread->max_ts(),
thread->id(),
m_recent_completions)));
}
serialize_events(fd, ios);
}
void process_event(uint64_t ts, struct bt_ctf_event *evt,
IO::ptrs *ios) {
const char *event_name = bt_ctf_event_name(evt);
const struct bt_definition *scope_context = bt_ctf_get_top_level_scope(evt,
BT_STREAM_EVENT_CONTEXT);
ASSERT_EXIT(scope_context != NULL, "Error retrieving event context");
const struct bt_definition *scope_fields = bt_ctf_get_top_level_scope(evt,
BT_EVENT_FIELDS);
ASSERT_EXIT(scope_fields != NULL, "Error retrieving event fields");
const struct bt_definition *pthread_id_field = bt_ctf_get_field(evt, scope_context, "pthread_id");
ASSERT_EXIT(pthread_id_field != NULL, "Error retrieving thread id");
thread_id_t threadID = bt_ctf_get_uint64(pthread_id_field);
Thread::ptr &thread(m_threads[threadID]);
if (!thread) {
thread.reset(new Thread(threadID, m_window));
IO::ptr io(new StartThreadIO(next_id(), ts - 4, threadID));
ios->push_back(io);
}
thread->insert_ts(ts);
class FieldLookup {
public:
FieldLookup(struct bt_ctf_event *evt,
const struct bt_definition *scope)
: m_evt(evt),
m_scope(scope) {
}
const char* string(const char* name) {
const struct bt_definition *field = bt_ctf_get_field(m_evt, m_scope, name);
ASSERT_EXIT(field != NULL, "Error retrieving field '" << name << "'");
const char* c = bt_ctf_get_string(field);
int err = bt_ctf_field_get_error();
ASSERT_EXIT(c && err == 0, "Error retrieving field value '" << name <<
"': error=" << err);
return c;
}
int64_t int64(const char* name) {
const struct bt_definition *field = bt_ctf_get_field(m_evt, m_scope, name);
ASSERT_EXIT(field != NULL, "Error retrieving field '" << name << "'");
int64_t val = bt_ctf_get_int64(field);
int err = bt_ctf_field_get_error();
ASSERT_EXIT(err == 0, "Error retrieving field value '" << name <<
"': error=" << err);
return val;
}
uint64_t uint64(const char* name) {
const struct bt_definition *field = bt_ctf_get_field(m_evt, m_scope, name);
ASSERT_EXIT(field != NULL, "Error retrieving field '" << name << "'");
uint64_t val = bt_ctf_get_uint64(field);
int err = bt_ctf_field_get_error();
ASSERT_EXIT(err == 0, "Error retrieving field value '" << name <<
"': error=" << err);
return val;
}
private:
struct bt_ctf_event *m_evt;
const struct bt_definition *m_scope;
} fields(evt, scope_fields);
if (strcmp(event_name, "librbd:open_image_enter") == 0) {
string name(fields.string("name"));
string snap_name(fields.string("snap_name"));
bool readonly = fields.uint64("read_only");
imagectx_id_t imagectx = fields.uint64("imagectx");
action_id_t ionum = next_id();
pair<string, string> aname(map_image_snap(name, snap_name));
IO::ptr io(new OpenImageIO(ionum, ts, threadID, m_recent_completions,
imagectx, aname.first, aname.second,
readonly));
thread->issued_io(io, &m_latest_ios);
ios->push_back(io);
} else if (strcmp(event_name, "librbd:open_image_exit") == 0) {
completed(thread->latest_io());
boost::shared_ptr<OpenImageIO> io(boost::dynamic_pointer_cast<OpenImageIO>(thread->latest_io()));
ceph_assert(io);
m_open_images.insert(io->imagectx());
} else if (strcmp(event_name, "librbd:close_image_enter") == 0) {
imagectx_id_t imagectx = fields.uint64("imagectx");
action_id_t ionum = next_id();
IO::ptr io(new CloseImageIO(ionum, ts, threadID, m_recent_completions,
imagectx));
thread->issued_io(io, &m_latest_ios);
ios->push_back(thread->latest_io());
} else if (strcmp(event_name, "librbd:close_image_exit") == 0) {
completed(thread->latest_io());
boost::shared_ptr<CloseImageIO> io(boost::dynamic_pointer_cast<CloseImageIO>(thread->latest_io()));
ceph_assert(io);
m_open_images.erase(io->imagectx());
} else if (strcmp(event_name, "librbd:aio_open_image_enter") == 0) {
string name(fields.string("name"));
string snap_name(fields.string("snap_name"));
bool readonly = fields.uint64("read_only");
imagectx_id_t imagectx = fields.uint64("imagectx");
uint64_t completion = fields.uint64("completion");
action_id_t ionum = next_id();
pair<string, string> aname(map_image_snap(name, snap_name));
IO::ptr io(new AioOpenImageIO(ionum, ts, threadID, m_recent_completions,
imagectx, aname.first, aname.second,
readonly));
thread->issued_io(io, &m_latest_ios);
ios->push_back(io);
m_pending_ios[completion] = io;
} else if (strcmp(event_name, "librbd:aio_close_image_enter") == 0) {
imagectx_id_t imagectx = fields.uint64("imagectx");
uint64_t completion = fields.uint64("completion");
action_id_t ionum = next_id();
IO::ptr io(new AioCloseImageIO(ionum, ts, threadID, m_recent_completions,
imagectx));
thread->issued_io(io, &m_latest_ios);
ios->push_back(thread->latest_io());
m_pending_ios[completion] = io;
} else if (strcmp(event_name, "librbd:read_enter") == 0 ||
strcmp(event_name, "librbd:read2_enter") == 0) {
string name(fields.string("name"));
string snap_name(fields.string("snap_name"));
bool readonly = fields.int64("read_only");
imagectx_id_t imagectx = fields.uint64("imagectx");
uint64_t offset = fields.uint64("offset");
uint64_t length = fields.uint64("length");
require_image(ts, thread, imagectx, name, snap_name, readonly, ios);
action_id_t ionum = next_id();
IO::ptr io(new ReadIO(ionum, ts, threadID, m_recent_completions, imagectx,
offset, length));
thread->issued_io(io, &m_latest_ios);
ios->push_back(io);
} else if (strcmp(event_name, "librbd:read_exit") == 0) {
completed(thread->latest_io());
} else if (strcmp(event_name, "librbd:write_enter") == 0 ||
strcmp(event_name, "librbd:write2_enter") == 0) {
string name(fields.string("name"));
string snap_name(fields.string("snap_name"));
bool readonly = fields.int64("read_only");
uint64_t offset = fields.uint64("off");
uint64_t length = fields.uint64("buf_len");
imagectx_id_t imagectx = fields.uint64("imagectx");
require_image(ts, thread, imagectx, name, snap_name, readonly, ios);
action_id_t ionum = next_id();
IO::ptr io(new WriteIO(ionum, ts, threadID, m_recent_completions,
imagectx, offset, length));
thread->issued_io(io, &m_latest_ios);
ios->push_back(io);
} else if (strcmp(event_name, "librbd:write_exit") == 0) {
completed(thread->latest_io());
} else if (strcmp(event_name, "librbd:discard_enter") == 0) {
string name(fields.string("name"));
string snap_name(fields.string("snap_name"));
bool readonly = fields.int64("read_only");
uint64_t offset = fields.uint64("off");
uint64_t length = fields.uint64("len");
imagectx_id_t imagectx = fields.uint64("imagectx");
require_image(ts, thread, imagectx, name, snap_name, readonly, ios);
action_id_t ionum = next_id();
IO::ptr io(new DiscardIO(ionum, ts, threadID, m_recent_completions,
imagectx, offset, length));
thread->issued_io(io, &m_latest_ios);
ios->push_back(io);
} else if (strcmp(event_name, "librbd:discard_exit") == 0) {
completed(thread->latest_io());
} else if (strcmp(event_name, "librbd:aio_read_enter") == 0 ||
strcmp(event_name, "librbd:aio_read2_enter") == 0) {
string name(fields.string("name"));
string snap_name(fields.string("snap_name"));
bool readonly = fields.int64("read_only");
uint64_t completion = fields.uint64("completion");
imagectx_id_t imagectx = fields.uint64("imagectx");
uint64_t offset = fields.uint64("offset");
uint64_t length = fields.uint64("length");
require_image(ts, thread, imagectx, name, snap_name, readonly, ios);
action_id_t ionum = next_id();
IO::ptr io(new AioReadIO(ionum, ts, threadID, m_recent_completions,
imagectx, offset, length));
ios->push_back(io);
thread->issued_io(io, &m_latest_ios);
m_pending_ios[completion] = io;
} else if (strcmp(event_name, "librbd:aio_write_enter") == 0 ||
strcmp(event_name, "librbd:aio_write2_enter") == 0) {
string name(fields.string("name"));
string snap_name(fields.string("snap_name"));
bool readonly = fields.int64("read_only");
uint64_t offset = fields.uint64("off");
uint64_t length = fields.uint64("len");
uint64_t completion = fields.uint64("completion");
imagectx_id_t imagectx = fields.uint64("imagectx");
require_image(ts, thread, imagectx, name, snap_name, readonly, ios);
action_id_t ionum = next_id();
IO::ptr io(new AioWriteIO(ionum, ts, threadID, m_recent_completions,
imagectx, offset, length));
thread->issued_io(io, &m_latest_ios);
ios->push_back(io);
m_pending_ios[completion] = io;
} else if (strcmp(event_name, "librbd:aio_discard_enter") == 0) {
string name(fields.string("name"));
string snap_name(fields.string("snap_name"));
bool readonly = fields.int64("read_only");
uint64_t offset = fields.uint64("off");
uint64_t length = fields.uint64("len");
uint64_t completion = fields.uint64("completion");
imagectx_id_t imagectx = fields.uint64("imagectx");
require_image(ts, thread, imagectx, name, snap_name, readonly, ios);
action_id_t ionum = next_id();
IO::ptr io(new AioDiscardIO(ionum, ts, threadID, m_recent_completions,
imagectx, offset, length));
thread->issued_io(io, &m_latest_ios);
ios->push_back(io);
m_pending_ios[completion] = io;
} else if (strcmp(event_name, "librbd:aio_complete_enter") == 0) {
uint64_t completion = fields.uint64("completion");
map<uint64_t, IO::ptr>::iterator itr = m_pending_ios.find(completion);
if (itr != m_pending_ios.end()) {
IO::ptr completedIO(itr->second);
m_pending_ios.erase(itr);
completed(completedIO);
}
}
}
action_id_t next_id() {
action_id_t id = m_io_count;
m_io_count += 2;
return id;
}
void completed(IO::ptr io) {
uint64_t limit = (io->start_time() < m_window ?
0 : io->start_time() - m_window);
for (io_set_t::iterator itr = m_recent_completions.begin();
itr != m_recent_completions.end(); ) {
IO::ptr recent_comp(*itr);
if ((recent_comp->start_time() < limit ||
io->dependencies().count(recent_comp) != 0) &&
m_latest_ios.count(recent_comp) == 0) {
m_recent_completions.erase(itr++);
} else {
++itr;
}
}
m_recent_completions.insert(io);
}
pair<string, string> map_image_snap(string image_name, string snap_name) {
if (!m_anonymize) {
return pair<string, string>(image_name, snap_name);
}
AnonymizedImage& m(m_anonymized_images[image_name]);
if (m.image_name() == "") {
m.init(image_name, m_anonymized_images.size());
}
return m.anonymize(snap_name);
}
void require_image(uint64_t ts,
Thread::ptr thread,
imagectx_id_t imagectx,
const string& name,
const string& snap_name,
bool readonly,
IO::ptrs *ios) {
ceph_assert(thread);
if (m_open_images.count(imagectx) > 0) {
return;
}
action_id_t ionum = next_id();
pair<string, string> aname(map_image_snap(name, snap_name));
IO::ptr io(new OpenImageIO(ionum, ts - 2, thread->id(),
m_recent_completions, imagectx, aname.first,
aname.second, readonly));
thread->issued_io(io, &m_latest_ios);
ios->push_back(io);
completed(io);
m_open_images.insert(imagectx);
}
uint64_t m_window;
map<thread_id_t, Thread::ptr> m_threads;
uint32_t m_io_count;
io_set_t m_recent_completions;
set<imagectx_id_t> m_open_images;
// keyed by completion
map<uint64_t, IO::ptr> m_pending_ios;
std::set<IO::ptr> m_latest_ios;
bool m_anonymize;
map<string, AnonymizedImage> m_anonymized_images;
bool m_verbose;
};
int main(int argc, char** argv) {
vector<string> args;
for (int i = 0; i < argc; i++) {
args.push_back(string(argv[i]));
}
Processor p;
p.run(args);
}
| 20,311 | 33.721368 | 149 |
cc
|
null |
ceph-main/src/rbd_replay/rbd-replay.cc
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2014 Adam Crume <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#include <vector>
#include <boost/thread.hpp>
#include "common/ceph_argparse.h"
#include "global/global_init.h"
#include "Replayer.hpp"
#include "rbd_replay_debug.hpp"
#include "ImageNameMap.hpp"
using namespace std;
using namespace rbd_replay;
static const char* get_remainder(const char *string, const char *prefix) {
while (*prefix) {
if (*prefix++ != *string++) {
return NULL;
}
}
return string;
}
static void usage(const char* program) {
cout << "Usage: " << program << " --conf=<config_file> <replay_file>" << std::endl;
cout << "Options:" << std::endl;
cout << " -p, --pool-name <pool> Name of the pool to use. Default: rbd" << std::endl;
cout << " --latency-multiplier <float> Multiplies inter-request latencies. Default: 1" << std::endl;
cout << " --read-only Only perform non-destructive operations." << std::endl;
cout << " --map-image <rule> Add a rule to map image names in the trace to" << std::endl;
cout << " image names in the replay cluster." << std::endl;
cout << " --dump-perf-counters *Experimental*" << std::endl;
cout << " Dump performance counters to standard out before" << std::endl;
cout << " an image is closed. Performance counters may be dumped" << std::endl;
cout << " multiple times if multiple images are closed, or if" << std::endl;
cout << " the same image is opened and closed multiple times." << std::endl;
cout << " Performance counters and their meaning may change between" << std::endl;
cout << " versions." << std::endl;
cout << std::endl;
cout << "Image mapping rules:" << std::endl;
cout << "A rule of image1@snap1=image2@snap2 would map snap1 of image1 to snap2 of" << std::endl;
cout << "image2." << std::endl;
}
int main(int argc, const char **argv) {
auto args = argv_to_vec(argc, argv);
if (args.empty()) {
cerr << argv[0] << ": -h or --help for usage" << std::endl;
exit(1);
}
if (ceph_argparse_need_usage(args)) {
usage(argv[0]);
exit(0);
}
auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
CODE_ENVIRONMENT_UTILITY, 0);
std::vector<const char*>::iterator i;
string pool_name;
float latency_multiplier = 1;
bool readonly = false;
ImageNameMap image_name_map;
std::string val;
std::ostringstream err;
bool dump_perf_counters = false;
for (i = args.begin(); i != args.end(); ) {
if (ceph_argparse_double_dash(args, i)) {
break;
} else if (ceph_argparse_witharg(args, i, &val, "-p", "--pool", (char*)NULL)) {
pool_name = val;
} else if (ceph_argparse_witharg(args, i, &latency_multiplier, err, "--latency-multiplier",
(char*)NULL)) {
if (!err.str().empty()) {
cerr << err.str() << std::endl;
return 1;
}
} else if (ceph_argparse_flag(args, i, "--read-only", (char*)NULL)) {
readonly = true;
} else if (ceph_argparse_witharg(args, i, &val, "--map-image", (char*)NULL)) {
ImageNameMap::Mapping mapping;
if (image_name_map.parse_mapping(val, &mapping)) {
image_name_map.add_mapping(mapping);
} else {
cerr << "Unable to parse mapping string: '" << val << "'" << std::endl;
return 1;
}
} else if (ceph_argparse_flag(args, i, "--dump-perf-counters", (char*)NULL)) {
dump_perf_counters = true;
} else if (get_remainder(*i, "-")) {
cerr << "Unrecognized argument: " << *i << std::endl;
return 1;
} else {
++i;
}
}
common_init_finish(g_ceph_context);
string replay_file;
if (!args.empty()) {
replay_file = args[0];
}
if (replay_file.empty()) {
cerr << "No replay file specified." << std::endl;
return 1;
}
unsigned int nthreads = boost::thread::hardware_concurrency();
Replayer replayer(2 * nthreads + 1);
replayer.set_latency_multiplier(latency_multiplier);
replayer.set_pool_name(pool_name);
replayer.set_readonly(readonly);
replayer.set_image_name_map(image_name_map);
replayer.set_dump_perf_counters(dump_perf_counters);
replayer.run(replay_file);
}
| 4,707 | 35.215385 | 117 |
cc
|
null |
ceph-main/src/rbd_replay/rbd_loc.cc
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2014 Adam Crume <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#include "rbd_loc.hpp"
#include "include/ceph_assert.h"
using namespace std;
using namespace rbd_replay;
rbd_loc::rbd_loc() {
}
rbd_loc::rbd_loc(const string &pool, const string &image, const string &snap)
: pool(pool),
image(image),
snap(snap) {
}
bool rbd_loc::parse(string name_string) {
int field = 0;
string fields[3];
bool read_slash = false;
bool read_at = false;
for (size_t i = 0, n = name_string.length(); i < n; i++) {
char c = name_string[i];
switch (c) {
case '/':
if (read_slash || read_at) {
return false;
}
ceph_assert(field == 0);
field++;
read_slash = true;
break;
case '@':
if (read_at) {
return false;
}
ceph_assert(field < 2);
field++;
read_at = true;
break;
case '\\':
if (i == n - 1) {
return false;
}
fields[field].push_back(name_string[++i]);
break;
default:
fields[field].push_back(c);
}
}
if (read_slash) {
pool = fields[0];
image = fields[1];
// note that if read_at is false, then fields[2] is the empty string,
// so this is still correct
snap = fields[2];
} else {
pool = "";
image = fields[0];
// note that if read_at is false, then fields[1] is the empty string,
// so this is still correct
snap = fields[1];
}
return true;
}
static void write(const string &in, string *out) {
for (size_t i = 0, n = in.length(); i < n; i++) {
char c = in[i];
if (c == '@' || c == '/' || c == '\\') {
out->push_back('\\');
}
out->push_back(c);
}
}
string rbd_loc::str() const {
string out;
if (!pool.empty()) {
write(pool, &out);
out.push_back('/');
}
write(image, &out);
if (!snap.empty()) {
out.push_back('@');
write(snap, &out);
}
return out;
}
int rbd_loc::compare(const rbd_loc& rhs) const {
int c = pool.compare(rhs.pool);
if (c) {
return c;
}
c = image.compare(rhs.image);
if (c) {
return c;
}
c = snap.compare(rhs.snap);
if (c) {
return c;
}
return 0;
}
bool rbd_loc::operator==(const rbd_loc& rhs) const {
return compare(rhs) == 0;
}
bool rbd_loc::operator<(const rbd_loc& rhs) const {
return compare(rhs) < 0;
}
| 2,670 | 19.389313 | 77 |
cc
|
null |
ceph-main/src/rbd_replay/rbd_loc.hpp
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2014 Adam Crume <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef _INCLUDED_RBD_REPLAY_RBD_LOC_HPP
#define _INCLUDED_RBD_REPLAY_RBD_LOC_HPP
#include <string>
namespace rbd_replay {
/**
Stores a pool, image name, and snap name triple.
rbd_locs can be converted to/from strings with the format pool/image\@snap.
The slash and at signs can be omitted if the pool and snap are empty, respectively.
Backslashes can be used to escape slashes and at signs in names.
Examples:
|Pool | Image | Snap | String |
|------|-------|------|--------------------|
|rbd | vm | 1 | rbd/vm\@1 |
|rbd | vm | | rbd/vm |
| | vm | 1 | vm\@1 |
| | vm | | vm |
|rbd | | 1 | rbd/\@1 |
|rbd\@x| vm/y | 1 | rbd\\\@x/vm\\/y\@1 |
(The empty string should obviously be avoided as the image name.)
Note that the non-canonical forms /vm\@1 and rbd/vm\@ can also be parsed,
although they will be formatted as vm\@1 and rbd/vm.
*/
struct rbd_loc {
/**
Constructs an rbd_loc with the empty string for the pool, image, and snap.
*/
rbd_loc();
/**
Constructs an rbd_loc with the given pool, image, and snap.
*/
rbd_loc(const std::string &pool, const std::string &image, const std::string &snap);
/**
Parses an rbd_loc from the given string.
If parsing fails, the contents are unmodified.
@retval true if parsing succeeded
*/
bool parse(std::string name_string);
/**
Returns the string representation of the locator.
*/
std::string str() const;
/**
Compares the locators lexicographically by pool, then image, then snap.
*/
int compare(const rbd_loc& rhs) const;
/**
Returns true if the locators have identical pool, image, and snap.
*/
bool operator==(const rbd_loc& rhs) const;
/**
Compares the locators lexicographically by pool, then image, then snap.
*/
bool operator<(const rbd_loc& rhs) const;
std::string pool;
std::string image;
std::string snap;
};
}
#endif
| 2,490 | 26.373626 | 86 |
hpp
|
null |
ceph-main/src/rbd_replay/rbd_replay_debug.hpp
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2014 Adam Crume <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef _INCLUDED_RBD_REPLAY_DEBUG_H
#define _INCLUDED_RBD_REPLAY_DEBUG_H
#include "common/debug.h"
#include "include/ceph_assert.h"
namespace rbd_replay {
static const int ACTION_LEVEL = 11;
static const int DEPGRAPH_LEVEL = 12;
static const int SLEEP_LEVEL = 13;
static const int THREAD_LEVEL = 10;
}
#define dout_subsys ceph_subsys_rbd_replay
#undef dout_prefix
#define dout_prefix *_dout << "rbd_replay: "
#endif
| 847 | 23.228571 | 70 |
hpp
|
null |
ceph-main/src/rgw/librgw.cc
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab ft=cpp
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2022 New Dream Network
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#include <sys/types.h>
#include <string.h>
#include <chrono>
#include "include/rados/librgw.h"
#include "include/str_list.h"
#include "common/ceph_argparse.h"
#include "common/ceph_context.h"
#include "common/dout.h"
#include "rgw_lib.h"
#include <errno.h>
#include <thread>
#include <string>
#include <mutex>
#define dout_subsys ceph_subsys_rgw
namespace rgw {
bool global_stop = false;
static std::mutex librgw_mtx;
static RGWLib rgwlib;
} // namespace rgw
extern "C" {
int librgw_create(librgw_t* rgw, int argc, char **argv)
{
using namespace rgw;
int rc = -EINVAL;
g_rgwlib = &rgwlib;
if (! g_ceph_context) {
std::lock_guard<std::mutex> lg(librgw_mtx);
if (! g_ceph_context) {
std::vector<std::string> spl_args;
// last non-0 argument will be split and consumed
if (argc > 1) {
const std::string spl_arg{argv[(--argc)]};
get_str_vec(spl_arg, " \t", spl_args);
}
auto args = argv_to_vec(argc, argv);
// append split args, if any
for (const auto& elt : spl_args) {
args.push_back(elt.c_str());
}
rc = rgwlib.init(args);
}
}
*rgw = g_ceph_context->get();
return rc;
}
void librgw_shutdown(librgw_t rgw)
{
using namespace rgw;
CephContext* cct = static_cast<CephContext*>(rgw);
rgwlib.stop();
dout(1) << "final shutdown" << dendl;
cct->put();
}
} /* extern "C" */
| 1,794 | 18.944444 | 70 |
cc
|
null |
ceph-main/src/rgw/rgw_acl.cc
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab ft=cpp
#include <string.h>
#include <iostream>
#include <map>
#include "include/types.h"
#include "common/Formatter.h"
#include "rgw_acl.h"
#include "rgw_acl_s3.h"
#include "rgw_user.h"
#define dout_subsys ceph_subsys_rgw
using namespace std;
bool operator==(const ACLPermission& lhs, const ACLPermission& rhs) {
return lhs.flags == rhs.flags;
}
bool operator!=(const ACLPermission& lhs, const ACLPermission& rhs) {
return !(lhs == rhs);
}
bool operator==(const ACLGranteeType& lhs, const ACLGranteeType& rhs) {
return lhs.type == rhs.type;
}
bool operator!=(const ACLGranteeType& lhs, const ACLGranteeType& rhs) {
return lhs.type != rhs.type;
}
bool operator==(const ACLGrant& lhs, const ACLGrant& rhs) {
return lhs.type == rhs.type && lhs.id == rhs.id
&& lhs.email == rhs.email && lhs.permission == rhs.permission
&& lhs.name == rhs.name && lhs.group == rhs.group
&& lhs.url_spec == rhs.url_spec;
}
bool operator!=(const ACLGrant& lhs, const ACLGrant& rhs) {
return !(lhs == rhs);
}
bool operator==(const ACLReferer& lhs, const ACLReferer& rhs) {
return lhs.url_spec == rhs.url_spec && lhs.perm == rhs.perm;
}
bool operator!=(const ACLReferer& lhs, const ACLReferer& rhs) {
return !(lhs == rhs);
}
bool operator==(const RGWAccessControlList& lhs,
const RGWAccessControlList& rhs) {
return lhs.acl_user_map == rhs.acl_user_map
&& lhs.acl_group_map == rhs.acl_group_map
&& lhs.referer_list == rhs.referer_list
&& lhs.grant_map == rhs.grant_map;
}
bool operator!=(const RGWAccessControlList& lhs,
const RGWAccessControlList& rhs) {
return !(lhs == rhs);
}
bool operator==(const ACLOwner& lhs, const ACLOwner& rhs) {
return lhs.id == rhs.id && lhs.display_name == rhs.display_name;
}
bool operator!=(const ACLOwner& lhs, const ACLOwner& rhs) {
return !(lhs == rhs);
}
bool operator==(const RGWAccessControlPolicy& lhs,
const RGWAccessControlPolicy& rhs) {
return lhs.acl == rhs.acl && lhs.owner == rhs.owner;
}
bool operator!=(const RGWAccessControlPolicy& lhs,
const RGWAccessControlPolicy& rhs) {
return !(lhs == rhs);
}
void RGWAccessControlList::_add_grant(ACLGrant *grant)
{
ACLPermission& perm = grant->get_permission();
ACLGranteeType& type = grant->get_type();
switch (type.get_type()) {
case ACL_TYPE_REFERER:
referer_list.emplace_back(grant->get_referer(), perm.get_permissions());
/* We're specially handling the Swift's .r:* as the S3 API has a similar
* concept and thus we can have a small portion of compatibility here. */
if (grant->get_referer() == RGW_REFERER_WILDCARD) {
acl_group_map[ACL_GROUP_ALL_USERS] |= perm.get_permissions();
}
break;
case ACL_TYPE_GROUP:
acl_group_map[grant->get_group()] |= perm.get_permissions();
break;
default:
{
rgw_user id;
if (!grant->get_id(id)) {
ldout(cct, 0) << "ERROR: grant->get_id() failed" << dendl;
}
acl_user_map[id.to_str()] |= perm.get_permissions();
}
}
}
void RGWAccessControlList::add_grant(ACLGrant *grant)
{
rgw_user id;
grant->get_id(id); // not that this will return false for groups, but that's ok, we won't search groups
grant_map.insert(pair<string, ACLGrant>(id.to_str(), *grant));
_add_grant(grant);
}
void RGWAccessControlList::remove_canon_user_grant(rgw_user& user_id)
{
auto multi_map_iter = grant_map.find(user_id.to_str());
if(multi_map_iter != grant_map.end()) {
auto grants = grant_map.equal_range(user_id.to_str());
grant_map.erase(grants.first, grants.second);
}
auto map_iter = acl_user_map.find(user_id.to_str());
if (map_iter != acl_user_map.end()){
acl_user_map.erase(map_iter);
}
}
uint32_t RGWAccessControlList::get_perm(const DoutPrefixProvider* dpp,
const rgw::auth::Identity& auth_identity,
const uint32_t perm_mask)
{
ldpp_dout(dpp, 5) << "Searching permissions for identity=" << auth_identity
<< " mask=" << perm_mask << dendl;
return perm_mask & auth_identity.get_perms_from_aclspec(dpp, acl_user_map);
}
uint32_t RGWAccessControlList::get_group_perm(const DoutPrefixProvider *dpp,
ACLGroupTypeEnum group,
const uint32_t perm_mask) const
{
ldpp_dout(dpp, 5) << "Searching permissions for group=" << (int)group
<< " mask=" << perm_mask << dendl;
const auto iter = acl_group_map.find((uint32_t)group);
if (iter != acl_group_map.end()) {
ldpp_dout(dpp, 5) << "Found permission: " << iter->second << dendl;
return iter->second & perm_mask;
}
ldpp_dout(dpp, 5) << "Permissions for group not found" << dendl;
return 0;
}
uint32_t RGWAccessControlList::get_referer_perm(const DoutPrefixProvider *dpp,
const uint32_t current_perm,
const std::string http_referer,
const uint32_t perm_mask)
{
ldpp_dout(dpp, 5) << "Searching permissions for referer=" << http_referer
<< " mask=" << perm_mask << dendl;
/* This function is basically a transformation from current perm to
* a new one that takes into consideration the Swift's HTTP referer-
* based ACLs. We need to go through all items to respect negative
* grants. */
uint32_t referer_perm = current_perm;
for (const auto& r : referer_list) {
if (r.is_match(http_referer)) {
referer_perm = r.perm;
}
}
ldpp_dout(dpp, 5) << "Found referer permission=" << referer_perm << dendl;
return referer_perm & perm_mask;
}
uint32_t RGWAccessControlPolicy::get_perm(const DoutPrefixProvider* dpp,
const rgw::auth::Identity& auth_identity,
const uint32_t perm_mask,
const char * const http_referer,
bool ignore_public_acls)
{
ldpp_dout(dpp, 20) << "-- Getting permissions begin with perm_mask=" << perm_mask
<< dendl;
uint32_t perm = acl.get_perm(dpp, auth_identity, perm_mask);
if (auth_identity.is_owner_of(owner.get_id())) {
perm |= perm_mask & (RGW_PERM_READ_ACP | RGW_PERM_WRITE_ACP);
}
if (perm == perm_mask) {
return perm;
}
/* should we continue looking up? */
if (!ignore_public_acls && ((perm & perm_mask) != perm_mask)) {
perm |= acl.get_group_perm(dpp, ACL_GROUP_ALL_USERS, perm_mask);
if (false == auth_identity.is_owner_of(rgw_user(RGW_USER_ANON_ID))) {
/* this is not the anonymous user */
perm |= acl.get_group_perm(dpp, ACL_GROUP_AUTHENTICATED_USERS, perm_mask);
}
}
/* Should we continue looking up even deeper? */
if (nullptr != http_referer && (perm & perm_mask) != perm_mask) {
perm = acl.get_referer_perm(dpp, perm, http_referer, perm_mask);
}
ldpp_dout(dpp, 5) << "-- Getting permissions done for identity=" << auth_identity
<< ", owner=" << owner.get_id()
<< ", perm=" << perm << dendl;
return perm;
}
bool RGWAccessControlPolicy::verify_permission(const DoutPrefixProvider* dpp,
const rgw::auth::Identity& auth_identity,
const uint32_t user_perm_mask,
const uint32_t perm,
const char * const http_referer,
bool ignore_public_acls)
{
uint32_t test_perm = perm | RGW_PERM_READ_OBJS | RGW_PERM_WRITE_OBJS;
uint32_t policy_perm = get_perm(dpp, auth_identity, test_perm, http_referer, ignore_public_acls);
/* the swift WRITE_OBJS perm is equivalent to the WRITE obj, just
convert those bits. Note that these bits will only be set on
buckets, so the swift READ permission on bucket will allow listing
the bucket content */
if (policy_perm & RGW_PERM_WRITE_OBJS) {
policy_perm |= (RGW_PERM_WRITE | RGW_PERM_WRITE_ACP);
}
if (policy_perm & RGW_PERM_READ_OBJS) {
policy_perm |= (RGW_PERM_READ | RGW_PERM_READ_ACP);
}
uint32_t acl_perm = policy_perm & perm & user_perm_mask;
ldpp_dout(dpp, 10) << " identity=" << auth_identity
<< " requested perm (type)=" << perm
<< ", policy perm=" << policy_perm
<< ", user_perm_mask=" << user_perm_mask
<< ", acl perm=" << acl_perm << dendl;
return (perm == acl_perm);
}
bool RGWAccessControlPolicy::is_public(const DoutPrefixProvider *dpp) const
{
static constexpr auto public_groups = {ACL_GROUP_ALL_USERS,
ACL_GROUP_AUTHENTICATED_USERS};
return std::any_of(public_groups.begin(), public_groups.end(),
[&, dpp](ACLGroupTypeEnum g) {
auto p = acl.get_group_perm(dpp, g, RGW_PERM_FULL_CONTROL);
return (p != RGW_PERM_NONE) && (p != RGW_PERM_INVALID);
}
);
}
void ACLPermission::generate_test_instances(list<ACLPermission*>& o)
{
ACLPermission *p = new ACLPermission;
p->set_permissions(RGW_PERM_WRITE_ACP);
o.push_back(p);
o.push_back(new ACLPermission);
}
void ACLPermission::dump(Formatter *f) const
{
f->dump_int("flags", flags);
}
void ACLGranteeType::dump(Formatter *f) const
{
f->dump_unsigned("type", type);
}
void ACLGrant::dump(Formatter *f) const
{
f->open_object_section("type");
type.dump(f);
f->close_section();
f->dump_string("id", id.to_str());
f->dump_string("email", email);
f->open_object_section("permission");
permission.dump(f);
f->close_section();
f->dump_string("name", name);
f->dump_int("group", (int)group);
f->dump_string("url_spec", url_spec);
}
void ACLGrant::generate_test_instances(list<ACLGrant*>& o)
{
rgw_user id("rgw");
string name, email;
name = "Mr. RGW";
email = "r@gw";
ACLGrant *g1 = new ACLGrant;
g1->set_canon(id, name, RGW_PERM_READ);
g1->email = email;
o.push_back(g1);
ACLGrant *g2 = new ACLGrant;
g1->set_group(ACL_GROUP_AUTHENTICATED_USERS, RGW_PERM_WRITE);
o.push_back(g2);
o.push_back(new ACLGrant);
}
void ACLGranteeType::generate_test_instances(list<ACLGranteeType*>& o)
{
ACLGranteeType *t = new ACLGranteeType;
t->set(ACL_TYPE_CANON_USER);
o.push_back(t);
o.push_back(new ACLGranteeType);
}
void RGWAccessControlList::generate_test_instances(list<RGWAccessControlList*>& o)
{
RGWAccessControlList *acl = new RGWAccessControlList(NULL);
list<ACLGrant *> glist;
list<ACLGrant *>::iterator iter;
ACLGrant::generate_test_instances(glist);
for (iter = glist.begin(); iter != glist.end(); ++iter) {
ACLGrant *grant = *iter;
acl->add_grant(grant);
delete grant;
}
o.push_back(acl);
o.push_back(new RGWAccessControlList(NULL));
}
void ACLOwner::generate_test_instances(list<ACLOwner*>& o)
{
ACLOwner *owner = new ACLOwner;
owner->id = "rgw";
owner->display_name = "Mr. RGW";
o.push_back(owner);
o.push_back(new ACLOwner);
}
void RGWAccessControlPolicy::generate_test_instances(list<RGWAccessControlPolicy*>& o)
{
list<RGWAccessControlList *> acl_list;
list<RGWAccessControlList *>::iterator iter;
for (iter = acl_list.begin(); iter != acl_list.end(); ++iter) {
RGWAccessControlList::generate_test_instances(acl_list);
iter = acl_list.begin();
RGWAccessControlPolicy *p = new RGWAccessControlPolicy(NULL);
RGWAccessControlList *l = *iter;
p->acl = *l;
string name = "radosgw";
rgw_user id("rgw");
p->owner.set_name(name);
p->owner.set_id(id);
o.push_back(p);
delete l;
}
o.push_back(new RGWAccessControlPolicy(NULL));
}
void RGWAccessControlList::dump(Formatter *f) const
{
map<string, int>::const_iterator acl_user_iter = acl_user_map.begin();
f->open_array_section("acl_user_map");
for (; acl_user_iter != acl_user_map.end(); ++acl_user_iter) {
f->open_object_section("entry");
f->dump_string("user", acl_user_iter->first);
f->dump_int("acl", acl_user_iter->second);
f->close_section();
}
f->close_section();
map<uint32_t, int>::const_iterator acl_group_iter = acl_group_map.begin();
f->open_array_section("acl_group_map");
for (; acl_group_iter != acl_group_map.end(); ++acl_group_iter) {
f->open_object_section("entry");
f->dump_unsigned("group", acl_group_iter->first);
f->dump_int("acl", acl_group_iter->second);
f->close_section();
}
f->close_section();
multimap<string, ACLGrant>::const_iterator giter = grant_map.begin();
f->open_array_section("grant_map");
for (; giter != grant_map.end(); ++giter) {
f->open_object_section("entry");
f->dump_string("id", giter->first);
f->open_object_section("grant");
giter->second.dump(f);
f->close_section();
f->close_section();
}
f->close_section();
}
void ACLOwner::dump(Formatter *f) const
{
encode_json("id", id.to_str(), f);
encode_json("display_name", display_name, f);
}
void ACLOwner::decode_json(JSONObj *obj) {
string id_str;
JSONDecoder::decode_json("id", id_str, obj);
id.from_str(id_str);
JSONDecoder::decode_json("display_name", display_name, obj);
}
void RGWAccessControlPolicy::dump(Formatter *f) const
{
encode_json("acl", acl, f);
encode_json("owner", owner, f);
}
ACLGroupTypeEnum ACLGrant::uri_to_group(string& uri)
{
// this is required for backward compatibility
return ACLGrant_S3::uri_to_group(uri);
}
| 13,781 | 30.110609 | 105 |
cc
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.