Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
cosmos
Collaborator

Management API Object Creation

Sharing some straight forward API examples for a recent use case creating many objects and adding them to groups, hope this is useful.

Only issue I have is the login does not display the username prompt.

## Login session (enter username at blank prompt)
mgmt_cli login > session.id

## Add host objects
cat << EOF > hosts
name,ip-address
Host-10.0.0.1,10.0.0.1
EOF
mgmt_cli -s session.id add host -b hosts

## Add network objects
cat << EOF > networks
name,subnet,subnet-mask
Net-10.1.1.0,10.1.1.0,255.255.255.0
Net-10.1.2.0,10.1.2.0,255.255.255.0
EOF
mgmt_cli -s session.id add network -b networks

## Add group objects
cat << EOF > group
name
bond0.123_spf
EOF
mgmt_cli -s session.id add group -b group

## Add members to group
cat << EOF > members
name,members.add
bond0.123_spf,Host-10.0.0.1
bond0.123_spf,Net-10.1.1.0
bond0.123_spf,Net-10.1.2.0
EOF
mgmt_cli -s session.id set group -b members

## Publish changes
mgmt_cli -s session.id publish

## Log out
mgmt_cli -s session.id logout

 

0 Kudos
0 Replies