conoha 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: db68d93da75070b139bc50e3bad0c5cdbc797858
4
- data.tar.gz: 6434e3250a3905c0294b611af874748d923d0cd4
2
+ SHA256:
3
+ metadata.gz: 839eeeeaa6d817fca7e8522f7aef1c2ef93fc759cf2bf195d059720e655e9548
4
+ data.tar.gz: e717b7aec46f17a71d2a1edc76e3eaf01307930233ccefb9389402560cb3ee09
5
5
  SHA512:
6
- metadata.gz: ecf861e9f3799087c8f1a6b8a89a2356cf7d4e8ebcedbc4e022895c74d544b1208da9f762fa7b8ecec496f49363109dcb7bbf1b46a4bbb88a74b41c8cf8b2a52
7
- data.tar.gz: 927d7413a91e54020585667fe316f00e8a33e80ebb06cd7b35b69902a288d6ecc24497ee011f9edc6ba089e8f35ed866f6e1a0824fa1d0755837bf91541ee5ad
6
+ metadata.gz: a167e3593d07fc4b5fb3a0da035ff6722a9e828ec544d725b39de1eb9f5c741667c2f14151b17239ce76a41305797711c1cfc527011beaafcb8845f6e208e065
7
+ data.tar.gz: a2c2430cc7c1000cc776cdb1d8e58406a7c1d53307b4f02db4a48086c63797a9bef5bcff41d017f8c57bb76e1a5e616eff7bc021484fa4bb930e64397e3d32aa
data/README.md CHANGED
@@ -109,6 +109,20 @@ conoha createfromimage fedcba98-7654-3210-fedc-ba9876543210 g-1gb
109
109
  conoha createfromimage ubuntu-backup g-1gb
110
110
  # You can remove the last argument (default value is "g-1gb")
111
111
  conoha createfromimage fedcba98-7654-3210-fedc-ba9876543210
112
+ # You can specify the user_data.
113
+ # More information:
114
+ # https://www.conoha.jp/guide/startupscript.php
115
+ # https://www.conoha.jp/docs/compute-create_vm.html
116
+ # "g-1gb" (or any other RAM specification) is required now, because
117
+ # "--user-data" and "BASE64_STRING" are detected by their argument position
118
+ # (4th and 5th), sorry for my poor implementation...
119
+ conoha createfromimage fedcba98-7654-3210-fedc-ba9876543210 g-1gb --user-data BASE64_STRING
120
+ # You can get BASE64_STRING from like a following command e.g.
121
+ cat <<EOF | base64 -w
122
+ #!/bin/bash
123
+
124
+ apt-get -y install nginx
125
+ EOF
112
126
 
113
127
  # SSH
114
128
  conoha ssh 01234567-89ab-cdef-0123-456789abcdef root # ssh root@ipaddress
data/exe/conoha CHANGED
@@ -109,7 +109,8 @@ when 'createfromimage', 'restore'
109
109
  exit 1 if ARGV.size < 1
110
110
  image_ref = image_ref_or_name ARGV[0]
111
111
  ram = ARGV[1] || 'g-1gb'
112
- puts Conoha.create_from_image image_ref, ram
112
+ user_data = (ARGV[2] == '--user-data' ? ARGV[3] : nil)
113
+ puts Conoha.create_from_image image_ref, ram, user_data: user_data
113
114
  when 'ssh'
114
115
  exit 1 if ARGV.size < 1 || 2 < ARGV.size
115
116
  ipaddress = ipv4(Conoha.ip_address_of(server_id(ARGV.first)))
@@ -76,13 +76,14 @@ class Conoha
76
76
  # @param [String] os
77
77
  # @param [String] ram
78
78
  # @param [String] name_tag (default: nil)
79
+ # @option [String] user_data
79
80
  # @raise [StandardError]
80
81
  # when "os" doesn't exist in image_tag_dictionary
81
82
  # when "image_tag" doesn't exist in images
82
- def self.create(os, ram, name_tag = nil)
83
+ def self.create(os, ram, name_tag = nil, user_data: nil)
83
84
  image_ref = image_ref_from_image_tag(image_tag_dictionary(os))
84
85
  uri = "https://compute.#{region}.conoha.io/v2/#{tenant_id}/servers"
85
- payload = payload_for_create_vps image_ref, ram, public_key
86
+ payload = payload_for_create_vps image_ref, ram, public_key, user_data: user_data
86
87
  if name_tag
87
88
  payload[:server].merge!({metadata: {instance_name_tag: name_tag}})
88
89
  end
@@ -163,9 +164,9 @@ class Conoha
163
164
  res.code == '204' ? 'OK' : 'Error'
164
165
  end
165
166
 
166
- def self.create_from_image(image_ref, ram)
167
+ def self.create_from_image(image_ref, ram, user_data: nil)
167
168
  uri = "https://compute.#{region}.conoha.io/v2/#{tenant_id}/servers"
168
- payload = payload_for_create_vps image_ref, ram, public_key
169
+ payload = payload_for_create_vps image_ref, ram, public_key, user_data: user_data
169
170
  res = https_post uri, payload, authtoken
170
171
  JSON.parse(res.body)["server"]["id"]
171
172
  end
@@ -307,15 +308,19 @@ EOS
307
308
  # @param [String] image_ref
308
309
  # @param [String] ram
309
310
  # @param [String] public_key
310
- def self.payload_for_create_vps image_ref, ram, public_key
311
- {
312
- server: {
313
- adminPass: randstr,
314
- imageRef: image_ref,
315
- flavorRef: flavor_ref(ram),
316
- key_name: public_key,
317
- security_groups: [{name: 'default'}, {name: 'gncs-ipv4-all'}],
311
+ # @option [String] user_data
312
+ def self.payload_for_create_vps image_ref, ram, public_key, user_data: nil
313
+ ret =
314
+ {
315
+ server: {
316
+ adminPass: randstr,
317
+ imageRef: image_ref,
318
+ flavorRef: flavor_ref(ram),
319
+ key_name: public_key,
320
+ security_groups: [{name: 'default'}, {name: 'gncs-ipv4-all'}],
321
+ }
318
322
  }
319
- }
323
+ ret[:server].merge!({ user_data: user_data }) if user_data
324
+ ret
320
325
  end
321
326
  end
@@ -1,3 +1,3 @@
1
1
  module ConohaVersion
2
- ITSELF = "0.10.0"
2
+ ITSELF = "0.11.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conoha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ka
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-04 00:00:00.000000000 Z
11
+ date: 2018-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  version: '0'
154
154
  requirements: []
155
155
  rubyforge_project:
156
- rubygems_version: 2.6.13
156
+ rubygems_version: 2.7.6
157
157
  signing_key:
158
158
  specification_version: 4
159
159
  summary: ConoHa VPS CLI Tool