wakame-vdc-agents 11.06.0 → 11.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +19 -31
- data/bin/hva +15 -5
- data/bin/nsa +15 -5
- data/bin/sta +9 -222
- data/config/db/migrations/0001_v1110_origin.rb +446 -0
- data/config/hva.conf.example +19 -11
- data/config/nsa.conf.example +1 -1
- data/lib/dcmgr.rb +99 -22
- data/lib/dcmgr/cli/base.rb +34 -1
- data/lib/dcmgr/cli/host.rb +24 -20
- data/lib/dcmgr/cli/image.rb +38 -19
- data/lib/dcmgr/cli/keypair.rb +16 -12
- data/lib/dcmgr/cli/network.rb +189 -81
- data/lib/dcmgr/cli/quota.rb +2 -2
- data/lib/dcmgr/cli/security_group.rb +106 -0
- data/lib/dcmgr/cli/spec.rb +144 -39
- data/lib/dcmgr/cli/storage.rb +16 -15
- data/lib/dcmgr/cli/tag.rb +20 -14
- data/lib/dcmgr/cli/vlan.rb +5 -5
- data/lib/dcmgr/drivers/backing_store.rb +32 -0
- data/lib/dcmgr/drivers/comstar.rb +81 -0
- data/lib/dcmgr/drivers/iijgio_storage.rb +9 -19
- data/lib/dcmgr/drivers/iscsi_target.rb +41 -0
- data/lib/dcmgr/drivers/kvm.rb +161 -28
- data/lib/dcmgr/drivers/linux_iscsi.rb +60 -0
- data/lib/dcmgr/drivers/local_storage.rb +24 -0
- data/lib/dcmgr/drivers/lxc.rb +167 -125
- data/lib/dcmgr/drivers/raw.rb +74 -0
- data/lib/dcmgr/drivers/s3_storage.rb +7 -19
- data/lib/dcmgr/drivers/snapshot_storage.rb +18 -28
- data/lib/dcmgr/drivers/storage_initiator.rb +28 -0
- data/lib/dcmgr/drivers/sun_iscsi.rb +32 -0
- data/lib/dcmgr/drivers/zfs.rb +77 -0
- data/lib/dcmgr/endpoints/core_api.rb +315 -263
- data/lib/dcmgr/endpoints/errors.rb +21 -10
- data/lib/dcmgr/endpoints/metadata.rb +360 -23
- data/lib/dcmgr/helpers/cli_helper.rb +6 -3
- data/lib/dcmgr/helpers/ec2_metadata_helper.rb +9 -0
- data/lib/dcmgr/helpers/nic_helper.rb +11 -0
- data/lib/dcmgr/helpers/snapshot_storage_helper.rb +34 -0
- data/lib/dcmgr/models/account.rb +0 -6
- data/lib/dcmgr/models/account_resource.rb +0 -4
- data/lib/dcmgr/models/base_new.rb +14 -2
- data/lib/dcmgr/models/dhcp_range.rb +38 -0
- data/lib/dcmgr/models/frontend_system.rb +0 -6
- data/lib/dcmgr/models/history.rb +0 -11
- data/lib/dcmgr/models/host_node.rb +131 -0
- data/lib/dcmgr/models/hostname_lease.rb +0 -8
- data/lib/dcmgr/models/image.rb +31 -18
- data/lib/dcmgr/models/instance.rb +137 -143
- data/lib/dcmgr/models/instance_nic.rb +52 -29
- data/lib/dcmgr/models/instance_security_group.rb +9 -0
- data/lib/dcmgr/models/instance_spec.rb +163 -31
- data/lib/dcmgr/models/ip_lease.rb +10 -21
- data/lib/dcmgr/models/mac_lease.rb +30 -11
- data/lib/dcmgr/models/network.rb +148 -27
- data/lib/dcmgr/models/physical_network.rb +18 -0
- data/lib/dcmgr/models/quota.rb +0 -10
- data/lib/dcmgr/models/request_log.rb +3 -18
- data/lib/dcmgr/models/security_group.rb +66 -0
- data/lib/dcmgr/models/security_group_rule.rb +145 -0
- data/lib/dcmgr/models/ssh_key_pair.rb +16 -19
- data/lib/dcmgr/models/{storage_pool.rb → storage_node.rb} +35 -25
- data/lib/dcmgr/models/tag.rb +0 -14
- data/lib/dcmgr/models/tag_mapping.rb +1 -7
- data/lib/dcmgr/models/vlan_lease.rb +2 -8
- data/lib/dcmgr/models/volume.rb +49 -37
- data/lib/dcmgr/models/volume_snapshot.rb +15 -17
- data/lib/dcmgr/node_modules/hva_collector.rb +69 -28
- data/lib/dcmgr/node_modules/instance_ha.rb +23 -12
- data/lib/dcmgr/node_modules/instance_monitor.rb +16 -2
- data/lib/dcmgr/node_modules/openflow_controller.rb +784 -0
- data/lib/dcmgr/node_modules/scheduler.rb +189 -0
- data/lib/dcmgr/node_modules/service_netfilter.rb +452 -227
- data/lib/dcmgr/node_modules/service_openflow.rb +731 -0
- data/lib/dcmgr/node_modules/sta_collector.rb +20 -0
- data/lib/dcmgr/node_modules/sta_tgt_initializer.rb +35 -0
- data/lib/dcmgr/rack/request_logger.rb +11 -6
- data/lib/dcmgr/rpc/hva_handler.rb +256 -110
- data/lib/dcmgr/rpc/sta_handler.rb +244 -0
- data/lib/dcmgr/scheduler.rb +122 -8
- data/lib/dcmgr/scheduler/host_node/exclude_same.rb +24 -0
- data/lib/dcmgr/scheduler/host_node/find_first.rb +12 -0
- data/lib/dcmgr/scheduler/host_node/least_usage.rb +28 -0
- data/lib/dcmgr/scheduler/host_node/per_instance.rb +18 -0
- data/lib/dcmgr/scheduler/host_node/specify_node.rb +26 -0
- data/lib/dcmgr/scheduler/network/flat_single.rb +23 -0
- data/lib/dcmgr/scheduler/network/nat_one_to_one.rb +23 -0
- data/lib/dcmgr/scheduler/network/per_instance.rb +39 -0
- data/lib/dcmgr/scheduler/network/vif_template.rb +19 -0
- data/lib/dcmgr/scheduler/storage_node/find_first.rb +13 -0
- data/lib/dcmgr/scheduler/storage_node/least_usage.rb +23 -0
- data/lib/dcmgr/storage_service.rb +39 -40
- data/lib/dcmgr/tags.rb +3 -3
- data/lib/dcmgr/version.rb +1 -1
- data/lib/dcmgr/vnet.rb +105 -0
- data/lib/dcmgr/vnet/factories.rb +141 -0
- data/lib/dcmgr/vnet/isolators/by_securitygroup.rb +21 -0
- data/lib/dcmgr/vnet/isolators/dummy.rb +17 -0
- data/lib/dcmgr/vnet/netfilter/cache.rb +51 -0
- data/lib/dcmgr/vnet/netfilter/chain.rb +66 -0
- data/lib/dcmgr/vnet/netfilter/controller.rb +193 -0
- data/lib/dcmgr/vnet/netfilter/ebtables_rule.rb +53 -0
- data/lib/dcmgr/vnet/netfilter/iptables_rule.rb +45 -0
- data/lib/dcmgr/vnet/netfilter/task_manager.rb +459 -0
- data/lib/dcmgr/vnet/tasks/accept_all_dns.rb +19 -0
- data/lib/dcmgr/vnet/tasks/accept_arp_broadcast.rb +24 -0
- data/lib/dcmgr/vnet/tasks/accept_arp_from_friends.rb +34 -0
- data/lib/dcmgr/vnet/tasks/accept_arp_from_gateway.rb +21 -0
- data/lib/dcmgr/vnet/tasks/accept_arp_to_host.rb +30 -0
- data/lib/dcmgr/vnet/tasks/accept_ip_from_friends.rb +26 -0
- data/lib/dcmgr/vnet/tasks/accept_ip_from_gateway.rb +23 -0
- data/lib/dcmgr/vnet/tasks/accept_ip_to_anywhere.rb +18 -0
- data/lib/dcmgr/vnet/tasks/accept_related_established.rb +45 -0
- data/lib/dcmgr/vnet/tasks/accept_wakame_dhcp_only.rb +33 -0
- data/lib/dcmgr/vnet/tasks/accept_wakame_dns_only.rb +33 -0
- data/lib/dcmgr/vnet/tasks/debug_iptables.rb +21 -0
- data/lib/dcmgr/vnet/tasks/drop_arp_forwarding.rb +27 -0
- data/lib/dcmgr/vnet/tasks/drop_arp_to_host.rb +24 -0
- data/lib/dcmgr/vnet/tasks/drop_ip_from_anywhere.rb +18 -0
- data/lib/dcmgr/vnet/tasks/drop_ip_spoofing.rb +34 -0
- data/lib/dcmgr/vnet/tasks/drop_mac_spoofing.rb +33 -0
- data/lib/dcmgr/vnet/tasks/exclude_from_nat.rb +47 -0
- data/lib/dcmgr/vnet/tasks/security_group.rb +37 -0
- data/lib/dcmgr/vnet/tasks/static_nat.rb +54 -0
- data/lib/dcmgr/vnet/tasks/translate_metadata_address.rb +32 -0
- metadata +105 -68
- data/lib/dcmgr/cli/group.rb +0 -101
- data/lib/dcmgr/endpoints/core_api_mock.rb +0 -865
- data/lib/dcmgr/models/host_pool.rb +0 -122
- data/lib/dcmgr/models/instance_netfilter_group.rb +0 -16
- data/lib/dcmgr/models/netfilter_group.rb +0 -89
- data/lib/dcmgr/models/netfilter_rule.rb +0 -21
- data/lib/dcmgr/scheduler/find_last.rb +0 -16
- data/lib/dcmgr/scheduler/find_random.rb +0 -16
- data/lib/dcmgr/stm/instance.rb +0 -25
- data/lib/dcmgr/stm/snapshot_context.rb +0 -33
- data/lib/dcmgr/stm/volume_context.rb +0 -65
data/Rakefile
CHANGED
@@ -9,36 +9,23 @@ require 'dcmgr'
|
|
9
9
|
|
10
10
|
task :environment do
|
11
11
|
Dcmgr.configure 'config/dcmgr.conf'
|
12
|
-
Dcmgr.run_initializers
|
13
12
|
end
|
14
13
|
|
15
14
|
namespace :db do
|
16
15
|
desc 'Create all database tables'
|
17
16
|
task :init => [ :environment ] do
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
Dcmgr::Models.const_get(c).create_table!
|
23
|
-
}
|
24
|
-
Isono::Models::NodeState.create_table!
|
25
|
-
Isono::Models::JobState.create_table!
|
26
|
-
|
27
|
-
Dcmgr::Models::CREATE_TABLE_CLASSES.each { |c|
|
28
|
-
Dcmgr::Models.const_get(c).install_data
|
29
|
-
}
|
17
|
+
Dcmgr.run_initializers(:sequel)
|
18
|
+
|
19
|
+
Sequel.extension :migration
|
20
|
+
Sequel::Migrator.apply(Sequel::DATABASES.first, File.expand_path('../config/db/migrations', __FILE__), 9999)
|
30
21
|
end
|
31
22
|
|
32
23
|
desc 'Drop all database tables'
|
33
24
|
task :drop => [ :environment ] do
|
34
|
-
|
35
|
-
require 'isono'
|
25
|
+
Dcmgr.run_initializers(:sequel)
|
36
26
|
|
37
|
-
|
38
|
-
|
39
|
-
}
|
40
|
-
Isono::Models::NodeState.drop_table
|
41
|
-
Isono::Models::JobState.drop_table
|
27
|
+
Sequel.extension :migration
|
28
|
+
Sequel::Migrator.apply(Sequel::DATABASES.first, File.expand_path('../config/db/migrations', __FILE__), 0)
|
42
29
|
end
|
43
30
|
end
|
44
31
|
|
@@ -67,8 +54,8 @@ task :gem do
|
|
67
54
|
s.email = ['dev@axsh.net']
|
68
55
|
s.homepage = 'http://wakame.jp/'
|
69
56
|
s.name = 'wakame-vdc-dcmgr'
|
70
|
-
s.summary = "
|
71
|
-
s.description = ''
|
57
|
+
s.summary = "Wakame-VDC: Server modules"
|
58
|
+
s.description = 'Datacenter Hypervisor'
|
72
59
|
s.require_path = 'lib'
|
73
60
|
s.required_ruby_version = '>= 1.8.7'
|
74
61
|
|
@@ -80,18 +67,20 @@ task :gem do
|
|
80
67
|
s.bindir='bin'
|
81
68
|
s.executables = %w(collector)
|
82
69
|
|
83
|
-
s.add_dependency "isono", "0.2.
|
70
|
+
s.add_dependency "isono", "0.2.9"
|
84
71
|
s.add_dependency "log4r"
|
85
72
|
s.add_dependency "extlib", '0.9.15'
|
86
73
|
s.add_dependency "configuration"
|
87
|
-
s.add_dependency "statemachine", '1.1.1'
|
88
74
|
s.add_dependency "ruby-hmac"
|
89
75
|
s.add_dependency "ipaddress", '0.7.0'
|
90
|
-
s.add_dependency "rack", ">= 1.2
|
91
|
-
s.add_dependency "sinatra", "1.2.
|
76
|
+
s.add_dependency "rack", ">= 1.3.2"
|
77
|
+
s.add_dependency "sinatra", "1.2.6"
|
92
78
|
s.add_dependency "json", ">= 1.2.0"
|
93
|
-
s.add_dependency "sequel", "3.
|
79
|
+
s.add_dependency "sequel", "3.27.0"
|
94
80
|
s.add_dependency "mysql", ">= 2.8.1"
|
81
|
+
s.add_dependency "net-dhcp", ">= 1.1.0"
|
82
|
+
s.add_dependency "bit-struct", ">= 0.13.6"
|
83
|
+
s.add_dependency "racket", ">= 1.0.11"
|
95
84
|
|
96
85
|
s.add_development_dependency 'bacon'
|
97
86
|
s.add_development_dependency 'rake'
|
@@ -107,8 +96,8 @@ task :gem do
|
|
107
96
|
s.email = ['dev@axsh.net']
|
108
97
|
s.homepage = 'http://wakame.jp/'
|
109
98
|
s.name = 'wakame-vdc-agents'
|
110
|
-
s.summary = "
|
111
|
-
s.description = ''
|
99
|
+
s.summary = "Wakame-VDC: Agent modules"
|
100
|
+
s.description = 'Datacenter Hypervisor'
|
112
101
|
s.require_path = 'lib'
|
113
102
|
s.required_ruby_version = '>= 1.8.7'
|
114
103
|
|
@@ -119,11 +108,10 @@ task :gem do
|
|
119
108
|
s.bindir='bin'
|
120
109
|
s.executables = %w(hva sta nsa)
|
121
110
|
|
122
|
-
s.add_dependency "isono", "0.2.
|
111
|
+
s.add_dependency "isono", "0.2.9"
|
123
112
|
s.add_dependency "log4r"
|
124
113
|
s.add_dependency "extlib", '0.9.15'
|
125
114
|
s.add_dependency "configuration"
|
126
|
-
s.add_dependency "statemachine", '1.1.1'
|
127
115
|
s.add_dependency "ruby-hmac"
|
128
116
|
s.add_dependency "ipaddress", '0.7.0'
|
129
117
|
s.add_dependency "open4"
|
data/bin/hva
CHANGED
@@ -13,16 +13,13 @@ manifest = DEFAULT_MANIFEST.dup
|
|
13
13
|
manifest.instance_eval do
|
14
14
|
node_name 'hva'
|
15
15
|
node_instance_id "#{Isono::Util.default_gw_ipaddr}"
|
16
|
-
load_module Isono::NodeModules::NodeHeartbeat
|
17
|
-
load_module Dcmgr::NodeModules::ServiceNetfilter
|
18
|
-
load_module Dcmgr::NodeModules::InstanceMonitor
|
19
16
|
|
20
17
|
config do |c|
|
21
18
|
c.vm_data_dir = '/var/lib/vm'
|
19
|
+
c.edge_networking = 'netfilter'
|
22
20
|
c.enable_ebtables = true
|
23
21
|
c.enable_iptables = true
|
24
22
|
c.hv_ifindex = 2 # ex. /sys/class/net/eth0/ifindex => 2
|
25
|
-
c.bridge_prefix = 'br'
|
26
23
|
c.bridge_novlan = 'br0'
|
27
24
|
c.verbose_netfilter = false
|
28
25
|
c.packet_drop_log = false
|
@@ -30,8 +27,21 @@ manifest.instance_eval do
|
|
30
27
|
end
|
31
28
|
|
32
29
|
load_config File.expand_path('config/hva.conf', app_root)
|
30
|
+
|
31
|
+
load_module Isono::NodeModules::NodeHeartbeat
|
32
|
+
load_module Dcmgr::NodeModules::InstanceMonitor
|
33
|
+
case config.edge_networking
|
34
|
+
when 'openflow'
|
35
|
+
load_module Dcmgr::NodeModules::ServiceOpenFlow
|
36
|
+
when 'off'
|
37
|
+
# Don't load openflow nor netfilter
|
38
|
+
when 'netfilter', 'legacy_netfilter'
|
39
|
+
load_module Dcmgr::NodeModules::ServiceNetfilter
|
40
|
+
else
|
41
|
+
raise "Configuration error: '#{config.edge_networking}' is not a valid option for edge_networking. Valid options are 'openflow', 'netfilter', 'legacy_netfilter' and 'off'"
|
42
|
+
end
|
33
43
|
end
|
34
44
|
|
35
45
|
start(manifest) do
|
36
|
-
endpoint "
|
46
|
+
endpoint "hva-handle.#{@node.node_id}", Dcmgr::Rpc::HvaHandler
|
37
47
|
end
|
data/bin/nsa
CHANGED
@@ -46,10 +46,10 @@ class SuperviseDnsmasq < Isono::NodeModules::Base
|
|
46
46
|
config_section.dhcp_hosts_conf + ".dhcp",
|
47
47
|
config_section.dhcp_hosts_conf
|
48
48
|
)
|
49
|
-
cmd = "#{manifest.config.dnsmasq_bin_path} #{opts}"
|
49
|
+
@cmd = "#{manifest.config.dnsmasq_bin_path} #{opts}"
|
50
50
|
|
51
51
|
@dnsmasq_pid = fork {
|
52
|
-
Process.exec(cmd)
|
52
|
+
Process.exec(@cmd)
|
53
53
|
}
|
54
54
|
begin
|
55
55
|
if !Process.waitpid(@dnsmasq_pid, Process::WNOHANG).nil?
|
@@ -63,8 +63,8 @@ class SuperviseDnsmasq < Isono::NodeModules::Base
|
|
63
63
|
|
64
64
|
event = Isono::NodeModules::EventChannel.new(node)
|
65
65
|
|
66
|
-
event.subscribe('
|
67
|
-
logger.info("refresh on
|
66
|
+
event.subscribe('instance.scheduled', '#') do |args|
|
67
|
+
logger.info("refresh on instance.scheduled: #{args.inspect}")
|
68
68
|
myinstance.refresh_dnsmasq_conf
|
69
69
|
end
|
70
70
|
|
@@ -83,7 +83,13 @@ class SuperviseDnsmasq < Isono::NodeModules::Base
|
|
83
83
|
EM.defer {
|
84
84
|
begin
|
85
85
|
generate_dhcp_conf()
|
86
|
-
|
86
|
+
if Process.waitpid(@dnsmasq_pid, Process::WNOHANG).nil?
|
87
|
+
system("/bin/kill -HUP #{@dnsmasq_pid}")
|
88
|
+
else
|
89
|
+
@dnsmasq_pid = fork {
|
90
|
+
Process.exec(@cmd)
|
91
|
+
}
|
92
|
+
end
|
87
93
|
logger.info("refreshed dnsmasq conf")
|
88
94
|
rescue Exception => e
|
89
95
|
logger.error(e)
|
@@ -112,8 +118,12 @@ dhcp-option=tag:<%= nwid %>,option:domain-name,<%= v[:domain_name] %>
|
|
112
118
|
<%- else # if @conf_ver_253 -%>
|
113
119
|
dhcp-range=net:<%= nwid %>,<%= v[:ipv4_first] %>,static,<%= v[:netmask] %>
|
114
120
|
dhcp-option=<%= nwid %>,option:netmask,<%= v[:netmask] %>
|
121
|
+
<%- if not v[:ipv4_gw].nil? -%>
|
115
122
|
dhcp-option=<%= nwid %>,option:router,<%= v[:ipv4_gw] %>
|
123
|
+
<%- end -%>
|
124
|
+
<%- if not v[:dns_server].nil? -%>
|
116
125
|
dhcp-option=<%= nwid %>,option:dns-server,<%= v[:dns_server] %>
|
126
|
+
<%- end -%>
|
117
127
|
dhcp-option=<%= nwid %>,option:domain-name,<%= v[:domain_name] %>
|
118
128
|
#dhcp-option=<%= nwid %>,option:domain-search,<%= v[:domain_name] %>
|
119
129
|
<%- end # if @conf_ver_253 -%>
|
data/bin/sta
CHANGED
@@ -9,234 +9,21 @@ require 'isono'
|
|
9
9
|
|
10
10
|
include Isono::Runner::RpcServer
|
11
11
|
|
12
|
-
class ZfsHandler < EndpointBuilder
|
13
|
-
include Dcmgr::Logger
|
14
|
-
include Dcmgr::Helpers::CliHelper
|
15
|
-
|
16
|
-
job :create_volume do
|
17
|
-
volume_id = request.args[0]
|
18
|
-
dest = Dcmgr::StorageService.repository(request.args[1])
|
19
|
-
data = rpc.request('sta-collector', 'get_volume', volume_id)
|
20
|
-
raise "Invalid volume state: #{data[:state]}" unless data[:state].to_s == 'registering'
|
21
|
-
|
22
|
-
unless data[:snapshot_id].nil?
|
23
|
-
sdata = rpc.request('sta-collector', 'get_snapshot', data[:snapshot_id])
|
24
|
-
raise "Invalid snapshot state: #{sdata[:state]}" unless sdata[:state].to_s == 'available'
|
25
|
-
end
|
26
|
-
logger.info("creating new volume #{volume_id}")
|
27
|
-
|
28
|
-
rpc.request('sta-collector', 'update_volume', volume_id, {:state=>:creating, :export_path=>data[:uuid]})
|
29
|
-
|
30
|
-
vol_path = "#{data[:storage_pool][:export_path]}/#{data[:uuid]}"
|
31
|
-
sh("/usr/sbin/zfs list %s > /dev/null 2>&1", [File.dirname(vol_path)])
|
32
|
-
if $?.exitstatus != 0
|
33
|
-
# create parent filesystem
|
34
|
-
sh("/usr/sbin/zfs create -p %s", [File.dirname(vol_path)])
|
35
|
-
logger.info("create parent filesystem: #{File.dirname(vol_path)}")
|
36
|
-
end
|
37
|
-
|
38
|
-
if sdata
|
39
|
-
zsnap_dir = "#{data[:storage_pool][:snapshot_base_path]}/#{sdata[:account_id]}/"
|
40
|
-
zsnap_filename = "#{sdata[:uuid]}.zsnap"
|
41
|
-
zsnap_file = File.join(zsnap_dir, zsnap_filename)
|
42
|
-
|
43
|
-
unless File.exists?(zsnap_file)
|
44
|
-
if Dcmgr::StorageService.has_driver?(dest[:driver])
|
45
|
-
begin
|
46
|
-
storage = Dcmgr::StorageService.new(dest[:driver], dest[:access_key], dest[:secret_key])
|
47
|
-
snapshot_file = "#{dest[:path]}#{dest[:filename]}"
|
48
|
-
bucket = storage.bucket(dest[:bucket])
|
49
|
-
bucket.download(snapshot_file, zsnap_filename, zsnap_dir)
|
50
|
-
logger.info("download to #{dest[:driver]}: #{snapshot_file}")
|
51
|
-
rescue => e
|
52
|
-
logger.error(e.message)
|
53
|
-
raise "snapshot not downloaded" if $?.exitstatus != 0
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
# create volume from snapshot
|
59
|
-
if File.exists?(zsnap_file)
|
60
|
-
sh("/usr/sbin/zfs receive %s < %s", [vol_path, zsnap_file])
|
61
|
-
if $?.exitstatus != 0
|
62
|
-
raise "volume already exists: #{volume_id}"
|
63
|
-
end
|
64
|
-
else
|
65
|
-
raise "snapshot file isn't exists: #{zsnap_file}"
|
66
|
-
end
|
67
|
-
|
68
|
-
sh("/usr/sbin/zfs destroy %s@%s", [vol_path, sdata[:uuid]])
|
69
|
-
if $?.exitstatus != 0
|
70
|
-
raise "volume snapshot has not deleted: #{volume_id}@#{sdata[:uuid]}"
|
71
|
-
end
|
72
|
-
|
73
|
-
sh("/usr/sbin/zfs list %s", [vol_path])
|
74
|
-
if $?.exitstatus != 0
|
75
|
-
raise "volume has not be created: #{volume_id}"
|
76
|
-
end
|
77
|
-
|
78
|
-
sh("rm -rf %s", ["#{data[:storage_pool][:snapshot_base_path]}/#{sdata[:account_id]}/#{sdata[:uuid]}.zsnap"])
|
79
|
-
logger.info("delete file: " + File.join(zsnap_dir, zsnap_file))
|
80
|
-
|
81
|
-
if $?.exitstatus != 0
|
82
|
-
raise "snapshot file cna't deleted"
|
83
|
-
end
|
84
|
-
else
|
85
|
-
# create volume
|
86
|
-
sh("/usr/sbin/zfs create -p -V %s %s", ["#{data[:size]}m", vol_path])
|
87
|
-
if $?.exitstatus != 0
|
88
|
-
raise "volume already exists: #{volume_id}"
|
89
|
-
end
|
90
|
-
sh("/usr/sbin/zfs list %s", [vol_path])
|
91
|
-
if $?.exitstatus != 0
|
92
|
-
raise "volume has not be created: #{volume_id}"
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
logger.info("created new volume: #{volume_id}")
|
97
|
-
|
98
|
-
sh("/usr/sbin/zfs shareiscsi=on %s/%s", [data[:storage_pool][:export_path], data[:uuid]])
|
99
|
-
if $?.exitstatus != 0
|
100
|
-
raise "failed iscsi target request: #{volume_id}"
|
101
|
-
end
|
102
|
-
il = sh("iscsitadm list target -v %s", ["#{data[:storage_pool][:export_path]}/#{data[:uuid]}"])
|
103
|
-
if $?.exitstatus != 0
|
104
|
-
raise "iscsi target has not be created #{volume_id}"
|
105
|
-
end
|
106
|
-
il = il[:stdout].downcase.split("\n").select {|row| row.strip!}
|
107
|
-
# :transport_information => {:iqn => "iqn.1986-03.com.sun:02:787bca42-9639-44e4-f115-f5b06ed31817", :lun => 0}
|
108
|
-
opt = {:iqn => il[0].split(": ").last, :lun=>il[6].split(": ").last.to_i}
|
109
|
-
|
110
|
-
rpc.request('sta-collector', 'update_volume', volume_id, {:state=>:available, :transport_information=>opt})
|
111
|
-
logger.info("registered iscsi target: #{volume_id}")
|
112
|
-
end
|
113
|
-
|
114
|
-
job :delete_volume do
|
115
|
-
volume_id = request.args[0]
|
116
|
-
data = rpc.request('sta-collector', 'get_volume', volume_id)
|
117
|
-
logger.info("#{volume_id}: start deleting volume.")
|
118
|
-
errcount = 0
|
119
|
-
if data[:state].to_s == 'deleted'
|
120
|
-
raise "#{volume_id}: Invalid volume state: deleted"
|
121
|
-
end
|
122
|
-
if data[:state].to_s != 'deregistering'
|
123
|
-
logger.warn("#{volume_id}: Unexpected volume state but try again: #{data[:state]}")
|
124
|
-
end
|
125
|
-
|
126
|
-
# deregisterd iscsi target
|
127
|
-
begin
|
128
|
-
sh("/usr/sbin/zfs shareiscsi=off %s", ["#{data[:storage_pool][:export_path]}/#{data[:uuid]}"])
|
129
|
-
rescue => e
|
130
|
-
logger.error("#{volume_id}: Failed to delete ISCSI target entry.")
|
131
|
-
errcount += 1
|
132
|
-
end
|
133
|
-
|
134
|
-
rpc.request('sta-collector', 'update_volume', volume_id, {:state=>:deleting})
|
135
|
-
|
136
|
-
# delete volume
|
137
|
-
begin
|
138
|
-
sh("/usr/sbin/zfs destroy %s", ["#{data[:storage_pool][:export_path]}/#{data[:uuid]}"])
|
139
|
-
rescue => e
|
140
|
-
logger.error("#{volume_id}: Failed to delete zfs volume: #{data[:storage_pool][:export_path]}/#{data[:uuid]}")
|
141
|
-
errcount += 1
|
142
|
-
end
|
143
|
-
|
144
|
-
rpc.request('sta-collector', 'update_volume', volume_id, {:state=>:deleted, :deleted_at=>Time.now.utc})
|
145
|
-
if errcount > 0
|
146
|
-
logger.info("#{volume_id}: Encountered one or more errors during deleting.")
|
147
|
-
else
|
148
|
-
logger.info("#{volume_id}: Deleted volume successfully.")
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
job :create_snapshot do
|
153
|
-
snapshot_id = request.args[0]
|
154
|
-
dest = Dcmgr::StorageService.repository(request.args[1])
|
155
|
-
sdata = rpc.request('sta-collector', 'get_snapshot', snapshot_id) unless snapshot_id.nil?
|
156
|
-
data = rpc.request('sta-collector', 'get_volume', sdata[:origin_volume_id])
|
157
|
-
logger.info("create new snapshot: #{snapshot_id}")
|
158
|
-
raise "Invalid volume state: #{data[:state]}" unless data[:state].to_s == 'available' || data[:state].to_s == 'attached'
|
159
|
-
|
160
|
-
vol_path = "#{data[:storage_pool][:export_path]}/#{data[:uuid]}"
|
161
|
-
snap_dir = "#{data[:storage_pool][:snapshot_base_path]}/#{sdata[:account_id]}"
|
162
|
-
unless File.exist?(snap_dir)
|
163
|
-
# create a directory to save snapshot
|
164
|
-
`mkdir -p #{snap_dir}`
|
165
|
-
logger.info("create a directory: #{snap_dir}")
|
166
|
-
end
|
167
|
-
sh("/usr/sbin/zfs snapshot %s@%s", [vol_path, sdata[:uuid]])
|
168
|
-
zsnap_file = "#{snap_dir}/#{sdata[:uuid]}.zsnap"
|
169
|
-
sh("/usr/sbin/zfs send %s@%s > %s", [vol_path, sdata[:uuid], zsnap_file])
|
170
|
-
sh("/usr/sbin/zfs destroy %s@%s", [vol_path, sdata[:uuid]])
|
171
|
-
|
172
|
-
if Dcmgr::StorageService.has_driver?(dest[:driver])
|
173
|
-
begin
|
174
|
-
storage = Dcmgr::StorageService.new(dest[:driver], dest[:access_key], dest[:secret_key])
|
175
|
-
snapshot_file = "#{dest[:path]}#{dest[:filename]}"
|
176
|
-
bucket = storage.bucket(dest[:bucket])
|
177
|
-
bucket.upload(snapshot_file, "#{zsnap_file}")
|
178
|
-
logger.info("upload to #{dest[:driver]}: #{snapshot_file}")
|
179
|
-
rescue => e
|
180
|
-
logger.error(e.message)
|
181
|
-
raise "snapshot has not be uploaded" if $?.exitstatus != 0
|
182
|
-
ensure
|
183
|
-
sh("rm -rf %s", ["#{data[:storage_pool][:snapshot_base_path]}/#{sdata[:account_id]}/#{sdata[:uuid]}.zsnap"])
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
rpc.request('sta-collector', 'update_snapshot', snapshot_id, {:state=>:available})
|
188
|
-
logger.info("created new snapshot: #{snapshot_id}")
|
189
|
-
end
|
190
|
-
|
191
|
-
job :delete_snapshot do
|
192
|
-
snapshot_id = request.args[0]
|
193
|
-
dest = Dcmgr::StorageService.repository(request.args[1])
|
194
|
-
sdata = rpc.request('sta-collector', 'get_snapshot', snapshot_id)
|
195
|
-
data = rpc.request('sta-collector', 'get_volume', sdata[:origin_volume_id])
|
196
|
-
logger.info("deleting snapshot: #{snapshot_id}")
|
197
|
-
raise "Invalid snapshot state: #{sdata[:state]}" unless sdata[:state].to_s == 'deleting'
|
198
|
-
|
199
|
-
if Dcmgr::StorageService.has_driver?(dest[:driver])
|
200
|
-
begin
|
201
|
-
storage = Dcmgr::StorageService.new(dest[:driver], dest[:access_key], dest[:secret_key])
|
202
|
-
snapshot_file = "#{dest[:path]}#{dest[:filename]}"
|
203
|
-
bucket = storage.bucket(dest[:bucket])
|
204
|
-
bucket.delete(snapshot_file)
|
205
|
-
logger.info("delete sanpshot file from #{dest[:driver]}: #{snapshot_file}")
|
206
|
-
rescue => e
|
207
|
-
logger.error(e.message)
|
208
|
-
raise "snapshot has not be deleted" if $?.exitstatus != 0
|
209
|
-
end
|
210
|
-
else
|
211
|
-
sh("rm -rf %s", ["#{data[:storage_pool][:snapshot_base_path]}/#{sdata[:account_id]}/#{sdata[:uuid]}.zsnap"])
|
212
|
-
raise "snapshot has not be deleted" if $?.exitstatus != 0
|
213
|
-
end
|
214
|
-
|
215
|
-
rpc.request('sta-collector', 'update_snapshot', snapshot_id, {:state=>:deleted, :deleted_at=>Time.now.utc})
|
216
|
-
logger.info("deleted snapshot: #{snapshot_id}")
|
217
|
-
end
|
218
|
-
|
219
|
-
def rpc
|
220
|
-
@rpc ||= Isono::NodeModules::RpcChannel.new(@node)
|
221
|
-
end
|
222
|
-
|
223
|
-
def jobreq
|
224
|
-
@jobreq ||= Isono::NodeModules::JobChannel.new(@node)
|
225
|
-
end
|
226
|
-
|
227
|
-
def event
|
228
|
-
@event ||= Isono::NodeModules::EventChannel.new(@node)
|
229
|
-
end
|
230
|
-
end
|
231
|
-
|
232
12
|
manifest = Isono::Runner::RpcServer::DEFAULT_MANIFEST.dup
|
233
13
|
manifest.instance_eval do
|
234
14
|
node_name 'sta'
|
235
15
|
node_instance_id "#{Isono::Util.default_gw_ipaddr}"
|
236
|
-
|
16
|
+
|
17
|
+
config do |c|
|
18
|
+
c.tmp_dir = '/var/tmp'
|
19
|
+
end
|
20
|
+
|
21
|
+
load_config File.expand_path('config/sta.conf', app_root)
|
22
|
+
|
237
23
|
load_module Isono::NodeModules::NodeHeartbeat
|
24
|
+
load_module Dcmgr::NodeModules::StaTgtInitializer if config.backing_store == 'raw'
|
238
25
|
end
|
239
26
|
|
240
27
|
start(manifest) do
|
241
|
-
endpoint "
|
28
|
+
endpoint "sta-handle.#{@node.node_id}", Dcmgr::Rpc::StaHandler
|
242
29
|
end
|
@@ -0,0 +1,446 @@
|
|
1
|
+
Sequel.migration do
|
2
|
+
up do
|
3
|
+
create_table(:accounts) do
|
4
|
+
primary_key :id, :type=>"int(11)"
|
5
|
+
column :uuid, "varchar(255)", :null=>false
|
6
|
+
column :description, "varchar(255)"
|
7
|
+
column :enabled, "int(11)", :default=>1, :null=>false
|
8
|
+
column :created_at, "datetime", :null=>false
|
9
|
+
column :updated_at, "datetime", :null=>false
|
10
|
+
|
11
|
+
index [:uuid], :unique=>true, :name=>:uuid
|
12
|
+
end
|
13
|
+
|
14
|
+
create_table(:frontend_systems) do
|
15
|
+
primary_key :id, :type=>"int(11)"
|
16
|
+
column :kind, "varchar(255)", :null=>false
|
17
|
+
column :key, "varchar(255)", :null=>false
|
18
|
+
column :credential, "varchar(255)"
|
19
|
+
|
20
|
+
index [:key], :unique=>true, :name=>:key
|
21
|
+
end
|
22
|
+
|
23
|
+
create_table(:histories) do
|
24
|
+
primary_key :id, :type=>"int(11)"
|
25
|
+
column :uuid, "varchar(255)", :null=>false
|
26
|
+
column :attr, "varchar(255)", :null=>false
|
27
|
+
column :vchar_value, "varchar(255)"
|
28
|
+
column :blob_value, "text"
|
29
|
+
column :created_at, "datetime", :null=>false
|
30
|
+
|
31
|
+
index [:uuid, :attr]
|
32
|
+
index [:uuid, :created_at]
|
33
|
+
end
|
34
|
+
|
35
|
+
create_table(:host_nodes) do
|
36
|
+
primary_key :id, :type=>"int(11)"
|
37
|
+
column :account_id, "varchar(255)", :null=>false
|
38
|
+
column :uuid, "varchar(255)", :null=>false
|
39
|
+
column :created_at, "datetime", :null=>false
|
40
|
+
column :updated_at, "datetime", :null=>false
|
41
|
+
column :node_id, "varchar(255)"
|
42
|
+
column :arch, "varchar(255)", :null=>false
|
43
|
+
column :hypervisor, "varchar(255)", :null=>false
|
44
|
+
column :name, "varchar(255)", :null => true
|
45
|
+
column :offering_cpu_cores, "int(11)", :null=>false
|
46
|
+
column :offering_memory_size, "int(11)", :null=>false
|
47
|
+
|
48
|
+
index [:account_id]
|
49
|
+
index [:node_id]
|
50
|
+
index [:uuid], :unique=>true, :name=>:uuid
|
51
|
+
end
|
52
|
+
|
53
|
+
create_table(:hostname_leases) do
|
54
|
+
primary_key :id, :type=>"int(11)"
|
55
|
+
column :account_id, "varchar(255)", :null=>false
|
56
|
+
column :hostname, "varchar(32)", :null=>false
|
57
|
+
column :created_at, "datetime", :null=>false
|
58
|
+
column :updated_at, "datetime", :null=>false
|
59
|
+
|
60
|
+
index [:account_id, :hostname], :unique=>true
|
61
|
+
end
|
62
|
+
|
63
|
+
create_table(:images) do
|
64
|
+
primary_key :id, :type=>"int(11)"
|
65
|
+
column :account_id, "varchar(255)", :null=>false
|
66
|
+
column :uuid, "varchar(255)", :null=>false
|
67
|
+
column :created_at, "datetime", :null=>false
|
68
|
+
column :updated_at, "datetime", :null=>false
|
69
|
+
column :boot_dev_type, "int(11)", :default=>1, :null=>false
|
70
|
+
column :source, "text", :null=>false
|
71
|
+
column :arch, "varchar(255)", :null=>false
|
72
|
+
column :description, "text"
|
73
|
+
column :md5sum, "varchar(255)", :null=>false
|
74
|
+
column :is_public, "tinyint(1)", :null=>false, :default=>false
|
75
|
+
column :state, "varchar(255)", :default=>"init", :null=>false
|
76
|
+
column :features, "text"
|
77
|
+
|
78
|
+
index [:account_id]
|
79
|
+
index [:is_public]
|
80
|
+
index [:uuid], :unique=>true, :name=>:uuid
|
81
|
+
end
|
82
|
+
|
83
|
+
create_table(:instance_security_groups) do
|
84
|
+
primary_key :id, :type=>"int(11)"
|
85
|
+
column :instance_id, "int(11)", :null=>false
|
86
|
+
column :security_group_id, "int(11)", :null=>false
|
87
|
+
|
88
|
+
index [:instance_id]
|
89
|
+
index [:security_group_id]
|
90
|
+
end
|
91
|
+
|
92
|
+
create_table(:instance_nics) do
|
93
|
+
primary_key :id, :type=>"int(11)"
|
94
|
+
column :uuid, "varchar(255)", :null=>false
|
95
|
+
column :instance_id, "int(11)", :null=>false
|
96
|
+
column :network_id, "int(11)", :null=>false
|
97
|
+
column :nat_network_id, "int(11)"
|
98
|
+
column :mac_addr, "varchar(12)", :null=>false
|
99
|
+
column :device_index, "int(11)", :null=>false
|
100
|
+
column :deleted_at, "datetime"
|
101
|
+
column :created_at, "datetime", :null=>false
|
102
|
+
column :updated_at, "datetime", :null=>false
|
103
|
+
|
104
|
+
index [:deleted_at]
|
105
|
+
index [:instance_id]
|
106
|
+
index [:mac_addr]
|
107
|
+
index [:uuid], :unique=>true, :name=>:uuid
|
108
|
+
end
|
109
|
+
|
110
|
+
create_table(:instance_specs) do
|
111
|
+
primary_key :id, :type=>"int(11)"
|
112
|
+
column :account_id, "varchar(255)", :null=>false
|
113
|
+
column :uuid, "varchar(255)", :null=>false
|
114
|
+
column :hypervisor, "varchar(255)", :null=>false
|
115
|
+
column :arch, "varchar(255)", :null=>false
|
116
|
+
column :cpu_cores, "int(11)", :null=>false
|
117
|
+
column :memory_size, "int(11)", :null=>false
|
118
|
+
column :quota_weight, "double", :default=>1.0, :null=>false
|
119
|
+
column :vifs, "text", :default=>''
|
120
|
+
column :drives, "text", :default=>''
|
121
|
+
column :config, "text", :null=>false, :default=>''
|
122
|
+
column :created_at, "datetime", :null=>false
|
123
|
+
column :updated_at, "datetime", :null=>false
|
124
|
+
|
125
|
+
index [:account_id]
|
126
|
+
index [:uuid], :unique=>true, :name=>:uuid
|
127
|
+
end
|
128
|
+
|
129
|
+
create_table(:instances) do
|
130
|
+
primary_key :id, :type=>"int(11)"
|
131
|
+
column :account_id, "varchar(255)", :null=>false
|
132
|
+
column :uuid, "varchar(255)", :null=>false
|
133
|
+
column :host_node_id, "int(11)"
|
134
|
+
column :image_id, "int(11)", :null=>false
|
135
|
+
column :instance_spec_id, "int(11)", :null=>false
|
136
|
+
column :state, "varchar(255)", :default=>"init", :null=>false
|
137
|
+
column :status, "varchar(255)", :default=>"init", :null=>false
|
138
|
+
column :hostname, "varchar(32)", :null=>false
|
139
|
+
column :ssh_key_pair_id, "varchar(255)"
|
140
|
+
column :ha_enabled, "int(11)", :default=>0, :null=>false
|
141
|
+
column :quota_weight, "double", :default=>0.0, :null=>false
|
142
|
+
column :cpu_cores, "int(11)", :null=>false
|
143
|
+
column :memory_size, "int(11)", :null=>false
|
144
|
+
column :user_data, "text", :null=>false
|
145
|
+
column :runtime_config, "text", :null=>false
|
146
|
+
column :ssh_key_data, "text"
|
147
|
+
column :request_params, "text", :null=>false
|
148
|
+
column :terminated_at, "datetime"
|
149
|
+
column :created_at, "datetime", :null=>false
|
150
|
+
column :updated_at, "datetime", :null=>false
|
151
|
+
|
152
|
+
index [:account_id]
|
153
|
+
index [:host_node_id]
|
154
|
+
index [:state]
|
155
|
+
index [:terminated_at]
|
156
|
+
index [:uuid], :unique=>true, :name=>:uuid
|
157
|
+
end
|
158
|
+
|
159
|
+
create_table(:ip_leases) do
|
160
|
+
primary_key :id, :type=>"int(11)"
|
161
|
+
column :instance_nic_id, "int(11)"
|
162
|
+
column :network_id, "int(11)", :null=>false
|
163
|
+
column :ipv4, "varchar(50)"
|
164
|
+
column :alloc_type, "int(11)", :default=>0, :null=>false
|
165
|
+
column :description, "text"
|
166
|
+
column :created_at, "datetime", :null=>false
|
167
|
+
column :updated_at, "datetime", :null=>false
|
168
|
+
|
169
|
+
index [:instance_nic_id, :network_id]
|
170
|
+
index [:network_id, :ipv4], :unique=>true
|
171
|
+
end
|
172
|
+
|
173
|
+
create_table(:job_states) do
|
174
|
+
primary_key :id, :type=>"int(11)"
|
175
|
+
column :job_id, "varchar(80)", :null=>false
|
176
|
+
column :parent_job_id, "varchar(80)"
|
177
|
+
column :node_id, "varchar(255)", :null=>false
|
178
|
+
column :state, "varchar(255)", :null=>false
|
179
|
+
column :message, "text", :null=>false
|
180
|
+
column :created_at, "datetime", :null=>false
|
181
|
+
column :updated_at, "datetime", :null=>false
|
182
|
+
column :started_at, "datetime"
|
183
|
+
column :finished_at, "datetime"
|
184
|
+
|
185
|
+
index [:job_id], :unique=>true
|
186
|
+
end
|
187
|
+
|
188
|
+
create_table(:mac_leases) do
|
189
|
+
primary_key :id, :type=>"int(11)"
|
190
|
+
column :mac_addr, "char(12)", :null=>false
|
191
|
+
column :created_at, "datetime", :null=>false
|
192
|
+
column :updated_at, "datetime", :null=>false
|
193
|
+
|
194
|
+
index [:mac_addr], :unique=>true
|
195
|
+
end
|
196
|
+
|
197
|
+
create_table(:security_groups) do
|
198
|
+
primary_key :id, :type=>"int(11)"
|
199
|
+
column :account_id, "varchar(255)", :null=>false
|
200
|
+
column :uuid, "varchar(255)", :null=>false
|
201
|
+
column :created_at, "datetime", :null=>false
|
202
|
+
column :updated_at, "datetime", :null=>false
|
203
|
+
column :description, "varchar(255)"
|
204
|
+
column :rule, "text"
|
205
|
+
|
206
|
+
index [:account_id]
|
207
|
+
index [:uuid], :unique=>true, :name=>:uuid
|
208
|
+
end
|
209
|
+
|
210
|
+
create_table(:security_group_rules) do
|
211
|
+
primary_key :id, :type=>"int(11)"
|
212
|
+
column :created_at, "datetime", :null=>false
|
213
|
+
column :updated_at, "datetime", :null=>false
|
214
|
+
column :security_group_id, "int(11)", :null=>false
|
215
|
+
column :permission, "varchar(255)", :null=>false
|
216
|
+
|
217
|
+
index [:security_group_id]
|
218
|
+
end
|
219
|
+
|
220
|
+
create_table(:networks) do
|
221
|
+
primary_key :id, :type=>"int(11)"
|
222
|
+
column :account_id, "varchar(255)", :null=>false
|
223
|
+
column :uuid, "varchar(255)", :null=>false
|
224
|
+
column :ipv4_network, "varchar(255)", :null=>false
|
225
|
+
column :ipv4_gw, "varchar(255)"
|
226
|
+
column :prefix, "int(11)", :default=>24, :null=>false
|
227
|
+
column :metric, "int(11)", :default=>100, :null=>false
|
228
|
+
column :domain_name, "varchar(255)"
|
229
|
+
column :dns_server, "varchar(255)"
|
230
|
+
column :dhcp_server, "varchar(255)"
|
231
|
+
column :metadata_server, "varchar(255)"
|
232
|
+
column :metadata_server_port, "int(11)"
|
233
|
+
column :bandwidth, "int(11)"
|
234
|
+
column :vlan_lease_id, "int(11)", :default=>0, :null=>false
|
235
|
+
column :nat_network_id, "int(11)"
|
236
|
+
column :physical_network_id, "int(11)"
|
237
|
+
column :link_interface, "varchar(255)", :null=>false
|
238
|
+
column :description, "text"
|
239
|
+
column :created_at, "datetime", :null=>false
|
240
|
+
column :updated_at, "datetime", :null=>false
|
241
|
+
|
242
|
+
index [:account_id]
|
243
|
+
index [:nat_network_id]
|
244
|
+
index [:uuid], :unique=>true, :name=>:uuid
|
245
|
+
end
|
246
|
+
|
247
|
+
create_table(:dhcp_ranges) do
|
248
|
+
primary_key :id, :type=>"int(11)"
|
249
|
+
column :network_id, "int(11)", :null=>false
|
250
|
+
column :range_begin, "varchar(255)", :null=>false
|
251
|
+
column :range_end, "varchar(255)", :null=>false
|
252
|
+
column :created_at, "datetime", :null=>false
|
253
|
+
column :updated_at, "datetime", :null=>false
|
254
|
+
index [:network_id]
|
255
|
+
end
|
256
|
+
|
257
|
+
create_table(:physical_networks) do
|
258
|
+
primary_key :id, :type=>"int(11)"
|
259
|
+
column :name, "varchar(255)", :null=>false
|
260
|
+
column :interface, "varchar(255)"
|
261
|
+
column :description, "text"
|
262
|
+
column :created_at, "datetime", :null=>false
|
263
|
+
column :updated_at, "datetime", :null=>false
|
264
|
+
index [:name], :unique=>true
|
265
|
+
end
|
266
|
+
|
267
|
+
create_table(:node_states) do
|
268
|
+
primary_key :id, :type=>"int(11)"
|
269
|
+
column :node_id, "varchar(80)", :null=>false
|
270
|
+
column :boot_token, "varchar(10)", :null=>false
|
271
|
+
column :state, "varchar(10)"
|
272
|
+
column :created_at, "datetime", :null=>false
|
273
|
+
column :updated_at, "datetime", :null=>false
|
274
|
+
column :last_ping_at, "datetime", :null=>false
|
275
|
+
|
276
|
+
index [:node_id], :unique=>true
|
277
|
+
end
|
278
|
+
|
279
|
+
create_table(:quotas) do
|
280
|
+
primary_key :id, :type=>"int(11)"
|
281
|
+
column :account_id, "int(11)", :null=>false
|
282
|
+
column :instance_total_weight, "double"
|
283
|
+
column :volume_total_size, "int(11)"
|
284
|
+
column :created_at, "datetime", :null=>false
|
285
|
+
column :updated_at, "datetime", :null=>false
|
286
|
+
|
287
|
+
index [:account_id], :unique=>true
|
288
|
+
end
|
289
|
+
|
290
|
+
create_table(:request_logs) do
|
291
|
+
primary_key :id, :type=>"int(11)"
|
292
|
+
column :request_id, "varchar(40)", :null=>false
|
293
|
+
column :frontend_system_id, "varchar(40)", :null=>false
|
294
|
+
column :account_id, "varchar(40)", :null=>false
|
295
|
+
column :requester_token, "varchar(255)"
|
296
|
+
column :request_method, "varchar(10)", :null=>false
|
297
|
+
column :api_path, "varchar(255)", :null=>false
|
298
|
+
column :params, "text", :null=>false
|
299
|
+
column :response_status, "int(11)", :null=>false
|
300
|
+
column :response_msg, "text"
|
301
|
+
column :requested_at, "datetime", :null=>false
|
302
|
+
column :requested_at_usec, "int(11)", :null=>false
|
303
|
+
column :responded_at, "datetime", :null=>false
|
304
|
+
column :responded_at_usec, "int(11)", :null=>false
|
305
|
+
|
306
|
+
index [:request_id], :unique=>true, :name=>:request_id
|
307
|
+
end
|
308
|
+
|
309
|
+
create_table(:ssh_key_pairs) do
|
310
|
+
primary_key :id, :type=>"int(11)"
|
311
|
+
column :account_id, "varchar(255)", :null=>false
|
312
|
+
column :uuid, "char(8)", :null=>false
|
313
|
+
column :finger_print, "varchar(100)", :null=>false
|
314
|
+
column :public_key, "text", :null=>false
|
315
|
+
column :private_key, "text"
|
316
|
+
column :description, "text"
|
317
|
+
column :created_at, "datetime", :null=>false
|
318
|
+
column :updated_at, "datetime", :null=>false
|
319
|
+
|
320
|
+
index [:account_id]
|
321
|
+
index [:uuid], :unique=>true, :name=>:uuid
|
322
|
+
end
|
323
|
+
|
324
|
+
create_table(:storage_nodes) do
|
325
|
+
primary_key :id, :type=>"int(11)"
|
326
|
+
column :account_id, "varchar(255)", :null=>false
|
327
|
+
column :uuid, "varchar(255)", :null=>false
|
328
|
+
column :node_id, "varchar(255)", :null=>false
|
329
|
+
column :export_path, "varchar(255)", :null=>false
|
330
|
+
column :offering_disk_space, "int(11)", :null=>false
|
331
|
+
column :transport_type, "varchar(255)", :null=>false
|
332
|
+
column :storage_type, "varchar(255)", :null=>false
|
333
|
+
column :ipaddr, "varchar(255)", :null=>false
|
334
|
+
column :snapshot_base_path, "varchar(255)", :null=>false
|
335
|
+
column :created_at, "datetime", :null=>false
|
336
|
+
column :updated_at, "datetime", :null=>false
|
337
|
+
|
338
|
+
index [:account_id]
|
339
|
+
index [:node_id]
|
340
|
+
index [:uuid], :unique=>true, :name=>:uuid
|
341
|
+
end
|
342
|
+
|
343
|
+
create_table(:tag_mappings) do
|
344
|
+
primary_key :id, :type=>"int(11)"
|
345
|
+
column :tag_id, "int(11)", :null=>false
|
346
|
+
column :uuid, "varchar(255)", :null=>false
|
347
|
+
|
348
|
+
index [:tag_id]
|
349
|
+
index [:uuid]
|
350
|
+
end
|
351
|
+
|
352
|
+
create_table(:tags) do
|
353
|
+
primary_key :id, :type=>"int(11)"
|
354
|
+
column :account_id, "varchar(255)", :null=>false
|
355
|
+
column :uuid, "varchar(255)", :null=>false
|
356
|
+
column :type_id, "int(11)", :null=>false
|
357
|
+
column :name, "varchar(255)", :null=>false
|
358
|
+
column :attributes, "varchar(255)"
|
359
|
+
column :created_at, "datetime", :null=>false
|
360
|
+
column :updated_at, "datetime", :null=>false
|
361
|
+
|
362
|
+
index [:account_id]
|
363
|
+
index [:account_id, :type_id, :name], :unique=>true
|
364
|
+
index [:uuid], :unique=>true, :name=>:uuid
|
365
|
+
end
|
366
|
+
|
367
|
+
create_table(:vlan_leases) do
|
368
|
+
primary_key :id, :type=>"int(11)"
|
369
|
+
column :account_id, "varchar(255)", :null=>false
|
370
|
+
column :uuid, "varchar(255)", :null=>false
|
371
|
+
column :tag_id, "int(11)", :null=>false
|
372
|
+
column :created_at, "datetime", :null=>false
|
373
|
+
column :updated_at, "datetime", :null=>false
|
374
|
+
|
375
|
+
index [:uuid], :unique=>true, :name=>:uuid
|
376
|
+
index [:account_id]
|
377
|
+
index [:tag_id], :unique=>true
|
378
|
+
end
|
379
|
+
|
380
|
+
create_table(:volume_snapshots) do
|
381
|
+
primary_key :id, :type=>"int(11)"
|
382
|
+
column :account_id, "varchar(255)", :null=>false
|
383
|
+
column :uuid, "varchar(255)", :null=>false
|
384
|
+
column :storage_node_id, "int(11)", :null=>false
|
385
|
+
column :origin_volume_id, "varchar(255)", :null=>false
|
386
|
+
column :size, "int(11)", :null=>false
|
387
|
+
column :status, "int(11)", :default=>0, :null=>false
|
388
|
+
column :state, "varchar(255)", :default=>"initialized", :null=>false
|
389
|
+
column :destination_key, "varchar(255)", :null=>false
|
390
|
+
column :deleted_at, "datetime"
|
391
|
+
column :created_at, "datetime", :null=>false
|
392
|
+
column :updated_at, "datetime", :null=>false
|
393
|
+
|
394
|
+
index [:uuid], :unique=>true, :name=>:uuid
|
395
|
+
index [:account_id]
|
396
|
+
index [:deleted_at]
|
397
|
+
index [:storage_node_id]
|
398
|
+
end
|
399
|
+
|
400
|
+
create_table(:volumes) do
|
401
|
+
primary_key :id, :type=>"int(11)"
|
402
|
+
column :account_id, "varchar(255)", :null=>false
|
403
|
+
column :uuid, "varchar(255)", :null=>false
|
404
|
+
column :storage_node_id, "int(11)"
|
405
|
+
column :status, "varchar(255)", :default=>"initialized", :null=>false
|
406
|
+
column :state, "varchar(255)", :default=>"initialized", :null=>false
|
407
|
+
column :size, "int(11)", :null=>false
|
408
|
+
column :instance_id, "int(11)"
|
409
|
+
column :boot_dev, "int(11)", :default=>0, :null=>false
|
410
|
+
column :snapshot_id, "varchar(255)"
|
411
|
+
column :host_device_name, "varchar(255)"
|
412
|
+
column :guest_device_name, "varchar(255)"
|
413
|
+
column :export_path, "varchar(255)", :null=>false
|
414
|
+
column :transport_information, "text"
|
415
|
+
column :request_params, "text", :null=>false
|
416
|
+
column :deleted_at, "datetime"
|
417
|
+
column :attached_at, "datetime"
|
418
|
+
column :detached_at, "datetime"
|
419
|
+
column :created_at, "datetime", :null=>false
|
420
|
+
column :updated_at, "datetime", :null=>false
|
421
|
+
|
422
|
+
index [:uuid], :unique=>true, :name=>:uuid
|
423
|
+
index [:account_id]
|
424
|
+
index [:deleted_at]
|
425
|
+
index [:instance_id]
|
426
|
+
index [:snapshot_id]
|
427
|
+
index [:storage_node_id]
|
428
|
+
end
|
429
|
+
|
430
|
+
self[:accounts].insert(:id=>100, :uuid=>'00000000', :description=>'datacenter system account', :updated_at=>Time.now, :created_at=>Time.now)
|
431
|
+
self[:accounts].insert(:id=>101, :uuid=>'shpoolxx', :description=>'system account for shared resources', :updated_at=>Time.now, :created_at=>Time.now)
|
432
|
+
self[:quotas].insert(:id=>1, :account_id=>100,
|
433
|
+
:instance_total_weight=>Dcmgr.conf.account_instance_total_weight, :volume_total_size=>Dcmgr.conf.account_volume_total_size,
|
434
|
+
:updated_at=>Time.now, :created_at=>Time.now)
|
435
|
+
self[:quotas].insert(:id=>2, :account_id=>101,
|
436
|
+
:instance_total_weight=>Dcmgr.conf.account_instance_total_weight, :volume_total_size=>Dcmgr.conf.account_volume_total_size,
|
437
|
+
:updated_at=>Time.now, :created_at=>Time.now)
|
438
|
+
self[:tags].insert(:id=>1, :uuid=>'shhost', :account_id=>'a-shpoolxx', :type_id=>11, :name=>"default_shared_hosts", :updated_at=>Time.now, :created_at=>Time.now)
|
439
|
+
self[:tags].insert(:id=>2, :uuid=>'shnet', :account_id=>'a-shpoolxx', :type_id=>10,:name=>"default_shared_networks", :updated_at=>Time.now, :created_at=>Time.now)
|
440
|
+
self[:tags].insert(:id=>3, :uuid=>'shstor', :account_id=>'a-shpoolxx', :type_id=>12, :name=>"default_shared_storage", :updated_at=>Time.now, :created_at=>Time.now)
|
441
|
+
end
|
442
|
+
|
443
|
+
down do
|
444
|
+
drop_table(:accounts, :frontend_systems, :histories, :host_nodes, :hostname_leases, :images, :instance_security_groups, :instance_nics, :instance_specs, :instances, :ip_leases, :job_states, :mac_leases, :security_groups, :security_group_rules, :networks, :node_states, :quotas, :request_logs, :ssh_key_pairs, :storage_nodes, :tag_mappings, :tags, :vlan_leases, :volume_snapshots, :volumes, :dhcp_ranges, :physical_networks)
|
445
|
+
end
|
446
|
+
end
|