Skip to content

Commit

Permalink
renamed cepId -> cepOperationObjectId
Browse files Browse the repository at this point in the history
  • Loading branch information
ck-c8y committed Feb 27, 2024
1 parent 99635a7 commit 52c8268
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 28 deletions.
10 changes: 5 additions & 5 deletions analytics-service/c8y_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ def restart_cep(self, request_headers):

self._logger.info(f"Restarted CEP!")

def get_cep_id(self, request_headers):
def get_cep_operationobject_id(self, request_headers):
try:
self._logger.info(f"Retrieving id of service object for CEP ...")
self._logger.info(f"Retrieving id of operation object for CEP ...")

response = self.c8yapp.get_tenant_instance(headers=request_headers).get(
resource=f"/service/cep/diagnostics/apamaCtrlStatus")
try:
app_id = response["microservice_application_id"]
microservice_name = response["microservice_name"]
cep_id = None
cep_operationobject_id = None
query = f"applicationId eq '{app_id}' and name eq '{microservice_name}'"

self._logger.info(f"Build filter: {query}")
Expand All @@ -75,12 +75,12 @@ def get_cep_id(self, request_headers):
f"Found managed object: {managed_object.id} for cep app: {app_id}"
)
managed_object_id = managed_object
cep_id = managed_object_id.id
cep_operationobject_id = managed_object_id.id
break
if managed_object_id == None:
self._logger.error(f"Not found !")
return None
return {"id": cep_id}
return {"id": cep_operationobject_id}
except:
self._logger.error(
f"Error finding app id: {app_id}",
Expand Down
4 changes: 2 additions & 2 deletions analytics-service/flask_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ def get_cep_extension_metadata():
# returns:
# id
@app.route("/cep/id", methods=["GET"])
def get_cep_id():
result = agent.get_cep_id(request_headers=request.headers)
def get_cep_operationobject_id():
result = agent.get_cep_operationobject_id(request_headers=request.headers)
if (result == None):
return f"Not found", 400
return jsonify(result)
Expand Down
10 changes: 5 additions & 5 deletions analytics-ui/src/monitoring/engine-monitoring.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { HumanizePipe, PropertiesListItem } from '@c8y/ngx-components';
encapsulation: ViewEncapsulation.None
})
export class EngineMonitoringComponent implements OnInit {
cepId: string;
cepOperationObjectId: string;
cepCtrlStatusLabels$: BehaviorSubject<PropertiesListItem[]> =
new BehaviorSubject<PropertiesListItem[]>([]);
@Output() closeSubject: Subject<void> = new Subject();
Expand Down Expand Up @@ -47,7 +47,7 @@ export class EngineMonitoringComponent implements OnInit {
const humanize = new HumanizePipe();

this.init();
this.cepId = await this.analyticsService.getCEP_Id();
this.cepOperationObjectId = await this.analyticsService.getCEP_OperationObject();
const cepCtrlStatus = await this.analyticsService.getCEP_Status();
const cepCtrlStatusLabels = [];
Object.keys(cepCtrlStatus).forEach((key) => {
Expand All @@ -66,13 +66,13 @@ export class EngineMonitoringComponent implements OnInit {

const filterAlarm: object = {
pageSize: 5,
source: this.cepId,
source: this.cepOperationObjectId,
currentPage: 1,
withTotalPages: true
};
const filterEvent: object = {
pageSize: 5,
source: this.cepId,
source: this.cepOperationObjectId,
currentPage: 1,
withTotalPages: true
};
Expand Down Expand Up @@ -106,7 +106,7 @@ export class EngineMonitoringComponent implements OnInit {
}

private async init() {
this.cepId = await this.analyticsService.getCEP_Id();
this.cepOperationObjectId = await this.analyticsService.getCEP_OperationObject();
}

nextPageAlarm(direction: number) {
Expand Down
26 changes: 13 additions & 13 deletions analytics-ui/src/shared/analytics.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { isCustomCEP_Block, removeFileExtension } from './utils';
export class AnalyticsService {
appDeleted = new EventEmitter<IManagedObject>();
progress: BehaviorSubject<number> = new BehaviorSubject<number>(null);
private _cepId: Promise<string>;
private _cepOperationObjectId: Promise<string>;
private _cepStatus: Promise<any>;
private _blocksDeployed: Promise<CEP_Block[]>;
private _extensionsDeployed: Promise<IManagedObject[]>;
Expand Down Expand Up @@ -143,7 +143,7 @@ export class AnalyticsService {
async clearCaches() {
this._blocksDeployed = undefined;
this._extensionsDeployed = undefined;
this._cepId = undefined;
this._cepOperationObjectId = undefined;
}

async getLoadedCEP_Blocks(): Promise<CEP_Block[]> {
Expand Down Expand Up @@ -205,9 +205,9 @@ export class AnalyticsService {
return data;
}

async getCEP_Id(): Promise<string> {
let cepId: string;
if (!this._cepId) {
async getCEP_OperationObject(): Promise<string> {
let cepOperationObjectId: string;
if (!this._cepOperationObjectId) {
const useBackend = true;
if (useBackend) {
// get name of microservice from cep endpoint
Expand All @@ -221,7 +221,7 @@ export class AnalyticsService {
}
);
const data = await response.json();
cepId = data.id;
cepOperationObjectId = data.id;
} else {
// get name of microservice from cep endpoint
const response: IFetchResponse = await this.fetchClient.fetch(
Expand Down Expand Up @@ -256,12 +256,12 @@ export class AnalyticsService {
);
return;
}
cepId = data[0].id;
cepOperationObjectId = data[0].id;
}
}
this._cepId = Promise.resolve(cepId);
this._cepOperationObjectId = Promise.resolve(cepOperationObjectId);
}
return this._cepId;
return this._cepOperationObjectId;
}

getCEP_Restarting(): Subject<boolean> {
Expand Down Expand Up @@ -298,16 +298,16 @@ export class AnalyticsService {
}

async subscribeMonitoringChannel(): Promise<object> {
const cepId = await this.getCEP_Id();
console.log('Started subscription on :', cepId);
const cepOperationObjectId = await this.getCEP_OperationObject();
console.log('Started subscription on CEP operationObject:', cepOperationObjectId);
const subMO = this.realtime.subscribe(
`/managedobjects/${cepId}`,
`/managedobjects/${cepOperationObjectId}`,
this.updateStatusFromMO.bind(this)
);
return subMO;

// const sub = this.realtime.subscribe(
// `/events/${cepId}`,
// `/events/${cepOperationObjectId}`,
// this.updateStatus.bind(this)
// );
// this.subscription = this.restart$
Expand Down
6 changes: 3 additions & 3 deletions analytics-ui/src/status/engine-status.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { BehaviorSubject, Subject } from 'rxjs';
encapsulation: ViewEncapsulation.None
})
export class EngineStatusComponent implements OnInit {
cepId: string;
cepOperationObjectId: string;
cepCtrlStatus$: Subject<any> = new Subject<any>();
cepCtrlStatusLabels$: BehaviorSubject<PropertiesListItem[]> =
new BehaviorSubject<PropertiesListItem[]>([]);
Expand All @@ -24,7 +24,7 @@ export class EngineStatusComponent implements OnInit {
const humanize = new HumanizePipe();

this.init();
this.cepId = await this.analyticsService.getCEP_Id();
this.cepOperationObjectId = await this.analyticsService.getCEP_OperationObject();
const cepCtrlStatus = await this.analyticsService.getCEP_Status();
const cepCtrlStatusLabels = [];
Object.keys(cepCtrlStatus).forEach((key) => {
Expand All @@ -45,6 +45,6 @@ export class EngineStatusComponent implements OnInit {
}

private async init() {
this.cepId = await this.analyticsService.getCEP_Id();
this.cepOperationObjectId = await this.analyticsService.getCEP_OperationObject();
}
}

0 comments on commit 52c8268

Please sign in to comment.