xcat2 / xcat-inventory

An inventory tool for xcat cluster
8 stars 16 forks source link

Inventory import/export api #192

Closed robin2008 closed 5 years ago

robin2008 commented 5 years ago

Implement the requirements in https://github.ibm.com/xcat2/task_management/issues/139 to import/export the raw inventory json data by types.

bybai commented 5 years ago

@robin2008, Could you add description in “No description provided.” ?

robin2008 commented 5 years ago

Get by type of network

curl -X GET "http://10.4.39.1:5000/api/v2/inventory/?types=network" -H  "accept: application/json"
{
    "network": {
        "bmc": {
            "pool": {
                "dynamicrange": "10.134.95.1-10.134.95.254"
            },
            "basic_attr": {
                "mask": "255.255.224.0",
                "mtu": "1500",
                "mgtifname": "enP49p1s0f0",
                "net": "10.134.64.0",
                "gateway": "10.134.64.1"
            }
        },
        "netmgmt": {
            "pool": {
                "dynamicrange": "10.134.98.1-10.134.99.99"
            },
            "basic_attr": {
                "mask": "255.255.252.0",
                "mtu": "1500",
                "mgtifname": "enP1p9s0f2.822",
                "net": "10.134.96.0",
                "gateway": "10.134.96.1"
            }
        },
        "10_0_0_0-255_0_0_0": {
            "basic_attr": {
                "mask": "255.0.0.0",
                "mtu": "1500",
                "mgtifname": "eno1",
                "net": "10.0.0.0",
                "gateway": "10.0.0.101"
            },
            "service": {
                "tftpserver": "<xcatmaster>"
            }
        },
        "mgmt": {
            "pool": {
                "dynamicrange": "10.134.26.1-10.134.63.254"
            },
            "basic_attr": {
                "mask": "255.255.192.0",
                "mtu": "9000",
                "mgtifname": "bond0",
                "net": "10.134.0.0",
                "gateway": "10.134.0.1"
            }
        },
        "pdu": {
            "pool": {
                "dynamicrange": "10.134.101.150-10.134.101.253"
            },
            "basic_attr": {
                "mask": "255.255.254.0",
                "mtu": "1500",
                "mgtifname": "enP1p9s0f2.823",
                "net": "10.134.100.0",
                "gateway": "10.134.100.1"
            }
        },
        "public": {
            "basic_attr": {
                "mask": "255.255.255.192",
                "mtu": "1500",
                "mgtifname": "en01111",
                "net": "10.219.134.64",
                "gateway": "10.219.134.65"
            }
        }
    },
    "schema_version": "2.0"
}

and remove two of them, and then POST for import with `clean` flag.

curl -X POST "http://10.4.39.1:5000/api/v2/inventory/?types=network&clean=1" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"network\": { \"bmc\": { \"pool\": { \"dynamicrange\": \"10.134.95.1-10.134.95.254\" }, \"basic_attr\": { \"mask\": \"255.255.224.0\", \"mtu\": \"1500\", \"mgtifname\": \"enP49p1s0f0\", \"net\": \"10.134.64.0\", \"gateway\": \"10.134.64.1\" } }, \"netmgmt\": { \"pool\": { \"dynamicrange\": \"10.134.98.1-10.134.99.99\" }, \"basic_attr\": { \"mask\": \"255.255.252.0\", \"mtu\": \"1500\", \"mgtifname\": \"enP1p9s0f2.822\", \"net\": \"10.134.96.0\", \"gateway\": \"10.134.96.1\" } }, \"10_0_0_0-255_0_0_0\": { \"basic_attr\": { \"mask\": \"255.0.0.0\", \"mtu\": \"1500\", \"mgtifname\": \"eno1\", \"net\": \"10.0.0.0\", \"gateway\": \"10.0.0.101\" }, \"service\": { \"tftpserver\": \"\" } }, \"public\": { \"basic_attr\": { \"mask\": \"255.255.255.192\", \"mtu\": \"1500\", \"mgtifname\": \"en01111\", \"net\": \"10.219.134.64\", \"gateway\": \"10.219.134.65\" } } }, \"schema_version\": \"2.0\"}" null

lsdef -t network
10_0_0_0-255_0_0_0  (network)
bmc  (network)
netmgmt  (network)
public  (network)
robin2008 commented 5 years ago

some other UT result, please check the task contents

bybai commented 5 years ago

I am OK to merge it.