@CreatePermission
@EndpointDoc("Authenticate to a remote cluster")
def auth(self, url: str, cluster_alias: str, username: str,
- password=None, token=None, hub_url=None, cluster_fsid=None,
- prometheus_api_url=None, ssl_verify=False, ssl_certificate=None, ttl=None):
-
+ password=None, hub_url=None, ssl_verify=False, ssl_certificate=None, ttl=None):
try:
hub_fsid = mgr.get('config')['fsid']
except KeyError:
ssl_verify, ssl_certificate)
return True
- if token and cluster_fsid and prometheus_api_url:
- _set_prometheus_targets(prometheus_api_url)
- self.set_multi_cluster_config(cluster_fsid, username, url,
- cluster_alias, token, prometheus_api_url,
- ssl_verify, ssl_certificate)
- return True
+ return False
def check_cluster_connection(self, url, payload, username, ssl_verify, ssl_certificate):
try:
@Endpoint('PUT')
@UpdatePermission
# pylint: disable=W0613
- def reconnect_cluster(self, url: str, username=None, password=None, token=None,
+ def reconnect_cluster(self, url: str, username=None, password=None,
ssl_verify=False, ssl_certificate=None, ttl=None):
multicluster_config = self.load_multi_cluster_config()
if username and password:
spacingClass="mb-3"
i18n>{{ connectionMessage }}
</cd-alert-panel>
- <cd-alert-panel type="info"
- spacingClass="mb-3"
- i18n
- *ngIf="connectionVerified !== undefined && !connectionVerified && connectionMessage === 'Connection refused' || remoteClusterForm.getValue('showToken')">
- <p>You need to set this cluster's url as the cross origin url in the remote cluster you are trying to connect.
- You can do it by running this CLI command in your remote cluster and proceed with authentication via token.</p>
- <cd-code-block [codes]="[crossOriginCmd]"></cd-code-block>
- </cd-alert-panel>
<div class="form-group row">
<label class="cd-col-form-label required"
for="remoteClusterUrl"
*ngIf="remoteClusterForm.showError('remoteClusterUrl', frm, 'endpoint')"
i18n>Please enter a valid URL.
</span>
+ <span class="invalid-feedback"
+ *ngIf="remoteClusterForm.showError('remoteClusterUrl', frm, 'hubUrlCheck')"
+ i18n>The hub cluster cannot be connected.
+ </span>
</div>
</div>
<div class="form-group row">
</div>
</div>
<div class="form-group row"
- *ngIf="remoteClusterForm.getValue('showToken') && action !== 'edit'">
- <label class="cd-col-form-label required"
- for="clusterFsid"
- i18n>Cluster FSID
- </label>
- <div class="cd-col-form-input">
- <input id="clusterFsid"
- name="clusterFsid"
- class="form-control"
- type="text"
- formControlName="clusterFsid">
- <span class="invalid-feedback"
- *ngIf="remoteClusterForm.showError('clusterFsid', frm, 'required')"
- i18n>This field is required.
- </span>
- </div>
- </div>
- <div class="form-group row"
- *ngIf="remoteClusterForm.getValue('showToken') && action !== 'edit'">
- <label class="cd-col-form-label required"
- for="prometheusApiUrl"
- i18n>Prometheus API URL
- <cd-helper>
- <span>
- <p>Enter the Prometheus API URL. You can retrieve it from the CLI with: <b>{{ prometheusApiUrlCmd }} </b>
- <cd-copy-2-clipboard-button [source]="prometheusApiUrlCmd"
- [byId]="false"></cd-copy-2-clipboard-button>
- </p>
- </span>
- </cd-helper>
- </label>
- <div class="cd-col-form-input">
- <input id="prometheusApiUrl"
- name="prometheusApiUrl"
- class="form-control"
- type="text"
- formControlName="prometheusApiUrl">
- <span class="invalid-feedback"
- *ngIf="remoteClusterForm.showError('prometheusApiUrl', frm, 'required')"
- i18n>This field is required.
- </span>
- </div>
- </div>
- <div class="form-group row"
- *ngIf="!remoteClusterForm.getValue('showToken') && !showCrossOriginError && action !== 'edit'">
+ *ngIf="action !== 'edit'">
<label class="cd-col-form-label required"
for="password"
i18n>Password
</div>
</div>
<div class="form-group row"
- *ngIf="remoteClusterForm.getValue('showToken') && action !== 'edit'">
- <label class="cd-col-form-label required"
- for="apiToken"
- i18n>Token
- </label>
- <div class="cd-col-form-input">
- <input id="apiToken"
- name="apiToken"
- class="form-control"
- type="text"
- formControlName="apiToken">
- <span class="invalid-feedback"
- *ngIf="remoteClusterForm.showError('apiToken', frm, 'required')"
- i18n>This field is required.</span>
- </div>
- </div>
- <div class="form-group row"
- *ngIf="!remoteClusterForm.getValue('showToken') && action !== 'edit'">
+ *ngIf="action !== 'edit'">
<label class="cd-col-form-label"
for="ttl"
i18n>Login Expiration</label>
</select>
</div>
</div>
+ <!--
+ <div class="form-group row"
+ *ngIf="action !== 'edit'">
+ <label class="cd-col-form-label required"
+ for="apiToken"
+ i18n>Token
+ </label>
+ <div class="cd-col-form-input">
+ <input id="apiToken"
+ name="apiToken"
+ class="form-control"
+ type="text"
+ formControlName="apiToken">
+ <span class="invalid-feedback"
+ *ngIf="remoteClusterForm.showError('apiToken', frm, 'required')"
+ i18n>This field is required.</span>
+ </div>
+ </div>
<div class="form-group row"
*ngIf="action !== 'edit'">
<div class="cd-col-form-offset">
i18n>Auth with token</label>
</div>
</div>
- </div>
+ </div> -->
<!-- ssl -->
<div class="form-group row">
<div class="cd-col-form-offset">
readonly ipv4Rgx = /^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/i;
readonly ipv6Rgx = /^(?:[a-f0-9]{1,4}:){7}[a-f0-9]{1,4}$/i;
clusterApiUrlCmd = 'ceph mgr services';
- prometheusApiUrlCmd = 'ceph config get mgr mgr/dashboard/PROMETHEUS_API_HOST';
- crossOriginCmd = `ceph dashboard set-cross-origin-url ${window.location.origin}`;
remoteClusterForm: CdFormGroup;
- showToken = false;
connectionVerified: boolean;
connectionMessage = '';
private subs = new Subscription();
- showCrossOriginError = false;
action: string;
cluster: MultiCluster;
clustersData: MultiCluster[];
clusterUrls: string[];
clusterUsers: string[];
clusterUrlUserMap: Map<string, string>;
+ hubUrl: string;
constructor(
public activeModal: NgbActiveModal,
public notificationService: NotificationService,
private multiClusterService: MultiClusterService
) {
+ this.subs.add(
+ this.multiClusterService.subscribe((resp: any) => {
+ this.hubUrl = resp['hub_url'];
+ })
+ );
this.createForm();
}
ngOnInit(): void {
this.remoteClusterForm.get('clusterAlias').disable();
this.remoteClusterForm.get('username').setValue(this.cluster.user);
this.remoteClusterForm.get('username').disable();
- this.remoteClusterForm.get('clusterFsid').setValue(this.cluster.name);
- this.remoteClusterForm.get('clusterFsid').disable();
this.remoteClusterForm.get('ssl').setValue(this.cluster.ssl_verify);
this.remoteClusterForm.get('ssl_cert').setValue(this.cluster.ssl_certificate);
}
createForm() {
this.remoteClusterForm = new CdFormGroup({
- showToken: new FormControl(false),
+ // showToken: new FormControl(false),
username: new FormControl('', [
CdValidators.custom('uniqueUrlandUser', (username: string) => {
let remoteClusterUrl = '';
);
})
]),
- clusterFsid: new FormControl('', [
- CdValidators.requiredIf({
- showToken: true
- })
- ]),
- prometheusApiUrl: new FormControl('', [
- CdValidators.requiredIf({
- showToken: true
- })
- ]),
password: new FormControl('', []),
remoteClusterUrl: new FormControl(null, {
validators: [
);
}
}),
+ CdValidators.custom('hubUrlCheck', (remoteClusterUrl: string) => {
+ return this.action === 'connect' && remoteClusterUrl?.includes(this.hubUrl);
+ }),
Validators.required
]
}),
- apiToken: new FormControl('', [
- CdValidators.requiredIf({
- showToken: true
- })
- ]),
+ // apiToken: new FormControl('', [
+ // CdValidators.requiredIf({
+ // showToken: true
+ // })
+ // ]),
clusterAlias: new FormControl(null, {
validators: [
Validators.required,
handleError(error: any): void {
if (error.error.code === 'connection_refused') {
this.connectionVerified = false;
- this.showCrossOriginError = true;
this.connectionMessage = error.error.detail;
- this.crossOriginCmd = `ceph config set mgr mgr/dashboard/cross_origin_url ${window.location.origin} `;
} else {
this.connectionVerified = false;
this.connectionMessage = error.error.detail;
const clusterAlias = this.remoteClusterForm.getValue('clusterAlias');
const username = this.remoteClusterForm.getValue('username');
const password = this.remoteClusterForm.getValue('password');
- const token = this.remoteClusterForm.getValue('apiToken');
- const clusterFsid = this.remoteClusterForm.getValue('clusterFsid');
- const prometheusApiUrl = this.remoteClusterForm.getValue('prometheusApiUrl');
const ssl = this.remoteClusterForm.getValue('ssl');
const ttl = this.convertToHours(this.remoteClusterForm.getValue('ttl'));
const ssl_certificate = this.remoteClusterForm.getValue('ssl_cert')?.trim();
case 'reconnect':
this.subs.add(
this.multiClusterService
- .reConnectCluster(updatedUrl, username, password, token, ssl, ssl_certificate, ttl)
+ .reConnectCluster(updatedUrl, username, password, ssl, ssl_certificate, ttl)
.subscribe(commonSubscribtion)
);
break;
clusterAlias,
username,
password,
- token,
window.location.origin,
- clusterFsid,
- prometheusApiUrl,
ssl,
ssl_certificate,
ttl
}
}
- toggleToken() {
- this.showToken = !this.showToken;
- }
-
fileUpload(files: FileList, controlName: string) {
const file: File = files[0];
const reader = new FileReader();
import { Router } from '@angular/router';
import { CookiesService } from '~/app/shared/services/cookie.service';
import { Observable, Subscription } from 'rxjs';
+import { SettingsService } from '~/app/shared/api/settings.service';
@Component({
selector: 'cd-multi-cluster-list',
private notificationService: NotificationService,
private authStorageService: AuthStorageService,
private modalService: ModalService,
- private cookieService: CookiesService
+ private cookieService: CookiesService,
+ private settingsService: SettingsService
) {
this.tableActions = [
{
this.checkClusterConnectionStatus();
})
);
+
+ this.managedByConfig$ = this.settingsService.getValues('MANAGED_BY_CLUSTERS');
}
ngOnDestroy(): void {
clusterAlias: string,
username: string,
password: string,
- token = '',
hub_url = '',
- clusterFsid = '',
- prometheusApiUrl = '',
ssl = false,
cert = '',
ttl: number
cluster_alias: clusterAlias,
username,
password,
- token,
hub_url,
- cluster_fsid: clusterFsid,
- prometheus_api_url: prometheusApiUrl,
ssl_verify: ssl,
ssl_certificate: cert,
ttl: ttl
url: any,
username: string,
password: string,
- token = '',
ssl = false,
cert = '',
ttl: number
url,
username,
password,
- token,
ssl_verify: ssl,
ssl_certificate: cert,
ttl: ttl
properties:
cluster_alias:
type: string
- cluster_fsid:
- type: string
hub_url:
type: string
password:
type: string
- prometheus_api_url:
- type: string
ssl_certificate:
type: string
ssl_verify:
default: false
type: boolean
- token:
- type: string
ttl:
type: string
url:
ssl_verify:
default: false
type: boolean
- token:
- type: string
ttl:
type: string
url: