Skip to content

Commit

Permalink
Merge pull request #108 from playground/oh-mesh
Browse files Browse the repository at this point in the history
add unregisterMeshAgentByName
  • Loading branch information
playground authored Feb 29, 2024
2 parents e371f48 + 47a8d04 commit c3eae49
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 17 deletions.
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,21 @@ Register agent with Policy

```
- Run curl -sSL https://raw.githubusercontent.com/playground/hzn-cli/main/install.sh --output install.sh && bash ./install.sh
- 1) Cli-And-Anax 3) CLI-In-Container 5) Run-In-Containers 7) Confirm
2) CLI-Only 4) Anax-In-Container 6) All-In-One 8) Quit
Choose your environment setup: 1
- Cli-And-Anax runs both CLI & Agent on host machine, choose <Confirm> to continue setup.
- 1) Cli-And-Anax 3) CLI-In-Container 5) Run-In-Containers 7) OH-Mesh 9) Quit
2) CLI-Only 4) Anax-In-Container 6) All-In-One 8) Confirm
Choose your environment setup: 7
- You have chosen Cli-And-Anax
OH-Mesh, Set up OH Agent with Mesh, choose <Confirm> to continue setup.
Choose your environment setup: 8
You have chosen OH-Mesh
- 1) None
2) K3S
3) K8S
4) Confirm
5) Quit
Choose your kube to install: 2
Setup K3S for OH Agent with Mesh, choose <Confirm> to continue setup.
Choose your kube to install: 4
- You have chosen K3S for your setup
1) Config-File
2) Confirm
3) Help
Expand Down
1 change: 1 addition & 0 deletions build/common/src/hzn.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export declare class Hzn {
meshNodeList(): Observable<unknown>;
meshAgreementList(): Observable<unknown>;
registerMeshAgent(): Observable<unknown>;
unregisterMeshAgentByName(): Observable<unknown>;
unregisterMeshAgent(): Observable<unknown>;
unregisterAgent(): Observable<unknown>;
register(): Observable<unknown>;
Expand Down
5 changes: 4 additions & 1 deletion build/common/src/hzn.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/hzn.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build/common/src/interface/hzn-model.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/interface/hzn-model.js.map

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

1 change: 1 addition & 0 deletions build/common/src/utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export declare class Utils {
cleanUp(): Observable<unknown>;
uninstallK3s(): Observable<unknown>;
unregisterMeshAgent(params: IHznParam): Observable<unknown>;
unregisterMeshAgentByName(params: IHznParam): Observable<unknown>;
installK3s(params: IAutoParam): Observable<unknown>;
registerMeshAgent(): Observable<unknown>;
setupOpenHorizonMesh(params: IAutoParam, anax: string): Observable<unknown>;
Expand Down
9 changes: 8 additions & 1 deletion 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.8.0",
"version": "0.8.1",
"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
5 changes: 4 additions & 1 deletion src/common/src/hzn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,11 @@ export class Hzn {
registerMeshAgent() {
return utils.registerMeshAgent();
}
unregisterMeshAgentByName() {
return this.param.name.length > 0 ? utils.unregisterMeshAgentByName(this.param) : of('Please specify agent name')
}
unregisterMeshAgent() {
return this.param.name.length > 0 ? utils.unregisterMeshAgent(this.param) : of('Please specify agent name')
return utils.unregisterMeshAgent(this.param);
}
unregisterAgent() {
return utils.unregisterAgent(true)
Expand Down
4 changes: 2 additions & 2 deletions src/common/src/interface/hzn-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ export const justRun = [
'listPolicy', 'listService', 'listServicePolicy', 'listAllServices', 'publishMMSObject', 'publishMMSObjectPattern', 'publishMMSObjectPolicy',
'register', 'removeDeploymentPolicy', 'removeObject', 'removeOrg',
'removeNode', 'removeService', 'reviewPolicy', 'reviewServiceDefinition', 'createNetworkSegment',
'unregisterMeshAgent', 'registerMeshAgent', 'createDeployment', 'exposeDeployment', 'meshNodeList', 'meshAgreementList'
'unregisterMeshAgent', 'unregisterMeshAgentByName', 'registerMeshAgent', 'createDeployment', 'exposeDeployment', 'meshNodeList', 'meshAgreementList'
];
export const justRunCliOptional = [
'registerMeshAgent', 'unregisterMeshAgent', 'createDeployment', 'exposeDeployment', 'meshNodeList', 'meshAgreementList', 'createNetworkSegment'
'registerMeshAgent', 'unregisterMeshAgent', 'unregisterMeshAgentByName', 'createDeployment', 'exposeDeployment', 'meshNodeList', 'meshAgreementList', 'createNetworkSegment'
];
export const promptForUpdate = [
'setup', 'test', 'buildAndPublish', 'buildPublishAndRegister',
Expand Down
9 changes: 8 additions & 1 deletion src/common/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,14 @@ export class Utils {
}
unregisterMeshAgent(params: IHznParam) {
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 $HZN_ORG_ID/$HZN_EXCHANGE_USER_AUTH -X DELETE ${pEnv.HZN_EXCHANGE_URL}/v1/orgs/${pEnv.HZN_ORG_ID}/nodes/${pEnv.HZN_DEVICE_ID}`;
//const arg = `kubectl -n ohmesh3-frontend-ns exec -i agent-769d687ff9-8kssh -- hzn unregister -r -f --timeout 3`;
//const arg = `kubectl -n ${pEnv.AGENT_NAMESPACE} exec -i ${params.name} -- hzn unregister -r -f --timeout 3`;
return this.shell(arg);
}
unregisterMeshAgentByName(params: IHznParam) {
const pEnv = process.env;
//const arg = `curl -sL --insecure -u $HZN_ORG_ID/$HZN_EXCHANGE_USER_AUTH -X DELETE ${pEnv.HZN_EXCHANGE_URL}/v1/orgs/${pEnv.HZN_ORG_ID}/nodes/${pEnv.HZN_DEVICE_ID}`;
//const arg = `kubectl -n ohmesh3-frontend-ns exec -i agent-769d687ff9-8kssh -- hzn unregister -r -f --timeout 3`;
const arg = `kubectl -n ${pEnv.AGENT_NAMESPACE} exec -i ${params.name} -- hzn unregister -r -f --timeout 3`;
return this.shell(arg);
Expand Down

0 comments on commit c3eae49

Please sign in to comment.