wakame-vdc-webui 11.06.0 → 11.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/Rakefile +7 -7
  2. data/app/controllers/application_controller.rb +5 -1
  3. data/app/controllers/dialog_controller.rb +5 -8
  4. data/app/controllers/instances_controller.rb +25 -7
  5. data/app/controllers/keypairs_controller.rb +2 -3
  6. data/app/controllers/security_groups_controller.rb +14 -15
  7. data/app/controllers/sessions_controller.rb +4 -0
  8. data/app/controllers/snapshots_controller.rb +3 -3
  9. data/app/controllers/volumes_controller.rb +18 -12
  10. data/app/models/dcmgr_resource/instance.rb +18 -2
  11. data/app/models/dcmgr_resource/security_group.rb +38 -0
  12. data/app/models/dcmgr_resource/ssh_key_pair.rb +0 -1
  13. data/app/views/dialog/attach_volume.html.erb +7 -11
  14. data/app/views/dialog/create_and_edit_security_group.html.erb +10 -12
  15. data/app/views/dialog/create_ssh_keypair.html.erb +9 -14
  16. data/app/views/dialog/delete_security_group.html.erb +1 -1
  17. data/app/views/dialog/reboot_instances.html.erb +2 -2
  18. data/app/views/dialog/start_instances.html.erb +1 -1
  19. data/app/views/dialog/stop_instances.html.erb +2 -2
  20. data/app/views/instances/index.html.erb +114 -110
  21. data/app/views/keypairs/index.html.erb +4 -4
  22. data/app/views/layouts/login.html.erb +1 -1
  23. data/app/views/security_groups/index.html.erb +11 -11
  24. data/app/views/sessions/information.html.erb +0 -0
  25. data/app/views/sessions/new.html.erb +24 -31
  26. data/app/views/snapshots/index.html.erb +3 -0
  27. data/app/views/volumes/index.html.erb +0 -5
  28. data/config/application.rb +1 -1
  29. data/config/dcmgr_gui.yml +8 -0
  30. data/{app/api/config/environment.rb → config/environment-auth.rb} +1 -1
  31. data/config/environments/development.rb +1 -1
  32. data/config/environments/production.rb +38 -41
  33. data/config/environments/test.rb +1 -1
  34. data/config/initializers/site.rb +1 -1
  35. data/config/locales/en.yml +16 -7
  36. data/config/locales/ja.yml +6 -4
  37. data/config/routes.rb +3 -0
  38. data/db/migrations/0001_origin.rb +96 -0
  39. data/lib/cli/account.rb +43 -88
  40. data/lib/cli/user.rb +0 -37
  41. data/lib/tasks/dcmgr_gui.rake +2 -2
  42. data/public/i18n/Messages_en.properties +34 -0
  43. data/public/i18n/Messages_ja-JP.properties +0 -0
  44. data/public/i18n/Messages_ja.properties +32 -0
  45. data/public/javascripts/dcmgr_gui/application.js +7 -7
  46. data/public/javascripts/dcmgr_gui/core.js +33 -8
  47. data/public/javascripts/dcmgr_gui/image_panel.js +6 -8
  48. data/public/javascripts/dcmgr_gui/instance_panel.js +29 -29
  49. data/public/javascripts/dcmgr_gui/security_group_panel.js +8 -29
  50. data/public/javascripts/dcmgr_gui/sshkeypair_panel.js +2 -22
  51. data/public/javascripts/dcmgr_gui/volume_panel.js +16 -21
  52. data/public/javascripts/jquery-ui-1.8.4.custom.min.js +0 -0
  53. data/public/stylesheets/common.css +45 -0
  54. metadata +336 -332
  55. data/app/models/dcmgr_resource/netfilter_group.rb +0 -29
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ desc "build gem packages"
12
12
  task :gem do
13
13
  require 'rubygems'
14
14
  require 'rake/gempackagetask'
15
- require 'dcmgr'
15
+ require 'dcmgr/version'
16
16
 
17
17
  spec = Gem::Specification.new do |s|
18
18
  s.platform = Gem::Platform::RUBY
@@ -20,8 +20,8 @@ task :gem do
20
20
  s.authors = ['axsh Ltd.']
21
21
  s.email = ['dev@axsh.net']
22
22
  s.name = 'wakame-vdc-webui'
23
- s.summary = "Datacenter management toolkit for IaaS Cloud: UI frontend"
24
- s.description = ''
23
+ s.summary = "Wakame-VDC: UI frontend"
24
+ s.description = 'Datacenter Hypervisor'
25
25
  s.required_ruby_version = '>= 1.8.7'
26
26
 
27
27
  s.files = Dir['app/**/*.{rb,erb}','lib/**/*.rb',
@@ -32,13 +32,13 @@ task :gem do
32
32
  'script/*', 'test/**/*.rb', 'doc/**/*.*'] +
33
33
  %w(Rakefile config.ru LICENSE NOTICE INSTALL.txt INSTALL-API.txt tmp)
34
34
 
35
- s.add_dependency "rails", '3.0.0'
35
+ s.add_dependency "rails", '3.0.11'
36
36
  s.add_dependency 'mysql','2.8.1'
37
- s.add_dependency 'sequel','3.15.0'
38
- s.add_dependency 'json','1.4.6'
37
+ s.add_dependency 'sequel','3.27.0'
38
+ s.add_dependency 'json','1.6.3'
39
39
  s.add_dependency 'oauth','0.4.1'
40
- s.add_dependency 'i18n', '0.4.2'
41
40
  s.add_dependency 'nokogiri', '1.4.4'
41
+ s.add_dependency 'thor', '0.14.6'
42
42
  end
43
43
 
44
44
  File.open("#{spec.name}.gemspec", 'w'){|f| f.write(spec.to_ruby) }
@@ -1,7 +1,9 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  class ApplicationController < ActionController::Base
4
- protect_from_forgery
4
+ # disable reqeust forgery check since some pages are missing to set
5
+ # the token on using POST.
6
+ #protect_from_forgery
5
7
  include Authentication
6
8
  before_filter :login_required
7
9
  before_filter :set_locale
@@ -10,6 +12,7 @@ class ApplicationController < ActionController::Base
10
12
 
11
13
  def set_application
12
14
  @site = DCMGR_GUI_SITE
15
+ true
13
16
  end
14
17
 
15
18
  def dispatch(name, request)
@@ -55,6 +58,7 @@ class ApplicationController < ActionController::Base
55
58
 
56
59
  @locales = get_locales
57
60
  @locale = I18n.locale
61
+ true
58
62
  end
59
63
 
60
64
  def get_locales
@@ -9,7 +9,7 @@ class DialogController < ApplicationController
9
9
  end
10
10
 
11
11
  def attach_volume
12
- @volume_id = params[:ids][0]
12
+ @volume_ids = params[:ids]
13
13
  end
14
14
 
15
15
  def detach_volume
@@ -45,7 +45,6 @@ class DialogController < ApplicationController
45
45
  end
46
46
 
47
47
  def create_security_group
48
- @uuid = ''
49
48
  @description = ''
50
49
  @rule = ''
51
50
  render :create_and_edit_security_group
@@ -53,17 +52,15 @@ class DialogController < ApplicationController
53
52
 
54
53
  def delete_security_group
55
54
  @uuid = params[:ids][0]
56
- @netfilter_group = DcmgrResource::NetfilterGroup.show(@uuid)
57
- @name = @netfilter_group['name']
55
+ @security_group = DcmgrResource::SecurityGroup.show(@uuid)
58
56
  end
59
57
 
60
58
  def edit_security_group
61
59
  @uuid = params[:ids][0]
62
- @netfilter_group = DcmgrResource::NetfilterGroup.show(@uuid)
60
+ @security_group = DcmgrResource::SecurityGroup.show(@uuid)
63
61
 
64
- @name = @netfilter_group['name']
65
- @description = @netfilter_group["description"]
66
- @rule = @netfilter_group["rule"]
62
+ @description = @security_group["description"]
63
+ @rule = @security_group["rule"]
67
64
  render :create_and_edit_security_group
68
65
  end
69
66
 
@@ -11,7 +11,7 @@ class InstancesController < ApplicationController
11
11
  :host_pool_id => params[:host_pool_id],
12
12
  :host_name => params[:host_name],
13
13
  :user_data => params[:user_data],
14
- :nf_group => params[:nf_group],
14
+ :security_groups => params[:security_groups],
15
15
  :ssh_key => params[:ssh_key]
16
16
  }
17
17
  instance = DcmgrResource::Instance.create(params)
@@ -35,20 +35,38 @@ class InstancesController < ApplicationController
35
35
 
36
36
  def terminate
37
37
  instance_ids = params[:ids]
38
- response = []
38
+ res = []
39
39
  instance_ids.each do |instance_id|
40
- response << DcmgrResource::Instance.destroy(instance_id)
40
+ res << DcmgrResource::Instance.destroy(instance_id)
41
41
  end
42
- render :json => response
42
+ render :json => res
43
43
  end
44
44
 
45
45
  def reboot
46
46
  instance_ids = params[:ids]
47
- response = []
47
+ res = []
48
48
  instance_ids.each do |instance_id|
49
- response << DcmgrResource::Instance.reboot(instance_id)
49
+ res << DcmgrResource::Instance.reboot(instance_id)
50
50
  end
51
- render :json => response
51
+ render :json => res
52
+ end
53
+
54
+ def start
55
+ instance_ids = params[:ids]
56
+ res = []
57
+ instance_ids.each do |instance_id|
58
+ res << DcmgrResource::Instance.start(instance_id)
59
+ end
60
+ render :json => res
61
+ end
62
+
63
+ def stop
64
+ instance_ids = params[:ids]
65
+ res = []
66
+ instance_ids.each do |instance_id|
67
+ res << DcmgrResource::Instance.stop(instance_id)
68
+ end
69
+ render :json => res
52
70
  end
53
71
 
54
72
  def total
@@ -27,12 +27,11 @@ class KeypairsController < ApplicationController
27
27
 
28
28
  def create_ssh_keypair
29
29
  data = {
30
- :name => params[:name],
31
30
  :download_once => params[:download_once]
32
31
  }
33
32
 
34
- @filename = params[:name] + ".pem"
35
33
  @ssh_key_pair = DcmgrResource::SshKeyPair.create(data)
34
+ @filename = @ssh_key_pair.uuid + ".pem"
36
35
 
37
36
  send_data(@ssh_key_pair.private_key,{
38
37
  :filename => @filename,
@@ -54,7 +53,7 @@ class KeypairsController < ApplicationController
54
53
  def prk_download
55
54
  uuid = params[:id]
56
55
  @ssh_key_pair = DcmgrResource::SshKeyPair.show(uuid)
57
- @filename = @ssh_key_pair['name'] + ".pem"
56
+ @filename = @ssh_key_pair['uuid'] + ".pem"
58
57
  send_data(@ssh_key_pair['private_key'],{
59
58
  :filename => @filename,
60
59
  :type => 'application/pgp-encrypted',
@@ -10,31 +10,30 @@ class SecurityGroupsController < ApplicationController
10
10
  :start => params[:start].to_i - 1,
11
11
  :limit => params[:limit]
12
12
  }
13
- @netfilter_group = DcmgrResource::NetfilterGroup.list(data)
14
- respond_with(@netfilter_group[0],:to => [:json])
13
+ @security_group = DcmgrResource::SecurityGroup.list(data)
14
+ respond_with(@security_group[0],:to => [:json])
15
15
  end
16
16
 
17
17
  # security_groups/detail/s-000001.json
18
18
  def show
19
19
  uuid = params[:id]
20
- @netfilter_group = DcmgrResource::NetfilterGroup.show(uuid)
21
- respond_with(@netfilter_group,:to => [:json])
20
+ @security_group = DcmgrResource::SecurityGroup.show(uuid)
21
+ respond_with(@security_group,:to => [:json])
22
22
  end
23
23
 
24
24
  def create
25
25
  data = {
26
- :name => params[:name],
27
26
  :description => params[:description],
28
27
  :rule => params[:rule]
29
28
  }
30
- @netfilter_group = DcmgrResource::NetfilterGroup.create(data)
31
- render :json => @netfilter_group
29
+ @security_group = DcmgrResource::SecurityGroup.create(data)
30
+ render :json => @security_group
32
31
  end
33
32
 
34
33
  def destroy
35
34
  uuid = params[:id]
36
- @netfilter_group = DcmgrResource::NetfilterGroup.destroy(uuid)
37
- render :json => @netfilter_group
35
+ @security_group = DcmgrResource::SecurityGroup.destroy(uuid)
36
+ render :json => @security_group
38
37
  end
39
38
 
40
39
  def update
@@ -43,17 +42,17 @@ class SecurityGroupsController < ApplicationController
43
42
  :description => params[:description],
44
43
  :rule => params[:rule]
45
44
  }
46
- @netfilter_group = DcmgrResource::NetfilterGroup.update(uuid,data)
47
- render :json => @netfilter_group
45
+ @security_group = DcmgrResource::SecurityGroup.update(uuid,data)
46
+ render :json => @security_group
48
47
  end
49
48
 
50
49
  def show_groups
51
- @netfilter_group = DcmgrResource::NetfilterGroup.list
52
- respond_with(@netfilter_group[0],:to => [:json])
50
+ @security_group = DcmgrResource::SecurityGroup.list
51
+ respond_with(@security_group[0],:to => [:json])
53
52
  end
54
53
 
55
54
  def total
56
- total_resource = DcmgrResource::NetfilterGroup.total_resource
55
+ total_resource = DcmgrResource::SecurityGroup.total_resource
57
56
  render :json => total_resource
58
57
  end
59
- end
58
+ end
@@ -6,6 +6,10 @@ class SessionsController < ApplicationController
6
6
  @user = User.new
7
7
  end
8
8
 
9
+ def information
10
+ render :layout => false
11
+ end
12
+
9
13
  def create
10
14
  user = User.authenticate(params[:login], params[:password])
11
15
  @error_message = ''
@@ -21,11 +21,11 @@ class SnapshotsController < ApplicationController
21
21
 
22
22
  def destroy
23
23
  snapshot_ids = params[:ids]
24
- response = []
24
+ res = []
25
25
  snapshot_ids.each do |snapshot_id|
26
- response << DcmgrResource::VolumeSnapshot.delete(snapshot_id)
26
+ res << DcmgrResource::VolumeSnapshot.delete(snapshot_id)
27
27
  end
28
- render :json => response
28
+ render :json => res
29
29
  end
30
30
 
31
31
  def list
@@ -8,14 +8,14 @@ class VolumesController < ApplicationController
8
8
  def create
9
9
  snapshot_ids = params[:ids]
10
10
  if snapshot_ids
11
- response = []
11
+ res = []
12
12
  snapshot_ids.each do |snapshot_id|
13
13
  data = {
14
14
  :snapshot_id => snapshot_id
15
15
  }
16
- response << DcmgrResource::Volume.create(data)
16
+ res << DcmgrResource::Volume.create(data)
17
17
  end
18
- render :json => response
18
+ render :json => res
19
19
  else
20
20
  # Convert to MB
21
21
  size = case params[:unit]
@@ -40,11 +40,11 @@ class VolumesController < ApplicationController
40
40
 
41
41
  def destroy
42
42
  volume_ids = params[:ids]
43
- response = []
43
+ res = []
44
44
  volume_ids.each do |volume_id|
45
- response << DcmgrResource::Volume.destroy(volume_id)
45
+ res << DcmgrResource::Volume.destroy(volume_id)
46
46
  end
47
- render :json => response
47
+ render :json => res
48
48
  end
49
49
 
50
50
  def list
@@ -64,19 +64,25 @@ class VolumesController < ApplicationController
64
64
  end
65
65
 
66
66
  def attach
67
- volume_id = params[:volume_id]
68
67
  instance_id = params[:instance_id]
69
- response = DcmgrResource::Volume.attach(volume_id, instance_id)
70
- render :json => response
68
+ volume_ids = params[:volume_ids]
69
+ res = []
70
+ volume_ids.each do |volume_id|
71
+ data = {
72
+ :volume_id => volume_id
73
+ }
74
+ res << DcmgrResource::Volume.attach(volume_id, instance_id)
75
+ end
76
+ render :json => res
71
77
  end
72
78
 
73
79
  def detach
74
80
  volume_ids = params[:ids]
75
- response = []
81
+ res = []
76
82
  volume_ids.each do |volume_id|
77
- response << DcmgrResource::Volume.detach(volume_id)
83
+ res << DcmgrResource::Volume.detach(volume_id)
78
84
  end
79
- render :json => response
85
+ render :json => res
80
86
  end
81
87
 
82
88
  def total
@@ -15,8 +15,8 @@ module DcmgrResource
15
15
  instance.host_pool_id = params[:host_pool_id]
16
16
  instance.host_name = params[:host_name]
17
17
  instance.user_data = params[:user_data]
18
- instance.nf_group = params[:nf_group]
19
- instance.ssh_key = params[:ssh_key]
18
+ instance.security_groups = params[:security_groups]
19
+ instance.ssh_key_id = params[:ssh_key]
20
20
  instance.save
21
21
  instance
22
22
  end
@@ -32,6 +32,22 @@ module DcmgrResource
32
32
  self.collection_name = @collection
33
33
  result.body
34
34
  end
35
+
36
+ def self.start(instance_id)
37
+ @collection ||= self.collection_name
38
+ self.collection_name = File.join(@collection,instance_id)
39
+ result = self.put(:start)
40
+ self.collection_name = @collection
41
+ result.body
42
+ end
43
+
44
+ def self.stop(instance_id)
45
+ @collection ||= self.collection_name
46
+ self.collection_name = File.join(@collection,instance_id)
47
+ result = self.put(:stop)
48
+ self.collection_name = @collection
49
+ result.body
50
+ end
35
51
 
36
52
  end
37
53
  end
@@ -0,0 +1,38 @@
1
+ module DcmgrResource
2
+ class SecurityGroup < Base
3
+
4
+ def self.create(params)
5
+ security_group = self.new
6
+ security_group.description = params[:description]
7
+ security_group.rule = params[:rule]
8
+ security_group.save
9
+ security_group
10
+ end
11
+
12
+ # workaround for the bug:
13
+ # the value of the key "rule" is encoded to JSON wrongly by
14
+ # ActiveSupport::JSON encoder.
15
+ # "{\"security_group\":{\"description\":\"\",\"rule\":[[null,[],null]]}}"
16
+ # So it has to use the encoder from JSON library.
17
+ def to_json(options={})
18
+ require 'json'
19
+ {'security_group'=>@attributes}.to_json
20
+ end
21
+
22
+ def self.list(params = {})
23
+ self.find(:all,:params => params)
24
+ end
25
+
26
+ def self.show(uuid)
27
+ self.get(uuid)
28
+ end
29
+
30
+ def self.update(uuid,params)
31
+ self.put(uuid,params).body
32
+ end
33
+
34
+ def self.destroy(uuid)
35
+ self.delete(uuid).body
36
+ end
37
+ end
38
+ end
@@ -11,7 +11,6 @@ module DcmgrResource
11
11
 
12
12
  def self.create(params)
13
13
  ssh_key_pair = self.new
14
- ssh_key_pair.name = params[:name]
15
14
  ssh_key_pair.download_once = params[:download_once]
16
15
  ssh_key_pair.save
17
16
  ssh_key_pair
@@ -1,13 +1,9 @@
1
1
  <div id="attach_volume_dialog">
2
- <table>
3
- <tr>
4
- <td><%= t("dialog.attach_volume.volume_id") %>:</td>
5
- <td id="view_volume_id"><%= @volume_id %></td>
6
- <input id="volume_id" type="hidden" value="<%= @volume_id %>">
7
- </tr>
8
- <tr>
9
- <td><%= t("dialog.attach_volume.instance_id") %>:</td>
10
- <td><input id="instance_id" type="text" value=""></td>
11
- </tr>
12
- </table>
2
+ <p><%= t("dialog.attach_volume.instance_id") %>: <input id="instance_id" type="text" value=""></p>
3
+ <br />
4
+ <ul id="attach_volumes">
5
+ <% @volume_ids.each do |volume_id| %>
6
+ <li><%= volume_id %></li>
7
+ <% end %>
8
+ </ul>
13
9
  </div>
@@ -5,27 +5,25 @@
5
5
  }
6
6
  </style>
7
7
  <div id="create_security_group_dialog">
8
- <div id="security_group_name_field">
9
- <p><%= t("dialog.create_and_edit_security_group.name") %></p>
10
- <% if @name %>
11
- <input type="text" id="security_group_name" size="20" value="<%= @name %>" disabled>
12
- <% else %>
13
- <input type="text" id="security_group_name" size="20">
14
- <% end %>
15
- <input type="hidden" id="security_group_id" value="<%= @uuid %>">
16
- </div>
8
+ <div id="security_group_name_field">
9
+ <%- if @uuid -%>
10
+ <p>
11
+ UUID: <%= @uuid %>
12
+ </p>
13
+ <%- end -%>
14
+ <input type="hidden" id="security_group_id" value="<%= @uuid %>">
17
15
  <div id="security_group_description_field">
18
16
  <p>
19
17
  <%= t("dialog.create_and_edit_security_group.description") %>
20
18
  </p>
21
- <input type="text" id="security_group_description" size="43" value="<%= @description %>">
19
+ <input type="text" id="security_group_description" size="43" value="<%= @description %>">
22
20
  </div>
23
21
  <div id="security_group_rule_field">
24
22
  <p>
25
23
  <%= t("dialog.create_and_edit_security_group.rule") %> [<span rel="#rule_help" id="security_group_help" title="Rule Help" style="color:red">?</span>]
26
24
  </p>
27
25
  </div>
28
- <textarea id="security_group_rule" rows="10" cols="10" style="width:442px;height:320px" ><%= @rule %></textarea>
26
+ <textarea id="security_group_rule" rows="10" cols="10" style="width:442px;height:320px" ><%= @rule %></textarea>
29
27
  <div id="rule_help">
30
28
  <pre>
31
29
  SYNOPSIS
@@ -58,7 +56,7 @@ PARAMETERS
58
56
  ex. a-trustedx:default
59
57
 
60
58
  source cidr:
61
- ex. 0.0.0.0/0, 192.168.0.0/24
59
+ ex. 0.0.0.0/0, ip4:192.0.2.0/24
62
60
 
63
61
  </pre>
64
62
  </div>