Pages

Monday, February 12, 2018

[curl] OpenBMC Network

List Network Object Path
[curl]
curl -b cjar -k https://${bmc_ip}/xyz/openbmc_project/network/

For example
[curl in Linux]
$ curl -b cjar -k https://192.168.88.38/xyz/openbmc_project/network/
{
  "data": [
    "/xyz/openbmc_project/network/config",
    "/xyz/openbmc_project/network/host0",
    "/xyz/openbmc_project/network/eth0"
  ],
  "message": "200 OK",
  "status": "ok"
}


List Network Object
[curl]
curl -b cjar -k https://${bmc_ip}/xyz/openbmc_project/network/list

For example
[curl in Linux]
$ curl -b cjar -k https://192.168.88.38/xyz/openbmc_project/network/list
{
  "data": [
    "/xyz/openbmc_project/network/config",
    "/xyz/openbmc_project/network/eth0",
    "/xyz/openbmc_project/network/host0/intf",
    "/xyz/openbmc_project/network/eth0/ipv6/d689ebef",
    "/xyz/openbmc_project/network/eth0/ipv4/6a8406be",
    "/xyz/openbmc_project/network/host0/intf/addr",
    "/xyz/openbmc_project/network/eth0/ipv4/78de4ca5",
    "/xyz/openbmc_project/network/config/dhcp"
  ],
  "message": "200 OK",
  "status": "ok"
}


Enumerate Network Object
[curl]
curl -b cjar -k https://${bmc_ip}/xyz/openbmc_project/network/enumerate

For example
[curl in Linux]
$ curl -b cjar -k https://192.168.88.38/xyz/openbmc_project/network/enumerate
{
  "data": {
    "/xyz/openbmc_project/network/config": {
      "DefaultGateway": "192.168.88.1",
      "HostName": "computercheese"
    },
    "/xyz/openbmc_project/network/config/dhcp": {
      "DNSEnabled": 1,
      "HostNameEnabled": 1,
      "NTPEnabled": 1
    },
    "/xyz/openbmc_project/network/eth0": {
      "AutoNeg": 0,
      "DHCPEnabled": 1,
      "DomainName": [],
      "InterfaceName": "eth0",
      "MACAddress": "82:00:10:00:00:00",
      "NTPServers": [],
      "Nameservers": [],
      "Speed": 0
    },
    "/xyz/openbmc_project/network/eth0/ipv4/6a8406be": {
      "Address": "169.254.1.216",
      "Gateway": "0.0.0.0",
      "Origin": "xyz.openbmc_project.Network.IP.AddressOrigin.DHCP",
      "PrefixLength": 16,
      "Type": "xyz.openbmc_project.Network.IP.Protocol.IPv4"
    },
    "/xyz/openbmc_project/network/eth0/ipv4/78de4ca5": {
      "Address": "192.168.88.38",
      "Gateway": "0.0.0.0",
      "Origin": "xyz.openbmc_project.Network.IP.AddressOrigin.DHCP",
      "PrefixLength": 24,
      "Type": "xyz.openbmc_project.Network.IP.Protocol.IPv4"
    },
    "/xyz/openbmc_project/network/eth0/ipv6/d689ebef": {
      "Address": "fe80::8000:10ff:fe00:0",
      "Gateway": "",
      "Origin": "xyz.openbmc_project.Network.IP.AddressOrigin.DHCP",
      "PrefixLength": 64,
      "Type": "xyz.openbmc_project.Network.IP.Protocol.IPv6"
    },
    "/xyz/openbmc_project/network/host0/intf": {
      "MACAddress": "00:00:00:00:00:00"
    },
    "/xyz/openbmc_project/network/host0/intf/addr": {
      "Address": "0.0.0.0",
      "Gateway": "0.0.0.0",
      "Origin": "xyz.openbmc_project.Network.IP.AddressOrigin.Static",
      "PrefixLength": 0,
      "Type": "xyz.openbmc_project.Network.IP.Protocol.IPv4"
    }
  },
  "message": "200 OK",
  "status": "ok"
}


Network Configurations
[curl]
Get Default Gateway and Host Name
curl -b cjar -k https://${bmc_ip}/xyz/openbmc_project/network/config
Get Network Configurations
curl -b cjar -k https://${bmc_ip}/xyz/openbmc_project/network/config/dhcp

For example
[curl in Linux]
$ curl -b cjar -k https://192.168.88.38/xyz/openbmc_project/network/config
{
  "data": {
    "DefaultGateway": "192.168.88.1",
    "HostName": "computercheese"
  },
  "message": "200 OK",
  "status": "ok"
}
$ curl -b cjar -k https://192.168.88.38/xyz/openbmc_project/network/config/dhcp
{
  "data": {
    "DNSEnabled": 1,
    "HostNameEnabled": 1,
    "NTPEnabled": 1,
    "SendHostNameEnabled": 1
  },
  "message": "200 OK",
  "status": "ok"
}


BMC Ethernet
[curl]
Get eth0 MAC Address
curl -b cjar -k https://${bmc_ip}/xyz/openbmc_project/network/eth0/attr/MACAddress
Get eth0 IPv4 Address
curl -b cjar -k https://${bmc_ip}/xyz/openbmc_project/network/eth0/ipv4/enumerate
Get eth0 DHCP Setting
curl -b cjar -k https://${bmc_ip}/xyz/openbmc_project/network/eth0/attr/DHCPEnabled

For example
[curl in Linux]
$ curl -b cjar -k https://192.168.88.38/xyz/openbmc_project/network/eth0/attr/MACAddress
{
  "data": "82:00:10:00:00:00",
  "message": "200 OK",
  "status": "ok"
}
curl -b cjar -k https://192.168.88.38/xyz/openbmc_project/network/eth0/ipv4/enumerate
{
  "data": {
    "/xyz/openbmc_project/network/eth0/ipv4/591dd597": {
      "Address": "169.254.238.107",
      "Gateway": "0.0.0.0",
      "Origin": "xyz.openbmc_project.Network.IP.AddressOrigin.DHCP",
      "PrefixLength": 16,
      "Type": "xyz.openbmc_project.Network.IP.Protocol.IPv4"
    },
    "/xyz/openbmc_project/network/eth0/ipv4/5a45f7ee": {
      "Address": "192.168.88.38",
      "Gateway": "0.0.0.0",
      "Origin": "xyz.openbmc_project.Network.IP.AddressOrigin.DHCP",
      "PrefixLength": 24,
      "Type": "xyz.openbmc_project.Network.IP.Protocol.IPv4"
    }
  },
  "message": "200 OK",
  "status": "ok"
}
$ curl -b cjar -k https://192.168.88.1/xyz/openbmc_project/network/eth0/attr/DHCPEnabled
{
  "data": 1,
  "message": "200 OK",
  "status": "ok"
}


Set NTP Server
[curl]
curl -c cjar -b cjar -k -H "Content-Type: application/json" -X PUT -d '{"data": ["<NTP_Server>"] }' https://${bmc_ip}/xyz/openbmc_project/network/eth0/attr/NTPServers

For example
[curl in Linux]
curl -c cjar -b cjar -k -H "Content-Type: application/json" -X PUT -d '{"data": ["pool.ntp.org"] }' https://192.168.88.38/xyz/openbmc_project/network/eth0/attr/NTPServers
{
  "data": null,
  "message": "200 OK",
  "status": "ok"
}
$ curl b cjar -k https://192.168.88.38/xyz/openbmc_project/network/eth0
{
  "data": {
    "AutoNeg": 0,
    "DHCPEnabled": 1,
    "DomainName": [],
    "InterfaceName": "eth0",
    "MACAddress": "82:00:10:00:00:00",
    "NTPServers": [
      "pool.ntp.org"
    ],
    "Nameservers": [],
    "Speed": 0
  },
  "message": "200 OK",
  "status": "ok"
}


Set Name Server
[curl]
curl -c cjar -b cjar -k -H "Content-Type: application/json" -X PUT -d '{"data": ["<Name_Server>"] }' https://${bmc_ip}/xyz/openbmc_project/network/eth0/attr/Nameservers

For example
[curl in Linux]
$ curl -c cjar -b cjar -k -H "Content-Type: application/json" -X PUT -d '{"data": ["8.8.8.8"] }' https://192.168.88.38/xyz/openbmc_project/network/eth0/attr/Nameservers
{
  "data": null,
  "message": "200 OK",
  "status": "ok"
}
$ curl -b cjar -k https://192.168.88.38/xyz/openbmc_project/network/eth0
{
  "data": {
    "AutoNeg": 0,
    "DHCPEnabled": 1,
    "DomainName": [],
    "InterfaceName": "eth0",
    "MACAddress": "82:00:10:00:00:00",
    "NTPServers": [
      "pool.ntp.org"
    ],
    "Nameservers": [
      "8.8.8.8"
    ],
    "Speed": 0
  },
  "message": "200 OK",
  "status": "ok"
}


Network Factory Reset
[curl]
curl -c cjar -b cjar -k -H 'Content-Type: application/json' -X POST -d '{"data":[]}' https://${bmc_ip}/xyz/openbmc_project/network/action/Reset

For example
[curl in Linux]
$ curl -c cjar -b cjar -k -H 'Content-Type: application/json' -X POST -d '{"data":[]}' https://192.168.88.38/yz/openbmc_project/network/action/Reset
{
  "data": null,
  "message": "200 OK",
  "status": "ok"
}




Last Updated: 23-02-2018

No comments:

Post a Comment