File run_instance.rb
has 722 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'log4r'
require 'vagrant/util/retryable'
require 'vagrant-cloudstack/exceptions/exceptions'
require 'vagrant-cloudstack/util/timer'
require 'vagrant-cloudstack/model/cloudstack_resource'
Class RunInstance
has 49 methods (exceeds 20 allowed). Consider refactoring. Open
class RunInstance
include Vagrant::Util::Retryable
include VagrantPlugins::Cloudstack::Model
include VagrantPlugins::Cloudstack::Service
include VagrantPlugins::Cloudstack::Exceptions
Method compose_server_creation_options
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def compose_server_creation_options
options = {
:display_name => @domain_config.display_name,
:group => @domain_config.group,
:zone_id => @zone.id,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method apply_port_forwarding_rules
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def apply_port_forwarding_rules
return if @domain_config.port_forwarding_rules.empty?
@domain_config.port_forwarding_rules.each do |port_forwarding_rule|
# Sanatize/defaults pf rule before applying
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method generate_firewall_rules_for_communicators
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def generate_firewall_rules_for_communicators
return if @pf_ip_address.is_undefined? ||
!@domain_config.pf_trusted_networks ||
@domain_config.pf_open_firewall
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method create_randomport_forwarding_rule
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def create_randomport_forwarding_rule(rule, randomrange, filename)
pf_public_port = rule[:publicport]
retryable(:on => DuplicatePFRule, :tries => 10) do
begin
# Only if public port is missing, will generate a random one
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method generate_firewall_rules_for_portforwarding_rules
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def generate_firewall_rules_for_portforwarding_rules
@pf_ip_address.details.has_key?('vpcid') ? port_name = :privateport : port_name = :publicport
unless @domain_config.port_forwarding_rules.empty?
@domain_config.port_forwarding_rules.each do |port_forwarding_rule|
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method apply_firewall_rule
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def apply_firewall_rule(acl_name, options, response_string, type_string)
firewall_rule = nil
begin
resp = @env[:cloudstack_compute].request(options)
job_id = resp[response_string]['jobid']
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method store_password
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def store_password
password = nil
if @server.password_enabled and @server.respond_to?('job_id')
server_job_result = @env[:cloudstack_compute].query_async_job_result({:jobid => @server_job_id})
if server_job_result.nil?
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method wait_for_communicator_ready
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def wait_for_communicator_ready
@env[:metrics]['instance_ssh_time'] = Util::Timer.time do
# Wait for communicator to be ready.
communicator_short_name = get_communicator_short_name(@env[:machine].communicate)
@env[:ui].info(
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method auto_complete_firewall_rules
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def auto_complete_firewall_rules
@domain_config.firewall_rules.each do |firewall_rule|
firewall_rule[:ipaddressid] = @domain_config.pf_ip_address_id if firewall_rule[:ipaddressid].nil?
firewall_rule[:ipaddress] = @domain_config.pf_ip_address if firewall_rule[:ipaddress].nil?
firewall_rule[:cidrlist] = @domain_config.pf_trusted_networks.join(',') if firewall_rule[:cidrlist].nil?
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method apply_firewall_rule
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def apply_firewall_rule(acl_name, options, response_string, type_string)
firewall_rule = nil
begin
resp = @env[:cloudstack_compute].request(options)
job_id = resp[response_string]['jobid']
Method create_firewall_rule
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_firewall_rule(rule)
acl_name = ''
firewall_rule = nil
@env[:ui].info(I18n.t('vagrant_cloudstack.creating_firewall_rule'))
Method enable_static_nat
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def enable_static_nat(rule)
@env[:ui].info(I18n.t('vagrant_cloudstack.enabling_static_nat'))
begin
ip_address = sync_ip_address(rule[:ipaddressid], rule[:ipaddress])
Method apply_port_forwarding_rule
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def apply_port_forwarding_rule(rule)
port_forwarding_rule = nil
@env[:ui].info(I18n.t('vagrant_cloudstack.creating_port_forwarding_rule'))
return unless (options = compose_port_forwarding_rule_creation_options(rule))
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method show_creation_summary
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def show_creation_summary
# Launch!
@env[:ui].info(I18n.t('vagrant_cloudstack.launching_instance'))
@env[:ui].info(" -- Display Name: #{@domain_config.display_name}")
@env[:ui].info(" -- Group: #{@domain_config.group}") if @domain_config.group
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method create_firewall_rule
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def create_firewall_rule(rule)
acl_name = ''
firewall_rule = nil
@env[:ui].info(I18n.t('vagrant_cloudstack.creating_firewall_rule'))
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method sanitize_domain_config
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def sanitize_domain_config
# Accept a single entry as input, convert it to array
@domain_config.pf_trusted_networks = [@domain_config.pf_trusted_networks] if @domain_config.pf_trusted_networks
if @domain_config.network_id.nil?
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method resolve_network
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def resolve_network(cs_zone)
if cs_zone.network_type.downcase == 'basic'
# No network specification in basic zone
@env[:ui].warn(I18n.t('vagrant_cloudstack.basic_network', :zone_name => @zone.name)) if !@networks.empty? && (@networks[0].id || @networks[0].name)
@networks = [CloudstackResource.new(nil, nil, 'network')]
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method generate_and_apply_port_forwarding_rules_for_communicators
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def generate_and_apply_port_forwarding_rules_for_communicators
communicators_port_names = [Hash[:public_port => 'pf_public_port', :private_port => 'pf_private_port']]
communicators_port_names << Hash[:public_port => 'pf_public_rdp_port', :private_port => 'pf_private_rdp_port'] if is_windows_guest
communicators_port_names.each do |communicator_port_names|
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method wait_for_instance_ready
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def wait_for_instance_ready
@env[:metrics]['instance_ready_time'] = Util::Timer.time do
tries = @domain_config.instance_ready_timeout / 2
@env[:ui].info(I18n.t('vagrant_cloudstack.waiting_for_ready'))
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method evaluate_pf_private_port
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def evaluate_pf_private_port
return unless @domain_config.pf_private_port.nil?
communicator_short_name = get_communicator_short_name(@env[:machine].communicate)
communicator_config = @env[:machine].config.send(communicator_short_name)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"