saltstack/salt

View on GitHub
salt/utils/vmware.py

Summary

Maintainability
F
1 mo
Test Coverage

File vmware.py has 3073 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
Connection library for VMware

.. versionadded:: 2015.8.2
Severity: Major
Found in salt/utils/vmware.py - About 1 wk to fix

    Function _get_service_instance has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
    Open

    def _get_service_instance(host, username, password, protocol,
                              port, mechanism, principal, domain):
        '''
        Internal method to authenticate with a vCenter server or ESX/ESXi host
        and return the service instance object.
    Severity: Minor
    Found in salt/utils/vmware.py - About 6 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 wait_for_task has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

    def wait_for_task(task, instance_name, task_type, sleep_seconds=1, log_level='debug'):
        '''
        Waits for a task to be completed.
    
        task
    Severity: Minor
    Found in salt/utils/vmware.py - About 5 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 get_datastores has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_datastores(service_instance, reference, datastore_names=None,
                       backing_disk_ids=None, get_all_datastores=False):
        '''
        Returns a list of vim.Datastore objects representing the datastores visible
        from a VMware object, filtered by their names, or the backing disk
    Severity: Minor
    Found in salt/utils/vmware.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

    Function get_hardware_grains has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_hardware_grains(service_instance):
        '''
        Return hardware info for standard minion grains if the service_instance is a HostAgent type
    
        service_instance
    Severity: Minor
    Found in salt/utils/vmware.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

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

    def get_content(service_instance, obj_type, property_list=None,
                    container_ref=None, traversal_spec=None,
                    local_properties=False):
        '''
        Returns the content of the specified type of object for a Service Instance.
    Severity: Minor
    Found in salt/utils/vmware.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 get_datastores. (27)
    Open

    def get_datastores(service_instance, reference, datastore_names=None,
                       backing_disk_ids=None, get_all_datastores=False):
        '''
        Returns a list of vim.Datastore objects representing the datastores visible
        from a VMware object, filtered by their names, or the backing disk
    Severity: Minor
    Found in salt/utils/vmware.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 get_placement has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_placement(service_instance, datacenter, placement=None):
        '''
        To create a virtual machine a resource pool needs to be supplied, we would like to use the strictest as possible.
    
        datacenter
    Severity: Minor
    Found in salt/utils/vmware.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

    Function get_hosts has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_hosts(service_instance, datacenter_name=None, host_names=None,
                  cluster_name=None, get_all_hosts=False):
        '''
        Returns a list of vim.HostSystem objects representing ESXi hosts
        in a vcenter filtered by their names and/or datacenter, cluster membership.
    Severity: Minor
    Found in salt/utils/vmware.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

    Function get_assigned_licenses has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_assigned_licenses(service_instance, entity_ref=None, entity_name=None,
                              license_assignment_manager=None):
        '''
        Returns the licenses assigned to an entity. If entity ref is not provided,
        then entity_name is assumed to be the vcenter. This is later checked if
    Severity: Minor
    Found in salt/utils/vmware.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

    Function power_cycle_vm has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def power_cycle_vm(virtual_machine, action='on'):
        '''
        Powers on/off a virtual machine specified by it's name.
    
        virtual_machine
    Severity: Minor
    Found in salt/utils/vmware.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 wait_for_task. (21)
    Open

    def wait_for_task(task, instance_name, task_type, sleep_seconds=1, log_level='debug'):
        '''
        Waits for a task to be completed.
    
        task
    Severity: Minor
    Found in salt/utils/vmware.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 assign_license has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def assign_license(service_instance, license_key, license_name,
                       entity_ref=None, entity_name=None,
                       license_assignment_manager=None):
        '''
        Assigns a license to an entity.
    Severity: Minor
    Found in salt/utils/vmware.py - About 1 hr 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 get_service_instance has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_service_instance(host, username=None, password=None, protocol=None,
                             port=None, mechanism='userpass', principal=None,
                             domain=None):
        '''
        Authenticate with a vCenter server or ESX/ESXi host and return the service instance object.
    Severity: Minor
    Found in salt/utils/vmware.py - About 1 hr 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 get_diskgroups has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_diskgroups(host_ref, cache_disk_ids=None, get_all_disk_groups=False):
        '''
        Returns a list of vim.VsanHostDiskMapping objects representing disks
        in a ESXi host, filtered by their cannonical names.
    
    
    Severity: Minor
    Found in salt/utils/vmware.py - About 1 hr 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 get_gssapi_token has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_gssapi_token(principal, host, domain):
        '''
        Get the gssapi token for Kerberos connection
    
        principal
    Severity: Minor
    Found in salt/utils/vmware.py - About 1 hr 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 get_folder has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_folder(service_instance, datacenter, placement, base_vm_name=None):
        '''
        Returns a Folder Object
    
        service_instance
    Severity: Minor
    Found in salt/utils/vmware.py - About 1 hr 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 get_disks has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_disks(host_ref, disk_ids=None, scsi_addresses=None,
                  get_all_disks=False):
        '''
        Returns a list of vim.HostScsiDisk objects representing disks
        in a ESXi host, filtered by their cannonical names and scsi_addresses
    Severity: Minor
    Found in salt/utils/vmware.py - About 1 hr 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 get_datastore_files has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_datastore_files(service_instance, directory, datastores, container_object, browser_spec):
        '''
        Get the files with a given browser specification from the datastore.
    
        service_instance
    Severity: Minor
    Found in salt/utils/vmware.py - About 55 mins 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 _get_scsi_address_to_lun_key_map has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def _get_scsi_address_to_lun_key_map(service_instance,
                                         host_ref,
                                         storage_system=None,
                                         hostname=None):
        '''
    Severity: Minor
    Found in salt/utils/vmware.py - About 55 mins 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 get_all_luns has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_all_luns(host_ref, storage_system=None, hostname=None):
        '''
        Returns a list of all vim.HostScsiDisk objects in a disk
    
        host_ref
    Severity: Minor
    Found in salt/utils/vmware.py - About 55 mins 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 get_host_cache has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_host_cache(host_ref, host_cache_manager=None):
        '''
        Returns a vim.HostScsiDisk if the host cache is configured on the specified
        host, other wise returns None
    
    
    Severity: Minor
    Found in salt/utils/vmware.py - About 35 mins 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 _get_new_computed_partition_spec has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def _get_new_computed_partition_spec(storage_system,
                                         device_path,
                                         partition_info):
        '''
        Computes the new disk partition info when adding a new vmfs partition that
    Severity: Minor
    Found in salt/utils/vmware.py - About 35 mins 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 get_mors_with_properties has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_mors_with_properties(service_instance, object_type, property_list=None,
                                 container_ref=None, traversal_spec=None,
                                 local_properties=False):
        '''
        Returns a list containing properties and managed object references for the managed object.
    Severity: Minor
    Found in salt/utils/vmware.py - About 35 mins 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 erase_disk_partitions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def erase_disk_partitions(service_instance, host_ref, disk_id,
                              hostname=None, storage_system=None):
        '''
        Erases all partitions on a disk
    
    
    Severity: Minor
    Found in salt/utils/vmware.py - About 35 mins 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 get_resource_pools has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_resource_pools(service_instance, resource_pool_names, datacenter_name=None,
                           get_all_resource_pools=False):
        '''
        Retrieves resource pool objects
    
    
    Severity: Minor
    Found in salt/utils/vmware.py - About 35 mins 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

    Avoid too many return statements within this function.
    Open

            return 'e1000'
    Severity: Major
    Found in salt/utils/vmware.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return vim.vm.device.VirtualE1000e()
      Severity: Major
      Found in salt/utils/vmware.py - About 30 mins to fix

        Function get_dvportgroups has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def get_dvportgroups(parent_ref, portgroup_names=None,
                             get_all_portgroups=False):
            '''
            Returns distributed virtual porgroups (dvportgroups).
            The parent object can be either a datacenter or a dvs.
        Severity: Minor
        Found in salt/utils/vmware.py - About 25 mins 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 _get_dvs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def _get_dvs(service_instance, dvs_name):
            '''
            Return a reference to a Distributed Virtual Switch object.
        
            :param service_instance: PyVmomi service instance
        Severity: Minor
        Found in salt/utils/vmware.py - About 25 mins 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 esxcli has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def esxcli(host, user, pwd, cmd, protocol=None, port=None, esxi_host=None, credstore=None):
            '''
            Shell out and call the specified esxcli commmand, parse the result
            and return something sane.
        
        
        Severity: Minor
        Found in salt/utils/vmware.py - About 25 mins 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 register_vm has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def register_vm(datacenter, name, vmx_path, resourcepool_object, host_object=None):
            '''
            Registers a virtual machine to the inventory with the given vmx file, on success
            it returns the vim.VirtualMachine managed object reference
        
        
        Severity: Minor
        Found in salt/utils/vmware.py - About 25 mins 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 is_connection_to_a_vcenter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def is_connection_to_a_vcenter(service_instance):
            '''
            Function that returns True if the connection is made to a vCenter Server and
            False if the connection is made to an ESXi host
        
        
        Severity: Minor
        Found in salt/utils/vmware.py - About 25 mins 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 configure_host_cache has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def configure_host_cache(host_ref, datastore_ref, swap_size_MiB,
                                 host_cache_manager=None):
            '''
            Configures the host cahe of the specified host
        
        
        Severity: Minor
        Found in salt/utils/vmware.py - About 25 mins 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

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

        def update_dvs(dvs_ref, dvs_config_spec):
            '''
            Updates a distributed virtual switch with the config_spec.
        
            dvs_ref
        Severity: Major
        Found in salt/utils/vmware.py and 1 other location - About 1 day to fix
        salt/utils/vmware.py on lines 1326..1351

        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 160.

        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

        def update_dvportgroup(portgroup_ref, spec):
            '''
            Updates a distributed virtual portgroup
        
            portgroup_ref
        Severity: Major
        Found in salt/utils/vmware.py and 1 other location - About 1 day to fix
        salt/utils/vmware.py on lines 1155..1181

        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 160.

        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

                try:
                    task_info = task.info
                except vim.fault.NoPermission as exc:
                    log.exception(exc)
                    raise salt.exceptions.VMwareApiError(
        Severity: Major
        Found in salt/utils/vmware.py and 1 other location - About 1 day to fix
        salt/utils/vmware.py on lines 3195..3210

        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 142.

        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

            try:
                task_info = task.info
            except vim.fault.NoPermission as exc:
                log.exception(exc)
                raise salt.exceptions.VMwareApiError(
        Severity: Major
        Found in salt/utils/vmware.py and 1 other location - About 1 day to fix
        salt/utils/vmware.py on lines 3221..3236

        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 142.

        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

            try:
                device_info = storage_system.storageDeviceInfo
            except vim.fault.NoPermission as exc:
                log.exception(exc)
                raise salt.exceptions.VMwareApiError(
        Severity: Major
        Found in salt/utils/vmware.py and 1 other location - About 7 hrs to fix
        salt/utils/vmware.py on lines 2577..2589

        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 110.

        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

            try:
                device_info = storage_system.storageDeviceInfo
            except vim.fault.NoPermission as exc:
                log.exception(exc)
                raise salt.exceptions.VMwareApiError(
        Severity: Major
        Found in salt/utils/vmware.py and 1 other location - About 7 hrs to fix
        salt/utils/vmware.py on lines 2636..2648

        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 110.

        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 action == 'on':
                try:
                    task = virtual_machine.PowerOn()
                    task_name = 'power on'
                except vim.fault.NoPermission as exc:
        Severity: Major
        Found in salt/utils/vmware.py and 1 other location - About 6 hrs to fix
        salt/utils/vmware.py on lines 3500..3514

        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 117.

        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

            elif action == 'off':
                try:
                    task = virtual_machine.PowerOff()
                    task_name = 'power off'
                except vim.fault.NoPermission as exc:
        Severity: Major
        Found in salt/utils/vmware.py and 1 other location - About 6 hrs to fix
        salt/utils/vmware.py on lines 3485..3499

        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 117.

        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 3 locations. Consider refactoring.
        Open

                try:
                    entity_id = service_instance.content.about.instanceUuid
                except vim.fault.NoPermission as exc:
                    log.exception(exc)
                    raise salt.exceptions.VMwareApiError(
        Severity: Major
        Found in salt/utils/vmware.py and 2 other locations - About 6 hrs to fix
        salt/utils/vmware.py on lines 506..518
        salt/utils/vmware.py on lines 1484..1497

        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 114.

        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 3 locations. Consider refactoring.
        Open

            try:
                api_type = service_instance.content.about.apiType
            except vim.fault.NoPermission as exc:
                log.exception(exc)
                raise salt.exceptions.VMwareApiError(
        Severity: Major
        Found in salt/utils/vmware.py and 2 other locations - About 6 hrs to fix
        salt/utils/vmware.py on lines 1484..1497
        salt/utils/vmware.py on lines 1610..1622

        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 114.

        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 3 locations. Consider refactoring.
        Open

            try:
                lic_assignment_manager = \
                        service_instance.content.licenseManager.licenseAssignmentManager
            except vim.fault.NoPermission as exc:
                log.exception(exc)
        Severity: Major
        Found in salt/utils/vmware.py and 2 other locations - About 6 hrs to fix
        salt/utils/vmware.py on lines 506..518
        salt/utils/vmware.py on lines 1610..1622

        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 114.

        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

            try:
                vsan_host_config = host_ref.config.vsanHostConfig
            except vim.fault.NoPermission as exc:
                log.exception(exc)
                raise salt.exceptions.VMwareApiError(
        Severity: Major
        Found in salt/utils/vmware.py and 1 other location - About 6 hrs to fix
        salt/utils/vmware.py on lines 1459..1471

        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 112.

        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

            try:
                datastore_ref.RenameDatastore(new_datastore_name)
            except vim.fault.NoPermission as exc:
                log.exception(exc)
                raise salt.exceptions.VMwareApiError(
        Severity: Major
        Found in salt/utils/vmware.py and 1 other location - About 6 hrs to fix
        salt/utils/vmware.py on lines 2468..2480

        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 112.

        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

            try:
                task = portgroup_ref.Destroy_Task()
            except vim.fault.NoPermission as exc:
                log.exception(exc)
                raise salt.exceptions.VMwareApiError(
        Severity: Major
        Found in salt/utils/vmware.py and 1 other location - About 6 hrs to fix
        salt/utils/vmware.py on lines 3659..3671

        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 112.

        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

            try:
                task = vm_ref.Destroy_Task()
            except vim.fault.NoPermission as exc:
                log.exception(exc)
                raise salt.exceptions.VMwareApiError(
        Severity: Major
        Found in salt/utils/vmware.py and 1 other location - About 6 hrs to fix
        salt/utils/vmware.py on lines 1363..1375

        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 112.

        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

            try:
                lic_manager = service_instance.content.licenseManager
            except vim.fault.NoPermission as exc:
                log.exception(exc)
                raise salt.exceptions.VMwareApiError(
        Severity: Major
        Found in salt/utils/vmware.py and 1 other location - About 6 hrs to fix
        salt/utils/vmware.py on lines 2894..2906

        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 112.

        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

            try:
                host_ds_system.RemoveDatastore(datastore_ref)
            except vim.fault.NoPermission as exc:
                log.exception(exc)
                raise salt.exceptions.VMwareApiError(
        Severity: Major
        Found in salt/utils/vmware.py and 1 other location - About 6 hrs to fix
        salt/utils/vmware.py on lines 2226..2238

        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 112.

        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

            try:
                vm_ref.UnregisterVM()
            except vim.fault.NoPermission as exc:
                log.exception(exc)
                raise salt.exceptions.VMwareApiError(
        Severity: Major
        Found in salt/utils/vmware.py and 1 other location - About 4 hrs to fix
        salt/utils/vmware.py on lines 1694..1704

        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 83.

        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

                try:
                    entity_id = service_instance.content.about.instanceUuid
                except vim.fault.NoPermission as exc:
                    log.exception(exc)
                    raise salt.exceptions.VMwareApiError(
        Severity: Major
        Found in salt/utils/vmware.py and 1 other location - About 4 hrs to fix
        salt/utils/vmware.py on lines 3684..3694

        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 83.

        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 3 locations. Consider refactoring.
        Open

        def get_mor_using_container_view(si, obj_type, obj_name):
            '''
            Get reference to an object of specified object type and name
        
            si
        Severity: Major
        Found in salt/utils/vmware.py and 2 other locations - About 2 hrs to fix
        salt/utils/vmware.py on lines 1995..2013
        salt/utils/vmware.py on lines 2016..2034

        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 3 locations. Consider refactoring.
        Open

        def get_mor_by_moid(si, obj_type, obj_moid):
            '''
            Get reference to an object of specified object type and id
        
            si
        Severity: Major
        Found in salt/utils/vmware.py and 2 other locations - About 2 hrs to fix
        salt/utils/vmware.py on lines 296..315
        salt/utils/vmware.py on lines 1995..2013

        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 3 locations. Consider refactoring.
        Open

        def get_mor_by_name(si, obj_type, obj_name):
            '''
            Get reference to an object of specified object type and name
        
            si
        Severity: Major
        Found in salt/utils/vmware.py and 2 other locations - About 2 hrs to fix
        salt/utils/vmware.py on lines 296..315
        salt/utils/vmware.py on lines 2016..2034

        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 3 locations. Consider refactoring.
        Open

            items = [i['object'] for i in
                     get_mors_with_properties(service_instance,
                                              vim.Network,
                                              container_ref=parent_ref,
                                              property_list=properties,
        Severity: Major
        Found in salt/utils/vmware.py and 2 other locations - About 2 hrs to fix
        salt/utils/vmware.py on lines 1083..1089
        salt/utils/vmware.py on lines 1256..1263

        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 60.

        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 3 locations. Consider refactoring.
        Open

            items = [i['object'] for i in
                     get_mors_with_properties(service_instance,
                                              vim.DistributedVirtualSwitch,
                                              container_ref=dc_ref,
                                              property_list=properties,
        Severity: Major
        Found in salt/utils/vmware.py and 2 other locations - About 2 hrs to fix
        salt/utils/vmware.py on lines 1256..1263
        salt/utils/vmware.py on lines 1415..1422

        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 60.

        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 3 locations. Consider refactoring.
        Open

            items = [i['object'] for i in
                     get_mors_with_properties(service_instance,
                                              vim.DistributedVirtualPortgroup,
                                              container_ref=parent_ref,
                                              property_list=properties,
        Severity: Major
        Found in salt/utils/vmware.py and 2 other locations - About 2 hrs to fix
        salt/utils/vmware.py on lines 1083..1089
        salt/utils/vmware.py on lines 1415..1422

        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 60.

        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 5 locations. Consider refactoring.
        Open

                    traversal_spec = vmodl.query.PropertyCollector.TraversalSpec(
                        path='parent',
                        skip=True,
                        type=vim.HostSystem,
                        selectSet=[vmodl.query.PropertyCollector.TraversalSpec(
        Severity: Major
        Found in salt/utils/vmware.py and 4 other locations - About 1 hr to fix
        salt/utils/vmware.py on lines 1074..1081
        salt/utils/vmware.py on lines 1240..1248
        salt/utils/vmware.py on lines 1407..1414
        salt/utils/vmware.py on lines 1827..1834

        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 50.

        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 5 locations. Consider refactoring.
        Open

            traversal_spec = vmodl.query.PropertyCollector.TraversalSpec(
                path='networkFolder',
                skip=True,
                type=vim.Datacenter,
                selectSet=[vmodl.query.PropertyCollector.TraversalSpec(
        Severity: Major
        Found in salt/utils/vmware.py and 4 other locations - About 1 hr to fix
        salt/utils/vmware.py on lines 1240..1248
        salt/utils/vmware.py on lines 1407..1414
        salt/utils/vmware.py on lines 1827..1834
        salt/utils/vmware.py on lines 3399..3406

        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 50.

        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 5 locations. Consider refactoring.
        Open

            if isinstance(parent_ref, vim.Datacenter):
                traversal_spec = vmodl.query.PropertyCollector.TraversalSpec(
                    path='networkFolder',
                    skip=True,
                    type=vim.Datacenter,
        Severity: Major
        Found in salt/utils/vmware.py and 4 other locations - About 1 hr to fix
        salt/utils/vmware.py on lines 1074..1081
        salt/utils/vmware.py on lines 1407..1414
        salt/utils/vmware.py on lines 1827..1834
        salt/utils/vmware.py on lines 3399..3406

        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 50.

        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 5 locations. Consider refactoring.
        Open

            traversal_spec = vmodl.query.PropertyCollector.TraversalSpec(
                path='networkFolder',
                skip=True,
                type=vim.Datacenter,
                selectSet=[vmodl.query.PropertyCollector.TraversalSpec(
        Severity: Major
        Found in salt/utils/vmware.py and 4 other locations - About 1 hr to fix
        salt/utils/vmware.py on lines 1074..1081
        salt/utils/vmware.py on lines 1240..1248
        salt/utils/vmware.py on lines 1827..1834
        salt/utils/vmware.py on lines 3399..3406

        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 50.

        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 5 locations. Consider refactoring.
        Open

            traversal_spec = vmodl.query.PropertyCollector.TraversalSpec(
                path='hostFolder',
                skip=True,
                type=vim.Datacenter,
                selectSet=[vmodl.query.PropertyCollector.TraversalSpec(
        Severity: Major
        Found in salt/utils/vmware.py and 4 other locations - About 1 hr to fix
        salt/utils/vmware.py on lines 1074..1081
        salt/utils/vmware.py on lines 1240..1248
        salt/utils/vmware.py on lines 1407..1414
        salt/utils/vmware.py on lines 3399..3406

        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 50.

        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 len(resourcepool_objects) > 1:
                    raise salt.exceptions.VMwareMultipleObjectsError(' '.join([
                        'Multiple instances are available of the',
                        'specified host {}.'.format(placement['host'])]))
        Severity: Major
        Found in salt/utils/vmware.py and 1 other location - About 1 hr to fix
        salt/utils/vmware.py on lines 3357..3360

        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 46.

        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 len(folder_objects) > 1:
                    raise salt.exceptions.VMwareMultipleObjectsError(' '.join([
                        'Multiple instances are available of the',
                        'specified folder {0}'.format(placement['folder'])]))
        Severity: Major
        Found in salt/utils/vmware.py and 1 other location - About 1 hr to fix
        salt/utils/vmware.py on lines 3422..3425

        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 46.

        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 3 locations. Consider refactoring.
        Open

                if 'parent' in vm_props:
                    folder_object = vm_props['parent']
                else:
                    raise salt.exceptions.VMwareObjectRetrievalError(' '.join([
                        'The virtual machine parent',
        Severity: Major
        Found in salt/utils/vmware.py and 2 other locations - About 40 mins to fix
        salt/utils/vmware.py on lines 3429..3434
        salt/utils/vmware.py on lines 3440..3445

        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 42.

        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 3 locations. Consider refactoring.
        Open

                if 'parent' in res_props:
                    placement_object = res_props['parent']
                else:
                    raise salt.exceptions.VMwareObjectRetrievalError(' '.join([
                        'The resource pool\'s parent',
        Severity: Major
        Found in salt/utils/vmware.py and 2 other locations - About 40 mins to fix
        salt/utils/vmware.py on lines 3349..3354
        salt/utils/vmware.py on lines 3440..3445

        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 42.

        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 3 locations. Consider refactoring.
        Open

                if 'resourcePool' in clus_props:
                    resourcepool_object = clus_props['resourcePool']
                else:
                    raise salt.exceptions.VMwareObjectRetrievalError(' '.join([
                        'The cluster\'s resource pool',
        Severity: Major
        Found in salt/utils/vmware.py and 2 other locations - About 40 mins to fix
        salt/utils/vmware.py on lines 3349..3354
        salt/utils/vmware.py on lines 3429..3434

        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 42.

        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