Custom Search

Sunday, November 23, 2014

OpenStack OpenContrail Neutron IPAM API examples

1)
List all IPAMs

#neutron --debug ipam-list

a)

curl request generated by above CLI command
#curl -s http://127.0.0.1:9696/v2.0/ipams.json -X GET -H "X-Auth-Token:$TOKEN" -H "Content-Type: application/json" -H "Accept: application/json" -H "User-Agent: python-neutronclient" | python -mjson.tool

#curl -s http://127.0.0.1:9696/v2.0/ipams -X GET -H "X-Auth-Token:$TOKEN" -H "Content-Type: application/json" -H "Accept: application/json" -H "User-Agent: python-neutronclient" | python -mjson.tool


2)
Show IPAM

#neutron --debug ipam-show 58f9369b-d3ef-428a-bbc9-2b8c0e06b752

a)

curl request generated by above CLI command 
#curl -s http://127.0.0.1:9696/v2.0/ipams/58f9369b-d3ef-428a-bbc9-2b8c0e06b752.json -X GET -H "X-Auth-Token:$TOKEN" -H "Content-Type: application/json" -H "Accept: application/json" -H "User-Agent: python-neutronclient" | python -mjson.tool

#curl -s http://127.0.0.1:9696/v2.0/ipams/58f9369b-d3ef-428a-bbc9-2b8c0e06b752 -X GET -H "X-Auth-Token:$TOKEN" -H "Content-Type: application/json" -H "Accept: application/json" -H "User-Agent: python-neutronclient" | python -mjson.tool


3)
Delete IPAM

#neutron --debug ipam-delete d47aa080-cf94-46cc-9c07-da11819dc7ca


a)
curl request generated by above CLI command
#curl -s http://127.0.0.1:9696/v2.0/ipams/d47aa080-cf94-46cc-9c07-da11819dc7ca.json -X DELETE -H "X-Auth-Token:$TOKEN" -H "Content-Type: application/json" -H "Accept: application/json" -H "User-Agent: python-neutronclient" | python -mjson.tool

#curl -s http://127.0.0.1:9696/v2.0/ipams/d47aa080-cf94-46cc-9c07-da11819dc7ca -X DELETE -H "X-Auth-Token:$TOKEN" -H "Content-Type: application/json" -H "Accept: application/json" -H "User-Agent: python-neutronclient" | python -mjson.tool


4)
Create IPAM

#neutron --debug ipam-create ipam1

a) 
curl request generated by above CLI command
#curl -s http://127.0.0.1:9696/v2.0/ipams.json -X POST -H "X-Auth-Token:$TOKEN" -H "Content-Type: application/json" -H "Accept: application/json" -H "User-Agent: python-neutronclient" -d '{"ipam": {"name": "ipam1", "mgmt": {"method": "fixed"}}}'

#curl -s http://127.0.0.1:9696/v2.0/ipams -X POST -H "X-Auth-Token:$TOKEN" -H "Content-Type: application/json" -H "Accept: application/json" -H "User-Agent: python-neutronclient" -d '{"ipam": {"name": "ipam1", "mgmt": {"method": "fixed"}}}' | python -mjson.tool


b)

Create IPAM with "mgmt" databy making custom curl request
#curl -i http://127.0.0.1:9696/v2.0/ipams.json -X POST -H "X-Auth-Token:$TOKEN" -H "Content-Type: application/json" -H "Accept: application/json" -H "User-Agent: python-neutronclient" -d '{"ipam": {"name": "ipam28", "mgmt": {"ipam_method": null, "ipam_dns_method": "virtual-dns-server", "ipam_dns_server": {"tenant_dns_server_address": {"ip_address": []}, "virtual_dns_server_name": "default-domain:vdns"}, "dhcp_option_list": {"dhcp_option": [{"dhcp_option_value": "mydomain", "dhcp_option_name": "15"}, {"dhcp_option_value": "192.168.56.1", "dhcp_option_name": "4"}]}, "host_routes": null, "cidr_block": null}}}'

5)
Update IPAM


#neutron --debug ipam-update 07ae76d2-9fe4-466f-a98e-f82bc2b819d0 --name ipam5


a)

curl request generated by above CLI command
#curl -s http://127.0.0.1:9696/v2.0/ipams/07ae76d2-9fe4-466f-a98e-f82bc2b819d0.json -X PUT -H "X-Auth-Token:$TOKEN" -H "Content-Type: application/json" -H "Accept: application/json" -H "User-Agent: python-neutronclient" -d '{"ipam": {"name": "ipam5"}}' | python -mjson.tool

#curl -s http://127.0.0.1:9696/v2.0/ipams/07ae76d2-9fe4-466f-a98e-f82bc2b819d0 -X PUT -H "X-Auth-Token:$TOKEN" -H "Content-Type: application/json" -H "Accept: application/json" -H "User-Agent: python-neutronclient" -d '{"ipam": {"name": "ipam5"}}' | python -mjson.tool


b)
Update an IPAM's "mgmt" data by making custom curl request
#curl -i http://127.0.0.1:9696/v2.0/ipams/2e5810de-c681-4b0d-a346-99469f817b06.json -X PUT -H "X-Auth-Token:$TOKEN" -H "Content-Type: application/json" -H "Accept: application/json" -H "User-Agent: python-neutronclient" -d '{"ipam": {"mgmt": {"ipam_method": null, "ipam_dns_method": "virtual-dns-server", "ipam_dns_server": {"tenant_dns_server_address": {"ip_address": []}, "virtual_dns_server_name": "default-domain:vdns"}, "dhcp_option_list": {"dhcp_option": [{"dhcp_option_value": "mydomain", "dhcp_option_name": "15"}, {"dhcp_option_value": "192.168.56.1", "dhcp_option_name": "4"}]}, "host_routes": null, "cidr_block": null}}}'

3 comments:

  1. 1)
    IPAM dashboard code

    https://github.com/Juniper/contrail-horizon/blob/master/openstack_dashboard/api/contrail_quantum.py

    /usr/lib/python2.7/dist-packages/contrail_openstack_dashboard/openstack_dashboard/api/contrail_quantum.py

    2)
    icehouse
    --------------
    https://github.com/Juniper/python-neutronclient/blob/contrail/icehouse/neutronclient/v2_0/client.py
    https://github.com/Juniper/python-neutronclient/blob/contrail/icehouse/neutronclient/neutron/v2_0/ipam.py
    https://github.com/Juniper/python-neutronclient/blob/contrail/icehouse/neutronclient/shell.py

    juno
    -------
    https://github.com/Juniper/python-neutronclient/blob/contrail/juno/neutronclient/v2_0/client.py
    https://github.com/Juniper/python-neutronclient/blob/contrail/juno/neutronclient/neutron/v2_0/ipam.py
    https://github.com/Juniper/python-neutronclient/blob/contrail/juno/neutronclient/shell.py

    ReplyDelete
  2. #python neutron --debug contrail-ipam-show 733cad33-7663-4406-af61-f751c2a788dc --field id --field name --field fq_name --field mgmt --field tenant_id

    ReplyDelete
  3. | mgmt | {"ipam_method": null, "ipam_dns_method": "tenant-dns-server", "ipam_dns_server": {"tenant_dns_server_address": {"ip_address": ["192.13.4.5"]}, "virtual_dns_server_name": null}, "dhcp_option_list": {"dhcp_option": [{"dhcp_option_value": "10.1.1.2", "dhcp_option_name": "4"}, {"dhcp_option_value": "doooom", "dhcp_option_name": "15"}]}, "host_routes": null, "cidr_block": null}

    ReplyDelete