pec 0.4.3 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +9 -6
- data/lib/pec/configure.rb +3 -9
- data/lib/pec/configure/host.rb +2 -1
- data/lib/pec/configure/user_data.rb +2 -3
- data/lib/pec/director/helper.rb +4 -0
- data/lib/pec/director/make_director.rb +1 -0
- data/lib/pec/director/vm_status_director.rb +10 -7
- data/lib/pec/init.rb +4 -4
- data/lib/pec/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c854b8e393a921d53b14b6faa4704c69179e89f
|
4
|
+
data.tar.gz: b5e10b9145475986f2f59b23fb762bcac456bd1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc62df875382a1a9e46f84592212f69ec4c015132aa2804f8b698084b3af401218c6c005df8cf41dc7442bde7cd85910f3c1221dcc394c06f4c2063839fdc009
|
7
|
+
data.tar.gz: aa06178e8af7c13cb6019ee4db98624f873be9ab1e2368730522ce5942e548348d788162f71d2a1a34be1af2270f2c9b3c2f822d9576df782e01011aeeff040c
|
data/README.md
CHANGED
@@ -18,7 +18,7 @@ OpenStackにおいて複数サーバの起動一括起動停止や、 DHCPサー
|
|
18
18
|
|
19
19
|
```
|
20
20
|
create - /Pec.yaml
|
21
|
-
create - /
|
21
|
+
create - /user_data/web_server.yaml.sample
|
22
22
|
```
|
23
23
|
|
24
24
|
Pec.yamlに基づきホストを作成します。
|
@@ -33,10 +33,13 @@ Pec.yamlに基づきホストを作成します。
|
|
33
33
|
### Configure
|
34
34
|
#### Pec.yaml
|
35
35
|
```
|
36
|
-
|
36
|
+
_default_: &def
|
37
37
|
tenant: your_tenant
|
38
38
|
image: centos-7.1_chef-12.3_puppet-3.7
|
39
39
|
flavor: m1.small
|
40
|
+
|
41
|
+
pyama-test001:
|
42
|
+
<<: *def
|
40
43
|
networks:
|
41
44
|
eth0:
|
42
45
|
bootproto: static
|
@@ -57,8 +60,7 @@ pyama-test001:
|
|
57
60
|
fqdn: pyama-test001.ikemen.com
|
58
61
|
repo_releasever: 7.1.1503
|
59
62
|
pyama-test002:
|
60
|
-
|
61
|
-
flavor: m1.midium
|
63
|
+
<<: *def
|
62
64
|
・・・
|
63
65
|
|
64
66
|
```
|
@@ -66,14 +68,15 @@ pyama-test002:
|
|
66
68
|
|
67
69
|
| 項目名 | 説明 | 必須 | 例示 |
|
68
70
|
| -------------- | ---------------------------------------------- | ---- | ------------------------------- |
|
69
|
-
| instance_name | インスタンス名 | ○ | pyama-test001 |
|
71
|
+
| instance_name | インスタンス名 | ○ | pyama-test001* |
|
70
72
|
| tenant | テナント名 | ○ | your_tenant |
|
71
73
|
| image | イメージ名 | ○ | centos-7.1_chef-12.3_puppet-3.7 |
|
72
74
|
| flavor | フレーバー名 | ○ | m1.small |
|
73
75
|
| networks | ネットワーク定義 | - | [] |
|
74
76
|
| security_group | セキュリティグループ名 | - | [default,ssh] |
|
75
|
-
| templates | `user_data`のテンプレート.`./
|
77
|
+
| templates | `user_data`のテンプレート.`./user_data`に配置 | - | [base.yaml,webserver.yaml] |
|
76
78
|
| user_data | cloud-init記法に準拠 | - | - |
|
79
|
+
* 先頭が_で開始されるインスタンス名はyaml merge記法用途と認識し、スキップします
|
77
80
|
|
78
81
|
##### Networks
|
79
82
|
| 項目名 | 説明 | 必須 | 例示 |
|
data/lib/pec/configure.rb
CHANGED
@@ -11,17 +11,11 @@ module Pec
|
|
11
11
|
else
|
12
12
|
hash = YAML.load_file(file_name).to_hash
|
13
13
|
end
|
14
|
-
|
15
|
-
|
16
|
-
hash.each do |config|
|
17
|
-
if config[0] =~ /^_DEFAULT_/
|
18
|
-
config_default = config_default.update(config[1])
|
19
|
-
next
|
20
|
-
end
|
21
|
-
config[1] = config_default.update(config[1])
|
14
|
+
|
15
|
+
hash.reject {|c| c[0].to_s.match(/^_/)}.each do |config|
|
22
16
|
|
23
17
|
config[1]['user_data'] ||= {}
|
24
|
-
config[1]['user_data']['fqdn'] ||= config[0]
|
18
|
+
config[1]['user_data']['fqdn'] ||= config[0].to_s
|
25
19
|
|
26
20
|
host = Pec::Configure::Host.new(config)
|
27
21
|
@configure << host if host
|
data/lib/pec/configure/host.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Pec
|
2
2
|
class Configure
|
3
3
|
class Host
|
4
|
-
attr_reader :name, :image, :flavor,:security_group, :user_data, :networks, :templates, :tenant
|
4
|
+
attr_reader :name, :image, :flavor,:security_group, :user_data, :networks, :templates, :tenant, :availability_zone
|
5
5
|
def initialize(config)
|
6
6
|
check_format(config)
|
7
7
|
append_network(config[1])
|
@@ -12,6 +12,7 @@ module Pec
|
|
12
12
|
@user_data = config[1]["user_data"];
|
13
13
|
@templates = config[1]["templates"]
|
14
14
|
@tenant = config[1]["tenant"]
|
15
|
+
@availability_zone = config[1]["availability_zone"]
|
15
16
|
end
|
16
17
|
|
17
18
|
def append_network(config)
|
@@ -14,8 +14,8 @@ module Pec
|
|
14
14
|
def get_template(config)
|
15
15
|
config.templates.inject({}) do |merge_template, template|
|
16
16
|
template.to_s.concat('.yaml') unless template.to_s.match(/.*\.yaml/)
|
17
|
-
raise(Pec::Errors::UserData, "template:#{template} is not fond!") unless FileTest.exist?("
|
18
|
-
merge_template.deep_merge!(YAML.load_file("
|
17
|
+
raise(Pec::Errors::UserData, "template:#{template} is not fond!") unless FileTest.exist?("user_data/#{template}")
|
18
|
+
merge_template.deep_merge!(YAML.load_file("user_data/#{template}").to_hash)
|
19
19
|
end if config.templates
|
20
20
|
end
|
21
21
|
|
@@ -34,4 +34,3 @@ module Pec
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
37
|
-
|
data/lib/pec/director/helper.rb
CHANGED
@@ -26,6 +26,10 @@ module Pec
|
|
26
26
|
ports ? options.merge({ 'nics' => ports.map { |port| { port_id: port.id } } }) : options
|
27
27
|
end
|
28
28
|
|
29
|
+
def set_availability_zone(options, host)
|
30
|
+
host.availability_zone ? options.merge({ 'availability_zone' => host.availability_zone }) : options
|
31
|
+
end
|
32
|
+
|
29
33
|
def get_security_group_id(security_groups)
|
30
34
|
security_groups.map do |sg_name|
|
31
35
|
sg = Pec::Network::Security_Group.fetch(sg_name)
|
@@ -21,6 +21,7 @@ module Pec
|
|
21
21
|
image_ref = Pec::Compute::Image.get_ref(host.image)
|
22
22
|
options = { "user_data" => Pec::Configure::UserData.make(host, ports) }
|
23
23
|
options = Pec::Director::Helper.set_nics(options, ports)
|
24
|
+
options = Pec::Director::Helper.set_availability_zone(options, host)
|
24
25
|
|
25
26
|
Pec::Compute::Server.create(host.name, image_ref, flavor_ref, options)
|
26
27
|
end
|
@@ -11,22 +11,25 @@ module Pec
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def show_summary(host)
|
14
|
-
server
|
15
|
-
status
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
server = Pec::Compute::Server.fetch(host.name)
|
15
|
+
status = "uncreated"
|
16
|
+
availability_zone = ""
|
17
|
+
compute_node = ""
|
18
|
+
tenant_name = ""
|
19
|
+
flavor = ""
|
20
|
+
ip_address = ""
|
20
21
|
if server
|
21
22
|
detail = Pec::Resource.get.get_server_details(server["id"])
|
22
23
|
status = detail["status"]
|
24
|
+
availability_zone = detail["OS-EXT-AZ:availability_zone"]
|
23
25
|
compute_node = detail["OS-EXT-SRV-ATTR:host"]
|
24
26
|
tenant_name = Pec::Compute::Tenant.get_name(detail["tenant_id"])
|
25
27
|
flavor = Pec::Compute::Flavor.get_name(detail["flavor"]["id"])
|
26
28
|
ip_address = Pec::Director::Helper.parse_from_addresses(detail["addresses"]).join(",")
|
27
29
|
end
|
28
30
|
|
29
|
-
puts sprintf(" %-35s %-10s %-10s %-10s %-35s %-48s",
|
31
|
+
puts sprintf(" %-35s %-10s %-10s %-10s %-10s %-35s %-48s",
|
32
|
+
host.name, status, tenant_name, flavor, availability_zone, compute_node, ip_address)
|
30
33
|
end
|
31
34
|
|
32
35
|
def err_message(e, host)
|
data/lib/pec/init.rb
CHANGED
@@ -2,13 +2,13 @@ module Pec
|
|
2
2
|
class Init
|
3
3
|
class << self
|
4
4
|
def create_template_dir
|
5
|
-
dirname = "
|
5
|
+
dirname = "user_data"
|
6
6
|
unless FileTest.exist?(dirname)
|
7
|
-
FileUtils.mkdir_p(dirname)
|
7
|
+
FileUtils.mkdir_p(dirname)
|
8
8
|
open("#{dirname}/web_server.yaml.sample","w") do |e|
|
9
9
|
YAML.dump(Pec::Configure::Sample.user_data, e)
|
10
10
|
end if FileTest.exist?(dirname)
|
11
|
-
puts "create directry
|
11
|
+
puts "create directry user_data".green
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -23,7 +23,7 @@ module Pec
|
|
23
23
|
|
24
24
|
def create_fog_config
|
25
25
|
thor = Thor.new
|
26
|
-
if !File.exist?(File.expand_path("~/.fog")) || thor.yes?("Do you want to overwrite the existing ~/.fog? [y/N]")
|
26
|
+
if !File.exist?(File.expand_path("~/.fog")) || thor.yes?("Do you want to overwrite the existing ~/.fog? [y/N]")
|
27
27
|
thor.say("Start Configure by OpenStack", :yellow)
|
28
28
|
params = {}
|
29
29
|
|
data/lib/pec/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kazuhiko yamashita
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -190,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
190
|
version: '0'
|
191
191
|
requirements: []
|
192
192
|
rubyforge_project:
|
193
|
-
rubygems_version: 2.
|
193
|
+
rubygems_version: 2.4.6
|
194
194
|
signing_key:
|
195
195
|
specification_version: 4
|
196
196
|
summary: openstack vm booter.
|