sakurraform 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/sakurraform/cli/plan.rb +25 -4
- data/lib/sakurraform/cli/status.rb +2 -2
- data/lib/sakurraform/helper.rb +8 -3
- data/lib/sakurraform/resource/network.rb +10 -0
- data/lib/sakurraform/templates/network.tt +1 -2
- data/lib/sakurraform/templates/server.tt +4 -0
- data/lib/sakurraform/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3cce78309426bf6755b1fbf2d3cfca419611c7a
|
4
|
+
data.tar.gz: eea0d179c2a9f170c40ad87b8be7f0f221fbc76a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17348e6c25ad8d48838ef40361c5724dc59283da47a23f77da8af73210106a54615c9b5c093333e6532b09d11132e446e467c5624f85df54ddb38595fded94b8
|
7
|
+
data.tar.gz: 8f856f4d79dbf7420a690786359c570ff7213d2eaaad2e0c1792e67040da569293ac1cdbe835dd9d18be61066216b902aaf82751ca7f7a923ba2da1524236842
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# CHANGELOG of sakurraform
|
2
2
|
|
3
|
+
## Not release or WIP
|
4
|
+
|
5
|
+
## v0.4.0
|
6
|
+
|
7
|
+
- Support Simple L2 Switch
|
8
|
+
- Support add interfaces for server.
|
9
|
+
- SUpport connect interfaces to switch.
|
10
|
+
|
3
11
|
## v0.3.0
|
4
12
|
|
5
13
|
- Fix: build status crashes if other resources exists.
|
data/lib/sakurraform/cli/plan.rb
CHANGED
@@ -27,9 +27,16 @@ module SakurraForm
|
|
27
27
|
unless net.resource_id
|
28
28
|
net.resource_id = name_plus_uuid(net.name)
|
29
29
|
options = net.configuration.first.merge({'name' => net.resource_id})
|
30
|
-
say("Create new
|
31
|
-
|
32
|
-
|
30
|
+
say("Create new #{net.mode} #{net.name}")
|
31
|
+
case net.mode
|
32
|
+
when 'router'
|
33
|
+
router = network.routers.create(options)
|
34
|
+
switch = network.switches.find {|s| s.id == router.id}
|
35
|
+
when 'switch'
|
36
|
+
switch = network.switches.create(options)
|
37
|
+
else
|
38
|
+
raise "Not supported mode #{net.mode}..."
|
39
|
+
end
|
33
40
|
create_file "state/network/#{net.resource_id}.yml", switch.all_attributes.to_yaml
|
34
41
|
else
|
35
42
|
say("#{net.name} already available as #{net.resource_id}")
|
@@ -68,6 +75,20 @@ module SakurraForm
|
|
68
75
|
disk_id = server.disks.first['ID']
|
69
76
|
say("Associate #{sv_ipaddress} to #{sv.name}")
|
70
77
|
volume.associate_ip_to_disk(disk_id, subnet)
|
78
|
+
|
79
|
+
## Regist Interfaces
|
80
|
+
if sv.configuration.first["interfaces"]
|
81
|
+
ifs = sv.configuration.first["interfaces"]
|
82
|
+
c_switches = ifs.map do |target_sw|
|
83
|
+
say("Creating interface connected to #{target_sw}...")
|
84
|
+
resolve_sakura_id_by_combined(target_sw)
|
85
|
+
end
|
86
|
+
c_switches.map do |t_sw|
|
87
|
+
new_if = network.interfaces.regist_onto_server(server.id)
|
88
|
+
network.interfaces.connect_to_switch(new_if.id, t_sw)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
71
92
|
server.boot
|
72
93
|
create_file "state/server/#{sv.resource_id}.yml", server.all_attributes.to_yaml
|
73
94
|
else
|
@@ -124,7 +145,7 @@ module SakurraForm
|
|
124
145
|
col_networks.resources.each do |net|
|
125
146
|
if net.remote_state
|
126
147
|
# puts net.remote_state
|
127
|
-
if net.remote_state[:internet].any?
|
148
|
+
if net.remote_state[:internet] && net.remote_state[:internet].any?
|
128
149
|
say("Deleting Router #{net.resource_id} ...")
|
129
150
|
network.delete_router(net.remote_state[:internet]["ID"])
|
130
151
|
else
|
@@ -19,7 +19,7 @@ module SakurraForm
|
|
19
19
|
output["Networks"] = build_state_network(col_network)
|
20
20
|
else
|
21
21
|
Formatador.display_line('[green]Nework resources[/]')
|
22
|
-
Formatador.display_table(build_state_network(col_network), [:name, :sakurraform_name, :sakura_id, :subnets, :gateway])
|
22
|
+
Formatador.display_table(build_state_network(col_network), [:name, :mode, :sakurraform_name, :sakura_id, :subnets, :gateway])
|
23
23
|
say()
|
24
24
|
end
|
25
25
|
|
@@ -31,7 +31,7 @@ module SakurraForm
|
|
31
31
|
say(JSON.pretty_generate(output))
|
32
32
|
else
|
33
33
|
Formatador.display_line('[green]Server resources[/]')
|
34
|
-
Formatador.display_table(build_state_server(col_server), [:name, :sakurraform_name, :sakura_id, :ipaddress, :status, :last_state_changed])
|
34
|
+
Formatador.display_table(build_state_server(col_server), [:name, :sakurraform_name, :sakura_id, :ipaddress, :network, :status, :last_state_changed])
|
35
35
|
end
|
36
36
|
if options[:sync]
|
37
37
|
col_server.resources.each do |r|
|
data/lib/sakurraform/helper.rb
CHANGED
@@ -52,10 +52,13 @@ module SakurraForm
|
|
52
52
|
table_datum = {}
|
53
53
|
# pp resource
|
54
54
|
table_datum[:name] = resource.name
|
55
|
+
table_datum[:mode] = resource.mode
|
55
56
|
table_datum[:sakurraform_name] = resource.resource_id ? resource.resource_id : 'not created'
|
56
57
|
table_datum[:sakura_id] = resource.remote_state ? resource.remote_state[:id] : 'not created'
|
57
|
-
|
58
|
-
|
58
|
+
if resource.mode == 'router'
|
59
|
+
table_datum[:subnets] = resource.remote_state && resource.remote_state[:subnets] ? resource.remote_state[:subnets].first['NetworkAddress'] + '/' + resource.remote_state[:subnets].first['NetworkMaskLen'].to_s : 'not created'
|
60
|
+
table_datum[:gateway] = resource.remote_state && resource.remote_state[:subnets] ? resource.remote_state[:subnets].first['DefaultRoute'] : 'not created'
|
61
|
+
end
|
59
62
|
|
60
63
|
table_data << table_datum
|
61
64
|
end
|
@@ -66,7 +69,7 @@ module SakurraForm
|
|
66
69
|
table_data = []
|
67
70
|
col_server.resources.each do |resource|
|
68
71
|
table_datum = {}
|
69
|
-
#
|
72
|
+
# pp resource
|
70
73
|
table_datum[:name] = resource.name
|
71
74
|
table_datum[:sakurraform_name] = resource.resource_id ? resource.resource_id : 'not created'
|
72
75
|
table_datum[:sakura_id] = resource.remote_state ? resource.remote_state[:id] : 'not created'
|
@@ -74,6 +77,8 @@ module SakurraForm
|
|
74
77
|
table_datum[:last_state_changed] = resource.remote_state && resource.remote_state[:instance] ? resource.remote_state[:instance]['StatusChangedAt'] : 'not created'
|
75
78
|
table_datum[:ipaddress] = resource.remote_state && resource.remote_state[:interfaces] ? resource.remote_state[:interfaces].first['UserIPAddress'] : 'not created'
|
76
79
|
|
80
|
+
table_datum[:network] = resource.remote_state && resource.remote_state[:interfaces] ? resource.remote_state[:interfaces].map {|i| i['Switch']['ID'] } : 'not created'
|
81
|
+
|
77
82
|
table_data << table_datum
|
78
83
|
end
|
79
84
|
table_data
|
@@ -1,6 +1,16 @@
|
|
1
1
|
module SakurraForm
|
2
2
|
class Resource
|
3
3
|
class Network < SakurraForm::Resource::Base
|
4
|
+
attr_reader :mode
|
5
|
+
def initialize(name, enable_remote = false)
|
6
|
+
super
|
7
|
+
if @configuration.first.has_key?(:networkmasklen)
|
8
|
+
@mode = 'router'
|
9
|
+
else
|
10
|
+
@mode = 'switch'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
4
14
|
def collect_remote_state
|
5
15
|
return {} unless @resource_id
|
6
16
|
network = Fog::Network[:sakuracloud]
|
@@ -7,6 +7,8 @@ server:
|
|
7
7
|
diskplan: 4
|
8
8
|
sourcearchive: 112500463685
|
9
9
|
switch: network[defaultrouter]
|
10
|
+
interfaces:
|
11
|
+
- network[localswitch1]
|
10
12
|
meta:
|
11
13
|
network_offset: 3
|
12
14
|
chef_environment: null
|
@@ -20,6 +22,8 @@ server:
|
|
20
22
|
diskplan: 4
|
21
23
|
sourcearchive: 112500463685
|
22
24
|
switch: network[defaultrouter]
|
25
|
+
interfaces:
|
26
|
+
- network[localswitch1]
|
23
27
|
meta:
|
24
28
|
network_offset: 4
|
25
29
|
chef_environment: null
|
data/lib/sakurraform/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sakurraform
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sawanoboly
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|