Skip to content
This repository has been archived by the owner on Jun 14, 2022. It is now read-only.

Commit

Permalink
sync cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
vvsviridov committed Dec 26, 2021
1 parent ac4f525 commit 14ee1ef
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ Error corrections

## 1.0.5a

Added `alarms` command
Added `alarms`, `sync` commands
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Authentication Successful
- `fdn <valid FDN>` - navigate to FDN
- `home` - navigate to root folder
- `alarms` - show alarms
- `sync` - initiate node synchronization
- `persistent` - toggle persistent attributes inclusion
- `exit` - logout and exit application

Expand Down Expand Up @@ -370,4 +371,4 @@ EMN returns error if commited configuration includes attributes with type SHORT.

1.0.4a - Error corrections

1.0.5a - Added `alarms` command
1.0.5a - Added `alarms`, `sync` commands
11 changes: 8 additions & 3 deletions lib/TopologyBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const logAttributes = require('../util/logAttributes')
const { createAxiosInstance } = require('../util/axiosInstance')

const alarms = require('../lib/commands/alarms')
const sync = require('../lib/commands/sync')
const login = require('../lib/commands/login')
const logout = require('../lib/commands/logout')
const initialPrompt = require('../lib/commands/initialPrompt')
Expand Down Expand Up @@ -45,11 +46,11 @@ class TopologyBrowser {
createAxiosInstance(url)
}

async login(){
async login() {
return await login.call(this)
}

async logout(){
async logout() {
await logout.call(this)
}

Expand All @@ -61,7 +62,7 @@ class TopologyBrowser {
return await this.nextVariants(input)
}

async nextObjects(input){
async nextObjects(input) {
return await nextObjects.call(this, input)
}

Expand Down Expand Up @@ -130,6 +131,10 @@ class TopologyBrowser {
await alarms.call(this, fdn)
}

async sync(fdn) {
await sync.call(this, fdn)
}

}


Expand Down
2 changes: 1 addition & 1 deletion lib/commands/nextObjects.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const requestWrapper = require('../../util/requestWrapper')

const otherCommands = ['show', 'config', 'up', 'home', 'fdn', 'persistent', 'alarms', 'exit']
const otherCommands = ['show', 'config', 'up', 'home', 'fdn', 'persistent', 'alarms', 'sync', 'exit']


async function nextObjects(input){
Expand Down
30 changes: 30 additions & 0 deletions lib/commands/sync.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const colors = require('colors')

const requestWrapper = require('../../util/requestWrapper')


async function sync(fdn) {
const meContextFind = fdn.match(/(NetworkElement|MeContext)=([\w-]+),?/)
if (!meContextFind) {
console.log('No sync object in FDN!'.yellow)
return
}
const actionUrl = `${this.objectUrl}v1/perform-mo-action/NetworkElement=${meContextFind[2]},CmFunction=1?actionName=sync`
const axiosConfig = {
method: 'post',
url: actionUrl,
headers: {
'Content-Type': 'application/json'
},
}
const response = await requestWrapper(axiosConfig, 'Initiate Node Sync...')
if (response.status === 200) {
console.log(`
${response.data.body.bold}
${response.data.title.green}
`)
}
}


module.exports = sync
3 changes: 3 additions & 0 deletions lib/inputHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ async function handleCommand(tplg, fdn, command) {
case 'alarms':
await tplg.alarms(fdn)
break
case 'sync':
await tplg.sync(fdn)
break

default:
fdn = commandOther(tplg, fdn, command)
Expand Down

0 comments on commit 14ee1ef

Please sign in to comment.