1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333
|
===========================================
OAR Documentation - REST API - User's doc
===========================================
:Dedication: For users whishing to make programs interfaced with OAR
.. include:: doc_abstract.rst
**BE CAREFULL : THIS DOCUMENTATION IS FOR OAR >= 2.5.0**
PDF version : `<OAR-DOCUMENTATION-API-USER.pdf>`_
.. section-numbering::
.. contents:: Table of Contents
-------------------------------------------------------------------------------
Introduction
============
The OAR REST API allows to interact with OAR over http using a REST library. Most of the operations usually done with the oar Unix commands may be done using this API from your favourite language.
Concepts
========
Access
------
A simple GET query to the API using wget may look like this::
# Get the list of resources
wget -O - http://www.mydomain.org/oarapi/resources.yaml?structure=simple
You can also access to the API using a browser. Make it point to http://www.myoarcluster.local/oarapi/index.html and you'll see a very simple HTML interface allowing you to browse the cluster resources, post a job using a form or even create resources if you are a OAR administrator. (of course, replace www.myoarcluster.local by a valid name allowing you to join the http service of the host where the API is installed).
But generally, you'll use a REST client or a REST library provided for your favorite language. You'll see examples using a ruby rest library in the next parts of this document.
Check your system administrator to know on which URI the OAR API is installed.
Authentication
--------------
Most of the time, you'll make requests that needs you to be authenticated. The way you are authenticated depends on what your local admistrator configured. There's almost as many possibilities as what Apache (the http server used by this API) may manage.
The simplest method is a "Basic authentication" with a login/password. It may be binded to a local directory (for example LDAP). You may also find an "ident" based authentication that guesses automatically your login from a little daemon running on your client host.
If the "ident" method is used, your unix login is automatically used. But as only a few hosts may be trusted, you'll probably have to open a tunnel to one of this host. You may use ssh to do this. For example, supposing access.mycluster.fr is a gateway host trusted by the api host::
$ ssh -NL 8080:api.mycluster.fr:80 login@access.mycluster.fr
Then, point your REST client to::
# http://localhost:8080
Formats and data structure types
--------------------------------
The API currently can serve data into *YAML*, *JSON* or *HTML*. Posted data can also be coded into *YAML*, *JSON* or *x-www-form-urlencoded* (for HTML from posts). You may specify the requested format by 2 ways:
* giving an extension to resources: **.yaml**, **.json** or **.html**
* setting the **HTTP_ACCEPT** header variable to **text/yaml**, **application/json** or **text/html**
For the posted data, you have to correctly set the **HTTP_CONTENT_TYPE** variable to **text/yaml**, **application/json** or **application/x-www-form-urlencoded**.
Sometimes, the data structures returned (not the coding format, but the contents: array, hashes, array of hashes,...) may be changed. Currently, we have 2 available data structure types: *simple* and *oar*. The structure is passed through the variable *structure* that you may pass in the url, for example: ?structure=simple
* The **simple** data structure tries to be as simple as possible, using simple arrays in place of hashes wherever it is possible
* The **oar** data structure serves data in the way oar does with the oarnodes/oarstat export options (-Y, -D, -J,...) Be aware that this data structure is not meant to be maintained since 2.5 release of OAR. The simple data structure is highly recommended.
By default, we use the *simple* data structure.
Here are some examples, using the ruby restclient (see next section)::
# Getting resources infos
# in JSON
irb(main):004:0> puts get('/resources.json')
# in YAML
irb(main):005:0> puts get('/resources.yaml')
# Same thing
irb(main):050:0> puts get('/resources', :accept=>"text/yaml")
# Specifying the "oar" data structure
irb(main):050:0> puts get('/resources.json?structure=oar')
# Specifying the "simple" data structure
irb(main):050:0> puts get('/resources.json?structure=simple')
Errors and debug
----------------
When the API returns an error, it generally uses a standard HTTP return status (404 NOT FOUND, 406 NOT ACCEPTABLE, ...). But it also returns a body containing a hash like the following::
{
"title" : "ERROR 406 - Invalid content type required */*",
"message" : "Valid types are text/yaml, application/json or text/html",
"code" : "200"
}
This error body is formated in the requested format. But if this format was not given, it uses JSON by default.
To allow you to see the error body, you may find it useful to activate the **debug=1** variable. It will force the API to always return a 200 OK status, even if there's an error so that you can see the body with a simple browser or a rest client without having to manage the errors. For example::
wget -nv -O - "http://localhost:8080/oargridapi/sites/grenoble?debug=1"
Here is an example of error catching in ruby::
# Function to get objects from the api
# We use the JSON format
def get(api,uri)
begin
return JSON.parse(api[uri].get(:accept => 'application/json'))
rescue => e
if e.respond_to?('http_code')
puts "ERROR #{e.http_code}:\n #{e.response.body}"
else
puts "Parse error:"
puts e.inspect
end
exit 1
end
end
Ruby REST client
================
One of the easiest way for testing this API is to use the rest-client ruby module:
http://rest-client.heroku.com/rdoc/
It may be used from ruby scripts (http://www.ruby.org/) or interactively.
It is available as a rubygem, so to install it, simply install rubygems and do "gem install rest-client". Then, you can run the interactive client which is nothing else than irb with shortcuts. Here is an example irb session::
$ export PATH=$PATH:/var/lib/gems/1.8/bin
$ restclient http://localhost/oarapi
irb(main):001:0> puts get('/jobs.yaml')
---
- api_timestamp: 1246457384
id: 551
name: ~
owner: bzizou
queue: besteffort
state: Waiting
submission: 1245858042
uri: /jobs/551
=> nil
irb(main):002:0>
or, if an http basic auth is required::
restclient http://localhost/api <login> <password>
...
Pagination and common rules into output data
============================================
Results served by the API are mainly of 2 kinds: "items" and "collections". A collection is actually an array of items. Some uris serve collections that may have a very big amount of items (for example all the terminated jobs of a cluster). For that reason, collections are often "paginated". It means that the collections are presented into pages that have got meta data to give you informations about offset, numbers, and links to previous/next page.
Furthermore, items are often composed of commonly used kind of data, especially 'id' and 'links'. We have tried to normalize this as much as possible, so, here is a description of the common properties of items and collections:
Items
-----
Items have the following features:
:Hash:
Items should be hashes (sometimes hash of hashes for the 'oar' data structure, but it is to be avoided)
:the 'id' key:
In general, when an item may be uniquely identified by an integer, it is given in the "id" key. Note that OAR nodes are identified by the 'network_address' key that is an integer, but this is an exception.
:the 'links' array:
Items, especially when listed in a collection, often give links to more informations or relative data. The links are listed in the links array. Each element of this array (a link) is composed of at least: a 'rel' key and a 'href' key. The 'rel' key is a string telling what is the relation between the current item and the resource pointed by the link. The 'href' key is a string giving the URI of the link relative to the root of the API. It's possible that other keys will be implemented in the future (for example a 'title' key.) Common values for 'rel' are: 'self', 'parent', 'next', 'previous'.
:the 'api_timestamp' value:
Each item has a 'api_timestamp' key giving the epoch unix date at which the API constructed the item. This field may be omitted when items are listed inside a collection; then the collection has a global api_timestamp value. This date is given in the timezone provided by the "GET /timezone uri".
Collections
-----------
Collections have the following features:
:the 'items' array:
The items array is the purpose of a collection. It lists all the items of the current page of a collection.
:the 'total' number:
It's an integer giving the total number of items in the collection. If the items array contains less elements than this number, then the collection has been paginated and a 'next' and/or 'previous' link should be provided.
:the 'offset' number:
It gives the offset at which the paginated list starts. If 0, then, it is the first page.
:the 'limit' parameter:
This is not in the output, but a parameter common to all paginable uris. If you specify a limit, then it gives the size of the pages.
:the 'links' array:
For a collection, the links array often gives the uri of the next/previous page. But it also gives the uri of the current page ('self') and may point to more informations relative to this collection. See the links array description from above for items, it is similar for the collection.
Examples
--------
*An item looks like this (yaml output):*
::
api_timestamp: 1286894740
available_upto: 2147483646
besteffort: YES
core: 1
cpu: 1
cpuset: 0
deploy: NO
desktop_computing: NO
expiry_date: 0
finaud_decision: NO
id: 1
last_available_upto: 0
last_job_date: 1286885902
links:
- href: /resources/nodes/fake1
rel: node
- href: /resources/1
rel: self
- href: /resources/1/jobs
rel: jobs
network_address: fake1
next_finaud_decision: NO
next_state: UnChanged
resource_id: 1
scheduler_priority: 0
state: Alive
state_num: 1
suspended_jobs: NO
type: default
*A collection looks like this (yaml output):*
::
api_timestamp: 1286894823
items:
- api_timestamp: 1286894823
id: 2
links:
- href: /jobs/2
rel: self
- href: /jobs/2/resources
rel: resources
name: ~
owner: kameleon
queue: default
state: Error
submission: 1284034267
- api_timestamp: 1286894823
id: 3
links:
- href: /jobs/3
rel: self
- href: /jobs/3/resources
rel: resources
name: ~
owner: kameleon
queue: default
state: Error
submission: 1284034383
links:
- href: /jobs.yaml?state=Error&limit=2&offset=0
rel: self
- href: /jobs.yaml?state=Error&limit=2&offset=2
rel: next
offset: 0
total: 2623
REST requests description
=========================
Examples are given in the YAML format because we think that it is the more human readable and so very suitable for this kind of documentation. But you can also use the JSON format for your input/output data. Each resource uri may be postfixed by .yaml, .jso of .html.
In this section, we describe every REST resources of the OAR API. The authentication may be:
- public: everybody can query this resource
- user: only authenticated and valid users can query this resource
- oar: only the oar user can query this resource (administration usage)
GET /index
----------
:description:
Home page for the HTML browsing
:formats:
html
:authentication:
public
:output:
*example*:
::
<HTML>
<HEAD>
<TITLE>OAR REST API</TITLE>
</HEAD>
<BODY>
<HR>
<A HREF=./resources.html>RESOURCES</A>
<A HREF=./jobs.html>JOBS</A>
<A HREF=./jobs/form.html>SUBMISSION</A>
<HR>
Welcome on the oar API
:note:
Header of the HTML resources may be customized into the **/etc/oar/api_html_header.pl** file.
GET /version
------------
:description:
Gives version informations about OAR and OAR API. Also gives the timezone of the API server.
:formats:
html , yaml , json
:authentication:
public
:output:
*structure*:
hash
*yaml example*:
::
---
api: 0.1.2
api_timestamp: 1245582255
api_timezone: CEST
apilib: 0.1.6
oar: 2.4.0
:usage example:
::
wget -q -O - http://localhost/oarapi/version.yaml
GET /whoami
-----------
:description:
Gives the name of authenticated user seen by OAR API. The name for a not authenticated user is the null string.
:formats:
html , yaml , json
:authentication:
public
:output:
*structure*:
hash
*yaml example*:
::
---
api_timestamp: 1245582255
authenticated_user: kameleon
:usage example:
::
wget -q -O - http://localhost/oarapi/whoami.yaml
GET /timezone
-------------
:description:
Gives the timezone of the OAR API server. The api_timestamp given in each query is an UTC timestamp (epoch unix time). This timezone information allows you to re-construct the local time.
:formats:
html , yaml , json
:authentication:
public
:output:
*structure*: hash
*yaml example*:
::
---
api_timestamp: 1245768107
timezone: CEST
:usage example:
::
wget -q -O - http://localhost/oarapi/timezone.yaml
GET /jobs
---------
:description:
List jobs (by default only the jobs in queue)
:formats:
html , yaml , json
:authentication:
public
:parameters:
- **state**: comma separated list of states for filtering the jobs. Possible values: Terminated, Running, Error, Waiting, Launching, Hold,...
- **array** (integer): to get the jobs belonging to an array
- **from** (timestamp): restrict the list to the jobs that are running or not yet started before this date. Using this parameters disables the default behavior of listing only the jobs that are in queue.
- **to** (timestamp): restrict the list to the jobs that are running or not yet finished at this date. Using this parameters disables the default behavior of listing only the jobs that are in queue.
- **user**: restrict the list to the jobs owned by this username
- **ids**: colon separated list of ids to get a set of jobs
:output:
*structure*: collection
*yaml example*:
::
api_timestamp: 1286895857
items:
- api_timestamp: 1286895857
id: 58
links:
- href: /jobs/58
rel: self
- href: /jobs/58/resources
rel: collection
title: resources
- href: /oarapi/jobs/58/nodes
rel: collection
title: nodes
name: ~
owner: kameleon
queue: default
state: Terminated
submission: 1284109267
- api_timestamp: 1286895857
id: 59
links:
- href: /jobs/59
rel: self
- href: /jobs/59/resources
rel: collection
title: resources
- href: /oarapi/jobs/59/nodes
rel: collection
title: nodes
name: ~
owner: kameleon
queue: default
state: Terminated
submission: 1284109846
links:
- href: /jobs.yaml?state=Terminated&limit=2&offset=48
rel: self
- href: /jobs.yaml?state=Terminated&limit=2&offset=50
rel: next
- href: /jobs.yaml?state=Terminated&limit=2&offset=46
rel: previous
offset: 48
total: 206
:note:
The "rel: resources" link of a job lists the assigned or reserved resources of a job.
:usage example:
::
wget -q -O - http://localhost/oarapi/jobs.yaml?state=Terminated,Running&limit=2&offset=48"
GET /jobs/details
-----------------
:description:
Same as /jobs, but with more details and "resources" and "nodes" links developped.
:formats:
html , yaml , json
:authentication:
public
:parameters:
- **state**: comma separated list of states for filtering the jobs. Possible values: Terminated, Running, Error, Waiting, Launching, Hold,...
:output:
*structure*: collection
*yaml example*:
::
api_timestamp: 1352707511
items:
- api_timestamp: 1352707511
array_id: 5540
array_index: ~
command: sleep 300
cpuset_name: kameleon_5540
dependencies: []
events: []
exit_code: ~
id: 5540
initial_request: oarsub sleep 300
launching_directory: /home/kameleon
links:
- href: /oarapi/jobs/5540
rel: self
- href: /oarapi/jobs/5540/resources
rel: collection
title: resources
- href: /oarapi/jobs/5540/nodes
rel: collection
title: nodes
message: Karma = 0.000
name: ~
nodes:
- api_timestamp: 1352707511
links:
- href: /oarapi/resources/nodes/node1
rel: self
network_address: node1
status: assigned
owner: kameleon
project: default
properties: desktop_computing = 'NO'
queue: default
reservation: None
resources:
- api_timestamp: 1352707511
id: 1
links:
- href: /oarapi/resources/1
rel: self
- href: /oarapi/resources/1/jobs
rel: collection
title: jobs
status: assigned
resubmit_job_id: ~
scheduled_start: 1352707488
start_time: 1352707488
state: Running
stderr_file: OAR.5540.stdout
stdout_file: OAR.5540.stderr
stop_time: 0
submission_time: 1352707487
type: PASSIVE
types: []
walltime: 7200
wanted_resources: "-l \"{type = 'default'}/resource_id=1,walltime=2:0:0\" "
- api_timestamp: 1352707511
array_id: 5542
array_index: ~
command: sleep 300
cpuset_name: kameleon_5542
dependencies: []
events: []
exit_code: ~
id: 5542
initial_request: oarsub -l /core=2 sleep 300
launching_directory: /home/kameleon
links:
- href: /oarapi/jobs/5542
rel: self
- href: /oarapi/jobs/5542/resources
rel: collection
title: resources
- href: /oarapi/jobs/5542/nodes
rel: collection
title: nodes
message: Karma = 0.000
name: ~
nodes:
- api_timestamp: 1352707511
links:
- href: /oarapi/resources/nodes/node1
rel: self
network_address: node1
status: assigned
owner: kameleon
project: default
properties: desktop_computing = 'NO'
queue: default
reservation: None
resources:
- api_timestamp: 1352707511
id: 3
links:
- href: /oarapi/resources/3
rel: self
- href: /oarapi/resources/3/jobs
rel: collection
title: jobs
status: assigned
- api_timestamp: 1352707511
id: 4
links:
- href: /oarapi/resources/4
rel: self
- href: /oarapi/resources/4/jobs
rel: collection
title: jobs
status: assigned
resubmit_job_id: ~
scheduled_start: 1352707510
start_time: 1352707510
state: Running
stderr_file: OAR.5542.stdout
stdout_file: OAR.5542.stderr
stop_time: 0
submission_time: 1352707509
type: PASSIVE
types: []
walltime: 7200
wanted_resources: "-l \"{type = 'default'}/core=2,walltime=2:0:0\" "
links:
- href: /oarapi/jobs/details.yaml?offset=0
rel: self
offset: 0
total: 2
usage example:
::
wget -q -O - http://localhost/oarapi/jobs/details.yaml
GET /jobs/table
---------------
:description:
Same as /jobs but outputs the data of the SQL job table
:formats:
html , yaml , json
:authentication:
public
:parameters:
- **state**: comma separated list of states for filtering the jobs. Possible values: Terminated, Running, Error, Waiting, Launching, Hold,...
:output:
*structure*: collection
*yaml example*:
::
---
items:
- accounted: NO
api_timestamp: 1253017554
array_id: 566
assigned_moldable_job: 566
checkpoint: 0
checkpoint_signal: 12
command: ''
exit_code: ~
file_id: ~
info_type: bart:33033
initial_request: oarsub -I
job_env: ~
job_group: ''
job_id: 566
job_name: ~
job_type: INTERACTIVE
job_user: bzizou
launching_directory: /home/bzizou/git/oar/git
message: FIFO scheduling OK
notify: ~
project: default
properties: desktop_computing = 'NO'
queue_name: default
reservation: None
resubmit_job_id: 0
scheduler_info: FIFO scheduling OK
start_time: 1253017553
state: Launching
stderr_file: OAR.%jobid%.stderr
stdout_file: OAR.%jobid%.stdout
stop_time: 0
submission_time: 1253017551
suspended: NO
uri: /jobs/566
- accounted: NO
api_timestamp: 1253017554
array_id: 560
assigned_moldable_job: 0
checkpoint: 0
checkpoint_signal: 12
command: /usr/bin/id
exit_code: ~
file_id: ~
info_type: 'bart:'
initial_request: oarsub --resource=/nodes=2/cpu=1 --use_job_key=1 /usr/bin/id
job_env: ~
job_group: ''
job_id: 560
job_name: ~
job_type: PASSIVE
job_user: bzizou
launching_directory: /home/bzizou
message: Cannot find enough resources which fit for the job 560
notify: ~
project: default
properties: desktop_computing = 'NO'
queue_name: default
reservation: None
resubmit_job_id: 0
scheduler_info: Cannot find enough resources which fit for the job 560
start_time: 0
state: Waiting
stderr_file: OAR.%jobid%.stderr
stdout_file: OAR.%jobid%.stdout
stop_time: 0
submission_time: 1246948570
suspended: NO
uri: /jobs/560
links:
- href: '/jobs/table.html?state=Terminated&limit=15&offset=0'
rel: previous
- href: '/jobs/table.html?state=Terminated&limit=15&offset=15'
rel: self
- href: '/jobs/table.html?state=Terminated&limit=15&offset=30'
rel: next
offset: 15
total: 41
*note*: Field names may vary from the other job lists because this query results more like a dump of the jobs table.
:usage example:
::
wget -q -O - http://localhost/oarapi/jobs/table.yaml
GET /jobs/<id>[/details]
------------------------
:description:
Get infos about the given job. If /details is appended, it gives more informations, such as the expanded list of resources allocated to the job.
:parameters:
- **id**: the id of a job
:formats:
html , yaml , json
:authentication:
user
:output:
*structure*: hash
*yaml example*:
::
api_timestamp: 1352707658
array_id: 5230
array_index: 3
command: /home/kameleon/cigri-3/tmp/test1.sh param48 48
cpuset_name: kameleon_5232
dependencies: []
events:
- date: 1351087783
description: Scheduler priority for job 5232 updated (network_address/resource_id)
event_id: 14454
job_id: 5232
to_check: NO
type: SCHEDULER_PRIORITY_UPDATED_STOP
- date: 1351087782
description: '[bipbip 5232] Ask to change the job state'
event_id: 14451
job_id: 5232
to_check: NO
type: SWITCH_INTO_TERMINATE_STATE
- date: 1351087660
description: Scheduler priority for job 5232 updated (network_address/resource_id)
event_id: 14446
job_id: 5232
to_check: NO
type: SCHEDULER_PRIORITY_UPDATED_START
exit_code: 0
id: 5232
initial_request: oarsub --resource=core=1 --type=besteffort /home/kameleon/cigri-3/tmp/test1.sh --array-param-file=/tmp/oarapi.paramfile.7QPM0
launching_directory: /home/kameleon
links:
- href: /oarapi/jobs/5232
rel: self
- href: /oarapi/jobs/5232/resources
rel: collection
title: resources
- href: /oarapi/jobs/5232/nodes
rel: collection
title: nodes
message: Karma = 0.000
name: ~
owner: kameleon
project: default
properties: (besteffort = 'YES') AND desktop_computing = 'NO'
queue: besteffort
reservation: None
resubmit_job_id: 0
scheduled_start: ~
start_time: 1351087660
state: Terminated
stderr_file: OAR.5232.stderr
stdout_file: OAR.5232.stdout
stop_time: 1351087782
submission_time: 1351087659
type: PASSIVE
types:
- besteffort
walltime: 7200
wanted_resources: "-l \"{type = 'default'}/core=1,walltime=2:0:0\" "
:usage example:
::
wget --user test --password test -q -O - http://localhost/oarapi/jobs/547.yaml
GET /jobs/<id>/resources
------------------------
:description:
Get resources reserved or assigned to a job
:parameters:
- **id**: the id of a job
:formats:
html , yaml , json
:authentication:
public
:output:
*structure*: hash
*yaml example*:
::
api_timestamp: 1352707730
items:
- api_timestamp: 1352707730
id: 7
links:
- href: /oarapi/resources/7
rel: self
- href: /oarapi/resources/7/jobs
rel: collection
title: jobs
status: assigned
links:
- href: /oarapi/jobs/5232/resources.yaml
rel: self
offset: 0
total: 1
:usage example:
::
wget -q -O - http://localhost/oarapi/jobs/547/resources.yaml
POST /jobs/<id>/deletions/new
-----------------------------
:description:
Deletes a job
:parameters:
- **id**: the id of a job
:formats:
html , yaml , json
:authentication:
user
:output:
*structure*: hash
*yaml example*:
::
---
api_timestamp: 1253025331
cmd_output: |
Deleting the job = 567 ...REGISTERED.
The job(s) [ 567 ] will be deleted in a near future.
id: 567
status: Delete request registered
:usage example:
::
irb(main):148:0> puts post('/jobs/567/deletions/new.yaml','')
POST /jobs/<id>/checkpoints/new
-------------------------------
:description:
Send the checkpoint signal to a job
:parameters:
- **id**: the id of a job
:formats:
html , yaml , json
:authentication:
user
:output:
*structure*: hash
*yaml example*:
::
---
api_timestamp: 1253025555
cmd_output: |
Checkpointing the job 568 ...DONE.
The job 568 was notified to checkpoint itself.
id: 568
status: Checkpoint request registered
:usage example:
::
irb(main):148:0> puts post('/jobs/568/checkpoints/new.yaml','')
POST /jobs/<id>/holds/new
-------------------------
:description:
Asks to hold a waiting job
:parameters:
- **id**: the id of a job
:formats:
html , yaml , json
:authentication:
user
:output:
*structure*: hash
*yaml example*:
::
---
api_timestamp: 1253025718
cmd_output: "[560] Hold request was sent to the OAR server.\n"
id: 560
status: Hold request registered
:usage example:
::
irb(main):148:0> puts post('/jobs/560/holds/new.yaml','')
POST /jobs/<id>/rholds/new
--------------------------
:description:
Asks to hold a running job
:parameters:
- **id**: the id of a job
:formats:
html , yaml , json
:authentication:
oar
:output:
*structure*: hash
*yaml example*:
::
---
api_timestamp: 1253025868
cmd_output: "[569] Hold request was sent to the OAR server.\n"
id: 569
status: Hold request registered
:usage example:
::
irb(main):148:0> puts post('/jobs/560/rholds/new.yaml','')
POST /jobs/<id>/resumptions/new
-------------------------------
:description:
Asks to resume a holded job
:parameters:
- **id**: the id of a job
:formats:
html , yaml , json
:authentication:
user
:output:
*structure*: hash
*yaml example*:
::
---
api_timestamp: 1253026081
cmd_output: "[569] Resume request was sent to the OAR server.\n"
id: 569
status: Resume request registered
:usage example:
::
irb(main):148:0> puts post('/jobs/560/resumptions/new.yaml','')
POST /jobs/<id>/signals/<signal>
--------------------------------
:description:
Asks to resume a holded job
:parameters:
- **id**: the id of a job
- **signal**: the number of a signal (see kill -l)
:formats:
html , yaml , json
:authentication:
user
:output:
*structure*: hash
*yaml example*:
::
---
api_timestamp: 1253102493
cmd_output: |
Signaling the job 574 with 12 signal.
DONE.
The job 574 was notified to signal itself with 12.
id: 574
status: Signal sending request registered
:usage example:
::
irb(main):148:0> puts post('/jobs/560/signals/12.yaml','')
POST /jobs
----------
:description:
Creates (submit) a new job
:formats:
html , yaml , json
:authentication:
user
:input:
Only [resource] and [command] are mandatory. Please, refer to the documentation of the *oarsub* command for the resource syntax which correspond to the -l (--resource) option.
*structure*: hash with possible arrays (for options that may be passed multiple times)
*fields*:
- **resource** (*string*): the resources description as required by oar (example: "/nodes=1/cpu=2")
- **command** (*string*): a command name or a script that is executed when the job starts
- **workdir** (*string*): the path of the directory from where the job will be submited
- **param_file** (*string*): the content of a parameters file, for the submission of an array job. For example: {"resource":"/nodes=1, "command":"sleep", "param_file":"60\n90\n30"}
- **All other option accepted by the oarsub unix command**: every long option that may be passed to the oarsub command is known as a key of the input hash. If the option is a toggle (no value), you just have to set it to "1" (for example: 'use-job-key' => '1'). Some options may be arrays (for example if you want to specify several 'types' for a job)
*yaml example*:
::
---
stdout: /tmp/outfile
command: /usr/bin/id;echo "OK"
resource: /nodes=2/cpu=1
workdir: ~bzizou/tmp
type:
- besteffort
- timesharing
use-job-key: 1
:output:
*structure*: hash
*yaml example*:
::
---
api_timestamp: 1332323792
cmd_output: |
[ADMISSION RULE] Modify resource description with type constraints
OAR_JOB_ID=4
id: 4
links:
- href: /oarapi-priv/jobs/4
rel: self
*note*: more informations about the submited job may be obtained with a GET on the provided *uri*.
:usage example:
::
# Submitting a job using ruby rest client
irb(main):010:0> require 'json'
irb(main):012:0> j={ 'resource' => '/nodes=2/cpu=1', 'command' => '/usr/bin/id' }
irb(main):015:0> job=post('/jobs' , j.to_json , :content_type => 'application/json')
# Submitting a job with a provided inline script
irb(main):024:0> script="#!/bin/bash
irb(main):025:0" echo \"Hello world\"
irb(main):026:0" whoami
irb(main):027:0" sleep 300
irb(main):028:0" "
irb(main):029:0> j={ 'resource' => '/nodes=2/cpu=1', 'script' => script , 'workdir' => '~bzizou/tmp'}
irb(main):030:0> job=post('/jobs' , j.to_json , :content_type => 'application/json')
POST /jobs/<id>
---------------
:description:
Updates a job.
In fact, as some clients (www browsers) doesn't support the DELETE method, this POST resource has been created mainly to workaround this and provide another way to delete a job. It also provides *checkpoint*, *hold* and *resume* methods, but one should preferably use the /checkpoints, /holds and /resumptions resources.
:formats:
html , yaml , json
:authentication:
user
:input:
*structure*: hash {"action" => "delete"}
*yaml example*:
::
---
method: delete
:output:
*structure*: hash
*yaml example*:
::
---
api_timestamp: 1245944206
cmd_output: |
Deleting the job = 554 ...REGISTERED.
The job(s) [ 554 ] will be deleted in a near future.
id: 554
status: Delete request registered
:usage example:
::
# Deleting a job in the ruby rest client
puts post('/jobs/554.yaml','{"method":"delete"}',:content_type => "application/json")
DELETE /jobs/<id>
-----------------
:description:
Delete or kill a job.
:formats:
html , yaml , json
:authentication:
user
:output:
*structure*: hash returning the status
*yaml example*:
::
---
api_timestamp: 1245944206
cmd_output: |
Deleting the job = 554 ...REGISTERED.
The job(s) [ 554 ] will be deleted in a near future.
id: 554
status: Delete request registered
:usage example:
::
# Deleting a job in the ruby rest client
puts delete('/jobs/554.yaml')
:note:
Not all clients support the DELETE method, especially some www browsers. So, you can do the same thing with a POST of a {"method":"delete"} hash on the /jobs/<id> resource.
GET /jobs/form
--------------
:description:
HTML form for posting (submiting) new jobs from a browser
:formats:
html
:authentication:
user
:output:
*example*:
::
<HTML>
<HEAD>
<TITLE>OAR REST API</TITLE>
</HEAD>
<BODY>
<HR>
<A HREF=../resources.html>RESOURCES</A>
<A HREF=../jobs.html>JOBS</A>
<A HREF=../jobs/form.html>SUBMISSION</A>
<HR>
<FORM METHOD=post ACTION=../jobs.html>
<TABLE>
<CAPTION>Job submission</CAPTION>
<TR>
<TD>Resources</TD>
<TD><INPUT TYPE=text SIZE=40 NAME=resource VALUE="/nodes=1/cpu=1,walltime=00:30:00"></TD>
</TR><TR>
<TD>Name</TD>
<TD><INPUT TYPE=text SIZE=40 NAME=name VALUE="Test_job"></TD>
</TR><TR>
<TD>Properties</TD>
<TD><INPUT TYPE=text SIZE=40 NAME=property VALUE=""></TD>
</TR><TR>
<TD>Program to run</TD>
<TD><INPUT TYPE=text SIZE=40 NAME=command VALUE='"/bin/sleep 300"'></TD>
</TR><TR>
<TD>Types</TD>
<TD><INPUT TYPE=text SIZE=40 NAME=type></TD>
</TR><TR>
<TD>Reservation dates</TD>
<TD><INPUT TYPE=text SIZE=40 NAME=reservation></TD>
</TR><TR>
<TD>Directory</TD>
<TD><INPUT TYPE=text SIZE=40 NAME=directory></TD>
</TR><TR>
<TD></TD><TD><INPUT TYPE=submit VALUE=SUBMIT></TD>
</TR>
</TABLE>
</FORM>
:note:
This form may be customized in the **/etc/oar/api_html_postform.pl** file
GET /resources
--------------
:description:
Get the list of resources and their state
:formats:
html , yaml , json
:authentication:
public
:output:
*structure*: hash
*fields*:
- **items** : list of resources
- **links** : links to previous, current and next resources
- **offset** : current offset
- **total** : resources total
*yaml example*:
::
---
items:
- api_timestamp: 1253201950
jobs_uri: /resources/4/jobs
network_address: liza-1
node_uri: /resources/nodes/liza-1
resource_id: 4
state: Alive
uri: /resources/4
- api_timestamp: 1253201950
jobs_uri: /resources/5/jobs
network_address: liza-1
node_uri: /resources/nodes/liza-1
resource_id: 5
state: Alive
uri: /resources/5
- api_timestamp: 1253201950
jobs_uri: /resources/6/jobs
network_address: liza-2
node_uri: /resources/nodes/liza-2
resource_id: 6
state: Alive
uri: /resources/6
- api_timestamp: 1253201950
jobs_uri: /resources/7/jobs
network_address: liza-2
node_uri: /resources/nodes/liza-2
resource_id: 7
state: Alive
uri: /resources/7
links:
- href: '/resources.yaml?limit=5&offset=2'
rel: previous
- href: '/resources.yaml?limit=5&offset=7'
rel: self
- href: '/resources.yaml?limit=5&offset=12'
rel: next
offset: 2
total: 49
*note*: More details about a resource can be obtained with a GET on the provided *uri*. The list of all the resources of the same node may be obtained with a GET on *node_uri*. The list of running jobs on a resource can be obtained with a GET on the jobs_uri resource.
*note*: The following parameters can be passed through the requested URL
- limit : limit of resources to be shown per page
- offset : the page result offset
:usage example:
::
wget -q -O - http://localhost/oarapi/resources.yaml
GET /resources/details
----------------------
:description:
Get the list of resources and all the details about them
:formats:
html , yaml , json
:authentication:
public
:output:
*structure*: hash
*fields*:
- **items** : list of resources
- **links** : links to previous, current and next resources
- **offset** : current offset
- **total** : total of resources
*yaml example*:
::
---
items:
- api_timestamp: 1281967035
available_upto: 0
besteffort: YES
core: ~
cpu: 0
cpufreq: ~
cpuset: 0
cputype: ~
deploy: NO
desktop_computing: NO
expiry_date: 0
finaud_decision: NO
jobs_uri: '/resources/1/jobs.html'
last_available_upto: 0
last_job_date: 1278588052
memnode: ~
network_address: node1
next_finaud_decision: NO
next_state: UnChanged
node_uri: '/resources/nodes/node1.html'
resource_id: 1
scheduler_priority: 0
state: Suspected
state_num: 3
suspended_jobs: NO
type: default
uri: '/resources/1.html'
- api_timestamp: 1281967035
available_upto: 0
besteffort: YES
core: ~
cpu: 0
cpufreq: ~
cpuset: 0
cputype: ~
deploy: NO
desktop_computing: NO
expiry_date: 0
finaud_decision: NO
jobs_uri: '/resources/2/jobs.html'
last_available_upto: 0
last_job_date: 1278588052
memnode: ~
network_address: node1
next_finaud_decision: NO
next_state: UnChanged
node_uri: '/resources/nodes/node1.html'
resource_id: 2
scheduler_priority: 0
state: Suspected
state_num: 3
suspended_jobs: NO
type: default
uri: '/resources/2.html'
- api_timestamp: 1281967035
available_upto: 0
besteffort: YES
core: ~
cpu: 1
cpufreq: ~
cpuset: 0
cputype: ~
deploy: NO
desktop_computing: NO
expiry_date: 0
finaud_decision: NO
jobs_uri: '/resources/3/jobs.html'
last_available_upto: 0
last_job_date: 1278588052
memnode: ~
network_address: node1
next_finaud_decision: NO
next_state: UnChanged
node_uri: '/resources/nodes/node1.html'
resource_id: 3
scheduler_priority: 0
state: Suspected
state_num: 3
suspended_jobs: NO
type: default
uri: '/resources/3.html'
links:
- href: '/resources/details.yaml?limit=5&offset=2'
rel: previous
- href: '/resources/details.yaml?limit=5&offset=7'
rel: self
- href: '/resources/details.yaml?limit=5&offset=12'
rel: next
offset: 2
total: 49
:usage example:
::
wget -q -O - http://localhost/oarapi/resources/details.yaml
*note*: The following parameters can be passed through the requested URL
- limit : limit of resources to be shown per page
- offset : the page result offset
GET /resources/<id>
-------------------
:description:
Get details about the resource identified by *id*
:formats:
html , yaml , json
:authentication:
public
:output:
*structure*: 1 element array of hash
*yaml example*:
::
---
api_timestamp: 1253202322
available_upto: 0
besteffort: YES
cluster: 0
cpu: 20
cpuset: 0
deploy: NO
desktop_computing: NO
expiry_date: 0
finaud_decision: NO
jobs_uri: /resources/1/jobs
last_available_upto: 0
last_job_date: 1253201845
licence: ~
network_address: bart-1
next_finaud_decision: NO
next_state: UnChanged
node_uri: /resources/nodes/bart-1
resource_id: 1
scheduler_priority: 0
state: Alive
state_num: 1
suspended_jobs: NO
test: ~
type: default
uri: /resources/1
:usage example:
::
wget -q -O - http://localhost/oarapi/resources/1.yaml
GET /resources/nodes/<network_address>
--------------------------------------
:description:
Get details about the resources belonging to the node identified by *network_address*
:formats:
html , yaml , json
:authentication:
public
:output:
*structure*: array of hashes
*yaml example*:
::
---
- api_timestamp: 1253202379
jobs_uri: /resources/4/jobs
network_address: liza-1
node_uri: /resources/nodes/liza-1
resource_id: 4
state: Alive
uri: /resources/4
- api_timestamp: 1253202379
jobs_uri: /resources/5/jobs
network_address: liza-1
node_uri: /resources/nodes/liza-1
resource_id: 5
state: Alive
uri: /resources/5
:usage example:
::
wget -q -O - http://localhost/oarapi/resources/nodes/liza-1.yaml
POST /resources/generate
------------------------
:description:
Generates (outputs) a set of resources. The result may then be directly sent to /resources for actual creation.
:formats:
html , yaml , json
:authentication:
oar
:input:
[resources] and [properties] entries are mandatory
*structure*: hash describing the resources to generate
*fields*:
- **resources** (*string*): A string corresponding to the resources definition.
- **properties** (*hash*): an optional hash defining some common properties for these new resources
*yaml example*:
::
---
ressources: /nodes=node{2}.test.generate/cpu={2}/core={2}
properties:
memnode: 1050
cpufreq: 5
:output:
*structure*: an array of hashes containing the generated resources that may be pushed to POST /resources for actual creation
*yaml example*:
::
---
api_timestamp: 1321366378
items:
- core: 1
cpu: 1
cpuset: 0
network_address: node1.test.generate
- core: 2
cpu: 1
cpuset: 1
network_address: node1.test.generate
- core: 3
cpu: 2
cpuset: 2
network_address: node1.test.generate
- core: 4
cpu: 2
cpuset: 3
network_address: node1.test.generate
- core: 5
cpu: 3
cpuset: 0
network_address: node2.test.generate
- core: 6
cpu: 3
cpuset: 1
network_address: node2.test.generate
- core: 7
cpu: 4
cpuset: 2
network_address: node2.test.generate
- core: 8
cpu: 4
cpuset: 3
network_address: node2.test.generate
links:
- href: /oarapi-priv/resources/generate.yaml
rel: self
offset: 0
total: 8
:usage example:
::
# Generating new resources with curl
curl -i -X POST http://oar:kameleon@localhost/oarapi-priv/resources/generate -H'Content-Type: application/json' -d '{"resources":"/nodes=node{2}.test.generate/cpu={2}/core={2}"}'
POST /resources
---------------
:description:
Creates a new resource or a set of new resources
:formats:
html , yaml , json
:authentication:
oar
:input:
A [hostname] or [network_address] entry is mandatory
*structure*: A hash describing the resource to be created. An array of hashes may be given for creating a set of new resources. The result of a /resources/generate query may be directly posted to /resources.
*fields*:
- **hostname** alias **network_address** (*string*): the network address given to the resource
- **properties** (*hash*): an optional hash defining some properties for this new resource
*yaml example*:
::
---
hostname: test2
properties:
besteffort: "NO"
cpu: "10"
:output:
*structure*: hash returning the id of the newly created resource and status (or an array of hashes if a set of resources has been given on the input)
*yaml example*:
::
---
api_timestamp: 1245946199
id: 32
status: ok
uri: /resources/32
warnings: []
:usage example:
::
# Adding a new resource with the ruby rest client (oar user only)
irb(main):078:0> r={ 'hostname'=>'test2', 'properties'=> { 'besteffort'=>'NO' , 'cpu' => '10' } }
irb(main):078:0> puts post('/resources', r.to_json , :content_type => 'application/json')
POST /resources/<id>/state
--------------------------
:description:
Change the state
:formats:
html , yaml , json
:authentication:
oar
:input:
A [state] entry is mandatory and must be "Absent", "Alive" or "Dead"
*structure*: hash of state
*fields*:
- **state**: Alive, Absent or Dead
*yaml example*:
::
---
state: Dead
:output:
*structure*:
*yaml example*:
::
---
api_timestamp: 1253283492
id: 34
status: Change state request registered
uri: /resources/34
:usage example:
::
irb
DELETE /resources/<id>
----------------------
:description:
Delete the resource identified by *id*
:formats:
html , yaml , json
:authentication:
oar
:output:
*structure*: hash returning the status
*yaml example*:
::
---
api_timestamp: 1245946801
status: deleted
:usage example:
::
# Deleting a resource with the ruby rest client
puts delete('/resources/32.yaml')
:note:
If the resource could not be deleted, returns a 403 and the reason into the message body.
DELETE /resources/<node>/<cpuset_id>
------------------------------------
:description:
Delete the resource corresponding to *cpuset_id* on node *node*. It is useful when you don't know about the ids, but only the number of cpus on physical nodes.
:formats:
html , yaml , json
:authentication:
oar
:output:
*structure*: hash returning the status
*yaml example*:
::
---
api_timestamp: 1246459253
status: deleted
=> nil
:usage example:
::
# Deleting a resource with the ruby rest client
puts delete('/resources/test/0.yaml')
:note:
If the resource could not be deleted, returns a 403 and the reason into the message body.
GET /admission_rules
--------------------
:description:
Get the list of admission rules
:formats:
html , yaml , json
:authentication:
oar
:output:
*structure*: hash
*fields*:
- **items** : list of admission rules
- **links** : links to previous, current and next admission rules
- **offset** : current offset
- **total** : total of admission rules
*yaml example*:
::
---
items:
- id: 1
links:
href: /admission_rules/1
rel: self
rule: 'if (not defined($queue_name)) {$queue_name="default";}'
- id: 2
links:
href: /admission_rules/2
rel: self
rule: 'die ("[ADMISSION RULE] root and oar users are not allowed to submit jobs.\n") if ( $user eq "root" or $user eq "oar" );'
- id: 3
links:
href: /admission_rules/3
rel: self
rule: |2
my $admin_group = "admin";
if ($queue_name eq "admin") {
my $members;
(undef,undef,undef, $members) = getgrnam($admin_group);
my %h = map { $_ => 1 } split(/\s+/,$members);
if ( $h{$user} ne 1 ) {
{die("[ADMISSION RULE] Only member of the group ".$admin_group." can submit jobs in the admin queue\n");}
}
}
links:
- href: '/admission_rules.yaml?limit=5&offset=0'
rel: previous
- href: '/admission_rules.yaml?limit=5&offset=5'
rel: self
- href: '/admission_rules.yaml?limit=5&offset=10'
rel: next
offset: 5
total: 5
:usage example:
::
wget -q -O - http://localhost/oarapi/admission_rules.yaml
*note*: The following parameters can be passed through the requested URL
- limit : limit of admission rules to be shown per page
- offset : the page result offset
GET /admission_rules/<id>
-------------------------
:description:
Get details about the admission rule identified by *id*
:formats:
html , yaml , json
:authentication:
oar
:output:
*structure*: 1 element array of hash
*yaml example*:
::
---
- id: 1
links:
href: /admission_rules/1
rel: self
rule: 'if (not defined($queue_name)) {$queue_name="default";}'
:usage example:
::
wget -q -O - http://localhost/oarapi/admission_rules/1.yaml
DELETE /admission_rule/<id>
---------------------------
:description:
Delete the admission rule identified by *id*
:formats:
html , yaml , json
:authentication:
oar
:output:
*structure*: hash returning the status
*yaml example*:
::
---
id: 32
api_timestamp: 1245946801
status: deleted
:usage example:
::
# Deleting an admisssion rule with the ruby rest client
puts delete('/admission_rules/32.yaml')
:note:
:note:
Not all clients support the DELETE method, especially some www browsers. So, you can do the same thing with a POST of a {"method":"delete"} hash on the /admission_rule/<id> rule.
If the admission rule could not be deleted, returns a 403 and the reason into the message body.
POST /admission_rules
---------------------
:description:
Add a new admission rule
:formats:
html , yaml , json
:authentication:
oar
:input:
*structure*: hash
*fields*:
- **rule** (*text*): The admission rule to add
*yaml example*:
::
---
rule: |
echo "This is a test rule"
:output:
A 201 (created) header is returned if the rule is successfully created, with a location value.
*yaml example*:
::
---
api_timestamp: 1340180126
id: 19
rule: echo "This is a test rule"
uri: /oarapi-priv/admission_rules/19
POST /admission_rules/<id>
--------------------------
:description:
Update or delete the admission rule given by *id*
:formats:
html , yaml , json
:authentication:
oar
:input:
*structure*: hash
*fields*:
- **rule** (*text*): The content of the admission rule to update
- **method=delete** : If given, the admission rule is deleted
*yaml example*:
::
---
rule: |
echo "This is a test rule"
:output:
A 201 (created) header is returned if the rule is successfully updated, with a location value.
*yaml example*:
::
---
api_timestamp: 1340180126
id: 19
rule: echo"test rule"
uri: /oarapi-priv/admission_rules/19
GET /config
-----------
:description:
Get the list of configured variables
:formats:
html , yaml , json
:authentication:
oar
:output:
*structure*: array of hashes
*yaml example*:
::
---
- id: DB_BASE_NAME
links:
href: /config/DB_BASE_NAME
rel: self
value: oar
- id: OARSUB_FORCE_JOB_KEY
links:
href: /config/OARSUB_FORCE_JOB_KEY
rel: self
value: no
- id: SCHEDULER_GANTT_HOLE_MINIMUM_TIME
links:
href: /config/SCHEDULER_GANTT_HOLE_MINIMUM_TIME
rel: self
value: 300
- id: SCHEDULER_RESOURCE_ORDER
links:
href: /config/SCHEDULER_RESOURCE_ORDER
rel: self
value: 'scheduler_priority ASC, suspended_jobs ASC, network_address DESC, resource_id ASC'
- id: SCHEDULER_PRIORITY_HIERARCHY_ORDER
links:
href: /config/SCHEDULER_PRIORITY_HIERARCHY_ORDER
rel: self
value: network_address/resource_id
- id: OARSUB_NODES_RESOURCES
links:
href: /config/OARSUB_NODES_RESOURCES
rel: self
value: network_address
- id: SCHEDULER_JOB_SECURITY_TIME
links:
href: /config/SCHEDULER_JOB_SECURITY_TIME
rel: self
value: 60
- id: DETACH_JOB_FROM_SERVER
links:
href: /config/DETACH_JOB_FROM_SERVER
rel: self
value: 0
- id: LOG_LEVEL
links:
href: /config/LOG_LEVEL
rel: self
value: 2
- id: OAREXEC_DEBUG_MODE
links:
href: /config/OAREXEC_DEBUG_MODE
rel: self
value: 0
.....
.....
:usage example:
::
curl -i -X GET http://login:password@localhost/oarapi-priv/config.yaml
GET /config/file
----------------
:description:
Get the raw config file of OAR. It also output the path of the file used by the API.
:formats:
html , yaml , json
:authentication:
oar
:output:
*structure*: hash
*fields*:
- **path** : The path of the config file
- **file** : The raw content of the config file (text)
:usage example:
::
curl -i -X GET http://kameleon:kameleon@localhost/oarapi-priv/config/file.yaml
GET /config/<variable>
----------------------
:description:
Get details about the configuration variable identified by *variable*
:formats:
html , yaml , json
:authentication:
oar
:output:
*structure*: 1 element array of hash
*yaml example*:
::
---
- id: DB_TYPE
links:
href: /config/DB_TYPE
rel: self
value: mysql
:usage example:
::
curl -i -X GET http://login:password@localhost/oarapi-priv/config/DB_TYPE.yaml
POST /config/<variable>
-----------------------
:description:
Change the value of the configuration variable identified by *variable*
:formats:
html , yaml , json
:authentication:
oar
:input:
A [value] entry is mandatory
*structure*: hash describing the new value of the variable
*fields*:
- **value** (*string*): the value of the given variable
*yaml example*:
::
---
value: 'state=Finishing,Running,Resuming,Suspended,Launching,toLaunch,Waiting,toAckReservation,Hold,Terminated'
:output:
*structure*: hash returning the variable and his new value
*yaml example*:
::
---
API_JOBS_URI_DEFAULT_PARAMS:
value: 'state=Finishing,Running,Resuming,Suspended,Launching,toLaunch,Waiting,toAckReservation,Hold,Terminated'
:usage example:
::
curl -i -X POST http://login:password@localhost/oarapi-priv/config/API_JOBS_URI_DEFAULT_PARAMS.yaml -H'Content-Type: text/yaml' -T config.yaml
:note:
config.yaml contains the value of the variable.
GET /media/ls/<file_path>
-------------------------
:description:
Get a list of the directory from the path given by *file_path*. The *file_path* may contain the special character "~" that is expanded to the home directory of the user that is making the request.
:formats:
html , yaml , json
:authentication:
user
:output:
*structure*: array of hashes giving for each listed file: the name, the mode, the size, the modification time and the type (*f* for a file or *d* for a directory)
*yaml example*:
::
---
api_timestamp: 1340095354
items:
- mode: 33188
mtime: 1339685040
name: API.pm
size: 58620
type: f
- mode: 16877
mtime: 1340094660
name: bart
size: ~
type: d
- mode: 16877
mtime: 1338993000
name: cigri-3
size: ~
type: d
- mode: 16877
mtime: 1340095200
name: oar
size: ~
type: d
- mode: 16877
mtime: 1334132940
name: oar_install
size: ~
type: d
- mode: 33261
mtime: 1339685040
name: oarapi.pl
size: 75939
type: f
- mode: 33261
mtime: 1340027400
name: test.sh
size: 43
type: f
links:
- href: /oarapi-priv/media/ls/~/
rel: self
offset: 0
total: 7
:usage example:
::
curl -i -X GET http://kameleon:kameleon@localhost/oarapi-priv/media/ls/~/ -H'Content-Type: text/yaml'
:note:
returns a 404 if the path does not exist, or a 403 if the path is not readable. Errors in debug mode (with ?debug=1) are formated into yaml.
GET /media/<file_path>
----------------------
:description:
Get a file located on the API host, into the path given by *file_path*. The *file_path* may contain the special character "~" that is expanded to the home directory of the user that is making the request.
:parameters:
- **tail**: specifies an optional number of lines for printing only the tail of a text file
:formats:
application/octet-stream
:authentication:
user
:output:
octet-stream
:usage example:
::
curl -i -H'Content-Type: application/octet-stream' http://kameleon:kameleon@localhost/oarapi-priv/media/~/cigri-3/CHANGELOG
:note:
returns a 404 if the file does not exist, or a 403 if the file is not readable. Errors in debug mode (with ?debug=1) are formated into yaml.
POST /media/<file_path>
-----------------------
:description:
Upload or create a file on the API host, into the path given by *file_path*. The *file_path* may contain the special character "~" that is expanded to the home directory of the user that is making the request. If the path does not exists, the directories are automatically created. If no data is passed, an empty file is created. If binary data is sent as POSTDATA, then it is a file to upload.
:formats:
application/octet-stream
:authentication:
user
:output:
201 if ok
:usage example:
::
curl -i -X POST -H'Content-Type: application/octet-stream' --data-binary @/etc/group http://kameleon:kameleon@localhost/oarapi-priv/media/~/testdir/testfile
POST /media/chmod/<file_path>
-----------------------------
:description:
Changes the permissions on a file: do a chmod(1) on *file_path*. The special character "~" is expanded as the home of the user that makes the query.
:formats:
html , yaml , json
:authentication:
user
:input:
A [mode] entry is mandatory
*mode*: A mode definition as passed to the "chmod" unix command.
:output:
202 if ok
:usage example:
::
curl -i -X POST http://kameleon:kameleon@localhost/oarapi-priv/media/chmod/~/param9 -H'Content-Type: application/json' -d '{"mode":"755"}'
DELETE /media/<file_path>
-------------------------
:description:
Delete the file or directory given by *file_path*. The *file_path* may contain the special character "~" that is expanded to the home directory of the user that is making the request. If the path is a directory, then it is deleted recursively.
:formats:
application/octet-stream
:authentication:
user
:output:
204 if ok
:usage example:
::
curl -i -X DELETE -H'Content-Type: application/octet-stream' http://kameleon:kameleon@localhost/oarapi-priv/media/~/testdir
Some equivalences with oar command line
=======================================
=============================== ======================================
OAR command REST request
=============================== ======================================
oarstat GET /jobs.html
oarstat -Y GET /jobs/details.yaml
oarstat -Y -j <id> GET /jobs/<id>.yaml
oarstat -Y -fj <id> GET /jobs/<id>/details.yaml
oardel <id> DELETE /jobs/<id>.yaml
oardel <id> *(alternative way)* POST /jobs/deletions/<id>/new.yaml
oarnodes -Y GET /resources/details.yaml
oarnodes -Y -r1 GET /resources/1.yaml
=============================== ======================================
|