tengine_resource 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/Gemfile.lock +67 -41
- data/bin/tengine_resource +8 -0
- data/lib/tengine/resource.rb +4 -0
- data/lib/tengine/resource/cli.rb +16 -0
- data/lib/tengine/resource/cli/credential.rb +65 -0
- data/lib/tengine/resource/cli/global_options.rb +47 -0
- data/lib/tengine/resource/cli/options.rb +10 -0
- data/lib/tengine/resource/cli/server.rb +64 -0
- data/lib/tengine/resource/provider.rb +15 -0
- data/lib/tengine/resource/server.rb +2 -1
- data/spec/fixtures/example_fixtures1.rb +118 -0
- metadata +100 -47
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZDJmNWU1OTMyMDcyZDZjMzk4MGU4ZTE2MWNjODFlNTZlMGRhMmIyYg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NGJkMDk0ZTY2ZDNjN2YzN2U3NTE5YjRhNDc1MGFlN2I1NjI0NjkwOQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZGU1Y2Y0MTVhYTczMTI4OGNhNWM3MjQzYmIxMDhmNTY2ZDQ5ZmUxOTFkMDMy
|
10
|
+
OTRkMmJjMDdkMGE4YTMwMjUyZDgwOTNkODgxMTk3OGZiODhmNmJkOGNhNGJh
|
11
|
+
M2ZlODQzNDQzZDUxZDQyZjBhMGYwNzVjZjI1Mzc4ZjJjNmYwMzg=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
Mjc4OTM3MTNhNDgxNzBkNTNjZDg4YWUzYzNkM2E2OTAxOTg3ZTE2ZTY0MDc5
|
14
|
+
YjdiNTVmMDMwMGFiN2ZmZjcwMDU0YTExZWNkMzgxZjYyOGFmNTEwMmE4OGEz
|
15
|
+
MzE5YWFjMWRiNWIyZjFhMDM3MTY0Y2I3NGQ1ZjllOWQ4ODQyNzU=
|
data/Gemfile.lock
CHANGED
@@ -1,49 +1,69 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
tengine_resource (1.
|
4
|
+
tengine_resource (1.2.0)
|
5
5
|
net-ssh (~> 2.5.2)
|
6
|
-
tengine_core (~> 1.
|
7
|
-
tengine_support (~> 1.
|
6
|
+
tengine_core (~> 1.2.0)
|
7
|
+
tengine_support (~> 1.2.0)
|
8
|
+
text-table (~> 1.2.2)
|
9
|
+
thor (>= 0.14.6)
|
8
10
|
|
9
11
|
GEM
|
10
12
|
remote: http://rubygems.org/
|
11
13
|
specs:
|
12
|
-
ZenTest (4.
|
13
|
-
activemodel (3.2.
|
14
|
-
activesupport (= 3.2.
|
14
|
+
ZenTest (4.9.1)
|
15
|
+
activemodel (3.2.12)
|
16
|
+
activesupport (= 3.2.12)
|
15
17
|
builder (~> 3.0.0)
|
16
|
-
activesupport (3.2.
|
18
|
+
activesupport (3.2.12)
|
17
19
|
i18n (~> 0.6)
|
18
20
|
multi_json (~> 1.0)
|
19
|
-
amq-client (0.
|
20
|
-
amq-protocol (>=
|
21
|
+
amq-client (0.9.12)
|
22
|
+
amq-protocol (>= 1.2.0)
|
21
23
|
eventmachine
|
22
|
-
amq-protocol (
|
23
|
-
amqp (0.
|
24
|
-
amq-client (~> 0.
|
25
|
-
amq-protocol (~>
|
24
|
+
amq-protocol (1.2.0)
|
25
|
+
amqp (0.9.10)
|
26
|
+
amq-client (~> 0.9.12)
|
27
|
+
amq-protocol (~> 1.2.0)
|
26
28
|
eventmachine
|
27
29
|
autotest (4.4.6)
|
28
30
|
ZenTest (>= 4.4.1)
|
29
31
|
builder (3.0.4)
|
32
|
+
coderay (1.0.9)
|
33
|
+
columnize (0.3.6)
|
30
34
|
daemons (1.1.9)
|
35
|
+
debugger (1.5.0)
|
36
|
+
columnize (>= 0.3.1)
|
37
|
+
debugger-linecache (~> 1.2.0)
|
38
|
+
debugger-ruby_core_source (~> 1.2.0)
|
39
|
+
debugger-linecache (1.2.0)
|
40
|
+
debugger-ruby_core_source (1.2.0)
|
31
41
|
diff-lcs (1.1.3)
|
32
|
-
eventmachine (1.0.
|
33
|
-
i18n (0.6.
|
42
|
+
eventmachine (1.0.3)
|
43
|
+
i18n (0.6.4)
|
34
44
|
macaddr (1.6.1)
|
35
45
|
systemu (~> 2.5.0)
|
36
|
-
|
37
|
-
|
38
|
-
|
46
|
+
method_source (0.8.1)
|
47
|
+
mongoid (3.1.3)
|
48
|
+
activemodel (~> 3.2)
|
49
|
+
moped (~> 1.4.2)
|
39
50
|
origin (~> 1.0)
|
40
51
|
tzinfo (~> 0.3.22)
|
41
|
-
moped (1.
|
42
|
-
multi_json (1.
|
52
|
+
moped (1.4.5)
|
53
|
+
multi_json (1.7.2)
|
43
54
|
net-ssh (2.5.2)
|
44
|
-
origin (1.0
|
45
|
-
|
46
|
-
|
55
|
+
origin (1.1.0)
|
56
|
+
pry (0.9.12.1)
|
57
|
+
coderay (~> 1.0.5)
|
58
|
+
method_source (~> 0.8)
|
59
|
+
slop (~> 3.4)
|
60
|
+
pry-debugger (0.2.2)
|
61
|
+
debugger (~> 1.3)
|
62
|
+
pry (~> 0.9.10)
|
63
|
+
pry-doc (0.4.5)
|
64
|
+
pry (>= 0.9)
|
65
|
+
yard (>= 0.8)
|
66
|
+
rake (10.0.4)
|
47
67
|
rspec (2.10.0)
|
48
68
|
rspec-core (~> 2.10.0)
|
49
69
|
rspec-expectations (~> 2.10.0)
|
@@ -54,40 +74,46 @@ GEM
|
|
54
74
|
rspec-mocks (2.10.1)
|
55
75
|
selectable_attr (0.3.17)
|
56
76
|
i18n
|
57
|
-
simplecov (0.
|
77
|
+
simplecov (0.7.1)
|
58
78
|
multi_json (~> 1.0)
|
59
|
-
simplecov-html (~> 0.
|
60
|
-
simplecov-html (0.
|
79
|
+
simplecov-html (~> 0.7.1)
|
80
|
+
simplecov-html (0.7.1)
|
81
|
+
slop (3.4.4)
|
61
82
|
systemu (2.5.2)
|
62
|
-
tengine_core (1.
|
83
|
+
tengine_core (1.2.0)
|
63
84
|
activemodel (>= 3.1.0)
|
64
85
|
activesupport (>= 3.1.0)
|
65
86
|
daemons (~> 1.1.4)
|
66
|
-
mongoid (
|
87
|
+
mongoid (>= 3.0.22)
|
67
88
|
selectable_attr (~> 0.3.15)
|
68
|
-
tengine_event (~> 1.
|
69
|
-
tengine_support (~> 1.
|
70
|
-
tengine_event (1.
|
89
|
+
tengine_event (~> 1.2.0)
|
90
|
+
tengine_support (~> 1.2.0)
|
91
|
+
tengine_event (1.2.0)
|
71
92
|
activesupport (>= 3.0.0)
|
72
|
-
amqp (~> 0.
|
73
|
-
tengine_support (~> 1.
|
93
|
+
amqp (~> 0.9.10)
|
94
|
+
tengine_support (~> 1.2.0)
|
74
95
|
uuid (~> 2.3.4)
|
75
|
-
tengine_support (1.
|
96
|
+
tengine_support (1.2.0)
|
76
97
|
activesupport (>= 3.0.0)
|
77
|
-
|
78
|
-
|
98
|
+
text-table (1.2.3)
|
99
|
+
thor (0.18.1)
|
100
|
+
tzinfo (0.3.37)
|
101
|
+
uuid (2.3.7)
|
79
102
|
macaddr (~> 1.0)
|
80
|
-
yard (0.8.
|
103
|
+
yard (0.8.6.1)
|
81
104
|
|
82
105
|
PLATFORMS
|
83
106
|
ruby
|
84
107
|
|
85
108
|
DEPENDENCIES
|
109
|
+
ZenTest (~> 4.9.0)
|
86
110
|
autotest
|
87
111
|
bundler
|
88
|
-
|
89
|
-
|
112
|
+
pry
|
113
|
+
pry-debugger
|
114
|
+
pry-doc
|
115
|
+
rake
|
90
116
|
rspec (~> 2.10.0)
|
91
|
-
simplecov
|
117
|
+
simplecov
|
92
118
|
tengine_resource!
|
93
|
-
yard
|
119
|
+
yard
|
data/lib/tengine/resource.rb
CHANGED
@@ -17,6 +17,10 @@ module Tengine::Resource
|
|
17
17
|
autoload :Watcher , 'tengine/resource/watcher'
|
18
18
|
autoload :Config , 'tengine/resource/config'
|
19
19
|
|
20
|
+
# 定数を参照した際にrequireしないように、明示的にrequireすることにしてあります。
|
21
|
+
# データ操作のためのコマンドラインインタフェース
|
22
|
+
# autoload :CLI , 'tengine/resource/cli'
|
23
|
+
|
20
24
|
def self.notify ctx, msg
|
21
25
|
# called from tengine_core/lib/tengine/core/plugins.rb
|
22
26
|
case msg when :after___evalate__
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'tengine/resource'
|
3
|
+
|
4
|
+
require 'thor'
|
5
|
+
require 'thor/group'
|
6
|
+
|
7
|
+
class Tengine::Resource::CLI < Thor
|
8
|
+
autoload :GlobalOptions, 'tengine/resource/cli/global_options'
|
9
|
+
autoload :Options , 'tengine/resource/cli/options'
|
10
|
+
|
11
|
+
autoload :Server , 'tengine/resource/cli/server'
|
12
|
+
autoload :Credential , 'tengine/resource/cli/credential'
|
13
|
+
|
14
|
+
register(Server , 'server' , 'server <command>' , 'Description.')
|
15
|
+
register(Credential, 'credential', 'credential <command>', 'Description.')
|
16
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'tengine/resource/cli'
|
3
|
+
|
4
|
+
class Tengine::Resource::CLI::Credential < Thor
|
5
|
+
include Tengine::Resource::CLI::GlobalOptions
|
6
|
+
include Tengine::Resource::CLI::Options
|
7
|
+
|
8
|
+
desc "list", "list credentials"
|
9
|
+
method_option :sort, type: :string, aliases: '-s', desc: "sort pattern. name, created_at and updated_at", default: "name"
|
10
|
+
def list(*args)
|
11
|
+
opts = merge_options(args, options)
|
12
|
+
config_mongoid
|
13
|
+
require 'text-table'
|
14
|
+
res = [%w[name auth_values created_at updated_at]]
|
15
|
+
sort_options = {(opts[:sort] || "name").to_sym => 1}
|
16
|
+
sort_options[:name] = 1 # 同じ時刻などのソートキーが決まらない場合を想定して名前もソートキーに入れる
|
17
|
+
Tengine::Resource::Credential.all.order_by(sort_options).each do |credential|
|
18
|
+
res << [
|
19
|
+
credential.name,
|
20
|
+
credential.auth_values.to_json,
|
21
|
+
credential.created_at.iso8601,
|
22
|
+
credential.updated_at.iso8601,
|
23
|
+
]
|
24
|
+
end
|
25
|
+
$stdout.puts res.to_table(:first_row_is_head => true)
|
26
|
+
res
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "add [name]", "add credential"
|
30
|
+
method_option :username , type: :string, aliases: '-u', desc: "username to login" # , required: true
|
31
|
+
method_option :password , type: :string, aliases: '-p', desc: "password"
|
32
|
+
method_option :private_key_file, type: :string, aliases: '-k', desc: "private key filepath. ex. ~/.ssh/id_rsa"
|
33
|
+
method_option :passphrase , type: :string, aliases: '-P', desc: "passphrase for private key"
|
34
|
+
def add(name, *args)
|
35
|
+
opts = merge_options(args, options)
|
36
|
+
config_mongoid
|
37
|
+
auth_type_key = !opts[:password].blank? ? :ssh_password :
|
38
|
+
!opts[:private_key_file].blank? ? :ssh_public_key_file :
|
39
|
+
(raise "password or private_key_file is required")
|
40
|
+
auth_values = { username: opts[:username] }
|
41
|
+
[:password, :private_key_file, :passphrase].each do |k|
|
42
|
+
if v = opts[k]
|
43
|
+
auth_values[k] = v
|
44
|
+
end
|
45
|
+
end
|
46
|
+
credential = Tengine::Resource::Credential.create!({
|
47
|
+
name: name,
|
48
|
+
auth_type_key: auth_type_key,
|
49
|
+
auth_values: auth_values
|
50
|
+
})
|
51
|
+
$stdout.puts "credential created successfully!: #{credential.to_json}"
|
52
|
+
end
|
53
|
+
|
54
|
+
desc "remove", "remove credential manually by using [name]"
|
55
|
+
def remove(name)
|
56
|
+
config_mongoid
|
57
|
+
if credential = Tengine::Resource::Credential.where({name: name}).first
|
58
|
+
credential.destroy
|
59
|
+
$stdout.puts "credential was destroyed successfully!: #{name}"
|
60
|
+
else
|
61
|
+
raise Mongoid::Errors::DocumentNotFound, "credential \"#{name}\" not found"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'tengine/resource/cli'
|
3
|
+
|
4
|
+
module Tengine::Resource::CLI::GlobalOptions
|
5
|
+
|
6
|
+
def self.included(mod)
|
7
|
+
mod.extend(ClassMethods)
|
8
|
+
end
|
9
|
+
|
10
|
+
def load_config
|
11
|
+
require 'tengine_resource'
|
12
|
+
@config = Tengine::Resource::Config::Resource.new.tap do |c|
|
13
|
+
if path = options[:config]
|
14
|
+
c.load_file(path)
|
15
|
+
else
|
16
|
+
c.load({:db => Tengine::Core::Config::DB::DEFAULT_SETTINGS})
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def config_mongoid
|
22
|
+
load_config
|
23
|
+
require 'mongoid'
|
24
|
+
Mongoid.configure do |c|
|
25
|
+
c.send :load_configuration, @config[:db]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
module ClassMethods
|
30
|
+
def self.extended(obj)
|
31
|
+
obj.instance_eval do
|
32
|
+
alias :desc_without_global_options :desc
|
33
|
+
alias :desc :desc_with_global_options
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def desc_with_global_options(*args, &block)
|
38
|
+
res = desc_without_global_options(*args, &block)
|
39
|
+
config_file
|
40
|
+
res
|
41
|
+
end
|
42
|
+
|
43
|
+
def config_file
|
44
|
+
method_option :config, :type => :string, :aliases => "-f", :desc => "config to connect MongoDB as same as tengine_resource_watcher's config"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'tengine/resource/cli'
|
2
|
+
require 'active_support/core_ext/hash/keys'
|
3
|
+
|
4
|
+
module Tengine::Resource::CLI::Options
|
5
|
+
def merge_options(args, options)
|
6
|
+
opts = args.last.is_a?(Hash) ? args.pop : {}
|
7
|
+
opts = opts.symbolize_keys
|
8
|
+
opts.merge(options.to_hash.symbolize_keys)
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'tengine/resource/cli'
|
3
|
+
require 'active_support/core_ext/hash/keys'
|
4
|
+
|
5
|
+
class Tengine::Resource::CLI::Server < Thor
|
6
|
+
include Tengine::Resource::CLI::GlobalOptions
|
7
|
+
include Tengine::Resource::CLI::Options
|
8
|
+
|
9
|
+
desc "list", "list servers"
|
10
|
+
method_option :sort, type: :string, aliases: '-s', desc: "sort pattern. name, created_at and updated_at", default: "name"
|
11
|
+
def list(*args)
|
12
|
+
opts = merge_options(args, options)
|
13
|
+
config_mongoid
|
14
|
+
require 'text-table'
|
15
|
+
res = [%w[provider virtual? name status addresses created_at updated_at]]
|
16
|
+
sort_options = {(opts[:sort] || "name").to_sym => 1}
|
17
|
+
sort_options[:name] = 1 # 同じ時刻などのソートキーが決まらない場合を想定して名前もソートキーに入れる
|
18
|
+
Tengine::Resource::Server.all.order_by(sort_options).each do |server|
|
19
|
+
res << [
|
20
|
+
server.provider ? server.provider.name : "-",
|
21
|
+
server.is_a?(Tengine::Resource::VirtualServer) ? "virtual" : "physical",
|
22
|
+
server.name,
|
23
|
+
server.status,
|
24
|
+
server.addresses.to_json,
|
25
|
+
server.created_at.iso8601,
|
26
|
+
server.updated_at.iso8601,
|
27
|
+
]
|
28
|
+
end
|
29
|
+
$stdout.puts res.to_table(:first_row_is_head => true)
|
30
|
+
res
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "add [name]", "add server"
|
34
|
+
method_option :addresses , type: :hash, aliases: '-a', desc: "ip addesses and hostnames like 'private_ip_address:192.168.1.10,private_dns_name:i-12345'"
|
35
|
+
method_option :properties, type: :hash, aliases: '-p', desc: "any properties"
|
36
|
+
# def add(name, options = {})
|
37
|
+
def add(name, *args)
|
38
|
+
opts = merge_options(args, options)
|
39
|
+
config_mongoid
|
40
|
+
Tengine::Resource::Provider.manual.tap do |provider|
|
41
|
+
server = provider.physical_servers.create!({
|
42
|
+
name: name,
|
43
|
+
provided_id: name,
|
44
|
+
addresses: opts[:addresses] || {},
|
45
|
+
properties: opts[:properties] || {}
|
46
|
+
})
|
47
|
+
$stdout.puts "server created successfully!: #{server.to_json}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
desc "remove", "remove server manually by using [name]"
|
52
|
+
def remove(name)
|
53
|
+
config_mongoid
|
54
|
+
Tengine::Resource::Provider.manual.tap do |provider|
|
55
|
+
if server = provider.physical_servers.where({name: name}).first
|
56
|
+
server.destroy
|
57
|
+
$stdout.puts "server was destroyed successfully!: #{name}"
|
58
|
+
else
|
59
|
+
raise "server \"#{name}\" not found under provider \"#{provider.name}\""
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -4,6 +4,7 @@ require 'mongoid'
|
|
4
4
|
class Tengine::Resource::Provider
|
5
5
|
include Mongoid::Document
|
6
6
|
include Mongoid::Timestamps
|
7
|
+
include Tengine::Core::SelectableAttr
|
7
8
|
include Tengine::Core::Validation
|
8
9
|
include Tengine::Core::FindByName
|
9
10
|
|
@@ -14,6 +15,13 @@ class Tengine::Resource::Provider
|
|
14
15
|
field :retry_count, :type => Integer, :default => 30 # プロバイダへの問い合わせリトライ回数
|
15
16
|
field :properties, :type => Hash, :default => {}
|
16
17
|
|
18
|
+
field :type_cd, type: Integer, default: 0
|
19
|
+
|
20
|
+
selectable_attr :type_cd do
|
21
|
+
entry 0, :normal, "Normal"
|
22
|
+
entry 1, :manual_control, "ManualControl"
|
23
|
+
end
|
24
|
+
|
17
25
|
validates :name, :presence => true, :uniqueness => true, :format => BASE_NAME.options
|
18
26
|
index({ name: 1 }, { unique: true })
|
19
27
|
|
@@ -53,6 +61,13 @@ class Tengine::Resource::Provider
|
|
53
61
|
end
|
54
62
|
|
55
63
|
class << self
|
64
|
+
def manual
|
65
|
+
entry = type_entry_by_key(:manual_control)
|
66
|
+
result = self.where({:type_cd => entry.id}).first
|
67
|
+
result ||= self.create!({name: entry.name, type_cd: entry.id})
|
68
|
+
result
|
69
|
+
end
|
70
|
+
|
56
71
|
def find_or_create_by_name!(attrs)
|
57
72
|
result = self.where({:name => attrs[:name]}).first
|
58
73
|
result ||= self.create!(attrs)
|
@@ -41,7 +41,8 @@ class Tengine::Resource::Server
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def hostname_or_ipv4
|
44
|
-
|
44
|
+
addrs = addresses.symbolize_keys
|
45
|
+
address_order.map{|key| addrs[key.to_sym]}.detect{|s| !s.blank?} # nilだけでなく空文字列も考慮する必要があります
|
45
46
|
end
|
46
47
|
|
47
48
|
def hostname_or_ipv4?
|
@@ -0,0 +1,118 @@
|
|
1
|
+
|
2
|
+
module ExampleFixtures1
|
3
|
+
module_function
|
4
|
+
|
5
|
+
def setup_timezone(zone_name = "Tokyo")
|
6
|
+
Time.zone ||= ActiveSupport::TimeZone.new(zone_name)
|
7
|
+
end
|
8
|
+
|
9
|
+
def build
|
10
|
+
setup_timezone
|
11
|
+
Tengine::Resource::Provider.delete_all
|
12
|
+
Tengine::Resource::Server.delete_all
|
13
|
+
Tengine::Resource::Provider.create!({
|
14
|
+
name: "ManualControl",
|
15
|
+
type_key: :manual_control,
|
16
|
+
}).tap do |provider|
|
17
|
+
provider.physical_servers.create!({
|
18
|
+
name: "physical_server_1",
|
19
|
+
addresses: {private_ip_address: "192.168.1.11", private_dns_name: "physical#1"},
|
20
|
+
created_at: Time.zone.parse("2013/01/21 10:00:00"),
|
21
|
+
updated_at: Time.zone.parse("2013/02/03 12:00:00"),
|
22
|
+
}).tap do |server|
|
23
|
+
server.guest_servers.create!({
|
24
|
+
name: "virtual_server_1",
|
25
|
+
provider_id: provider.id,
|
26
|
+
provided_id: "virtual_server_1",
|
27
|
+
addresses: {private_ip_address: "192.168.5.101", private_dns_name: "virtual#1"},
|
28
|
+
created_at: Time.zone.parse("2013/02/01 10:00:00"),
|
29
|
+
updated_at: Time.zone.parse("2013/02/01 12:00:00"),
|
30
|
+
})
|
31
|
+
server.guest_servers.create!({
|
32
|
+
name: "virtual_server_2",
|
33
|
+
provider_id: provider.id,
|
34
|
+
provided_id: "virtual_server_2",
|
35
|
+
addresses: {private_ip_address: "192.168.5.102", private_dns_name: "virtual#2"},
|
36
|
+
created_at: Time.zone.parse("2013/02/01 18:00:00"),
|
37
|
+
updated_at: Time.zone.parse("2013/02/01 18:00:00"),
|
38
|
+
})
|
39
|
+
end
|
40
|
+
provider.physical_servers.create!({
|
41
|
+
name: "physical_server_2",
|
42
|
+
addresses: {private_ip_address: "192.168.1.12", private_dns_name: "physical#2"},
|
43
|
+
created_at: Time.zone.parse("2013/01/31 10:00:00"),
|
44
|
+
updated_at: Time.zone.parse("2013/02/01 12:00:00"),
|
45
|
+
}).tap do |server|
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
Tengine::Resource::Provider.create!({
|
50
|
+
name: "goku_at_ec2_ap-northeast-1",
|
51
|
+
type_key: :normal
|
52
|
+
}).tap do |provider|
|
53
|
+
provider.physical_servers.create!({
|
54
|
+
name: "ap-northeast-1a",
|
55
|
+
provided_id: "ap-northeast-1a",
|
56
|
+
status: "available",
|
57
|
+
created_at: Time.zone.parse("2012/12/31 10:00:00"),
|
58
|
+
updated_at: Time.zone.parse("2013/02/04 10:00:00"),
|
59
|
+
}).tap do |server|
|
60
|
+
server.guest_servers.create!({
|
61
|
+
name: "AWS_Instance_1",
|
62
|
+
provider_id: provider.id,
|
63
|
+
provided_id: "i-12345678",
|
64
|
+
addresses: {
|
65
|
+
private_ip_address: "10.162.153.11",
|
66
|
+
private_dns_name: "ip-10.162.153.11-ap-northeast-1.compute.internal",
|
67
|
+
dns_name: "ec2-184-72-20-11.ap-northeast-1.compute.amazonaws.com",
|
68
|
+
ip_address: "184.72.20.11",
|
69
|
+
},
|
70
|
+
created_at: Time.zone.parse("2013/02/01 10:00:00"),
|
71
|
+
updated_at: Time.zone.parse("2013/02/04 10:00:00"),
|
72
|
+
})
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
def build_credentials
|
79
|
+
setup_timezone
|
80
|
+
Tengine::Resource::Credential.tap do |c|
|
81
|
+
c.delete_all
|
82
|
+
c.create!({name: "ssh_pw1", auth_type_key: :ssh_password,
|
83
|
+
auth_values: {
|
84
|
+
username: "goku",
|
85
|
+
password: "password1",
|
86
|
+
},
|
87
|
+
created_at: Time.zone.parse("2013/02/01 10:00:00"),
|
88
|
+
updated_at: Time.zone.parse("2013/02/04 10:00:00"),
|
89
|
+
})
|
90
|
+
c.create!({name: "ssh_pkf1", auth_type_key: :ssh_public_key_file,
|
91
|
+
auth_values: {
|
92
|
+
username: "gohan",
|
93
|
+
private_key_file: "~/.ssh/id_rsa",
|
94
|
+
passphrase: "passphrase",
|
95
|
+
},
|
96
|
+
created_at: Time.zone.parse("2013/02/01 14:00:00"),
|
97
|
+
updated_at: Time.zone.parse("2013/02/03 12:00:00"),
|
98
|
+
})
|
99
|
+
c.create!({name: "ssh_pw2", auth_type_key: :ssh_password,
|
100
|
+
auth_values: {
|
101
|
+
username: "piccolo",
|
102
|
+
password: "password2",
|
103
|
+
},
|
104
|
+
created_at: Time.zone.parse("2013/02/01 18:00:00"),
|
105
|
+
updated_at: Time.zone.parse("2013/02/04 12:00:00"),
|
106
|
+
})
|
107
|
+
c.create!({name: "ssh_pkf2", auth_type_key: :ssh_public_key_file,
|
108
|
+
auth_values: {
|
109
|
+
username: "yamcha",
|
110
|
+
private_key_file: "~/.ssh/id_rsa",
|
111
|
+
passphrase: "",
|
112
|
+
},
|
113
|
+
created_at: Time.zone.parse("2013/02/03 12:00:00"),
|
114
|
+
updated_at: Time.zone.parse("2013/02/03 12:00:00"),
|
115
|
+
})
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tengine_resource
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.2.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- taigou
|
@@ -14,44 +13,67 @@ authors:
|
|
14
13
|
autorequire:
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
|
-
date:
|
16
|
+
date: 2013-04-30 00:00:00.000000000 Z
|
18
17
|
dependencies:
|
18
|
+
- !ruby/object:Gem::Dependency
|
19
|
+
name: thor
|
20
|
+
requirement: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ! '>='
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.14.6
|
25
|
+
type: :runtime
|
26
|
+
prerelease: false
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ! '>='
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: 0.14.6
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: text-table
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ~>
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 1.2.2
|
39
|
+
type: :runtime
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.2.2
|
19
46
|
- !ruby/object:Gem::Dependency
|
20
47
|
name: tengine_support
|
21
48
|
requirement: !ruby/object:Gem::Requirement
|
22
|
-
none: false
|
23
49
|
requirements:
|
24
50
|
- - ~>
|
25
51
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
52
|
+
version: 1.2.0
|
27
53
|
type: :runtime
|
28
54
|
prerelease: false
|
29
55
|
version_requirements: !ruby/object:Gem::Requirement
|
30
|
-
none: false
|
31
56
|
requirements:
|
32
57
|
- - ~>
|
33
58
|
- !ruby/object:Gem::Version
|
34
|
-
version: 1.
|
59
|
+
version: 1.2.0
|
35
60
|
- !ruby/object:Gem::Dependency
|
36
61
|
name: tengine_core
|
37
62
|
requirement: !ruby/object:Gem::Requirement
|
38
|
-
none: false
|
39
63
|
requirements:
|
40
64
|
- - ~>
|
41
65
|
- !ruby/object:Gem::Version
|
42
|
-
version: 1.
|
66
|
+
version: 1.2.0
|
43
67
|
type: :runtime
|
44
68
|
prerelease: false
|
45
69
|
version_requirements: !ruby/object:Gem::Requirement
|
46
|
-
none: false
|
47
70
|
requirements:
|
48
71
|
- - ~>
|
49
72
|
- !ruby/object:Gem::Version
|
50
|
-
version: 1.
|
73
|
+
version: 1.2.0
|
51
74
|
- !ruby/object:Gem::Dependency
|
52
75
|
name: net-ssh
|
53
76
|
requirement: !ruby/object:Gem::Requirement
|
54
|
-
none: false
|
55
77
|
requirements:
|
56
78
|
- - ~>
|
57
79
|
- !ruby/object:Gem::Version
|
@@ -59,7 +81,6 @@ dependencies:
|
|
59
81
|
type: :runtime
|
60
82
|
prerelease: false
|
61
83
|
version_requirements: !ruby/object:Gem::Requirement
|
62
|
-
none: false
|
63
84
|
requirements:
|
64
85
|
- - ~>
|
65
86
|
- !ruby/object:Gem::Version
|
@@ -67,7 +88,6 @@ dependencies:
|
|
67
88
|
- !ruby/object:Gem::Dependency
|
68
89
|
name: bundler
|
69
90
|
requirement: !ruby/object:Gem::Requirement
|
70
|
-
none: false
|
71
91
|
requirements:
|
72
92
|
- - ! '>='
|
73
93
|
- !ruby/object:Gem::Version
|
@@ -75,7 +95,6 @@ dependencies:
|
|
75
95
|
type: :development
|
76
96
|
prerelease: false
|
77
97
|
version_requirements: !ruby/object:Gem::Requirement
|
78
|
-
none: false
|
79
98
|
requirements:
|
80
99
|
- - ! '>='
|
81
100
|
- !ruby/object:Gem::Version
|
@@ -83,23 +102,20 @@ dependencies:
|
|
83
102
|
- !ruby/object:Gem::Dependency
|
84
103
|
name: rake
|
85
104
|
requirement: !ruby/object:Gem::Requirement
|
86
|
-
none: false
|
87
105
|
requirements:
|
88
|
-
- -
|
106
|
+
- - ! '>='
|
89
107
|
- !ruby/object:Gem::Version
|
90
|
-
version: 0
|
108
|
+
version: '0'
|
91
109
|
type: :development
|
92
110
|
prerelease: false
|
93
111
|
version_requirements: !ruby/object:Gem::Requirement
|
94
|
-
none: false
|
95
112
|
requirements:
|
96
|
-
- -
|
113
|
+
- - ! '>='
|
97
114
|
- !ruby/object:Gem::Version
|
98
|
-
version: 0
|
115
|
+
version: '0'
|
99
116
|
- !ruby/object:Gem::Dependency
|
100
117
|
name: rspec
|
101
118
|
requirement: !ruby/object:Gem::Requirement
|
102
|
-
none: false
|
103
119
|
requirements:
|
104
120
|
- - ~>
|
105
121
|
- !ruby/object:Gem::Version
|
@@ -107,7 +123,6 @@ dependencies:
|
|
107
123
|
type: :development
|
108
124
|
prerelease: false
|
109
125
|
version_requirements: !ruby/object:Gem::Requirement
|
110
|
-
none: false
|
111
126
|
requirements:
|
112
127
|
- - ~>
|
113
128
|
- !ruby/object:Gem::Version
|
@@ -115,39 +130,34 @@ dependencies:
|
|
115
130
|
- !ruby/object:Gem::Dependency
|
116
131
|
name: yard
|
117
132
|
requirement: !ruby/object:Gem::Requirement
|
118
|
-
none: false
|
119
133
|
requirements:
|
120
|
-
- -
|
134
|
+
- - ! '>='
|
121
135
|
- !ruby/object:Gem::Version
|
122
|
-
version: 0
|
136
|
+
version: '0'
|
123
137
|
type: :development
|
124
138
|
prerelease: false
|
125
139
|
version_requirements: !ruby/object:Gem::Requirement
|
126
|
-
none: false
|
127
140
|
requirements:
|
128
|
-
- -
|
141
|
+
- - ! '>='
|
129
142
|
- !ruby/object:Gem::Version
|
130
|
-
version: 0
|
143
|
+
version: '0'
|
131
144
|
- !ruby/object:Gem::Dependency
|
132
145
|
name: simplecov
|
133
146
|
requirement: !ruby/object:Gem::Requirement
|
134
|
-
none: false
|
135
147
|
requirements:
|
136
|
-
- -
|
148
|
+
- - ! '>='
|
137
149
|
- !ruby/object:Gem::Version
|
138
|
-
version: 0
|
150
|
+
version: '0'
|
139
151
|
type: :development
|
140
152
|
prerelease: false
|
141
153
|
version_requirements: !ruby/object:Gem::Requirement
|
142
|
-
none: false
|
143
154
|
requirements:
|
144
|
-
- -
|
155
|
+
- - ! '>='
|
145
156
|
- !ruby/object:Gem::Version
|
146
|
-
version: 0
|
157
|
+
version: '0'
|
147
158
|
- !ruby/object:Gem::Dependency
|
148
159
|
name: autotest
|
149
160
|
requirement: !ruby/object:Gem::Requirement
|
150
|
-
none: false
|
151
161
|
requirements:
|
152
162
|
- - ! '>='
|
153
163
|
- !ruby/object:Gem::Version
|
@@ -155,15 +165,41 @@ dependencies:
|
|
155
165
|
type: :development
|
156
166
|
prerelease: false
|
157
167
|
version_requirements: !ruby/object:Gem::Requirement
|
158
|
-
none: false
|
159
168
|
requirements:
|
160
169
|
- - ! '>='
|
161
170
|
- !ruby/object:Gem::Version
|
162
171
|
version: '0'
|
163
172
|
- !ruby/object:Gem::Dependency
|
164
|
-
name:
|
173
|
+
name: pry
|
174
|
+
requirement: !ruby/object:Gem::Requirement
|
175
|
+
requirements:
|
176
|
+
- - ! '>='
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '0'
|
179
|
+
type: :development
|
180
|
+
prerelease: false
|
181
|
+
version_requirements: !ruby/object:Gem::Requirement
|
182
|
+
requirements:
|
183
|
+
- - ! '>='
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
version: '0'
|
186
|
+
- !ruby/object:Gem::Dependency
|
187
|
+
name: pry-doc
|
188
|
+
requirement: !ruby/object:Gem::Requirement
|
189
|
+
requirements:
|
190
|
+
- - ! '>='
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: '0'
|
193
|
+
type: :development
|
194
|
+
prerelease: false
|
195
|
+
version_requirements: !ruby/object:Gem::Requirement
|
196
|
+
requirements:
|
197
|
+
- - ! '>='
|
198
|
+
- !ruby/object:Gem::Version
|
199
|
+
version: '0'
|
200
|
+
- !ruby/object:Gem::Dependency
|
201
|
+
name: pry-debugger
|
165
202
|
requirement: !ruby/object:Gem::Requirement
|
166
|
-
none: false
|
167
203
|
requirements:
|
168
204
|
- - ! '>='
|
169
205
|
- !ruby/object:Gem::Version
|
@@ -171,16 +207,30 @@ dependencies:
|
|
171
207
|
type: :development
|
172
208
|
prerelease: false
|
173
209
|
version_requirements: !ruby/object:Gem::Requirement
|
174
|
-
none: false
|
175
210
|
requirements:
|
176
211
|
- - ! '>='
|
177
212
|
- !ruby/object:Gem::Version
|
178
213
|
version: '0'
|
214
|
+
- !ruby/object:Gem::Dependency
|
215
|
+
name: ZenTest
|
216
|
+
requirement: !ruby/object:Gem::Requirement
|
217
|
+
requirements:
|
218
|
+
- - ~>
|
219
|
+
- !ruby/object:Gem::Version
|
220
|
+
version: 4.9.0
|
221
|
+
type: :development
|
222
|
+
prerelease: false
|
223
|
+
version_requirements: !ruby/object:Gem::Requirement
|
224
|
+
requirements:
|
225
|
+
- - ~>
|
226
|
+
- !ruby/object:Gem::Version
|
227
|
+
version: 4.9.0
|
179
228
|
description: tengine_resource provides physical/virtual server management
|
180
229
|
email: tengine-info@groovenauts.jp
|
181
230
|
executables:
|
182
231
|
- tengine_resource_watchd
|
183
232
|
- create_indexes_for_tengine_resource
|
233
|
+
- tengine_resource
|
184
234
|
extensions: []
|
185
235
|
extra_rdoc_files:
|
186
236
|
- README.rdoc
|
@@ -189,8 +239,14 @@ files:
|
|
189
239
|
- Gemfile.lock
|
190
240
|
- README.rdoc
|
191
241
|
- bin/create_indexes_for_tengine_resource
|
242
|
+
- bin/tengine_resource
|
192
243
|
- bin/tengine_resource_watchd
|
193
244
|
- config/watchd.yml.erb.example
|
245
|
+
- lib/tengine/resource/cli/credential.rb
|
246
|
+
- lib/tengine/resource/cli/global_options.rb
|
247
|
+
- lib/tengine/resource/cli/options.rb
|
248
|
+
- lib/tengine/resource/cli/server.rb
|
249
|
+
- lib/tengine/resource/cli.rb
|
194
250
|
- lib/tengine/resource/config/resource.rb
|
195
251
|
- lib/tengine/resource/config.rb
|
196
252
|
- lib/tengine/resource/credential.rb
|
@@ -206,33 +262,30 @@ files:
|
|
206
262
|
- lib/tengine/resource/watcher.rb
|
207
263
|
- lib/tengine/resource.rb
|
208
264
|
- lib/tengine_resource.rb
|
265
|
+
- spec/fixtures/example_fixtures1.rb
|
209
266
|
- tmp/.gitkeep
|
210
267
|
homepage: http://github.com/tengine/tengine_resource
|
211
268
|
licenses:
|
212
269
|
- MPL2.0/LGPLv3
|
270
|
+
metadata: {}
|
213
271
|
post_install_message:
|
214
272
|
rdoc_options: []
|
215
273
|
require_paths:
|
216
274
|
- lib
|
217
275
|
required_ruby_version: !ruby/object:Gem::Requirement
|
218
|
-
none: false
|
219
276
|
requirements:
|
220
277
|
- - ! '>='
|
221
278
|
- !ruby/object:Gem::Version
|
222
279
|
version: '0'
|
223
|
-
segments:
|
224
|
-
- 0
|
225
|
-
hash: 3643853348357995462
|
226
280
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
227
|
-
none: false
|
228
281
|
requirements:
|
229
282
|
- - ! '>='
|
230
283
|
- !ruby/object:Gem::Version
|
231
284
|
version: '0'
|
232
285
|
requirements: []
|
233
286
|
rubyforge_project:
|
234
|
-
rubygems_version:
|
287
|
+
rubygems_version: 2.0.3
|
235
288
|
signing_key:
|
236
|
-
specification_version:
|
289
|
+
specification_version: 4
|
237
290
|
summary: tengine_resource provides physical/virtual server management
|
238
291
|
test_files: []
|