conoha 0.7.1 → 0.7.2

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
2
  SHA1:
3
- metadata.gz: 86401af3bb5aaeb5e9b71e3ae19eb3a6a33d4344
4
- data.tar.gz: 2756ef14e55555aef3a094562c694f4758a5c832
3
+ metadata.gz: 3ab3ff94a231bbb1a106e9be65d7b409742c7032
4
+ data.tar.gz: c24d9fddfbc25952b0032dc2d747edd51a6fc1eb
5
5
  SHA512:
6
- metadata.gz: a3d53106aa8dcf543e98ab26769ed7a9d6d18a1739d843b3abdf72c87964d20d5c6cb360590faee601b5613df284b517dee12536b1349a3fea229a522eba38fd
7
- data.tar.gz: eeebdee5db059fb9e77e0cc52450a138ad52cddd2377c17ca1148001ec3a1dda32cddedc3a55a0bbab288b3048f8102ac114adffcc04fc36b542cf6fe0d6fe8b
6
+ metadata.gz: 5d1d48a1c8ebdb485454b41eb9fd54b0e21adc3fa6c67dbf219def62ce836311f56d07b0e0e8339408e5b2d89adcd9b870a2fd4e7ace1afd21f5963a42a7e258
7
+ data.tar.gz: f7638572a90b3fe49882fd97b3148cddf37e80ef5543e1aec23baa0346dbc30b9832c51db6abe79704bad769bbb8eda7c5768722cbd3d41c843f9f092a9b62b5
@@ -1,7 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
4
- - 2.1.7
5
3
  - 2.2.3
6
4
  - 2.3.0
5
+ - 2.3.1
7
6
  before_install: gem install bundler -v 1.11.2
data/Guardfile CHANGED
@@ -1,15 +1,7 @@
1
1
  # vim: ft=ruby
2
2
 
3
- # @param [String] m1 e.g. 'foo/bar/a' when the matched string is 'lib/foo/bar/a.rb'
4
- # @return [String] e.g. 'test/foo/bar/test_a.rb' when m1 is 'foo/bar/a'
5
- def lib2test(m1)
6
- "test/#{File.dirname m1}/test_#{File.basename m1}.rb"
7
- end
8
-
9
3
  guard :minitest do
10
- watch('test/test_helper.rb') { 'test' }
11
- watch('test/test_conoha.rb')
12
- watch('lib/conoha.rb') { 'test/test_conoha.rb' }
13
- watch(%r{^test/.+\/test_.+\.rb$})
14
- watch(%r{^lib/(.+)\.rb$}) { |m| lib2test m[1] }
4
+ watch(%r{^test/(.*)\/?test_(.*)\.rb$})
5
+ watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
6
+ watch(%r{^test/test_helper\.rb$}) { 'test' }
15
7
  end
@@ -1,4 +1,4 @@
1
- Copyright (c) 2015 ka
1
+ Copyright (c) 2015-2016 ka
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -73,6 +73,9 @@ conoha shutdown 01234567-89ab-cdef-0123-456789abcdef
73
73
  # Boot VPS
74
74
  conoha boot 01234567-89ab-cdef-0123-456789abcdef
75
75
 
76
+ # Rebuild (Re-install the OS)
77
+ conoha rebuild 01234567-89ab-cdef-0123-456789abcdef ubuntu
78
+
76
79
  # Delte VPS
77
80
  conoha delete 01234567-89ab-cdef-0123-456789abcdef
78
81
 
@@ -170,6 +173,4 @@ conoharant destroy
170
173
 
171
174
  ## License
172
175
 
173
- [MIT](http://opensource.org/licenses/MIT)
174
-
175
- Copyright (C) 2015-2016 ka
176
+ [MIT](LICENSE.txt)
data/exe/conoha CHANGED
@@ -57,6 +57,9 @@ when 'create'
57
57
  STDERR.puts e.to_s
58
58
  exit 1
59
59
  end
60
+ when 'rebuild'
61
+ exit 1 if ARGV.size != 2
62
+ puts Conoha.rebuild *ARGV
60
63
  when 'delete'
61
64
  exit 1 if ARGV.size != 1
62
65
  puts Conoha.delete server_id(ARGV.first)
@@ -44,16 +44,26 @@ class Conoha
44
44
  imageRef: image_ref_from_os(os),
45
45
  flavorRef: flavor_ref(ram),
46
46
  key_name: public_key,
47
- security_groups: [
48
- {name: 'default'},
49
- {name: 'gncs-ipv4-all'}
50
- ]
47
+ security_groups: [{name: 'default'}, {name: 'gncs-ipv4-all'}],
51
48
  }
52
49
  }
53
50
  res = https_post uri, payload, authtoken
54
51
  JSON.parse(res.body)["server"]["id"]
55
52
  end
56
53
 
54
+ def self.rebuild(server_id, os)
55
+ uri = "https://compute.tyo1.conoha.io/v2/#{tenant_id}/servers/#{server_id}/action"
56
+ payload = {
57
+ rebuild: {
58
+ imageRef: image_ref_from_os(os),
59
+ adminPass: randstr,
60
+ key_name: public_key
61
+ }
62
+ }
63
+ res = https_post uri, payload, authtoken
64
+ res.code == '202' ? 'OK' : 'Error'
65
+ end
66
+
57
67
  def self.delete(server_id)
58
68
  uri = "https://compute.tyo1.conoha.io/v2/#{tenant_id}/servers/#{server_id}"
59
69
  res = https_delete uri, authtoken
@@ -113,10 +123,7 @@ class Conoha
113
123
  imageRef: image_ref,
114
124
  flavorRef: flavor_ref(ram),
115
125
  key_name: public_key,
116
- security_groups: [
117
- {name: 'default'},
118
- {name: 'gncs-ipv4-all'}
119
- ]
126
+ security_groups: [{name: 'default'}, {name: 'gncs-ipv4-all'}],
120
127
  }
121
128
  }
122
129
  res = https_post uri, payload, authtoken
@@ -63,7 +63,7 @@ end
63
63
 
64
64
  # @return [String] UUID of image
65
65
  # @params [String] os OS name
66
- # @raise [StandardError] When the OS name isn't be contained.
66
+ # @raise [StandardError] When the OS name isn't contained.
67
67
  def image_ref_from_os(os)
68
68
  dictionary = {
69
69
  'ubuntu' => '793be3e1-3c33-4ab3-9779-f4098ea90eb5', # Ubuntu 14.04 amd64
@@ -73,6 +73,36 @@ def image_ref_from_os(os)
73
73
  'centos72' => 'e141fc06-632e-42a9-9c2d-eec9201427ec', # CentOS 7.2
74
74
  'arch' => 'f5e5b475-ebec-4973-99c7-bc8add5d16c4', # Arch
75
75
  }
76
+ if dictionary.keys.include? os
77
+ dictionary[os]
78
+ else
79
+ raise StandardError.new <<EOS
80
+ "#{os}" doesn't exist.
81
+ Select os name from the following list:
82
+
83
+ #{dictionary.keys.join("\n")}
84
+ EOS
85
+ end
86
+ end
87
+
88
+ # @return [String] Image name tag
89
+ # @params [String] os OS name
90
+ # @raise [StandardError] When the OS name isn't included in the dictionary.
91
+ def image_tag_dictionary(os)
92
+ dictionary = {
93
+ 'ubuntu' => 'vmi-ubuntu-14.04-amd64', # Ubuntu 14.04 amd64
94
+ 'debian' => 'vmi-debian-8-amd64', # Debian 8 amd64
95
+ 'fedora23' => 'vmi-fedora-23-amd64', # Fedora 23 amd64
96
+ 'centos67' => 'vmi-centos-6.7-amd64', # CentOS 6.7
97
+ 'centos72' => 'vmi-centos-7.2-amd64', # CentOS 7.2
98
+ 'arch' => 'vmi-arch-amd64', # Arch
99
+ }
100
+
101
+ # 'opensuse' => 'vmi-opensuse-42.1-amd64' # openSUSE
102
+ # 'openbsd' => 'vmi-openbsd-5.8-amd64', # OpenBSD
103
+ # 'netbsd' => 'vmi-netbsd-7.0-amd64', # NetBSD
104
+ # 'freebsd' => 'vmi-freebsd-10.1-x86_64', # FreeBSD
105
+
76
106
  if dictionary.keys.include? os
77
107
  dictionary[os]
78
108
  else
@@ -1,3 +1,3 @@
1
1
  module ConohaVersion
2
- ITSELF = "0.7.1"
2
+ ITSELF = "0.7.2"
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.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ka
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-28 00:00:00.000000000 Z
11
+ date: 2016-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -144,4 +144,3 @@ signing_key:
144
144
  specification_version: 4
145
145
  summary: ConoHa VPS CLI Tool
146
146
  test_files: []
147
- has_rdoc: