conoha 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/conoha +22 -0
- data/lib/conoha.rb +1 -2
- data/lib/conoha/config.rb +29 -0
- data/lib/conoha/util.rb +3 -1
- data/lib/conoha/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6e33b2a50a3499c822087bdae43ec3d11d72601
|
4
|
+
data.tar.gz: e9a3bdfe441e42fb6a2df05deace4d0cf7c13945
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1386f8ee02eb554868aa1f7710a50299adc08d27a403da26efe356bec8420118376258397ef427ef6b38524a696d516e4159885b08909aeec984fa2671bc093f
|
7
|
+
data.tar.gz: de462decb4c6bbda886ce1e95301f61f0db34898973877410669e5e4595675eb9ae888efeb26d45383a1508299a3c66909de3db1676714bc2e856f5f1f9e1868
|
data/exe/conoha
CHANGED
@@ -85,6 +85,28 @@ when 'browse'
|
|
85
85
|
command = "xdg-open http://#{ipaddress}#{port}"
|
86
86
|
puts command
|
87
87
|
system command
|
88
|
+
when 'dump'
|
89
|
+
exit 1 if ARGV.size != 2
|
90
|
+
server_id_cache = server_id(ARGV[0])
|
91
|
+
puts "conoha shutdown #{server_id_cache}"
|
92
|
+
Conoha.shutdown server_id_cache
|
93
|
+
name = ARGV[1]
|
94
|
+
loop do
|
95
|
+
sleep 60
|
96
|
+
puts "conoha imagecreate #{server_id_cache} #{name}"
|
97
|
+
result = Conoha.create_image server_id_cache, name
|
98
|
+
break if result == 'OK'
|
99
|
+
puts '# Error! Retry after 60 seconds...'
|
100
|
+
end
|
101
|
+
puts '# OK!'
|
102
|
+
loop do
|
103
|
+
sleep 60
|
104
|
+
puts "conoha delete #{server_id_cache}"
|
105
|
+
result = Conoha.delete server_id_cache
|
106
|
+
break if result == 'OK'
|
107
|
+
puts '# Error! Retry after 60 seconds...'
|
108
|
+
end
|
109
|
+
puts '# OK!'
|
88
110
|
else
|
89
111
|
STDERR.puts 'Error'
|
90
112
|
end
|
data/lib/conoha.rb
CHANGED
@@ -168,7 +168,6 @@ EOS
|
|
168
168
|
end
|
169
169
|
|
170
170
|
def self.authtoken
|
171
|
-
# @@authtoken || (authenticate!; @@authtoken)
|
172
171
|
@@authtoken
|
173
172
|
end
|
174
173
|
|
@@ -219,6 +218,6 @@ EOS
|
|
219
218
|
end
|
220
219
|
|
221
220
|
def self.randstr
|
222
|
-
['0'..'9',
|
221
|
+
(1..60).map{['0'..'9','a'..'z','A'..'Z'].map(&:to_a).flatten.sample}.join
|
223
222
|
end
|
224
223
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
class Conoha
|
4
|
+
class Config
|
5
|
+
attr_reader :username, :password, :tenant_id, :public_key, :authtoken
|
6
|
+
|
7
|
+
class Error < StandardError
|
8
|
+
end
|
9
|
+
|
10
|
+
def load_from_yaml!(yaml_str)
|
11
|
+
loaded = YAML.load yaml_str
|
12
|
+
raise Error.new unless loaded.is_a? Hash
|
13
|
+
end
|
14
|
+
|
15
|
+
def load_from_json!(json_str)
|
16
|
+
parsed = JSON.parse json_str
|
17
|
+
raise Error.new unless parsed.is_a? Hash
|
18
|
+
@username = parsed["username"]
|
19
|
+
@password = parsed["password"]
|
20
|
+
@tenant_id = parsed["tenant_id"]
|
21
|
+
@public_key = parsed["public_key"]
|
22
|
+
@authtoken = parsed["authtoken"]
|
23
|
+
end
|
24
|
+
|
25
|
+
def authtoken=(authtoken)
|
26
|
+
@authtoken = authtoken
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/conoha/util.rb
CHANGED
@@ -18,7 +18,9 @@ end
|
|
18
18
|
# @return [Net::HTTPResponse]
|
19
19
|
# @params [String] uri_string URI string
|
20
20
|
# @params [Hash] payload HTTP request body
|
21
|
-
# @params [String] authtoken
|
21
|
+
# @params [String|nil] authtoken
|
22
|
+
# Authtoken string or `nil`.
|
23
|
+
# Can pass `nil` only on authenticating with username and password.
|
22
24
|
def https_post(uri_string, payload, authtoken)
|
23
25
|
uri = URI.parse uri_string
|
24
26
|
https = Net::HTTP.new(uri.host, uri.port)
|
data/lib/conoha/version.rb
CHANGED
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.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ka
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10
|
11
|
+
date: 2015-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- conoha.gemspec
|
115
115
|
- exe/conoha
|
116
116
|
- lib/conoha.rb
|
117
|
+
- lib/conoha/config.rb
|
117
118
|
- lib/conoha/util.rb
|
118
119
|
- lib/conoha/version.rb
|
119
120
|
homepage: https://github.com/kaosf/conoha
|