Skip to content

Commit

Permalink
Merge pull request #94 from playground/oh-mesh
Browse files Browse the repository at this point in the history
add purge flag
  • Loading branch information
playground authored Feb 19, 2024
2 parents f729aeb + 28a80e4 commit 7e2c2fc
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
4 changes: 2 additions & 2 deletions build/common/src/utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export declare class Utils {
installAnaxInContainer(configJson: any): Observable<unknown>;
installCliInContainer(configJson: any): Observable<unknown>;
updateConfig(configFile: string): Observable<unknown>;
proceedWithAutoInstall(params: IAutoParam, setup: SetupEnvironment): Observable<unknown>;
proceedWithAutoInstall(params: IAutoParam, setup: SetupEnvironment, purge?: boolean): Observable<unknown>;
autoRun(params: IAutoParam, setup: SetupEnvironment): Observable<unknown>;
setEnvFromEnvLocal(): void;
setEnvFromConfig(configFile: string): Observable<unknown>;
Expand Down Expand Up @@ -76,7 +76,7 @@ export declare class Utils {
aptUpdate(): Observable<unknown>;
installPrereq(): Observable<unknown>;
clearUnconfiguring(): Observable<unknown>;
purgeManagementHub(): Observable<unknown>;
purgeManagementHub(purge: boolean): Observable<unknown>;
cleanUp(): Observable<unknown>;
uninstallK3s(): Observable<unknown>;
unregisterMeshAgent(): Observable<unknown>;
Expand Down
13 changes: 7 additions & 6 deletions build/common/src/utils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/common/src/utils.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hzn-cli",
"version": "0.7.2",
"version": "0.7.3",
"description": "Open Horizon CLI toolkit helps streamline the process of preparing node agents and perform tasks between orgs environments",
"main": "./build/index.js",
"bin": {
Expand Down
13 changes: 7 additions & 6 deletions src/common/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,10 @@ export class Utils {
}
})
}
proceedWithAutoInstall(params: IAutoParam, setup: SetupEnvironment) {
proceedWithAutoInstall(params: IAutoParam, setup: SetupEnvironment, purge = true) {
return new Observable((observer) => {
// console.log('hzn_css', pEnv.HZN_CSS, typeof pEnv.HZN_CSS, Boolean(pEnv.HZN_CSS))
this.purgeManagementHub() // Leverage this function to cleanup and install prerequisites, maynot need preInstallHznCli anymore
this.purgeManagementHub(purge) // Leverage this function to cleanup and install prerequisites, maynot need preInstallHznCli anymore
.subscribe({
complete: () => {
const pEnv: any = process.env;
Expand Down Expand Up @@ -428,6 +428,7 @@ export class Utils {
observer.next('Please provide --config_file name')
observer.complete()
} else if(setup == SetupEnvironment.autoSetupAllInOne || setup == SetupEnvironment.autoSetupCliInContainer || setup == SetupEnvironment.autoSetupAnaxInContainer || setup == SetupEnvironment.autoSetupContainer || setup == SetupEnvironment.autoSetupOpenHorizonMesh) {
const purge = setup != SetupEnvironment.autoSetupOpenHorizonMesh;
let configJson
this.updateConfig(configFile)
.subscribe({
Expand All @@ -441,7 +442,7 @@ export class Utils {
Object.keys(org).forEach((key) => {
pEnv[key] = org[key]
})
this.proceedWithAutoInstall(params, setup)
this.proceedWithAutoInstall(params, setup, purge)
.subscribe({
complete: () => {
observer.next('')
Expand Down Expand Up @@ -957,8 +958,8 @@ export class Utils {
const arg = `docker exec horizon1 rm -rf /var/horizon/anax.db`
return this.shell(arg)
}
purgeManagementHub() {
if(os.arch() == 'x64' || process.platform == 'darwin') {
purgeManagementHub(purge: boolean) {
if(purge && (os.arch() == 'x64' || process.platform == 'darwin')) {
const arg = `curl -sSL https://raw.githubusercontent.com/open-horizon/devops/master/mgmt-hub/deploy-mgmt-hub.sh --output deploy-mgmt-hub.sh && chmod +x deploy-mgmt-hub.sh && sudo ./deploy-mgmt-hub.sh -PS && sudo rm -rf /tmp/horizon-all-in-1`
return this.shell(arg)
} else {
Expand All @@ -980,7 +981,7 @@ export class Utils {
}
unregisterMeshAgent() {
const pEnv = process.env;
const arg = `curl -sL --insecure -u $HZN_ORG_ID/$HZN_EXCHANGE_USER_AUTH -X DELETE ${pEnv.MESH_ENDPOINT}/v1/orgs/${pEnv.HZN_ORG_ID}/nodes/${pEnv.HZN_DEVICE_ID}`;
const arg = `curl -sL --insecure -u ${pEnv.HZN_ORG_ID}/${pEnv.HZN_EXCHANGE_USER_AUTH} -X DELETE ${pEnv.MESH_ENDPOINT}/v1/orgs/${pEnv.HZN_ORG_ID}/nodes/${pEnv.HZN_DEVICE_ID}`;
return this.shell(arg);
}
setupOpenHorizonMesh(params: IAutoParam, anax: string) {
Expand Down

0 comments on commit 7e2c2fc

Please sign in to comment.