Skip to content

Commit 02eb6cd

Browse files
authored
Merge pull request #12 from khos2ow/4.11_and_cookstyle
fix more cookstyle errors
2 parents ed56314 + ce2b45c commit 02eb6cd

File tree

19 files changed

+78
-87
lines changed

19 files changed

+78
-87
lines changed

.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
AllCops:
2+
Exclude:
3+
- 'Vagrantfile'

Berksfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
source "https://supermarket.chef.io"
1+
source 'https://supermarket.chef.io'
22

33
metadata

Thorfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ require 'bundler/setup'
55
require 'berkshelf/thor'
66

77
begin
8-
require "kitchen/thor_tasks"
8+
require 'kitchen/thor_tasks'
99
Kitchen::ThorTasks.new
1010
rescue LoadError
11-
puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV["CI"]
11+
puts '>>>>> Kitchen gem not loaded, omitting tasks' unless ENV['CI']
1212
end

Vagrantfile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
1818
#
1919
# $ vagrant plugin install vagrant-omnibus
2020
#
21-
if Vagrant.has_plugin?("vagrant-omnibus")
21+
if Vagrant.has_plugin?('vagrant-omnibus')
2222
config.omnibus.chef_version = 'latest'
2323
end
2424

@@ -27,7 +27,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
2727
# config.vm.box_url doesn't need to be specified.
2828
config.vm.box = 'chef/ubuntu-14.04'
2929

30-
3130
# Assign this VM to a host-only network IP, allowing you to access it
3231
# via the IP. Host-only networks can talk to the host machine as well as
3332
# any other machines on the same network, but cannot be accessed (through this
@@ -79,12 +78,12 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
7978
mysql: {
8079
server_root_password: 'rootpass',
8180
server_debian_password: 'debpass',
82-
server_repl_password: 'replpass'
83-
}
81+
server_repl_password: 'replpass',
82+
},
8483
}
8584

8685
chef.run_list = [
87-
'recipe[cloudstack::default]'
86+
'recipe[cloudstack::default]',
8887
]
8988
end
9089
end

libraries/database.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def init_config_database
4343
def dbconf_exist?
4444
# test if db.properties as been modified from default installation file. if password encrypted, then we step there to not break anything.
4545
Chef::Log.debug 'Checking to see if database config db.properties as been configured'
46-
conf_exist = Mixlib::ShellOut.new("cat /etc/cloudstack/management/db.properties |grep \"ENC(\"")
46+
conf_exist = Mixlib::ShellOut.new('cat /etc/cloudstack/management/db.properties |grep "ENC("')
4747
conf_exist.run_command
4848
if conf_exist.exitstatus == 0
4949
return true

libraries/global_setting.rb

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,25 @@
2020

2121
module Cloudstack
2222
module GlobalSetting
23-
2423
# Support whyrun
2524
def whyrun_supported?
2625
false
2726
end
28-
27+
2928
def load_current_value(name)
3029
require 'cloudstack_ruby_client'
3130
# get CloudStack current value of the Global Setting
3231
client = CloudstackRubyClient::Client.new('http://localhost:8080/client/api/', @current_resource.admin_apikey, @current_resource.admin_secretkey, false)
33-
client.list_configurations(:name => name)['configuration'].first['value']
32+
client.list_configurations(name: name)['configuration'].first['value']
3433
end
35-
34+
3635
def update_setting(name, value)
3736
require 'cloudstack_ruby_client'
3837
client = CloudstackRubyClient::Client.new('http://localhost:8080/client/api/', @current_resource.admin_apikey, @current_resource.admin_secretkey, false)
39-
client.update_configuration({
40-
:name => name,
41-
:value => value
42-
})
38+
client.update_configuration(
39+
name: name,
40+
value: value
41+
)
4342
end
44-
4543
end
4644
end

libraries/system_template.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def get_template_id
2828
template_id = Mixlib::ShellOut.new(template_cmd)
2929
template_id.run_command
3030
Chef::Log.debug "template id = #{template_id.stdout.chomp}"
31-
return template_id.stdout.chomp
31+
template_id.stdout.chomp
3232
end
3333

3434
# Create or mount secondary storage path
@@ -46,7 +46,7 @@ def secondary_storage
4646

4747
def download_systemvm_template
4848
# Create database configuration for cloudstack management server that will use and existing database.
49-
#puts "Downloading system template from: #{@current_resource.url}"
49+
# puts "Downloading system template from: #{@current_resource.url}"
5050
Chef::Log.info "Downloading system template for #{@current_resource.hypervisor}, this will take some time..."
5151
download_cmd = "/usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt -m #{@current_resource.nfs_path} -u #{@current_resource.url} -h #{@current_resource.hypervisor} -F"
5252
download_template = Mixlib::ShellOut.new(download_cmd)

providers/api_keys.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ def whyrun_supported?
4040

4141
action :create do
4242
wait_count = 0
43-
until cloudstack_api_is_running? or wait_count == 5 do
43+
until cloudstack_api_is_running? || wait_count == 5 do
4444
cloudstack_api_is_running?
4545
sleep(5)
46-
wait_count +=1
46+
wait_count += 1
4747
if wait_count == 1
4848
Chef::Log.info 'Waiting CloudStack to start'
4949
end
@@ -54,7 +54,7 @@ def whyrun_supported?
5454

5555
action :reset do
5656
# force generate new API keys
57-
#load_current_resource
57+
# load_current_resource
5858
if cloudstack_is_running?
5959
if @current_resource.username == 'admin'
6060
converge_by('Reseting admin api keys') do

providers/global_setting.rb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
unless @current_resource.admin_apikey.nil?
3434
unless @current_resource.exists
3535
converge_by("Update Global Setting: #{@current_resource.name} to #{@current_resource.value}") do
36-
#test_connection?(@current_resource.admin_apikey, @current_resource.admin_secretkey)
36+
# test_connection?(@current_resource.admin_apikey, @current_resource.admin_secretkey)
3737
update_setting(@current_resource.name, @current_resource.value)
3838
end
3939
end
@@ -44,7 +44,7 @@ def load_current_resource
4444
require 'cloudstack_ruby_client'
4545
@current_resource = Chef::Resource::CloudstackGlobalSetting.new(@new_resource.name)
4646
@current_resource.name(@new_resource.name)
47-
if $admin_apikey.nil?
47+
if $admin_apikey.nil?
4848
@current_resource.admin_apikey(@new_resource.admin_apikey)
4949
@current_resource.admin_secretkey(@new_resource.admin_secretkey)
5050
else # if it's the first run on the server $admin_apikey will not be empty
@@ -61,12 +61,10 @@ def load_current_resource
6161
current_value = load_current_value(@current_resource.name)
6262
if current_value.nil?
6363
Chef::Log.error "Global Setting: #{@current_resource.name} not found"
64+
elsif @current_resource.value == current_value
65+
@current_resource.exists = true
6466
else
65-
if @current_resource.value == current_value
66-
@current_resource.exists = true
67-
else
68-
@current_resource.exists = false
69-
end
67+
@current_resource.exists = false
7068
end
7169
end
7270
else

providers/setup_database.rb

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# limitations under the License.
1818
#
1919

20-
#include Chef::Mixin::ShellOut
20+
# include Chef::Mixin::ShellOut
2121
include Cloudstack::Helper
2222
include Cloudstack::Database
2323

@@ -59,16 +59,14 @@ def load_current_resource
5959

6060
if cloudstack_is_running?
6161
@current_resource.exists = true
62-
else
63-
if dbconf_exist?
64-
if db_exist?(@current_resource.ip, @current_resource.user, @current_resource.password)
65-
@current_resource.exists = true
66-
else
67-
Chef::Log.info 'Database server ready, not database found, creating it...'
68-
@current_resource.exists = false
69-
end
62+
elsif dbconf_exist?
63+
if db_exist?(@current_resource.ip, @current_resource.user, @current_resource.password)
64+
@current_resource.exists = true
7065
else
66+
Chef::Log.info 'Database server ready, not database found, creating it...'
7167
@current_resource.exists = false
7268
end
69+
else
70+
@current_resource.exists = false
7371
end
7472
end

0 commit comments

Comments
 (0)