Top Level Namespace
Defined Under Namespace
Modules: ConohaVersion Classes: Conoha
Instance Method Summary collapse
- #https_delete(uri_string, authtoken) ⇒ Net::HTTPResponse
- #https_get(uri_string, authtoken) ⇒ Net::HTTPResponse
- #https_post(uri_string, payload, authtoken) ⇒ Net::HTTPResponse
-
#image_tag_dictionary(os) ⇒ String
Image name tag.
-
#ipv4(ip_address) ⇒ String
IPv4 address (e.g. “111.111.111.111”).
Instance Method Details
#https_delete(uri_string, authtoken) ⇒ Net::HTTPResponse
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/conoha/util.rb', line 39 def https_delete(uri_string, authtoken) uri = URI.parse uri_string https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = true req = Net::HTTP::Delete.new(uri.request_uri) req['Content-Type'] = 'application/json' req['Accept'] = 'application/json' req['X-Auth-Token'] = authtoken https.request(req) end |
#https_get(uri_string, authtoken) ⇒ Net::HTTPResponse
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/conoha/util.rb', line 7 def https_get(uri_string, authtoken) uri = URI.parse uri_string https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = true req = Net::HTTP::Get.new(uri.path) req['Content-Type'] = 'application/json' req['Accept'] = 'application/json' req['X-Auth-Token'] = authtoken https.request(req) end |
#https_post(uri_string, payload, authtoken) ⇒ Net::HTTPResponse
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/conoha/util.rb', line 24 def https_post(uri_string, payload, authtoken) uri = URI.parse uri_string https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = true req = Net::HTTP::Post.new(uri.request_uri) req['Content-Type'] = 'application/json' req['Accept'] = 'application/json' req['X-Auth-Token'] = authtoken req.body = payload.to_json https.request(req) end |
#image_tag_dictionary(os) ⇒ String
Returns Image name tag.
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 |
# File 'lib/conoha/util.rb', line 67 def image_tag_dictionary(os) dictionary = { 'ubuntu' => 'vmi-ubuntu-16.04-amd64-unified', # Ubuntu 16.04 amd64 'ubuntu16' => 'vmi-ubuntu-16.04-amd64-unified', # Ubuntu 16.04 amd64 'ubuntu14' => 'vmi-ubuntu-14.04-amd64-unified', # Ubuntu 14.04 amd64 'debian' => 'vmi-debian-8.7-amd64-unified', # Debian 8 amd64 'fedora' => 'vmi-fedora-25-amd64', # Fedora 25 amd64 'fedora25' => 'vmi-fedora-25-amd64', # Fedora 25 amd64 'centos' => 'vmi-centos-7.3-amd64', # CentOS 7.3 'centos73' => 'vmi-centos-7.3-amd64', # CentOS 7.3 'centos72' => 'vmi-centos-7.2-amd64', # CentOS 7.2 'centos71' => 'vmi-centos-7.1-amd64', # CentOS 7.1 'centos68' => 'vmi-centos-6.8-amd64', # CentOS 6.8 'centos67' => 'vmi-centos-6.7-amd64', # CentOS 6.7 'centos66' => 'vmi-centos-6.6-amd64', # CentOS 6.6 'arch' => 'vmi-arch-amd64', # Arch 'opensuse' => 'vmi-opensuse-42.2-amd64-unified', # openSUSE 'openbsd' => 'vmi-openbsd-6.0-amd64', # OpenBSD 'netbsd' => 'vmi-netbsd-7.0-amd64', # NetBSD 'freebsd' => 'vmi-freebsd-10.3-x86_64', # FreeBSD 'docker' => 'vmi-docker-17.03-ubuntu-16.04-unified', # Docker on Ubuntu 16.04 # 20GB storage for 512MB RAM 'ubuntu-20gb' => 'vmi-ubuntu-16.04-amd64-unified-20gb', 'ubuntu16-20gb' => 'vmi-ubuntu-16.04-amd64-unified-20gb', 'ubuntu14-20gb' => 'vmi-ubuntu-14.04-amd64-unified-20gb', 'debian-20gb' => 'vmi-debian-8.7-amd64-unified-20gb', 'fedora-20gb' => 'vmi-fedora-25-amd64-20gb', 'fedora25-20gb' => 'vmi-fedora-25-amd64-20gb', 'centos-20gb' => 'vmi-centos-7.3-amd64-20gb', 'centos73-20gb' => 'vmi-centos-7.3-amd64-20gb', 'centos72-20gb' => 'vmi-centos-7.2-amd64-20gb', 'centos71-20gb' => 'vmi-centos-7.1-amd64-20gb', 'centos68-20gb' => 'vmi-centos-6.8-amd64-20gb', 'centos67-20gb' => 'vmi-centos-6.7-amd64-20gb', 'centos66-20gb' => 'vmi-centos-6.6-amd64-20gb', 'arch-20gb' => 'vmi-arch-amd64-20gb', 'opensuse-20gb' => 'vmi-opensuse-42.2-amd64-unified-20gb', 'openbsd-20gb' => 'vmi-openbsd-6.0-amd64-20gb', 'netbsd-20gb' => 'vmi-netbsd-7.0-amd64-20gb', 'freebsd-20gb' => 'vmi-freebsd-10.3-amd64-20gb', 'docker-20gb' => 'vmi-docker-17.03-ubuntu-16.04-unified-20gb', } if dictionary.keys.include? os dictionary[os] else raise StandardError.new <<EOS "#{os}" doesn't exist. Select os name from the following list: #{dictionary.keys.join("\n")} EOS end end |
#ipv4(ip_address) ⇒ String
Returns IPv4 address (e.g. “111.111.111.111”).
60 61 62 |
# File 'lib/conoha/util.rb', line 60 def ipv4(ip_address) ip_address.select { |e| e =~ /\d+\.\d+\.\d+\.\d+/ }.first end |