saltstack/salt

View on GitHub
salt/states/esxi.py

Summary

Maintainability
F
3 wks
Test Coverage

File esxi.py has 1283 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
Manage VMware ESXi Hosts.

.. versionadded:: 2015.8.4
Severity: Major
Found in salt/states/esxi.py - About 3 days to fix

    Function ssh_configured has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
    Open

    def ssh_configured(name,
                       service_running,
                       ssh_key=None,
                       ssh_key_file=None,
                       service_policy=None,
    Severity: Minor
    Found in salt/states/esxi.py - About 1 day to fix

    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

    Function diskgroups_configured has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
    Open

    def diskgroups_configured(name, diskgroups, erase_disks=False):
        '''
        Configures the disk groups to use for vsan.
    
        This function will do the following:
    Severity: Minor
    Found in salt/states/esxi.py - About 1 day to fix

    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

    Function syslog_configured has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
    Open

    def syslog_configured(name,
                          syslog_configs,
                          firewall=True,
                          reset_service=True,
                          reset_syslog_config=False,
    Severity: Minor
    Found in salt/states/esxi.py - About 1 day to fix

    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

    Function host_cache_configured has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
    Open

    def host_cache_configured(name, enabled, datastore, swap_size='100%',
                              dedicated_backing_disk=False,
                              erase_backing_disk=False):
        '''
        Configures the host cache used for swapping.
    Severity: Minor
    Found in salt/states/esxi.py - About 7 hrs to fix

    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

    Function ntp_configured has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
    Open

    def ntp_configured(name,
                       service_running,
                       ntp_servers=None,
                       service_policy=None,
                       service_restart=False,
    Severity: Minor
    Found in salt/states/esxi.py - About 7 hrs to fix

    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

    Cyclomatic complexity is too high in function diskgroups_configured. (45)
    Open

    @depends(HAS_PYVMOMI)
    @depends(HAS_JSONSCHEMA)
    def diskgroups_configured(name, diskgroups, erase_disks=False):
        '''
        Configures the disk groups to use for vsan.
    Severity: Minor
    Found in salt/states/esxi.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Function vsan_configured has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

    def vsan_configured(name, enabled, add_disks_to_vsan=False):
        '''
        Configures a host's VSAN properties such as enabling or disabling VSAN, or
        adding VSAN-eligible disks to the VSAN system for the host.
    
    
    Severity: Minor
    Found in salt/states/esxi.py - About 4 hrs to fix

    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

    Cyclomatic complexity is too high in function ssh_configured. (31)
    Open

    def ssh_configured(name,
                       service_running,
                       ssh_key=None,
                       ssh_key_file=None,
                       service_policy=None,
    Severity: Minor
    Found in salt/states/esxi.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Cyclomatic complexity is too high in function host_cache_configured. (29)
    Open

    @depends(HAS_PYVMOMI)
    @depends(HAS_JSONSCHEMA)
    def host_cache_configured(name, enabled, datastore, swap_size='100%',
                              dedicated_backing_disk=False,
                              erase_backing_disk=False):
    Severity: Minor
    Found in salt/states/esxi.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Function coredump_configured has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    def coredump_configured(name, enabled, dump_ip, host_vnic='vmk0', dump_port=6500):
        '''
        Ensures a host's core dump configuration.
    
        name
    Severity: Minor
    Found in salt/states/esxi.py - About 3 hrs to fix

    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

    Cyclomatic complexity is too high in function ntp_configured. (24)
    Open

    def ntp_configured(name,
                       service_running,
                       ntp_servers=None,
                       service_policy=None,
                       service_restart=False,
    Severity: Minor
    Found in salt/states/esxi.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Function vmotion_configured has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def vmotion_configured(name, enabled, device='vmk0'):
        '''
        Configures a host's VMotion properties such as enabling VMotion and setting
        the device VirtualNic that VMotion will use.
    
    
    Severity: Minor
    Found in salt/states/esxi.py - About 2 hrs to fix

    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

    Cyclomatic complexity is too high in function syslog_configured. (22)
    Open

    def syslog_configured(name,
                          syslog_configs,
                          firewall=True,
                          reset_service=True,
                          reset_syslog_config=False,
    Severity: Minor
    Found in salt/states/esxi.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Avoid deeply nested control flow statements.
    Open

                        for line in key_file:
                            if line.startswith('#'):
                                # Commented line
                                continue
                            ssh_key = ssh_key + line
    Severity: Major
    Found in salt/states/esxi.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          for disk_id in [cache_disk_id] + capacity_disk_ids:
                              __salt__['vsphere.erase_disk_partitions'](
                                  disk_id=disk_id, service_instance=si)
                          comments.append('Erased disks of diskgroup #{0}; '
      Severity: Major
      Found in salt/states/esxi.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if not msg:
                                msg = 'There was an error resetting a syslog config \'{0}\'.' \
                                      'Please check debug logs.'.format(val)
                            ret['comment'] = 'Error: {0}'.format(msg)
        Severity: Major
        Found in salt/states/esxi.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if not msg:
                                  msg = 'There was an error setting syslog config \'{0}\'. ' \
                                        'Please check debug logs.'.format(key)
                              ret['comment'] = msg
          Severity: Major
          Found in salt/states/esxi.py - About 45 mins to fix

            Avoid too many return statements within this function.
            Open

                            return ret
            Severity: Major
            Found in salt/states/esxi.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return ret
              Severity: Major
              Found in salt/states/esxi.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                    return ret
                Severity: Major
                Found in salt/states/esxi.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                      return ret
                  Severity: Major
                  Found in salt/states/esxi.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return ret
                    Severity: Major
                    Found in salt/states/esxi.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                      return ret
                      Severity: Major
                      Found in salt/states/esxi.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return ret
                        Severity: Major
                        Found in salt/states/esxi.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return ret
                          Severity: Major
                          Found in salt/states/esxi.py - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                    return ret
                            Severity: Major
                            Found in salt/states/esxi.py - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                              return ret
                              Severity: Major
                              Found in salt/states/esxi.py - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                                return ret
                                Severity: Major
                                Found in salt/states/esxi.py - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                          return ret
                                  Severity: Major
                                  Found in salt/states/esxi.py - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                        return ret
                                    Severity: Major
                                    Found in salt/states/esxi.py - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                              return ret
                                      Severity: Major
                                      Found in salt/states/esxi.py - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                            return ret
                                        Severity: Major
                                        Found in salt/states/esxi.py - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                                      return ret
                                          Severity: Major
                                          Found in salt/states/esxi.py - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                                return ret
                                            Severity: Major
                                            Found in salt/states/esxi.py - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                          return ret
                                              Severity: Major
                                              Found in salt/states/esxi.py - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                    return ret
                                                Severity: Major
                                                Found in salt/states/esxi.py - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                      return ret
                                                  Severity: Major
                                                  Found in salt/states/esxi.py - About 30 mins to fix

                                                    Avoid too many return statements within this function.
                                                    Open

                                                                        return ret
                                                    Severity: Major
                                                    Found in salt/states/esxi.py - About 30 mins to fix

                                                      Similar blocks of code found in 2 locations. Consider refactoring.
                                                      Open

                                                          if service_policy:
                                                              current_service_policy = __salt__[esxi_cmd]('get_service_policy',
                                                                                                          service_name=ntpd).get(host)
                                                              error = current_service_policy.get('Error')
                                                              if error:
                                                      Severity: Major
                                                      Found in salt/states/esxi.py and 1 other location - About 1 day to fix
                                                      salt/states/esxi.py on lines 820..841

                                                      Duplicated Code

                                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                      Tuning

                                                      This issue has a mass of 187.

                                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                      Refactorings

                                                      Further Reading

                                                      Similar blocks of code found in 2 locations. Consider refactoring.
                                                      Open

                                                          if service_policy:
                                                              current_service_policy = __salt__[esxi_cmd]('get_service_policy',
                                                                                                          service_name=ssh).get(host)
                                                              error = current_service_policy.get('Error')
                                                              if error:
                                                      Severity: Major
                                                      Found in salt/states/esxi.py and 1 other location - About 1 day to fix
                                                      salt/states/esxi.py on lines 438..459

                                                      Duplicated Code

                                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                      Tuning

                                                      This issue has a mass of 187.

                                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                      Refactorings

                                                      Further Reading

                                                      Similar blocks of code found in 2 locations. Consider refactoring.
                                                      Open

                                                          if service_running != ssh_running:
                                                              # Only actually run the command if not using test=True
                                                              if not __opts__['test']:
                                                                  # Start SSH if service_running=True
                                                                  if service_running is True:
                                                      Severity: Major
                                                      Found in salt/states/esxi.py and 1 other location - About 1 day to fix
                                                      salt/states/esxi.py on lines 414..435

                                                      Duplicated Code

                                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                      Tuning

                                                      This issue has a mass of 180.

                                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                      Refactorings

                                                      Further Reading

                                                      Similar blocks of code found in 2 locations. Consider refactoring.
                                                      Open

                                                          if service_running != ntp_running:
                                                              # Only run the command if not using test=True
                                                              if not __opts__['test']:
                                                                  # Start ntdp if service_running=True
                                                                  if ntp_running is True:
                                                      Severity: Major
                                                      Found in salt/states/esxi.py and 1 other location - About 1 day to fix
                                                      salt/states/esxi.py on lines 747..769

                                                      Duplicated Code

                                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                      Tuning

                                                      This issue has a mass of 180.

                                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                      Refactorings

                                                      Further Reading

                                                      Similar blocks of code found in 2 locations. Consider refactoring.
                                                      Open

                                                          if service_restart:
                                                              # Only run the command if not using test=True
                                                              if not __opts__['test']:
                                                                  response = __salt__[esxi_cmd]('service_restart',
                                                                                                service_name=ssh).get(host)
                                                      Severity: Major
                                                      Found in salt/states/esxi.py and 1 other location - About 5 hrs to fix
                                                      salt/states/esxi.py on lines 475..486

                                                      Duplicated Code

                                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                      Tuning

                                                      This issue has a mass of 103.

                                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                      Refactorings

                                                      Further Reading

                                                      Similar blocks of code found in 2 locations. Consider refactoring.
                                                      Open

                                                          if service_restart:
                                                              # Only run the command if not using test=True
                                                              if not __opts__['test']:
                                                                  response = __salt__[esxi_cmd]('service_restart',
                                                                                                service_name=ntpd).get(host)
                                                      Severity: Major
                                                      Found in salt/states/esxi.py and 1 other location - About 5 hrs to fix
                                                      salt/states/esxi.py on lines 844..855

                                                      Duplicated Code

                                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                      Tuning

                                                      This issue has a mass of 103.

                                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                      Refactorings

                                                      Further Reading

                                                      Similar blocks of code found in 2 locations. Consider refactoring.
                                                      Open

                                                              if not __opts__['test']:
                                                                  response = __salt__[esxi_cmd]('update_host_datetime').get(host)
                                                                  error = response.get('Error')
                                                                  if error:
                                                                      ret['comment'] = 'Error: {0}'.format(error)
                                                      Severity: Major
                                                      Found in salt/states/esxi.py and 1 other location - About 3 hrs to fix
                                                      salt/states/esxi.py on lines 646..651

                                                      Duplicated Code

                                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                      Tuning

                                                      This issue has a mass of 70.

                                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                      Refactorings

                                                      Further Reading

                                                      Similar blocks of code found in 2 locations. Consider refactoring.
                                                      Open

                                                                  if not __opts__['test']:
                                                                      response = __salt__[esxi_cmd]('vsan_add_disks').get(host)
                                                                      error = response.get('Error')
                                                                      if error:
                                                                          ret['comment'] = 'Error: {0}'.format(error)
                                                      Severity: Major
                                                      Found in salt/states/esxi.py and 1 other location - About 3 hrs to fix
                                                      salt/states/esxi.py on lines 464..469

                                                      Duplicated Code

                                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                      Tuning

                                                      This issue has a mass of 70.

                                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                      Refactorings

                                                      Further Reading

                                                      Similar blocks of code found in 2 locations. Consider refactoring.
                                                      Open

                                                          except CommandExecutionError as err:
                                                              log.error('Error: %s', err)
                                                              if si:
                                                                  __salt__['vsphere.disconnect'](si)
                                                              ret.update({
                                                      Severity: Major
                                                      Found in salt/states/esxi.py and 1 other location - About 2 hrs to fix
                                                      salt/states/esxdatacenter.py on lines 120..127

                                                      Duplicated Code

                                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                      Tuning

                                                      This issue has a mass of 68.

                                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                      Refactorings

                                                      Further Reading

                                                      Similar blocks of code found in 2 locations. Consider refactoring.
                                                      Open

                                                                  if disk_id not in existing_diskgroup['capacity_disks']:
                                                                      disk_scsi_addr = [d['scsi_address'] for d in host_disks
                                                                                        if d['id'] == disk_id][0]
                                                                      added_capacity_disk_ids.append(disk_id)
                                                                      added_capacity_disk_displays.append(
                                                      Severity: Major
                                                      Found in salt/states/esxi.py and 1 other location - About 2 hrs to fix
                                                      salt/states/esxi.py on lines 1224..1229

                                                      Duplicated Code

                                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                      Tuning

                                                      This issue has a mass of 65.

                                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                      Refactorings

                                                      Further Reading

                                                      Similar blocks of code found in 2 locations. Consider refactoring.
                                                      Open

                                                                  if disk_id not in capacity_disk_ids:
                                                                      disk_scsi_addr = [d['scsi_address'] for d in host_disks
                                                                                        if d['id'] == disk_id][0]
                                                                      removed_capacity_disk_ids.append(disk_id)
                                                                      removed_capacity_disk_displays.append(
                                                      Severity: Major
                                                      Found in salt/states/esxi.py and 1 other location - About 2 hrs to fix
                                                      salt/states/esxi.py on lines 1217..1222

                                                      Duplicated Code

                                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                      Tuning

                                                      This issue has a mass of 65.

                                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                      Refactorings

                                                      Further Reading

                                                      Identical blocks of code found in 2 locations. Consider refactoring.
                                                      Open

                                                          if 'vim25/6.0' in VmomiSupport.versionMap and \
                                                              sys.version_info > (2, 7) and sys.version_info < (2, 7, 9):
                                                      
                                                              log.debug('pyVmomi not loaded: Incompatible versions '
                                                                        'of Python. See Issue #29537.')
                                                      Severity: Major
                                                      Found in salt/states/esxi.py and 1 other location - About 2 hrs to fix
                                                      salt/modules/vsphere.py on lines 211..216

                                                      Duplicated Code

                                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                      Tuning

                                                      This issue has a mass of 55.

                                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                      Refactorings

                                                      Further Reading

                                                      Similar blocks of code found in 2 locations. Consider refactoring.
                                                      Open

                                                                  if enabled is True:
                                                                      response = __salt__[esxi_cmd]('vsan_enable').get(host)
                                                                      error = response.get('Error')
                                                                      if error:
                                                                          ret['comment'] = 'Error: {0}'.format(error)
                                                      Severity: Major
                                                      Found in salt/states/esxi.py and 1 other location - About 1 hr to fix
                                                      salt/states/esxi.py on lines 542..555

                                                      Duplicated Code

                                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                      Tuning

                                                      This issue has a mass of 57.

                                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                      Refactorings

                                                      Further Reading

                                                      Similar blocks of code found in 2 locations. Consider refactoring.
                                                      Open

                                                                  if enabled is True:
                                                                      response = __salt__[esxi_cmd]('vmotion_enable',
                                                                                                    device=device).get(host)
                                                                      error = response.get('Error')
                                                                      if error:
                                                      Severity: Major
                                                      Found in salt/states/esxi.py and 1 other location - About 1 hr to fix
                                                      salt/states/esxi.py on lines 618..630

                                                      Duplicated Code

                                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                      Tuning

                                                      This issue has a mass of 57.

                                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                      Refactorings

                                                      Further Reading

                                                      Similar blocks of code found in 2 locations. Consider refactoring.
                                                      Open

                                                          if current_ip != dump_ip:
                                                              ret['changes'].update({'dump_ip':
                                                                                    {'old': current_ip,
                                                                                     'new': dump_ip}})
                                                              changes = True
                                                      Severity: Minor
                                                      Found in salt/states/esxi.py and 1 other location - About 30 mins to fix
                                                      salt/states/esxi.py on lines 239..243

                                                      Duplicated Code

                                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                      Tuning

                                                      This issue has a mass of 40.

                                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                      Refactorings

                                                      Further Reading

                                                      Similar blocks of code found in 2 locations. Consider refactoring.
                                                      Open

                                                          if current_vnic != host_vnic:
                                                              ret['changes'].update({'host_vnic':
                                                                                    {'old': current_vnic,
                                                                                     'new': host_vnic}})
                                                              changes = True
                                                      Severity: Minor
                                                      Found in salt/states/esxi.py and 1 other location - About 30 mins to fix
                                                      salt/states/esxi.py on lines 232..236

                                                      Duplicated Code

                                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                      Tuning

                                                      This issue has a mass of 40.

                                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                      Refactorings

                                                      Further Reading

                                                      There are no issues that match your filters.

                                                      Category
                                                      Status