wakame-vdc-webui 10.12.0 → 11.06.0
Sign up to get free protection for your applications and to get access to all the features.
- data/INSTALL-API.txt +14 -0
- data/Rakefile +5 -1
- data/app/api/config/environment.rb +9 -0
- data/app/controllers/accounts_controller.rb +39 -1
- data/app/controllers/application_controller.rb +73 -1
- data/app/controllers/instance_specs_controller.rb +11 -0
- data/app/controllers/instances_controller.rb +7 -3
- data/app/controllers/{images_controller.rb → machine_images_controller.rb} +2 -3
- data/app/controllers/sessions_controller.rb +6 -3
- data/app/controllers/snapshots_controller.rb +17 -6
- data/app/controllers/volumes_controller.rb +6 -2
- data/app/helpers/application_helper.rb +9 -5
- data/app/helpers/machine_images_helper.rb +2 -0
- data/app/models/account.rb +22 -4
- data/app/models/base_new.rb +11 -2
- data/app/models/dcmgr_resource/base.rb +13 -0
- data/app/models/dcmgr_resource/instance_spec.rb +7 -0
- data/app/models/dcmgr_resource/volume_snapshot.rb +6 -0
- data/app/models/information.rb +1 -1
- data/app/models/oauth_consumer.rb +15 -0
- data/app/models/oauth_token.rb +10 -0
- data/app/models/user.rb +34 -1
- data/app/views/accounts/index.html.erb +42 -67
- data/app/views/accounts/password.html.erb +35 -0
- data/app/views/dialog/attach_volume.html.erb +2 -2
- data/app/views/dialog/create_and_edit_security_group.html.erb +61 -28
- data/app/views/dialog/create_snapshot.html.erb +11 -4
- data/app/views/dialog/create_ssh_keypair.html.erb +2 -2
- data/app/views/dialog/create_volume.html.erb +3 -4
- data/app/views/dialog/create_volume_from_snapshot.html.erb +1 -1
- data/app/views/dialog/delete_security_group.html.erb +1 -1
- data/app/views/dialog/delete_snapshot.html.erb +1 -1
- data/app/views/dialog/delete_ssh_keypair.html.erb +1 -1
- data/app/views/dialog/delete_volume.html.erb +1 -1
- data/app/views/dialog/detach_volume.html.erb +1 -1
- data/app/views/dialog/launch_instance.html.erb +10 -14
- data/app/views/dialog/reboot_instances.html.erb +1 -1
- data/app/views/dialog/terminate_instances.html.erb +1 -1
- data/app/views/home/index.html.erb +11 -11
- data/app/views/host_pools/index.html.erb +87 -92
- data/app/views/instances/index.html.erb +50 -52
- data/app/views/keypairs/index.html.erb +16 -16
- data/app/views/layouts/_header.html.erb +6 -6
- data/app/views/layouts/_informationarea.html.erb +5 -5
- data/app/views/layouts/_login_header.erb +1 -1
- data/app/views/layouts/_sidemenu.html.erb +30 -28
- data/app/views/layouts/application.html.erb +19 -3
- data/app/views/layouts/login.html.erb +4 -4
- data/app/views/{images → machine_images}/index.html.erb +20 -39
- data/app/views/security_groups/index.html.erb +20 -23
- data/app/views/sessions/new.html.erb +10 -5
- data/app/views/snapshots/index.html.erb +28 -26
- data/app/views/storage_pools/index.html.erb +17 -22
- data/app/views/volumes/index.html.erb +32 -34
- data/config/application-cli.rb +33 -0
- data/config/{application-api.rb → cli_token.rb} +0 -0
- data/config/environment-cli.rb +4 -0
- data/config/environments/development.rb +19 -0
- data/config/initializers/dcmgr_gui.rb +8 -3
- data/config/initializers/sequel.rb +4 -0
- data/config/initializers/site.rb +8 -0
- data/config/locales/en.yml +307 -1
- data/config/locales/ja-JP.yml +4 -0
- data/config/locales/ja.yml +309 -0
- data/config/routes.rb +16 -9
- data/lib/cli/account.rb +264 -0
- data/lib/cli/base.rb +74 -0
- data/lib/cli/errors.rb +59 -0
- data/lib/cli/user.rb +226 -0
- data/lib/tasks/dcmgr_api.rake +65 -12
- data/lib/tasks/dcmgr_gui.rake +96 -4
- data/lib/tasks/dcmgr_oauth.rake +39 -0
- data/public/i18n/Messages.properties +0 -0
- data/public/images/Chevron.gif +0 -0
- data/public/images/ChevronOverlay.png +0 -0
- data/public/images/IconHome.gif +0 -0
- data/public/images/bg-box-body.gif +0 -0
- data/public/images/bg-box-body.png +0 -0
- data/public/images/bg-box-bottom.gif +0 -0
- data/public/images/bg-box-bottom.png +0 -0
- data/public/images/bg-box-top.gif +0 -0
- data/public/images/bg-box-top.png +0 -0
- data/public/images/cluetip/arrowdown.gif +0 -0
- data/public/images/cluetip/arrowleft.gif +0 -0
- data/public/images/cluetip/arrowright.gif +0 -0
- data/public/images/cluetip/arrowup.gif +0 -0
- data/public/images/cluetip/bl.gif +0 -0
- data/public/images/cluetip/bl.png +0 -0
- data/public/images/cluetip/br.gif +0 -0
- data/public/images/cluetip/br.png +0 -0
- data/public/images/cluetip/darrowdown.gif +0 -0
- data/public/images/cluetip/darrowleft.gif +0 -0
- data/public/images/cluetip/darrowright.gif +0 -0
- data/public/images/cluetip/darrowup.gif +0 -0
- data/public/images/cluetip/itunes.png +0 -0
- data/public/images/cluetip/rarrowdown.gif +0 -0
- data/public/images/cluetip/rarrowleft.gif +0 -0
- data/public/images/cluetip/rarrowright.gif +0 -0
- data/public/images/cluetip/rarrowup.gif +0 -0
- data/public/images/cluetip/tl.gif +0 -0
- data/public/images/cluetip/tl.png +0 -0
- data/public/images/cluetip/tr.gif +0 -0
- data/public/images/cluetip/tr.png +0 -0
- data/public/images/cluetip/wait.gif +0 -0
- data/public/images/dialog-error.png +0 -0
- data/public/images/dialog-help.png +0 -0
- data/public/images/dialog-information.png +0 -0
- data/public/images/dialog-warning.png +0 -0
- data/public/images/ui-bg_flat_55_fcf0ba_40x100.png +0 -0
- data/public/images/ui-bg_glass_10_136d76_1x400.png +0 -0
- data/public/images/ui-bg_glass_10_458845_1x400.png +0 -0
- data/public/images/ui-bg_highlight-hard_100_f5f3e5_1x100.png +0 -0
- data/public/images/ui-bg_highlight-hard_100_fafaf4_1x100.png +0 -0
- data/public/images/ui-bg_highlight-soft_50_136d76_1x100.png +0 -0
- data/public/images/ui-bg_inset-soft_15_386b3d_1x100.png +0 -0
- data/public/images/ui-icons_4c9052_256x240.png +0 -0
- data/public/images/ui-icons_847e71_256x240.png +0 -0
- data/public/javascripts/dcmgr_gui/account_panel.js +6 -0
- data/public/javascripts/dcmgr_gui/application.js +78 -5
- data/public/javascripts/dcmgr_gui/core.js +409 -102
- data/public/javascripts/dcmgr_gui/dashboard_panel.js +12 -3
- data/public/javascripts/dcmgr_gui/host_pool_panel.js +1 -1
- data/public/javascripts/dcmgr_gui/image_panel.js +119 -65
- data/public/javascripts/dcmgr_gui/instance_panel.js +86 -44
- data/public/javascripts/dcmgr_gui/security_group_panel.js +135 -77
- data/public/javascripts/dcmgr_gui/snapshot_panel.js +119 -61
- data/public/javascripts/dcmgr_gui/sshkeypair_panel.js +71 -47
- data/public/javascripts/dcmgr_gui/storage_pool_panel.js +10 -10
- data/public/javascripts/dcmgr_gui/volume_panel.js +311 -155
- data/public/javascripts/jquery.cluetip.min.js +33 -0
- data/public/javascripts/jquery.easing.1.3.js +205 -0
- data/public/javascripts/jquery.hoverIntent.js +114 -0
- data/public/javascripts/jquery.i18n.properties-min.js +7 -0
- data/public/javascripts/jquery.jBreadCrumb.1.1.js +240 -0
- data/public/javascripts/sexyalertbox.v1.2.jquery.js +414 -0
- data/public/javascripts/ui.selectmenu.js +541 -0
- data/public/stylesheets/BreadCrumb.css +109 -0
- data/public/stylesheets/common.css +146 -86
- data/public/stylesheets/dialog.css +7 -7
- data/public/stylesheets/jquery-ui-1.8.4.custom.css +41 -40
- data/public/stylesheets/jquery.cluetip.css +179 -0
- data/public/stylesheets/sexyalertbox.css +67 -0
- data/public/stylesheets/ui.selectmenu.css +24 -0
- data/test/functional/{images_controller_test.rb → machine_images_controller_test.rb} +1 -1
- data/test/unit/helpers/machine_images_helper_test.rb +4 -0
- metadata +350 -221
- data/README +0 -256
- data/app/api/auth_server.rb +0 -28
- data/app/helpers/images_helper.rb +0 -2
- data/app/views/information/index.html.erb +0 -25
- data/app/views/layouts/_service_health.erb +0 -27
- data/test/unit/helpers/images_helper_test.rb +0 -4
data/lib/cli/user.rb
ADDED
@@ -0,0 +1,226 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'sequel'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
#TODO: Print only the first line of an exception?
|
7
|
+
module Cli
|
8
|
+
class UserCli < Base
|
9
|
+
namespace :user
|
10
|
+
|
11
|
+
#no_tasks {
|
12
|
+
#def before_task
|
13
|
+
## Setup DB connections and load paths for dcmgr_gui
|
14
|
+
#root_dir = File.expand_path('../../../', __FILE__)
|
15
|
+
|
16
|
+
##get the database details
|
17
|
+
##TODO:get this path in a less hard-coded way?
|
18
|
+
#content = File.new(File.expand_path('../../frontend/dcmgr_gui/config/database.yml', root_dir)).read
|
19
|
+
#settings = YAML::load content
|
20
|
+
|
21
|
+
##load the database variables
|
22
|
+
##TODO: get environment from RAILS_ENV
|
23
|
+
#db_environment = 'development'
|
24
|
+
#db_adapter = settings[db_environment]['adapter']
|
25
|
+
#db_host = settings[db_environment]['host']
|
26
|
+
#db_name = settings[db_environment]['database']
|
27
|
+
#db_user = settings[db_environment]['user']
|
28
|
+
#db_pwd = settings[db_environment]['password']
|
29
|
+
|
30
|
+
##Connect to the database
|
31
|
+
#url = "#{db_adapter}://#{db_host}/#{db_name}?user=#{db_user}&password=#{db_pwd}"
|
32
|
+
#db = Sequel.connect(url)
|
33
|
+
|
34
|
+
##load the cli environment
|
35
|
+
#$LOAD_PATH.unshift File.expand_path('../../frontend/dcmgr_gui/config', root_dir)
|
36
|
+
#$LOAD_PATH.unshift File.expand_path('../../frontend/dcmgr_gui/app/models', root_dir)
|
37
|
+
|
38
|
+
#require 'environment-cli'
|
39
|
+
#require 'user'
|
40
|
+
#require 'account'
|
41
|
+
#User.db = db
|
42
|
+
#Account.db = db
|
43
|
+
#end
|
44
|
+
#}
|
45
|
+
|
46
|
+
desc "add [options]", "Create a new user."
|
47
|
+
method_option :name, :type => :string, :required => true, :aliases => "-n", :desc => "The name for the new user." #Maximum size: 200
|
48
|
+
method_option :uuid, :type => :string, :aliases => "-u", :desc => "The UUID for the new user."
|
49
|
+
method_option :login_id, :type => :string, :aliases => "-l", :desc => "Optional: The login_id for the new user." #Maximum size: 255
|
50
|
+
method_option :password, :type => :string, :required => true, :aliases => "-p", :desc => "The password for the new user." #Maximum size: 255
|
51
|
+
method_option :primary_account_id, :type => :string, :aliases => "-a", :desc => "Optional: The primary account to associate this user with." #Maximum size: 255
|
52
|
+
#method_option :verbose, :type => :boolean, :aliases => "-v", :desc => "Print feedback on what is happening."
|
53
|
+
def add
|
54
|
+
if options[:name].length > 200
|
55
|
+
Error.raise("User name can not be longer than 200 characters", 100)
|
56
|
+
elsif options[:login_id] != nil && options[:login_id].length > 255
|
57
|
+
Error.raise("User login_id can not be longer than 255 characters",100)
|
58
|
+
elsif options[:password].length > 255
|
59
|
+
Error.raise("User password can not be longer than 255 characters", 100)
|
60
|
+
elsif options[:primary_account_id] != nil && options[:primary_account_id].length > 255
|
61
|
+
Error.raise(Thor::Error, "User primary_account_id can not be longer than 255 characters",100)
|
62
|
+
else
|
63
|
+
#Check if the primary account uuid exists
|
64
|
+
Error.raise("Unknown Account UUID #{options[:primary_account_id]}",100) if options[:primary_account_id] != nil && Account[options[:primary_account_id]].nil?
|
65
|
+
|
66
|
+
#The login id is needed to log into the web ui. Therefore we set it to name if it isn't provided.
|
67
|
+
if options[:login_id].nil?
|
68
|
+
login_id = options[:name]
|
69
|
+
else
|
70
|
+
login_id = options[:login_id]
|
71
|
+
end
|
72
|
+
|
73
|
+
#Check if username is available
|
74
|
+
Error.raise("Login id already in use: '#{login_id}'.",100) unless User.find(:name => login_id).nil?
|
75
|
+
|
76
|
+
#Encrypt the password
|
77
|
+
pwd_hash = User.encrypt_password(options[:password])
|
78
|
+
|
79
|
+
#Put them in there
|
80
|
+
fields = {:name => options[:name], :login_id => login_id, :password => pwd_hash}
|
81
|
+
fields.merge!({:uuid => options[:uuid]}) unless options[:uuid].nil?
|
82
|
+
new_uuid = super(User,fields)
|
83
|
+
|
84
|
+
#TODO: put this in the model instead
|
85
|
+
unless options[:primary_account_id] == nil
|
86
|
+
new_user = User[new_uuid]
|
87
|
+
prim_acc = Account[options[:primary_account_id]]
|
88
|
+
new_user.add_account(prim_acc)
|
89
|
+
new_user.primary_account_id = prim_acc.uuid
|
90
|
+
new_user.save
|
91
|
+
end
|
92
|
+
puts new_uuid
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
desc "show [UUID] [options]", "Show one user or all users currently in the database"
|
97
|
+
def show(uuid = nil)
|
98
|
+
if uuid
|
99
|
+
user = User[uuid] || UnknownUUIDError.raise(uuid)
|
100
|
+
puts ERB.new(<<__END, nil, '-').result(binding)
|
101
|
+
User UUID:
|
102
|
+
<%= user.canonical_uuid %>
|
103
|
+
Name:
|
104
|
+
<%= user.name %>
|
105
|
+
<%- if user.login_id -%>
|
106
|
+
Login ID:
|
107
|
+
<%= user.login_id %>
|
108
|
+
<%- end -%>
|
109
|
+
<%- if user.primary_account_id -%>
|
110
|
+
Primary Account:
|
111
|
+
<%- prim_acc = Account.find(:uuid => user.primary_account_id) -%>
|
112
|
+
<%- if prim_acc.class == Account -%>
|
113
|
+
<%= prim_acc.canonical_uuid %>\t<%= prim_acc.name %>
|
114
|
+
<%- else -%>
|
115
|
+
<%= Account.uuid_prefix%>-<%= prim_acc.uuid %>\t<%= prim_acc.name %>
|
116
|
+
<%- end -%>
|
117
|
+
<%- end -%>
|
118
|
+
<%- unless user.accounts.empty? -%>
|
119
|
+
Associated accounts:
|
120
|
+
<%- user.accounts.each { |row| -%>
|
121
|
+
<%- if row.class == Account -%>
|
122
|
+
<%= row.canonical_uuid %>\t<%= row.name %>
|
123
|
+
<%- else -%>
|
124
|
+
<%= Account.uuid_prefix%>-<%= row.uuid %>\t<%= row.name %>
|
125
|
+
<%- end -%>
|
126
|
+
<%- } -%>
|
127
|
+
<%- end -%>
|
128
|
+
__END
|
129
|
+
else
|
130
|
+
user = User.all
|
131
|
+
puts ERB.new(<<__END, nil, '-').result(binding)
|
132
|
+
<%- user.each { |row| -%>
|
133
|
+
<%= row.canonical_uuid %>\t<%= row.name %>
|
134
|
+
<%- } -%>
|
135
|
+
__END
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
desc "modify UUID [options]", "Update an existing user."
|
140
|
+
method_option :name, :type => :string, :aliases => "-n", :desc => "The new name for the user." #Maximum size: 200
|
141
|
+
method_option :login_id, :type => :string, :aliases => "-l", :desc => "The new login_id for the user." #Maximum size: 255
|
142
|
+
method_option :password, :type => :string, :aliases => "-p", :desc => "The new password for the user." #Maximum size: 255
|
143
|
+
#method_option :primary_account_id, :type => :string, :aliases => "-a", :desc => "The new primary account to associate this user with."
|
144
|
+
def modify(uuid)
|
145
|
+
Error.raise("User name can not be longer than 200 characters",100) if options[:name] != nil && options[:name].length > 200
|
146
|
+
Error.raise("User login_id can not be longer than 255 characters",100) if options[:login_id] != nil && options[:login_id].length > 255
|
147
|
+
Error.raise("User password can not be longer than 255 characters",100) if options[:password] != nil && options[:password].length > 255
|
148
|
+
Error.raise("User primary_account_id can not be longer than 255 characters",100) if options[:primary_account_id] != nil && options[:primary_account_id].length > 255
|
149
|
+
|
150
|
+
fields = options.merge({})
|
151
|
+
fields[:password] = User.encrypt_password(options[:password])
|
152
|
+
fields[:primary_account_id] = Account.trim_uuid(options[:primary_account_id]) unless options[:primary_account_id].nil?
|
153
|
+
|
154
|
+
super(User,uuid,fields)
|
155
|
+
end
|
156
|
+
|
157
|
+
#TODO: allow deletion of multiple id's at once
|
158
|
+
desc "del UUID", "Delete an existing user."
|
159
|
+
method_option :verbose, :type => :boolean, :aliases => "-v", :desc => "Print feedback on what is happening."
|
160
|
+
def del(uuid)
|
161
|
+
super(User,uuid)
|
162
|
+
puts "User #{uuid} has been deleted." if options[:verbose]
|
163
|
+
end
|
164
|
+
|
165
|
+
desc "primacc UUID", "Set or get the primary account for a user"
|
166
|
+
method_option :account_id, :type => :string, :aliases => "-a", :desc => "The id of the new primary account"
|
167
|
+
def primacc(uuid)
|
168
|
+
user = User[uuid] || UnknownUUIDError.raise(uuid)
|
169
|
+
|
170
|
+
if options[:account_id]
|
171
|
+
acc = Account[options[:account_id]] || UnknownUUIDError.raise(options[:account_id])
|
172
|
+
user.primary_account_id = acc.uuid
|
173
|
+
user.save
|
174
|
+
user.add_account(acc) unless user.accounts.member?(acc)
|
175
|
+
else
|
176
|
+
puts Account.uuid_prefix + "-" + user.primary_account_id
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
desc "associate UUID", "Associate a user with one or multiple accounts."
|
181
|
+
method_option :account_ids, :type => :array, :required => true, :aliases => "-a", :desc => "The id of the acounts to associate these user with. Any non-existing or non numeral id will be ignored"
|
182
|
+
method_option :verbose, :type => :boolean, :aliases => "-v", :desc => "Print feedback on what is happening."
|
183
|
+
def associate(uuid)
|
184
|
+
user = User[uuid] || UnknownUUIDError.raise(uuid)
|
185
|
+
options[:account_ids].each { |a|
|
186
|
+
if Account[a].nil?
|
187
|
+
puts "Unknown Account UUID: #{a}" if options[:verbose]
|
188
|
+
elsif !user.accounts.index(Account[a]).nil?
|
189
|
+
puts "User #{uuid} is already associated with account #{a}." if options[:verbose]
|
190
|
+
else
|
191
|
+
user.add_account(Account[a])
|
192
|
+
if user.primary_account_id.nil?
|
193
|
+
user.primary_account_id = Account.trim_uuid(a)
|
194
|
+
user.save
|
195
|
+
end
|
196
|
+
puts "User #{uuid} successfully associated with account #{a}." if options[:verbose]
|
197
|
+
end
|
198
|
+
}
|
199
|
+
end
|
200
|
+
|
201
|
+
desc "dissociate UUID", "Dissociate a user from one or multiple accounts."
|
202
|
+
method_option :account_ids, :type => :array, :required => true, :aliases => "-a", :desc => "The id of the acounts to dissociate these user from. Any non-existing or non numeral id will be ignored"
|
203
|
+
method_option :verbose, :type => :boolean, :aliases => "-v", :desc => "Print feedback on what is happening."
|
204
|
+
def dissociate(uuid)
|
205
|
+
user = User[uuid] || UnknownUUIDError.raise(uuid)
|
206
|
+
options[:account_ids].each { |a|
|
207
|
+
if Account[a].nil?
|
208
|
+
puts "Unknown Account UUID: #{a}" if options[:verbose]
|
209
|
+
elsif user.accounts.index(Account[a]).nil?
|
210
|
+
puts "User #{uuid} is not associated with account #{a}." if options[:verbose]
|
211
|
+
else
|
212
|
+
user.remove_account(Account[a])
|
213
|
+
|
214
|
+
puts "User #{uuid} successfully dissociated from account #{a}." if options[:verbose]
|
215
|
+
|
216
|
+
if Account[a].uuid == user.primary_account_id
|
217
|
+
user.primary_account_id = nil
|
218
|
+
user.save
|
219
|
+
puts "This was user #{uuid}'s primary account. Has been set to Null now." if options[:verbose]
|
220
|
+
end
|
221
|
+
end
|
222
|
+
}
|
223
|
+
end
|
224
|
+
|
225
|
+
end
|
226
|
+
end
|
data/lib/tasks/dcmgr_api.rake
CHANGED
@@ -1,32 +1,85 @@
|
|
1
|
+
def get_rackup_command(mode)
|
2
|
+
default_mode = 'rackup'
|
3
|
+
unless ['rackup', 'unicorn'].include? mode
|
4
|
+
mode = default_mode
|
5
|
+
end
|
6
|
+
mode
|
7
|
+
end
|
8
|
+
|
1
9
|
namespace :api do
|
2
10
|
desc 'Create proxy configuration file.'
|
3
11
|
task :create_proxy_config => :environment do |t,args|
|
4
12
|
base_dir = Dir.getwd
|
5
|
-
|
6
|
-
|
13
|
+
file = File.join(base_dir, 'config', 'proxy.conf')
|
7
14
|
config_file = ERB.new File.new("./app/api/proxy_nginx.conf", "r").read
|
8
|
-
File.open(
|
15
|
+
File.open(file, "w+") { |f| f.write(config_file.result(binding)) }
|
9
16
|
|
10
|
-
puts "Created new proxy configuration file: '#{
|
17
|
+
puts "Created new proxy configuration file: '#{file}'."
|
11
18
|
end
|
12
19
|
|
13
20
|
desc 'Start proxy server'
|
14
21
|
task :start_proxy => :environment do |t,args|
|
15
|
-
|
16
|
-
|
22
|
+
|
23
|
+
user = DcmgrGui::Application.config.proxy_root_user
|
24
|
+
nginx = DcmgrGui::Application.config.proxy_nginx
|
25
|
+
exec "sudo -u #{user} #{nginx} -c #{Dir.getwd}/config/proxy.conf"
|
17
26
|
puts "Nginx proxy server up and running."
|
18
27
|
end
|
19
28
|
|
20
29
|
desc 'Stop proxy server'
|
21
30
|
task :stop_proxy => :environment do |t,args|
|
22
|
-
|
23
|
-
|
31
|
+
user = DcmgrGui::Application.config.proxy_root_user
|
32
|
+
nginx = DcmgrGui::Application.config.proxy_nginx
|
33
|
+
exec "sudo -u #{user} #{nginx} -s stop -c #{Dir.getwd}/config/proxy.conf"
|
24
34
|
puts "Nginx proxy server shut down."
|
25
35
|
end
|
26
|
-
|
27
|
-
|
28
|
-
|
36
|
+
|
37
|
+
desc 'Create configuration file for auth server.'
|
38
|
+
task :create_auth_server_config => :environment do |t,args|
|
39
|
+
base_dir = Dir.getwd
|
40
|
+
file = File.join(base_dir, 'config', 'auth_server.conf')
|
41
|
+
config_file = ERB.new File.new("./app/api/auth_server.conf", "r").read
|
42
|
+
File.open(file, "w+") { |f| f.write(config_file.result(binding)) }
|
43
|
+
|
44
|
+
puts "Created auth server configuration file: '#{file}'."
|
45
|
+
end
|
46
|
+
|
47
|
+
desc 'Start auth server'
|
48
|
+
task :start_auth_server,[:mode] => :environment do |t,args|
|
49
|
+
mode = get_rackup_command(args['mode'])
|
50
|
+
rackup_file = "#{Dir.getwd}/app/api/config.ru"
|
51
|
+
pid_file = "/var/run/wakame-auth.pid"
|
52
|
+
host = DcmgrGui::Application.config.auth_host
|
53
|
+
port = DcmgrGui::Application.config.auth_port
|
29
54
|
|
30
|
-
|
55
|
+
command = "sudo #{mode} #{rackup_file} -D -o #{host} -p #{port}"
|
56
|
+
if mode == 'rackup'
|
57
|
+
command = "#{command} -P #{pid_file}"
|
58
|
+
elsif mode == 'unicorn'
|
59
|
+
begin
|
60
|
+
require 'unicorn'
|
61
|
+
rescue ::LoadError => e
|
62
|
+
abort(e.message)
|
63
|
+
end
|
64
|
+
command = "#{command} -c #{Dir.getwd}/config/auth_server.conf"
|
65
|
+
end
|
66
|
+
exec "#{command}"
|
67
|
+
puts "Auth server up and running."
|
68
|
+
end
|
69
|
+
|
70
|
+
desc 'Stop auth server'
|
71
|
+
task :stop_auth_server,[:mode] => :environment do |t,args|
|
72
|
+
pid_file = "/var/run/wakame-auth.pid"
|
73
|
+
if File.exists? pid_file
|
74
|
+
mode = get_rackup_command(args['mode'])
|
75
|
+
if mode == 'rackup'
|
76
|
+
command = "sudo kill -SIGINT `cat #{pid_file}`"
|
77
|
+
elsif mode == 'unicorn'
|
78
|
+
command = "sudo kill -QUIT `cat #{pid_file}`"
|
79
|
+
end
|
80
|
+
exec command
|
81
|
+
puts "Auth server shut down."
|
82
|
+
end
|
31
83
|
end
|
84
|
+
|
32
85
|
end
|
data/lib/tasks/dcmgr_gui.rake
CHANGED
@@ -6,19 +6,31 @@ namespace :db do
|
|
6
6
|
|
7
7
|
task :sample_data => :environment do
|
8
8
|
User.create(:uuid => '00000000',
|
9
|
-
:login_id => '
|
10
|
-
:password => User.encrypt_password('
|
9
|
+
:login_id => 'wakame',
|
10
|
+
:password => User.encrypt_password('wakame'),
|
11
11
|
:primary_account_id => '00000000'
|
12
12
|
)
|
13
13
|
|
14
14
|
Account.create(:uuid => '00000000',
|
15
|
-
:name => '
|
15
|
+
:name => 'wakame',
|
16
16
|
:enable => 1
|
17
17
|
)
|
18
|
+
|
19
|
+
User.create(:uuid => 'shpoolxx',
|
20
|
+
:login_id => 'demo',
|
21
|
+
:password => User.encrypt_password('demo'),
|
22
|
+
:primary_account_id => 'shpoolxx'
|
23
|
+
)
|
24
|
+
|
25
|
+
Account.create(:uuid => 'shpoolxx',
|
26
|
+
:name => 'demo',
|
27
|
+
:enable => 1
|
28
|
+
)
|
18
29
|
|
19
30
|
sql = 'insert into users_accounts(user_id,account_id) values(?,?)'
|
20
31
|
DB = Schema.current_connect
|
21
32
|
DB['users_accounts'].with_sql(sql,1,1).first
|
33
|
+
DB['users_accounts'].with_sql(sql,2,2).first
|
22
34
|
|
23
35
|
publish_date = '2010-11-19 9:00:00'
|
24
36
|
title = "新機能の提供を開始しました。"
|
@@ -33,6 +45,38 @@ namespace :db do
|
|
33
45
|
end
|
34
46
|
|
35
47
|
namespace :admin do
|
48
|
+
desc 'Create information'
|
49
|
+
task :create_information,[:url] => :environment do |t, args|
|
50
|
+
require 'nokogiri'
|
51
|
+
require 'open-uri'
|
52
|
+
|
53
|
+
if args[:url].nil?
|
54
|
+
puts 'Please set the url.'
|
55
|
+
exit(0)
|
56
|
+
end
|
57
|
+
|
58
|
+
xml = args[:url]
|
59
|
+
doc = Nokogiri::XML(open(xml))
|
60
|
+
|
61
|
+
@links = doc.xpath('//item').map do |i|
|
62
|
+
{'title' => i.xpath('title'),
|
63
|
+
'link' => i.xpath('link'),
|
64
|
+
'description' => i.xpath('description'),
|
65
|
+
'created_at' => i.xpath('pubDate')
|
66
|
+
}
|
67
|
+
end
|
68
|
+
|
69
|
+
#Rest information table
|
70
|
+
Information.truncate
|
71
|
+
|
72
|
+
@links.each do |item|
|
73
|
+
Information.create(:title => item['title'].text,
|
74
|
+
:description => item['description'].text,
|
75
|
+
:link => item['link'].text,
|
76
|
+
:created_at => DateTime.parse(item['created_at'].text))
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
36
80
|
desc 'Create user'
|
37
81
|
task :create_user,[:login_id,:password] => :environment do |t,args|
|
38
82
|
password = encrypted_password = User.encrypt_password(args[:password])
|
@@ -48,4 +92,52 @@ namespace :admin do
|
|
48
92
|
sql = 'insert into users_accounts(user_id,account_id) values(?,?)'
|
49
93
|
DB['users_accounts'].with_sql(sql,args[:user_id],result.id).first
|
50
94
|
end
|
51
|
-
|
95
|
+
|
96
|
+
desc 'Generate i18n files for javascript'
|
97
|
+
task :generate_i18n => :environment do |t, args|
|
98
|
+
locals_path = File.join(RAILS_ROOT, 'config', 'locales')
|
99
|
+
I18n.load_path.each do |path|
|
100
|
+
if path =~ %r{#{locals_path}}
|
101
|
+
locale = path.sub(%r{#{locals_path}/}, '').split('.')[0]
|
102
|
+
data = YAML.load(File.read(path))[locale]
|
103
|
+
i18n_table = []
|
104
|
+
if data.is_a? Hash
|
105
|
+
data.keys.each do |key|
|
106
|
+
|
107
|
+
if key == 'dialog'
|
108
|
+
data[key].keys.each do |i18n_key|
|
109
|
+
i18n_value = data[key][i18n_key]['header']
|
110
|
+
if i18n_value
|
111
|
+
i18n_table.push({:key => "#{i18n_key}_header",
|
112
|
+
:value => i18n_value})
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
if ['button', 'parts', 'pagenate', 'date', 'error_box'].include? key
|
118
|
+
data[key].keys.each do |i18n_key|
|
119
|
+
i18n_value = data[key][i18n_key]
|
120
|
+
if i18n_value
|
121
|
+
i18n_table.push({:key => "#{i18n_key}_#{key}",
|
122
|
+
:value => i18n_value})
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
output_data = ''
|
131
|
+
i18n_table.each do |data|
|
132
|
+
output_data += "#{data[:key]} = #{data[:value]}\n"
|
133
|
+
end
|
134
|
+
output_filename = "Messages_#{locale}.properties"
|
135
|
+
output_file = File.join(File.join(RAILS_ROOT, 'public', 'i18n'), output_filename)
|
136
|
+
f = File.open(output_file, "w")
|
137
|
+
f.write(output_data)
|
138
|
+
f.close
|
139
|
+
puts("Generated 18n file #{output_file}")
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|