-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] Fixing licensing after server NP cutover
- Loading branch information
1 parent
5a21805
commit 0f25951
Showing
62 changed files
with
535 additions
and
714 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export { MlLicense, LicenseStatus, MINIMUM_FULL_LICENSE, MINIMUM_LICENSE } from './ml_license'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { Observable, Subscription } from 'rxjs'; | ||
import { ILicense, LICENSE_CHECK_STATE } from '../../../../../plugins/licensing/common/types'; | ||
import { PLUGIN_ID } from '../constants/app'; | ||
|
||
export const MINIMUM_LICENSE = 'basic'; | ||
export const MINIMUM_FULL_LICENSE = 'platinum'; | ||
|
||
export interface LicenseStatus { | ||
isValid: boolean; | ||
isSecurityEnabled: boolean; | ||
message?: string; | ||
} | ||
|
||
export class MlLicense { | ||
private _licenseSubscription: Subscription | null = null; | ||
private _license: ILicense | null = null; | ||
private _isSecurityEnabled: boolean = false; | ||
private _hasLicenseExpired: boolean = false; | ||
private _isMlEnabled: boolean = false; | ||
private _isMinimumLicense: boolean = false; | ||
private _isFullLicense: boolean = false; | ||
private _initialized: boolean = false; | ||
|
||
public setup( | ||
license$: Observable<ILicense>, | ||
postInitFunctions?: Array<(lic: MlLicense) => void> | ||
) { | ||
this._licenseSubscription = license$.subscribe(async license => { | ||
const { isEnabled: securityIsEnabled } = license.getFeature('security'); | ||
|
||
this._license = license; | ||
this._isSecurityEnabled = securityIsEnabled; | ||
this._hasLicenseExpired = this._license.status === 'expired'; | ||
this._isMlEnabled = this._license.getFeature(PLUGIN_ID).isEnabled; | ||
this._isMinimumLicense = | ||
this._license.check(PLUGIN_ID, MINIMUM_LICENSE).state === LICENSE_CHECK_STATE.Valid; | ||
this._isFullLicense = | ||
this._license.check(PLUGIN_ID, MINIMUM_FULL_LICENSE).state === LICENSE_CHECK_STATE.Valid; | ||
|
||
if (this._initialized === false && postInitFunctions !== undefined) { | ||
postInitFunctions.forEach(f => f(this)); | ||
} | ||
this._initialized = true; | ||
}); | ||
} | ||
|
||
public unsubscribe() { | ||
if (this._licenseSubscription !== null) { | ||
this._licenseSubscription.unsubscribe(); | ||
} | ||
} | ||
|
||
public isSecurityEnabled() { | ||
return this._isSecurityEnabled; | ||
} | ||
|
||
public hasLicenseExpired() { | ||
return this._hasLicenseExpired; | ||
} | ||
|
||
public isMlEnabled() { | ||
return this._isMlEnabled; | ||
} | ||
|
||
public isMinimumLicense() { | ||
return this._isMinimumLicense; | ||
} | ||
|
||
public isFullLicense() { | ||
return this._isFullLicense; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 0 additions & 36 deletions
36
x-pack/legacy/plugins/ml/public/application/license/__tests__/check_license.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.