Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
morris
Contributor

mgmt_cli Export all Hosts, Networks and Groups with members

Hi Guys,

we want to export all hosts, network and group objects so we can import them into another management.

 

For networks:

mgmt_cli -m localhost -s sid.txt show networks --format json | jq '.objects[] | {name, subnet4, "mask-length4"}'

Output:

"name": "CP_default_Office_Mode_addresses_pool",
"subnet4": "172.16.10.0",
"mask-length4": 24
}
{
"name": "IPv6_Link_Local_Hosts",
"subnet4": null,
"mask-length4": null
}
{
"name": "test-network",
"subnet4": "192.168.0.0",
"mask-length4": 16
}

Hosts:
mgmt_cli -m localhost -s sid.txt show hosts --format json | jq '.objects[] | {name, "ipv4-address"}'

Output:
"name": "test1",
"ipv4-address": "1.1.1.1"
}
{
"name": "test2",
"ipv4-address": "2.2.2.2"
}

 

The only issue I have are the groups:

mgmt_cli -m localhost -s sid.txt show groups details-level "full" --format json | jq '.objects[] | {name, members}'

Output:
"name": "testgroup",
"members": [
"a25ca22d-1494-49d2-89a5-f7dc6a804aa5",
"6d6903bc-aa68-4446-821d-50d0aa33dcc4"
]

 

The members only show with the UUID and not in clear-text.

Yes, I can manually search for the UUID but it seems pretty uncomfortable to me:
mgmt_cli -m localhost -s sid.txt show object uid "a25ca22d-1494-49d2-89a5-f7dc6a804aa5" --format json | jq '.object | {name, type, "ipv4-address"}'
"name": "test1",
"type": "host",
"ipv4-address": "1.1.1.1"

 

In contrast If I search for one specific group instead of "show groups" the members are shown in cleartext.

Any suggestions how to improve this?

 

 

0 Kudos
2 Replies
Amir_Senn
Employee
Employee

If it makes it better, you can take network group name or uid and put it in another API, show group.

You can take names of groups and loop through all the names:

mgmt_cli -r true show group name "Demo_Group" --format json
{
"uid" : "9bc6cc71-39d4-4ef1-acc8-c0f161df058b",
"name" : "Demo_Group",
"type" : "group",
"domain" : {
"uid" : "41e821a0-3720-11e3-aa6e-0800200c9fde",
"name" : "SMC User",
"domain-type" : "domain"
},
"members" : [ {
"uid" : "c717c05f-0285-4945-86a2-9b533d41e936",
"name" : "dummy1",
"type" : "host",
"domain" : {
"uid" : "41e821a0-3720-11e3-aa6e-0800200c9fde",
"name" : "SMC User",
"domain-type" : "domain"
},
"ipv4-address" : "1.1.1.1",
"icon" : "Objects/host",
"color" : "black"
}, {
"uid" : "0e696c35-d96e-4715-9b42-c933da5f9aaa",
"name" : "dummy2",
"type" : "host",
"domain" : {
"uid" : "41e821a0-3720-11e3-aa6e-0800200c9fde",
"name" : "SMC User",
"domain-type" : "domain"
},
"ipv4-address" : "2.2.2.2",
"icon" : "Objects/host",
"color" : "black"
},

.....

Kind regards, Amir Senn
0 Kudos
PhoneBoy
Admin
Admin

0 Kudos

Leaderboard

Epsum factorial non deposit quid pro quo hic escorol.

Upcoming Events

    CheckMates Events