xcat2 / xcat-inventory

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

add distros DB API #191

Closed bybai closed 5 years ago

bybai commented 5 years ago

For https://github.ibm.com/xcat2/task_management/issues/143

Description: Add distros DB API delete, get, post

UT:

  1. get distro list defined in store

    curl -X GET "http://10.4.41.7:5000/api/v2/inventory/distros" -H  "accept: application/json"
    [
    {
    "meta": {
      "name": "rhels7.6-x86_64"
    },
    "spec": {
      "majorversion": "7",
      "minorversion": "6",
      "arch": "x86_64",
      "basename": "rhels",
      "dirpaths": "/install/rhels7.6/x86_64",
      "type": "Linux"
    }
    }
    ]
  2. get specified distro:

    curl -X GET "http://10.4.41.7:5000/api/v2/inventory/distros/rhels7.6-x86_64" -H  "accept: application/json"
    {
    "meta": {
    "name": "rhels7.6-x86_64"
    },
    "spec": {
    "majorversion": "7",
    "minorversion": "6",
    "arch": "x86_64",
    "basename": "rhels",
    "dirpaths": "/install/rhels7.6/x86_64",
    "type": "Linux"
    }
    }
  3. delete method:

    ]# lsdef -t osdistro
    rhels7.6  (osdistro)
    rhels7.6-x86_64  (osdistro)
    ]#curl -X DELETE "http://10.4.41.7:5000/api/v2/inventory/distros/rhels7.6" -H  "accept: application/json"
    null
    ]# lsdef -t osdistro
    rhels7.6-x86_64  (osdistro)
  4. after the input format is changed, the new POST method using valid data to UT:

    1. valid 2 ISO locations as input data
      /mnt/iso/suse/15/x86_64/SLE-15-Installer-DVD-x86_64-GM-DVD1.iso,/mnt/iso/suse/15/x86_64/SLE-15-Packages-x86_64-GM-DVD1.iso
      1. Curl URL:
        curl -X POST "http://10.4.41.7:5000/api/v2/inventory/distros?Image%20paths=%2Fmnt%2Fiso%2Fsuse%2F15%2Fx86_64%2FSLE-15-Installer-DVD-x86_64-GM-DVD1.iso%2C%2Fmnt%2Fiso%2Fsuse%2F15%2Fx86_64%2FSLE-15-Packages-x86_64-GM-DVD1.iso" -H  "accept: application/json"
      2. Request URL
        http://10.4.41.7:5000/api/v2/inventory/distros?Image%20paths=%2Fmnt%2Fiso%2Fsuse%2F15%2Fx86_64%2FSLE-15-Installer-DVD-x86_64-GM-DVD1.iso%2C%2Fmnt%2Fiso%2Fsuse%2F15%2Fx86_64%2FSLE-15-Packages-x86_64-GM-DVD1.iso
      3. Response code: 201
  5. empty input data for POST method:

    1. Curl:
      curl -X POST "http://10.4.41.7:5000/api/v2/inventory/distros" -H  "accept: application/json"
      1. Response
        {
        "message": "Image not found"
        }
      2. Response code:400
  6. invalid input data for POST method:

    1. Curl:
       curl -X POST "http://10.4.41.7:5000/api/v2/inventory/distros?Image%20paths=ldkjflskkl" -H  "accept: application/json"
    2. Response: 400
       {
            "message": "The management server was unable to find/read /tmp/ldkjflskkl. Ensure that file exists on the server at the specified location."
       }