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
@@ -100,11 +100,6 @@ jQuery(function($){
100
100
  <td class="title"><%= t("volumes.details.created_at") %>:</td>
101
101
  <td colspan="7">${item.created_at}</td>
102
102
  </tr>
103
- <tr>
104
- <td class="padcell"></td>
105
- <td class="title"><%= t("volumes.details.updated_at") %>:</td>
106
- <td colspan="7">${item.updated_at}</td>
107
- </tr>
108
103
  </table>
109
104
  </div>
110
105
  </script>
@@ -3,7 +3,7 @@ require File.expand_path('../boot', __FILE__)
3
3
  # require 'rails/all'
4
4
  # require "active_record/railtie"
5
5
  require "action_controller/railtie"
6
- require "action_mailer/railtie"
6
+ #require "action_mailer/railtie"
7
7
  require "active_resource/railtie"
8
8
  require "rails/test_unit/railtie"
9
9
 
@@ -0,0 +1,8 @@
1
+ development:
2
+ dcmgr_site: 'http://localhost:9001/'
3
+
4
+ test:
5
+ dcmgr_site: 'http://localhost:9001/'
6
+
7
+ production:
8
+ dcmgr_site: 'http://localhost:9001/'
@@ -1,5 +1,5 @@
1
1
  # Load the rails application
2
- require File.expand_path('../../../../config/application', __FILE__)
2
+ require File.join(File.dirname(__FILE__), 'application')
3
3
 
4
4
  # Initialize the rails application
5
5
  DcmgrGui::Application.initialize!
@@ -15,7 +15,7 @@ DcmgrGui::Application.configure do
15
15
  config.action_controller.perform_caching = false
16
16
 
17
17
  # Don't care if the mailer can't send
18
- config.action_mailer.raise_delivery_errors = false
18
+ #config.action_mailer.raise_delivery_errors = false
19
19
 
20
20
  # Print deprecation notices to the Rails logger
21
21
  config.active_support.deprecation = :log
@@ -1,49 +1,46 @@
1
1
  DcmgrGui::Application.configure do
2
2
  # Settings specified here will take precedence over those in config/environment.rb
3
3
 
4
- # The production environment is meant for finished, "live" apps.
5
- # Code is not reloaded between requests
6
- config.cache_classes = true
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the webserver when you make code changes.
7
+ config.cache_classes = true
7
8
 
8
- # Full error reports are disabled and caching is turned on
9
- config.consider_all_requests_local = false
10
- config.action_controller.perform_caching = true
11
-
12
- # Specifies the header that your server uses for sending files
13
- config.action_dispatch.x_sendfile_header = "X-Sendfile"
14
-
15
- # For nginx:
16
- # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
17
-
18
- # If you have no front-end server that supports something like X-Sendfile,
19
- # just comment this out and Rails will serve the files
20
-
21
- # See everything in the log (default is :info)
22
- # config.log_level = :debug
23
-
24
- # Use a different logger for distributed setups
25
- # config.logger = SyslogLogger.new
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
26
11
 
27
- # Use a different cache store in production
28
- # config.cache_store = :mem_cache_store
29
-
30
- # Disable Rails's static asset server
31
- # In production, Apache or nginx will already do this
32
- config.serve_static_assets = false
33
-
34
- # Enable serving of images, stylesheets, and javascripts from an asset server
35
- # config.action_controller.asset_host = "http://assets.example.com"
36
-
37
- # Disable delivery errors, bad email addresses will be ignored
38
- # config.action_mailer.raise_delivery_errors = false
39
-
40
- # Enable threaded mode
41
- # config.threadsafe!
12
+ # Show full error reports and disable caching
13
+ config.consider_all_requests_local = false
14
+ config.action_view.debug_rjs = false
15
+ config.action_controller.perform_caching = true
42
16
 
43
- # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
44
- # the I18n.default_locale when a translation can not be found)
17
+ # Don't care if the mailer can't send
18
+ #config.action_mailer.raise_delivery_errors = false
19
+
20
+ # Print deprecation notices to the Rails logger
21
+ config.active_support.deprecation = :log
22
+
23
+ # Only use best-standards-support built into browsers
24
+ config.action_dispatch.best_standards_support = :builtin
25
+
26
+ # Config authentication for WebAPI
27
+ # Setting proxy server
28
+ config.proxy_host = "127.0.0.1"
29
+ config.proxy_port = 8080
30
+ config.proxy_scheme = "http"
31
+ config.proxy_dcmgr_host = "127.0.0.1"
32
+ config.proxy_dcmgr_port = 9001
33
+ config.proxy_root_user = 'root'
34
+ config.proxy_nginx = '/opt/nginx/sbin/nginx'
35
+
36
+ # Setting authentication server
37
+ config.auth_host = "127.0.0.1"
38
+ config.auth_port = 3000
39
+ config.auth_root_user = 'root'
40
+
41
+ config.i18n.load_path += Dir[Rails.root.join('locales', '*.{rb,yml}').to_s]
42
+ config.i18n.default_locale = :en
43
+ #config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
44
+
45
45
  config.i18n.fallbacks = true
46
-
47
- # Send deprecation notices to registered listeners
48
- config.active_support.deprecation = :notify
49
46
  end
@@ -23,7 +23,7 @@ DcmgrGui::Application.configure do
23
23
  # Tell Action Mailer not to deliver emails to the real world.
24
24
  # The :test delivery method accumulates sent emails in the
25
25
  # ActionMailer::Base.deliveries array.
26
- config.action_mailer.delivery_method = :test
26
+ #config.action_mailer.delivery_method = :test
27
27
 
28
28
  # Use SQL instead of Active Record's schema dumper when creating the test database.
29
29
  # This is necessary if your schema can't be completely dumped by the schema dumper,
@@ -1,7 +1,7 @@
1
1
  DCMGR_GUI_SITE = {
2
2
  :title => 'Wakame UI',
3
3
  :meta => {
4
- :keywords => 'あくしゅ,axsh,wakame',
4
+ :keywords => 'axsh,wakame',
5
5
  :description => 'Wakame UI'
6
6
  },
7
7
  :logo => 'Wakame Inexhaustible Supply of Cloud Fuel.'
@@ -20,6 +20,8 @@ en:
20
20
  attach: "Yes, Attach"
21
21
  detach: "Yes, Detach"
22
22
  launch: "Launch"
23
+ start: "Start"
24
+ stop: "Stop"
23
25
  selectmenu:
24
26
  select_action: "Select an Action"
25
27
  select_region: "Region: "
@@ -34,10 +36,10 @@ en:
34
36
  dialog:
35
37
  terminate_instances:
36
38
  header: "Terminate Instances"
37
- message: "Are you sure you want to terminate this instance?"
39
+ message: "Are you sure you want to terminate those instances?"
38
40
  reboot_instances:
39
41
  header: "Reboot Instances"
40
- message: "Are you sure you want to reboot this instance?"
42
+ message: "Are you sure you want to reboot those instances?"
41
43
  launch_instance:
42
44
  header: "Launch Instance"
43
45
  wmi_id: "WMI ID"
@@ -77,7 +79,6 @@ en:
77
79
  edit_security_group:
78
80
  header: "Edit Security Group"
79
81
  create_and_edit_security_group:
80
- name: "Name"
81
82
  description: "Description"
82
83
  rule: "Rule"
83
84
  delete_security_group:
@@ -85,11 +86,16 @@ en:
85
86
  message: "Are you sure you want to delete the following security_group?"
86
87
  create_ssh_keypair:
87
88
  header: "Create SSH Key Pair"
88
- keypair_name: "Key Pair Name"
89
89
  download_once: "Download Once"
90
90
  delete_ssh_keypair:
91
91
  header: "Delete SSH Key Pair"
92
92
  message: "Are you sure you want to delete the following key pair?"
93
+ start_instances:
94
+ header: "Start Instances"
95
+ message: "Are you sure you want to start those instances?"
96
+ stop_instances:
97
+ header: "Stop Instances"
98
+ message: "Are you sure you want to stop those instances?"
93
99
  login:
94
100
  sign_in: "Sign In"
95
101
  user: "User"
@@ -127,6 +133,8 @@ en:
127
133
  header: "Instance Actions"
128
134
  terminate: "Terminate"
129
135
  reboot: "Reboot"
136
+ start: "Start"
137
+ stop: "Stop"
130
138
  list:
131
139
  instance_id: "Instance ID"
132
140
  wmi_id: "WMI ID"
@@ -229,6 +237,7 @@ en:
229
237
  capacity: "Capacity"
230
238
  origin_volume_id: "OriginVolumeID"
231
239
  destination: "Destiantion"
240
+ backing_store: "BackingStore"
232
241
  status: "Status"
233
242
  created_at: "Created At"
234
243
  updated_at: "Updated At"
@@ -257,12 +266,12 @@ en:
257
266
  delete_security_group: "Delete Security Group"
258
267
  edit_security_group: "Edit"
259
268
  list:
260
- name: "Name"
269
+ name: "Security Group ID"
261
270
  descriptions: "Description"
262
271
  action: "Action"
263
272
  details:
264
273
  header: "Details"
265
- name: "Name"
274
+ name: "Security Group ID"
266
275
  description: "Description"
267
276
  created_at: "Created At"
268
277
  updated_at: "Updated At"
@@ -277,7 +286,7 @@ en:
277
286
  secret_access_key: "Secret Access Key"
278
287
  details:
279
288
  header: "Details"
280
- name: "Name"
289
+ uuid: "UUID"
281
290
  fingerprint: "Fingerprint"
282
291
  created_at: "Created"
283
292
  updated_at: "Updated"
@@ -19,6 +19,8 @@ ja:
19
19
  attach: "アタッチ"
20
20
  detach: "デタッチ"
21
21
  launch: "起動"
22
+ start: "再開"
23
+ stop: "一時停止"
22
24
  selectmenu:
23
25
  select_action: "アクション"
24
26
  select_region: "データセンタ: "
@@ -76,7 +78,6 @@ ja:
76
78
  edit_security_group:
77
79
  header: "セキュリティグループを編集"
78
80
  create_and_edit_security_group:
79
- name: "セキュリティグループ名"
80
81
  description: "詳細"
81
82
  rule: "ルール"
82
83
  delete_security_group:
@@ -84,7 +85,6 @@ ja:
84
85
  message: "セキュリティーグループを削除します。よろしいですか?"
85
86
  create_ssh_keypair:
86
87
  header: "キーペアを作成"
87
- keypair_name: "キーペア名"
88
88
  download_once: "1回限り"
89
89
  delete_ssh_keypair:
90
90
  header: "キーペアを削除"
@@ -126,6 +126,8 @@ ja:
126
126
  header: "アクション"
127
127
  terminate: "停止"
128
128
  reboot: "再起動"
129
+ start: "再開"
130
+ stop: "一時停止"
129
131
  list:
130
132
  instance_id: "インスタンスID"
131
133
  wmi_id: "WMI ID"
@@ -227,6 +229,7 @@ ja:
227
229
  capacity: "容量"
228
230
  origin_volume_id: "ボリューム元ID"
229
231
  destination: "保存先"
232
+ backing_store: "バッキングストア"
230
233
  status: "状態"
231
234
  created_at: "作成日"
232
235
  updated_at: "更新日"
@@ -260,7 +263,6 @@ ja:
260
263
  action: "アクション"
261
264
  details:
262
265
  header: "詳細"
263
- name: "名前"
264
266
  description: "詳細"
265
267
  created_at: "作成日"
266
268
  updated_at: "更新日"
@@ -275,7 +277,7 @@ ja:
275
277
  secret_access_key: "シークレットキー"
276
278
  details:
277
279
  header: "詳細"
278
- name: "名前"
280
+ uuid: "UUID"
279
281
  fingerprint: "フィンガープリント"
280
282
  created_at: "作成日"
281
283
  updated_at: "更新日"
data/config/routes.rb CHANGED
@@ -57,6 +57,8 @@ DcmgrGui::Application.routes.draw do
57
57
  post 'instances/reboot' ,:to => 'instances#reboot'
58
58
  post 'instances' ,:to => 'instances#create'
59
59
  get 'instances/show/:id' ,:to => 'instances#show'
60
+ post 'instances/start' ,:to => 'instances#start'
61
+ post 'instances/stop' ,:to => 'instances#stop'
60
62
 
61
63
  #instance_specs
62
64
  get 'instance_specs/all' ,:to => 'instance_specs#show_instance_specs'
@@ -93,6 +95,7 @@ DcmgrGui::Application.routes.draw do
93
95
  #sessions
94
96
  get 'login' => 'sessions#new', :as => :login
95
97
  get 'logout' => 'sessions#destroy', :as => :logout
98
+ get 'sessions/information', :to => 'sessions#information'
96
99
  resource :session, :only => [:new, :create, :destroy]
97
100
 
98
101
  #storage_pools
@@ -0,0 +1,96 @@
1
+ Sequel.migration do
2
+ up do
3
+ create_table(:accounts, :ignore_index_errors=>true) do
4
+ primary_key :id
5
+ String :uuid, :null=>false, :size=>8, :fixed=>true
6
+ DateTime :created_at, :null=>false
7
+ DateTime :updated_at, :null=>false
8
+ String :name, :null=>false, :size=>255
9
+ String :description, :size=>255
10
+ TrueClass :enable, :default=>true
11
+ DateTime :deleted_at
12
+ TrueClass :is_deleted, :default=>false
13
+
14
+ index [:uuid], :unique=>true, :name=>:uuid
15
+ end
16
+
17
+ create_table(:authzs) do
18
+ primary_key :id
19
+ DateTime :created_at, :null=>false
20
+ DateTime :updated_at, :null=>false
21
+ Integer :user_id, :null=>false
22
+ Integer :account_id, :null=>false
23
+ Integer :type_id, :null=>false
24
+ end
25
+
26
+ create_table(:information) do
27
+ primary_key :id
28
+ DateTime :created_at, :null=>false
29
+ DateTime :updated_at, :null=>false
30
+ String :title, :size=>255
31
+ String :link, :text=>true
32
+ String :description, :text=>true
33
+ end
34
+
35
+ create_table(:oauth_consumers, :ignore_index_errors=>true) do
36
+ primary_key :id
37
+ DateTime :created_at, :null=>false
38
+ DateTime :updated_at, :null=>false
39
+ String :key, :null=>false, :size=>40
40
+ String :secret, :null=>false, :size=>40
41
+ Integer :account_id, :null=>false
42
+
43
+ index [:account_id], :unique=>true, :name=>:account_id
44
+ index [:key], :unique=>true
45
+ end
46
+
47
+ create_table(:tag_mappings, :ignore_index_errors=>true) do
48
+ primary_key :id
49
+ Integer :tag_id, :null=>false
50
+ Integer :target_type
51
+ Integer :target_id, :null=>false
52
+
53
+ index [:tag_id, :target_type, :target_id]
54
+ end
55
+
56
+ create_table(:tags, :ignore_index_errors=>true) do
57
+ primary_key :id
58
+ String :uuid, :null=>false, :size=>8, :fixed=>true
59
+ DateTime :created_at, :null=>false
60
+ DateTime :updated_at, :null=>false
61
+ Integer :account_id, :null=>false
62
+ Integer :owner_id, :null=>false
63
+ String :name, :null=>false, :size=>32, :fixed=>true
64
+
65
+ index [:account_id]
66
+ index [:uuid], :unique=>true, :name=>:uuid
67
+ end
68
+
69
+ create_table(:users, :ignore_index_errors=>true) do
70
+ primary_key :id
71
+ String :uuid, :null=>false, :size=>8, :fixed=>true
72
+ DateTime :created_at, :null=>false
73
+ DateTime :updated_at, :null=>false
74
+ DateTime :last_login_at, :null=>false
75
+ String :name, :null=>false, :size=>200, :fixed=>true
76
+ String :login_id, :size=>255
77
+ String :password, :null=>false, :size=>255
78
+ String :primary_account_id, :size=>255
79
+ String :locale, :null=>false, :size=>255
80
+ String :time_zone, :null=>false, :size=>255
81
+
82
+ index [:login_id], :unique=>true, :name=>:login_id
83
+ index [:uuid], :unique=>true, :name=>:uuid
84
+ end
85
+
86
+ create_table(:users_accounts) do
87
+ primary_key :id
88
+ Integer :user_id, :null=>false
89
+ Integer :account_id, :null=>false
90
+ end
91
+ end
92
+
93
+ down do
94
+ drop_table(:accounts, :authzs, :information, :oauth_consumers, :tag_mappings, :tags, :users, :users_accounts)
95
+ end
96
+ end
data/lib/cli/account.rb CHANGED
@@ -7,48 +7,11 @@ require 'yaml'
7
7
  module Cli
8
8
  class AccountCli < Base
9
9
  namespace :account
10
- #M=Dcmgr::Models
11
-
12
- #no_tasks {
13
- #def before_task
14
- ## Setup DB connections and load paths for dcmgr_gui
15
- #root_dir = File.expand_path('../../../', __FILE__)
16
-
17
- ##get the database details
18
- ##TODO:get this path in a less hard-coded way?
19
- #content = File.new(File.expand_path('../../frontend/dcmgr_gui/config/database.yml', root_dir)).read
20
- #settings = YAML::load content
21
-
22
- ##load the database variables
23
- ##TODO: get environment from RAILS_ENV
24
- #db_environment = 'development'
25
- #db_adapter = settings[db_environment]['adapter']
26
- #db_host = settings[db_environment]['host']
27
- #db_name = settings[db_environment]['database']
28
- #db_user = settings[db_environment]['user']
29
- #db_pwd = settings[db_environment]['password']
30
-
31
- ##Connect to the database
32
- #url = "#{db_adapter}://#{db_host}/#{db_name}?user=#{db_user}&password=#{db_pwd}"
33
- #db = Sequel.connect(url)
34
-
35
- ##load the cli environment
36
- #$LOAD_PATH.unshift File.expand_path('../../frontend/dcmgr_gui/config', root_dir)
37
- #$LOAD_PATH.unshift File.expand_path('../../frontend/dcmgr_gui/app/models', root_dir)
38
- ##require 'account'
39
- #require 'environment-cli'
40
-
41
- ##Associate the models with their respective database
42
- #Account.db = db
43
- #User.db = db
44
- #end
45
- #}
46
10
 
47
11
  desc "add [options]", "Create a new account."
48
- method_option :name, :type => :string, :aliases => "-n", :required => true, :desc => "The name for the new account." #Maximum size: 255
12
+ method_option :name, :type => :string, :aliases => "-n", :required => true, :desc => "The name for the new account."
49
13
  method_option :uuid, :type => :string, :aliases => "-u", :desc => "The UUID for the new account."
50
14
  method_option :description, :type => :string, :aliases => "-d", :default => "", :desc => "The description for this account."
51
- #method_option :verbose, :type => :boolean, :aliases => "-v", :desc => "Print feedback on what is happening."
52
15
  def add
53
16
  #Check if the data we got is valid
54
17
  if options[:name] != nil && options[:name].length > 255
@@ -58,24 +21,6 @@ module Cli
58
21
  raise "Account description can not be longer than 100 chracters."
59
22
  end
60
23
 
61
- #Put them in the backend
62
- #fields = {:description => options[:description], :enabled => M::Account::ENABLED}
63
- #fields.merge!({:uuid => options[:uuid]}) unless options[:uuid].nil?
64
-
65
- #new_uuid = super(M::Account,fields)
66
-
67
- ##This should never happen as long as the databases remain synchronized.
68
- #begin
69
- #raise "A uuid collision occurred. This means the account databases are not synchronized." if Account[new_uuid] != nil
70
- #rescue
71
- #M::Account[new_uuid].delete
72
- #raise
73
- #end
74
-
75
- #Put them in the frontend
76
- #super(Account,{:uuid => new_uuid,:name => options[:name],:description => options[:description]})
77
-
78
- #puts new_uuid
79
24
  fields = {:name => options[:name],:description => options[:description], :enable => Account::ENABLED}
80
25
  fields.merge!({:uuid => options[:uuid]}) unless options[:uuid].nil?
81
26
  puts super(Account,fields)
@@ -85,8 +30,7 @@ module Cli
85
30
  method_option :deleted, :type => :boolean, :default => false, :aliases => "-d", :desc => "Show deleted accounts."
86
31
  def show(uuid = nil)
87
32
  if uuid
88
- #back_acc = M::Account[uuid] || raise(Thor::Error, "Unknown Account UUID: #{uuid}")
89
- acc = Account[uuid] || raise(Thor::Error, "Unknown Account UUID: #{uuid}")
33
+ acc = Account[uuid] || UnknownUUIDError.raise(uuid)
90
34
  puts ERB.new(<<__END, nil, '-').result(binding)
91
35
  Account UUID:
92
36
  <%- if acc.class == Account -%>
@@ -135,22 +79,22 @@ __END
135
79
  end
136
80
 
137
81
  desc "modify UUID [options]", "Modify an existing account."
138
- method_option :name, :type => :string, :aliases => "-n", :desc => "The new name for the account." #Maximum size: 200
82
+ method_option :name, :type => :string, :aliases => "-n", :desc => "The new name for the account."
139
83
  method_option :description, :type => :string, :aliases => "-d", :desc => "The new description for the account."
140
- #method_option :verbose, :type => :boolean, :aliases => "-v", :desc => "Print feedback on what is happening."
141
84
  def modify(uuid)
142
85
  raise "Account name can not be longer than 255 characters." if options[:name] != nil && options[:name].length > 255
143
86
  raise "Description can not be longer than 100 characters." if options[:description] != nil && options[:description].length > 100
144
87
  super(Account,uuid,{:name => options[:name],:description => options[:description]})
145
- #super(M::Account,uuid,{:description => options[:description]})
146
88
  end
147
89
 
148
90
  #TODO: show account to confirm deletion
149
91
  desc "del UUID [options]", "Deletes an existing account."
150
92
  method_option :verbose, :type => :boolean, :aliases => "-v", :desc => "Print feedback on what is happening."
151
93
  def del(uuid)
94
+ to_do = Account[uuid]
95
+ Error.raise("Unknown frontend account UUID: #{uuid}", 100) if to_do == nil or to_do.is_deleted
96
+
152
97
  super(Account,uuid)
153
- #super(M::Account,uuid)
154
98
 
155
99
  puts "Account #{uuid} has been deleted." if options[:verbose]
156
100
  end
@@ -160,19 +104,14 @@ __END
160
104
  def enable(uuid)
161
105
  to_enable = Account[uuid]
162
106
  Error.raise("Unknown frontend account UUID: #{uuid}", 100) if to_enable == nil or to_enable.is_deleted
163
- #to_enable_back = M::Account[uuid] || Error.raise("Unknown backend account UUID: #{uuid}", 100)
164
107
 
165
- if to_enable.enable?# && to_enable_back.enable?
108
+ if to_enable.enable?
166
109
  puts "Account #{uuid} is already enabled." if options[:verbose]
167
- else
110
+ else
168
111
  to_enable.enable = Account::ENABLED
169
112
  to_enable.updated_at = Time.now.utc.iso8601
170
- to_enable.save
171
-
172
- #to_enable_back.enabled = Dcmgr::Models::Account::ENABLED
173
- #to_enable_back.updated_at = Time.now.utc.iso8601
174
- #to_enable_back.save
175
-
113
+ to_enable.save
114
+
176
115
  puts "Account #{uuid} has been enabled." if options[:verbose]
177
116
  end
178
117
  end
@@ -182,19 +121,14 @@ __END
182
121
  def disable(uuid)
183
122
  to_disable = Account[uuid]
184
123
  UnknownUUIDError.raise(uuid) if to_disable == nil or to_disable.is_deleted
185
- #to_disable_back = M::Account[uuid] || Error.raise("Unknown backend account UUID: #{uuid}", 100)
186
124
 
187
- if to_disable.disable? #&& to_disable_back.disable?
125
+ if to_disable.disable?
188
126
  puts "Account #{id} is already disabled." if options[:verbose]
189
127
  else
190
128
  to_disable.enable = Account::DISABLED
191
129
  to_disable.updated_at = Time.now.utc.iso8601
192
130
  to_disable.save
193
131
 
194
- #to_disable_back.enabled = M::Account::DISABLED
195
- #to_disable_back.updated_at = Time.now.utc.iso8601
196
- #to_disable_back.save
197
-
198
132
  puts "Account #{uuid} has been disabled." if options[:verbose]
199
133
  end
200
134
  end
@@ -249,16 +183,37 @@ __END
249
183
  }
250
184
  end
251
185
 
252
- #desc "quota UUID [options]","Set quota settings for an account."
253
- #method_option :weight, :type => :numeric, :aliases => "-w", :desc => "The instance total weight to set this account's quota to."
254
- #method_option :size, :type => :numeric, :aliases => "-s", :desc => "The volume total size to set this account's quota to."
255
- #def quota(uuid)
256
- #account = M::Account[uuid] || UnknownUUIDError.raise(uuid)
257
- #account.quota.instance_total_weight = options[:weight] unless options[:weight].nil?
258
- #account.quota.volume_total_size = options[:size] unless options[:size].nil?
259
- #account.quota.updated_at = Time.now.utc.iso8601
260
- #account.quota.save
261
- #end
262
-
186
+
187
+ desc "oauth UUID [options]", "Generate or show OAuth key and secret"
188
+ def oauth(uuid)
189
+ require 'oauth'
190
+ acc = Account[uuid]
191
+ Error.raise("Unknown frontend account UUID: #{uuid}", 100) if acc == nil or acc.is_deleted
192
+
193
+ oauth_token = OauthToken.new
194
+ oauth_token.generate_keys
195
+ oauth_consumer = OauthConsumer.find(:account_id => acc.id)
196
+ if oauth_consumer.nil?
197
+ oauth_consumer = OauthConsumer.create(
198
+ :key => oauth_token.token,
199
+ :secret => oauth_token.secret,
200
+ :account_id => acc.id
201
+ )
202
+ end
203
+
204
+ puts ERB.new(<<__END, nil, '-').result(binding)
205
+ Account UUID:
206
+ <%- if acc.class == Account -%>
207
+ <%= acc.canonical_uuid %>
208
+ <%- else -%>
209
+ <%= Account.uuid_prefix%>-<%= acc.uuid %>
210
+ <%- end -%>
211
+
212
+ Consumer Key:
213
+ <%= oauth_consumer.key %>
214
+ Consumer Secret:
215
+ <%= oauth_consumer.secret %>
216
+ __END
217
+ end
263
218
  end
264
219
  end