Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
Net_Works
Contributor
Jump to solution

mgmt_cli -- message: "Unrecognized parameter [ip-address]

Hi All,

I'm trying to use 'mgmt_cli' to add multiple hosts to our management server (81.10). I'm following the format in the 'Management API Reference'. I've created a .csv file and tried to import using --batch:

[Expert@mgmt:0]# mgmt_cli add host --batch cli_mgmt_test.csv:

At first this failed with the following error

---------------------------------------------START
Time: [22:34:12] 1/4/2023
---------------------------------------------
"Publish operation" failed (100%)
Publish failed, the following error has occurred:
tasks:
- task-id: "01234567-89ab-cdef-bfad-4320b3d28dca"
task-name: "Publish operation"
status: "failed"
progress-percentage: 100
suppressed: false
task-details:
- fault-message: "Publish cannot be performed without entering a session name and description."
--------------------------------------------------END


So I altered the command to include the session description:

[Expert@mgmt:0]# mgmt_cli set session description "API Session test" add host --batch cli_mgmt_test.csv


This time it failed with the following error:

--------------------------------------------------START
Line 2: code: "generic_err_invalid_parameter_name"
message: "Unrecognized parameter [ip-address]"

Line 3: code: "generic_err_invalid_parameter_name"
message: "Unrecognized parameter [ip-address]"

Line 4: code: "generic_err_invalid_parameter_name"
message: "Unrecognized parameter [ip-address]"

Line 5: code: "generic_err_invalid_parameter_name"
message: "Unrecognized parameter [ip-address]"


Executed command failed. Changes are discarded.
--------------------------------------------------END

My .csv look like this:

[Expert@mgmt:0]# cat cli_mgmt_test.csv
name,ip-address,color,comments
net-test.svr.1,169.254.0.1,red,this is a test -- delete once complete
net-test.svr.2,169.254.0.2,red,this is a test -- delete once complete
net-test.svr.3,169.254.0.3,red,this is a test -- delete once complete
net-test.svr.4,169.254.0.4,red,this is a test -- delete once complete

 

Any ideas why its not liking the ip-address? I've also tried using 'ipv4-address' with same failure. I'm able to create the hosts directly on Smartconsole but want to know how to create hosts via a batch script.

Thanks in advance.

0 Kudos
1 Solution

Accepted Solutions
Net_Works
Contributor

Hi All,

This took a little while to figure out as I'm quite new when it comes to APIs.

Anyway, after a bit more reading and playing around, I managed to figure it out -- as Im using 81.10, I have a windows version of  mgmt_cli.exe so created a local script pointing to my management server with a local copy of the .csv file. Here is a copy of the working script:

----------------------START
mgmt_cli.exe login -u myusername -p mypassword -m [mgmt IP address] > C:\Users\username\Documents\id.txt
mgmt_cli.exe add host --batch C:\Users\username\Documents\cli-mgmt-test.csv -s C:\Users\username\Documents\id.txt
mgmt_cli.exe set session description "API Session Test" new-name "username@03042023" -s C:\Users\username\Documents\id.txt
mgmt_cli.exe publish -s C:\Users\username\Documents\id.txt
mgmt_cli.exe logout -s C:\Users\username\Documents\id.txt
----------------------END

Simple I know but chuffed to get this working -- can now build on this for all sorts of tasks.

Thanks all and hope someone finds this useful 🙂

Chris.

View solution in original post

5 Replies
PhoneBoy
Admin
Admin

This should be two separate commands:

mgmt_cli set session description “API Test”
mgmt_cli add host --batch cli_mgmt_test.csv

0 Kudos
Net_Works
Contributor

Hi Phoneboy,

Just tried and get the following error on the first cmd:

--------------------------------------START
[Expert@mgmt:0]# mgmt_cli set session description “API Test”
Username: [myusername]
Password: [mypassword]

Error: The parameters of set-session command should be provided in pairs (key and value). You have provided an odd number of parameters which suggests that you are probably missing a parameter.
[Expert@mgmt:0]#
--------------------------------------END

Kind Rgds

Chris

 

0 Kudos
mcatanzaro
Employee
Employee

See sk113078. Your csv filename shouldn't contain underscores.

0 Kudos
Net_Works
Contributor

Hi, I removed the underscores from the .csv but get the same issue.

Thanks

0 Kudos
Net_Works
Contributor

Hi All,

This took a little while to figure out as I'm quite new when it comes to APIs.

Anyway, after a bit more reading and playing around, I managed to figure it out -- as Im using 81.10, I have a windows version of  mgmt_cli.exe so created a local script pointing to my management server with a local copy of the .csv file. Here is a copy of the working script:

----------------------START
mgmt_cli.exe login -u myusername -p mypassword -m [mgmt IP address] > C:\Users\username\Documents\id.txt
mgmt_cli.exe add host --batch C:\Users\username\Documents\cli-mgmt-test.csv -s C:\Users\username\Documents\id.txt
mgmt_cli.exe set session description "API Session Test" new-name "username@03042023" -s C:\Users\username\Documents\id.txt
mgmt_cli.exe publish -s C:\Users\username\Documents\id.txt
mgmt_cli.exe logout -s C:\Users\username\Documents\id.txt
----------------------END

Simple I know but chuffed to get this working -- can now build on this for all sorts of tasks.

Thanks all and hope someone finds this useful 🙂

Chris.

Leaderboard

Epsum factorial non deposit quid pro quo hic escorol.

Upcoming Events

    CheckMates Events