Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Reference data in Linode API
# Setup
require 'pp'
require 'linode'
l = Linode.new api_key: 'my-api-key' # Get that from https://manager.linode.com/profile/index
a = l.avail
# Let's Rock It ...
2.1.0 :011 > pp a.datacenters
[#<Linode::OpenStruct location="Dallas, TX, USA", datacenterid=2, abbr="dallas">,
[#<Linode::OpenStruct location="Dallas, TX, USA", datacenterid=2, abbr="dallas">,
#<Linode::OpenStruct location="Fremont, CA, USA", datacenterid=3, abbr="fremont">,
#<Linode::OpenStruct location="Atlanta, GA, USA", datacenterid=4, abbr="atlanta">,
#<Linode::OpenStruct location="Newark, NJ, USA", datacenterid=6, abbr="newark">,
#<Linode::OpenStruct location="London, England, UK", datacenterid=7, abbr="london">,
#<Linode::OpenStruct location="Tokyo, JP", datacenterid=8, abbr="tokyo">]
2.1.0 :017 > pp a.linodeplans
[#<Linode::OpenStruct price=20.0, ram=1024, xfer=2000, planid=1, label="Linode 1024", avail={"3"=>500, "2"=>500, "7"=>500, "6"=>500, "4"=>500, "8"=>500}, disk=48>,
#<Linode::OpenStruct price=40.0, ram=2048, xfer=4000, planid=3, label="Linode 2048", avail={"3"=>500, "2"=>500, "7"=>500, "6"=>500, "4"=>500, "8"=>500}, disk=96>,
#<Linode::OpenStruct price=80.0, ram=4096, xfer=8000, planid=5, label="Linode 4096", avail={"3"=>500, "2"=>500, "7"=>500, "6"=>500, "4"=>500, "8"=>500}, disk=192>,
#<Linode::OpenStruct price=160.0, ram=8192, xfer=16000, planid=6, label="Linode 8192", avail={"3"=>500, "2"=>500, "7"=>500, "6"=>500, "4"=>500, "8"=>500}, disk=384>,
#<Linode::OpenStruct price=320.0, ram=16384, xfer=20000, planid=7, label="Linode 16384", avail={"3"=>500, "2"=>500, "7"=>500, "6"=>500, "4"=>500, "8"=>500}, disk=768>,
#<Linode::OpenStruct price=480.0, ram=24576, xfer=20000, planid=8, label="Linode 24576", avail={"3"=>500, "2"=>500, "7"=>500, "6"=>500, "4"=>500, "8"=>500}, disk=1152>,
#<Linode::OpenStruct price=640.0, ram=32768, xfer=20000, planid=9, label="Linode 32768", avail={"3"=>500, "2"=>500, "7"=>500, "6"=>500, "4"=>500, "8"=>500}, disk=1536>,
#<Linode::OpenStruct price=800.0, ram=40960, xfer=20000, planid=10, label="Linode 40960", avail={"3"=>500, "2"=>500, "7"=>500, "6"=>500, "4"=>500, "8"=>500}, disk=1920>]
2.1.0 :012 > pp a.distributions
[#<Linode::OpenStruct requirespvopskernel=1, distributionid=112, is64bit=1, label="Arch Linux 2013.06", minimagesize=500, create_dt="2013-06-06 02:45:11.0">,
#<Linode::OpenStruct requirespvopskernel=1, distributionid=119, is64bit=1, label="CentOS 6.4", minimagesize=725, create_dt="2013-12-02 12:52:14.0">,
#<Linode::OpenStruct requirespvopskernel=1, distributionid=121, is64bit=1, label="Debian 7.3", minimagesize=756, create_dt="2013-12-31 14:10:18.0">,
#<Linode::OpenStruct requirespvopskernel=1, distributionid=122, is64bit=1, label="Fedora 20", minimagesize=650, create_dt="2013-01-27 10:00:00.0">,
#<Linode::OpenStruct requirespvopskernel=1, distributionid=118, is64bit=1, label="Gentoo 2013-11-26", minimagesize=1024, create_dt="2013-11-26 15:20:31.0">,
#<Linode::OpenStruct requirespvopskernel=1, distributionid=120, is64bit=1, label="openSUSE 13.1", minimagesize=1024, create_dt="2013-12-02 12:53:29.0">,
#<Linode::OpenStruct requirespvopskernel=1, distributionid=117, is64bit=1, label="Slackware 14.1", minimagesize=875, create_dt="2013-11-25 11:11:02.0">,
#<Linode::OpenStruct requirespvopskernel=1, distributionid=65, is64bit=1, label="Ubuntu 10.04 LTS", minimagesize=450, create_dt="2010-04-29 00:00:00.0">,
#<Linode::OpenStruct requirespvopskernel=1, distributionid=99, is64bit=1, label="Ubuntu 12.04 LTS", minimagesize=650, create_dt="2012-04-26 17:25:16.0">,
#<Linode::OpenStruct requirespvopskernel=1, distributionid=111, is64bit=1, label="Ubuntu 13.04", minimagesize=770, create_dt="2013-05-08 11:31:32.0">,
#<Linode::OpenStruct requirespvopskernel=1, distributionid=116, is64bit=1, label="Ubuntu 13.10", minimagesize=750, create_dt="2013-10-28 20:10:11.0">,
#<Linode::OpenStruct requirespvopskernel=1, distributionid=113, is64bit=0, label="Arch Linux 2013.06 32bit", minimagesize=500, create_dt="2013-06-06 02:45:11.0">,
#<Linode::OpenStruct requirespvopskernel=1, distributionid=64, is64bit=0, label="Ubuntu 10.04 LTS 32bit", minimagesize=450, create_dt="2010-04-29 00:00:00.0">,
#<Linode::OpenStruct requirespvopskernel=1, distributionid=98, is64bit=0, label="Ubuntu 12.04 LTS 32bit", minimagesize=650, create_dt="2012-04-26 17:25:16.0">,
#<Linode::OpenStruct requirespvopskernel=1, distributionid=110, is64bit=0, label="Ubuntu 13.04 32bit", minimagesize=770, create_dt="2013-05-08 11:31:32.0">,
#<Linode::OpenStruct requirespvopskernel=1, distributionid=105, is64bit=1, label="Arch Linux 2012.10", minimagesize=500, create_dt="2012-10-22 15:00:49.0">,
#<Linode::OpenStruct requirespvopskernel=1, distributionid=60, is64bit=1, label="CentOS 5.6", minimagesize=950, create_dt="2009-08-17 00:00:00.0">,
#<Linode::OpenStruct requirespvopskernel=1, distributionid=89, is64bit=1, label="CentOS 6.2", minimagesize=800, create_dt="2011-07-19 11:38:20.0">,
#<Linode::OpenStruct requirespvopskernel=1, distributionid=109, is64bit=1, label="Debian 7", minimagesize=660, create_dt="2013-05-08 11:31:32.0">,
#<Linode::OpenStruct requirespvopskernel=1, distributionid=114, is64bit=1, label="Fedora 19", minimagesize=750, create_dt="2013-08-26 15:29:21.0">,
#<Linode::OpenStruct requirespvopskernel=1, distributionid=115, is64bit=1, label="openSUSE 12.3", minimagesize=1024, create_dt="2013-09-19 10:49:09.0">,
#<Linode::OpenStruct requirespvopskernel=1, distributionid=87, is64bit=1, label="Slackware 13.37", minimagesize=600, create_dt="2011-06-05 15:11:59.0">,
#<Linode::OpenStruct requirespvopskernel=1, distributionid=107, is64bit=1, label="Ubuntu 12.10", minimagesize=660, create_dt="2012-11-06 11:51:25.0">,
#<Linode::OpenStruct requirespvopskernel=1, distributionid=104, is64bit=0, label="Arch Linux 2012.10 32bit", minimagesize=500, create_dt="2012-10-22 15:00:49.0">,
#<Linode::OpenStruct requirespvopskernel=1, distributionid=59, is64bit=0, label="CentOS 5.6 32bit", minimagesize=950, create_dt="2009-08-17 00:00:00.0">,
#<Linode::OpenStruct requirespvopskernel=1, distributionid=108, is64bit=0, label="Debian 7 32bit", minimagesize=660, create_dt="2013-05-08 11:31:32.0">,
#<Linode::OpenStruct requirespvopskernel=1, distributionid=86, is64bit=0, label="Slackware 13.37 32bit", minimagesize=600, create_dt="2011-06-05 15:11:59.0">,
#<Linode::OpenStruct requirespvopskernel=1, distributionid=106, is64bit=0, label="Ubuntu 12.10 32bit", minimagesize=660, create_dt="2012-11-06 11:51:25.0">]
2.1.0 :014 > pp a.kernels
[#<Linode::OpenStruct label="Latest 32 bit (3.12.9-x86-linode56)", isxen=1, ispvops=1, kernelid=137>,
#<Linode::OpenStruct label="3.10.3-x86-linode53", isxen=1, ispvops=1, kernelid=169>,
#<Linode::OpenStruct label="3.11.6-x86-linode54", isxen=1, ispvops=1, kernelid=171>,
#<Linode::OpenStruct label="3.12.6-x86-linode55", isxen=1, ispvops=1, kernelid=174>,
#<Linode::OpenStruct label="3.12.9-x86-linode56", isxen=1, ispvops=1, kernelid=176>,
#<Linode::OpenStruct label="3.9.3-x86-linode52", isxen=1, ispvops=1, kernelid=167>,
#<Linode::OpenStruct label="Latest 64 bit (3.12.9-x86_64-linode37)", isxen=1, ispvops=1, kernelid=138>,
#<Linode::OpenStruct label="3.10.3-x86_64-linode34", isxen=1, ispvops=1, kernelid=170>,
#<Linode::OpenStruct label="3.11.6-x86_64-linode35", isxen=1, ispvops=1, kernelid=172>,
#<Linode::OpenStruct label="3.12.6-x86_64-linode36", isxen=1, ispvops=1, kernelid=173>,
#<Linode::OpenStruct label="3.12.9-x86_64-linode37", isxen=1, ispvops=1, kernelid=175>,
#<Linode::OpenStruct label="3.9.3-x86_64-linode33", isxen=1, ispvops=1, kernelid=168>,
#<Linode::OpenStruct label="pv-grub-x86_32", isxen=1, ispvops=0, kernelid=92>,
#<Linode::OpenStruct label="pv-grub-x86_64", isxen=1, ispvops=0, kernelid=95>,
#<Linode::OpenStruct label="Recovery - Finnix (kernel)", isxen=1, ispvops=0, kernelid=61>,
#<Linode::OpenStruct label="Latest 2.6 (2.6.39.1-linode34)", isxen=1, ispvops=1, kernelid=110>,
#<Linode::OpenStruct label="Latest Legacy (2.6.18.8-linode22)", isxen=1, ispvops=0, kernelid=60>,
#<Linode::OpenStruct label="2.6.18.8-domU-linode7", isxen=1, ispvops=0, kernelid=81>,
#<Linode::OpenStruct label="2.6.18.8-linode10", isxen=1, ispvops=0, kernelid=89>,
#<Linode::OpenStruct label="2.6.18.8-linode16", isxen=1, ispvops=0, kernelid=98>,
#<Linode::OpenStruct label="2.6.18.8-linode19", isxen=1, ispvops=0, kernelid=103>,
#<Linode::OpenStruct label="2.6.18.8-linode22", isxen=1, ispvops=0, kernelid=113>,
#<Linode::OpenStruct label="2.6.24.4-linode8", isxen=1, ispvops=1, kernelid=84>,
#<Linode::OpenStruct label="2.6.25-linode9", isxen=1, ispvops=1, kernelid=88>,
#<Linode::OpenStruct label="2.6.25.10-linode12", isxen=1, ispvops=1, kernelid=90>,
#<Linode::OpenStruct label="2.6.26-linode13", isxen=1, ispvops=1, kernelid=91>,
#<Linode::OpenStruct label="2.6.27.4-linode14", isxen=1, ispvops=1, kernelid=93>,
#<Linode::OpenStruct label="2.6.28-linode15", isxen=1, ispvops=1, kernelid=96>,
#<Linode::OpenStruct label="2.6.28.3-linode17", isxen=1, ispvops=1, kernelid=99>,
#<Linode::OpenStruct label="2.6.29-linode18", isxen=1, ispvops=1, kernelid=101>,
#<Linode::OpenStruct label="2.6.30.5-linode20", isxen=1, ispvops=1, kernelid=105>,
#<Linode::OpenStruct label="2.6.31.5-linode21", isxen=1, ispvops=1, kernelid=109>,
#<Linode::OpenStruct label="2.6.32-linode23", isxen=1, ispvops=1, kernelid=115>,
#<Linode::OpenStruct label="2.6.32.12-linode25", isxen=1, ispvops=1, kernelid=119>,
#<Linode::OpenStruct label="2.6.32.16-linode28", isxen=1, ispvops=1, kernelid=123>,
#<Linode::OpenStruct label="2.6.33-linode24", isxen=1, ispvops=1, kernelid=117>,
#<Linode::OpenStruct label="2.6.34-linode27", isxen=1, ispvops=1, kernelid=120>,
#<Linode::OpenStruct label="2.6.35.7-linode29", isxen=1, ispvops=1, kernelid=126>,
#<Linode::OpenStruct label="2.6.37-linode30", isxen=1, ispvops=1, kernelid=127>,
#<Linode::OpenStruct label="2.6.38-linode31", isxen=1, ispvops=1, kernelid=128>,
#<Linode::OpenStruct label="2.6.38.3-linode32", isxen=1, ispvops=1, kernelid=130>,
#<Linode::OpenStruct label="2.6.39-linode33", isxen=1, ispvops=1, kernelid=131>,
#<Linode::OpenStruct label="2.6.39.1-linode34", isxen=1, ispvops=1, kernelid=134>,
#<Linode::OpenStruct label="3.0.0-linode35", isxen=1, ispvops=1, kernelid=135>,
#<Linode::OpenStruct label="3.0.17-linode41", isxen=1, ispvops=1, kernelid=147>,
#<Linode::OpenStruct label="3.0.18-linode43", isxen=1, ispvops=1, kernelid=149>,
#<Linode::OpenStruct label="3.0.4-linode36", isxen=1, ispvops=1, kernelid=139>,
#<Linode::OpenStruct label="3.0.4-linode37", isxen=1, ispvops=1, kernelid=141>,
#<Linode::OpenStruct label="3.0.4-linode38", isxen=1, ispvops=1, kernelid=142>,
#<Linode::OpenStruct label="3.1.0-linode39", isxen=1, ispvops=1, kernelid=143>,
#<Linode::OpenStruct label="3.1.10-linode42", isxen=1, ispvops=1, kernelid=148>,
#<Linode::OpenStruct label="3.2.1-linode40", isxen=1, ispvops=1, kernelid=145>,
#<Linode::OpenStruct label="3.4.2-linode44", isxen=1, ispvops=1, kernelid=152>,
#<Linode::OpenStruct label="3.5.2-linode45", isxen=1, ispvops=1, kernelid=153>,
#<Linode::OpenStruct label="3.5.3-linode46", isxen=1, ispvops=1, kernelid=156>,
#<Linode::OpenStruct label="3.6.5-linode47", isxen=1, ispvops=1, kernelid=157>,
#<Linode::OpenStruct label="3.7.10-linode49", isxen=1, ispvops=1, kernelid=161>,
#<Linode::OpenStruct label="3.7.5-linode48", isxen=1, ispvops=1, kernelid=159>,
#<Linode::OpenStruct label="3.8.4-linode50", isxen=1, ispvops=1, kernelid=163>,
#<Linode::OpenStruct label="3.9.2-x86-linode51", isxen=1, ispvops=1, kernelid=166>,
#<Linode::OpenStruct label="Latest 2.6 (2.6.39.1-x86_64-linode19)", isxen=1, ispvops=1, kernelid=111>,
#<Linode::OpenStruct label="Latest Legacy (2.6.18.8-x86_64-linode10)", isxen=1, ispvops=0, kernelid=107>,
#<Linode::OpenStruct label="2.6.16.38-x86_64-linode2", isxen=1, ispvops=0, kernelid=85>,
#<Linode::OpenStruct label="2.6.18.8-x86_64-linode1", isxen=1, ispvops=0, kernelid=86>,
#<Linode::OpenStruct label="2.6.18.8-x86_64-linode10", isxen=1, ispvops=0, kernelid=114>,
#<Linode::OpenStruct label="2.6.18.8-x86_64-linode7", isxen=1, ispvops=0, kernelid=104>,
#<Linode::OpenStruct label="2.6.27.4-x86_64-linode3", isxen=1, ispvops=1, kernelid=94>,
#<Linode::OpenStruct label="2.6.28-x86_64-linode4", isxen=1, ispvops=1, kernelid=97>,
#<Linode::OpenStruct label="2.6.28.3-x86_64-linode5", isxen=1, ispvops=1, kernelid=100>,
#<Linode::OpenStruct label="2.6.29-x86_64-linode6", isxen=1, ispvops=1, kernelid=102>,
#<Linode::OpenStruct label="2.6.30.5-x86_64-linode8", isxen=1, ispvops=1, kernelid=106>,
#<Linode::OpenStruct label="2.6.31.5-x86_64-linode9", isxen=1, ispvops=1, kernelid=112>,
#<Linode::OpenStruct label="2.6.32-x86_64-linode11", isxen=1, ispvops=1, kernelid=116>,
#<Linode::OpenStruct label="2.6.32.12-x86_64-linode12", isxen=1, ispvops=1, kernelid=118>,
#<Linode::OpenStruct label="2.6.32.12-x86_64-linode15", isxen=1, ispvops=1, kernelid=124>,
#<Linode::OpenStruct label="2.6.34-x86_64-linode13", isxen=1, ispvops=1, kernelid=121>,
#<Linode::OpenStruct label="2.6.34-x86_64-linode14", isxen=1, ispvops=1, kernelid=122>,
#<Linode::OpenStruct label="2.6.35.4-x86_64-linode16", isxen=1, ispvops=1, kernelid=125>,
#<Linode::OpenStruct label="2.6.38-x86_64-linode17", isxen=1, ispvops=1, kernelid=129>,
#<Linode::OpenStruct label="2.6.39-x86_64-linode18", isxen=1, ispvops=1, kernelid=132>,
#<Linode::OpenStruct label="2.6.39.1-x86_64-linode19", isxen=1, ispvops=1, kernelid=133>,
#<Linode::OpenStruct label="3.0.0-x86_64-linode20", isxen=1, ispvops=1, kernelid=136>,
#<Linode::OpenStruct label="3.0.18-x86_64-linode24", isxen=1, ispvops=1, kernelid=150>,
#<Linode::OpenStruct label="3.0.4-x86_64-linode21", isxen=1, ispvops=1, kernelid=140>,
#<Linode::OpenStruct label="3.1.0-x86_64-linode22", isxen=1, ispvops=1, kernelid=144>,
#<Linode::OpenStruct label="3.2.1-x86_64-linode23", isxen=1, ispvops=1, kernelid=146>,
#<Linode::OpenStruct label="3.4.2-x86_64-linode25", isxen=1, ispvops=1, kernelid=151>,
#<Linode::OpenStruct label="3.5.2-x86_64-linode26", isxen=1, ispvops=1, kernelid=154>,
#<Linode::OpenStruct label="3.5.3-x86_64-linode27", isxen=1, ispvops=1, kernelid=155>,
#<Linode::OpenStruct label="3.6.5-x86_64-linode28", isxen=1, ispvops=1, kernelid=158>,
#<Linode::OpenStruct label="3.7.10-x86_64-linode30", isxen=1, ispvops=1, kernelid=162>,
#<Linode::OpenStruct label="3.7.5-x86_64-linode29", isxen=1, ispvops=1, kernelid=160>,
#<Linode::OpenStruct label="3.8.4-x86_64-linode31", isxen=1, ispvops=1, kernelid=164>,
#<Linode::OpenStruct label="3.9.2-x86_64-linode32", isxen=1, ispvops=1, kernelid=165>]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment