QualiSystems/vCenterShell

View on GitHub

Showing 222 of 222 total issues

File vmomi_service.py has 613 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import time

import requests
from pyVmomi import vim

Severity: Major
Found in package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py - About 1 day to fix

    File command_orchestrator.py has 469 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import time
    from datetime import datetime
    import jsonpickle
    
    from cloudshell.cp.vcenter.commands.vm_details import VmDetailsCommand
    Severity: Minor
    Found in package/cloudshell/cp/vcenter/commands/command_orchestrator.py - About 7 hrs to fix

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

          def test_find_by_uuid_with_dc_object(self):
              dc = self.pv_service.find_item_in_path_by_type(self.si, 'DC0', vim.Datacenter)
      
              def action():
                  # vm name = DC0_C0_RP0_VM0
      Severity: Major
      Found in integration/performance/SearchObjectsPerfTest.py and 1 other location - About 6 hrs to fix
      integration/performance/SearchObjectsPerfTest.py on lines 64..76

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

      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 test_find_by_uuid_flat_obj_with_dc_object(self):
              dc = self.pv_service.find_item_in_path_by_type(self.si, 'DC0', vim.Datacenter)
      
              def action():
                  # vm name = DC0_C0_RP0_VM0
      Severity: Major
      Found in integration/performance/SearchObjectsPerfTest.py and 1 other location - About 6 hrs to fix
      integration/performance/SearchObjectsPerfTest.py on lines 78..90

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

      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

      package/cloudshell/cp/vcenter/models/vCenterVMFromTemplateResourceModel.py on lines 0..15

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

      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

      package/cloudshell/cp/vcenter/models/vCenterCloneVMFromVMResourceModel.py on lines 0..15

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

      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 __init__(self, pyvmomi_service, task_waiter, deployer, resource_model_parser, snapshot_saver, folder_manager,
                       cancellation_service, port_group_configurer):
              """
              :param pyvmomi_service:
              :type pyvmomi_service: pyVmomiService
      package/cloudshell/cp/vcenter/commands/save_sandbox.py on lines 17..36

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

      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 __init__(self, pyvmomi_service, task_waiter, deployer, resource_model_parser, snapshot_saver, folder_manager,
                       cancellation_service, port_group_configurer):
              """
              :param pyvmomi_service:
              :type pyvmomi_service: pyVmomiService
      Severity: Major
      Found in package/cloudshell/cp/vcenter/commands/save_sandbox.py and 1 other location - About 6 hrs to fix
      package/cloudshell/cp/vcenter/commands/delete_saved_sandbox.py on lines 15..33

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

      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

              for device in virtual_machine.config.hardware.device:
                  if isinstance(device, vim.vm.device.VirtualEthernetCard) and \
                          (filter_function is None or filter_function(device)):
                      nicspec = vim.vm.device.VirtualDeviceSpec()
                      nicspec.operation = vim.vm.device.VirtualDeviceSpec.Operation.remove
      package/cloudshell/cp/vcenter/network/vnic/vnic_service.py on lines 50..56

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

      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

              for device in virtual_machine.config.hardware.device:
                  if isinstance(device, vim.vm.device.VirtualEthernetCard) and \
                          (filter_function is None or filter_function(device)):
                      nicspec = vim.vm.device.VirtualDeviceSpec()
                      nicspec.operation = vim.vm.device.VirtualDeviceSpec.Operation.remove
      Severity: Major
      Found in package/cloudshell/cp/vcenter/network/vnic/vnic_service.py and 1 other location - About 5 hrs to fix
      package/cloudshell/cp/vcenter/commands/disconnect_dvswitch.py on lines 110..116

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

      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_deploy_from_template_vm_location(self, data_holder, folder_manager, logger, si, vcenter_resource_model):
              vm_location = data_holder.template_resource_model.vm_location or vcenter_resource_model.vm_location
              folder_path = VMLocation.combine([vcenter_resource_model.default_datacenter, vm_location])
              folder_manager.get_or_create_vcenter_folder(si,
                                                          logger,
      Severity: Major
      Found in package/cloudshell/cp/vcenter/commands/deploy_vm.py and 1 other location - About 5 hrs to fix
      package/cloudshell/cp/vcenter/commands/deploy_vm.py on lines 71..79

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

      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_deploy_from_image_vm_location(self, data_holder, folder_manager, logger, si, vcenter_resource_model):
              vm_location = data_holder.image_params.vm_location or vcenter_resource_model.vm_location
              folder_path = VMLocation.combine([vcenter_resource_model.default_datacenter, vm_location])
              folder_manager.get_or_create_vcenter_folder(si,
                                                          logger,
      Severity: Major
      Found in package/cloudshell/cp/vcenter/commands/deploy_vm.py and 1 other location - About 5 hrs to fix
      package/cloudshell/cp/vcenter/commands/deploy_vm.py on lines 61..69

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

      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

      pyVmomiService has 40 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class pyVmomiService:
          # region consts
          ChildEntity = 'childEntity'
          VM = 'vmFolder'
          Network = 'networkFolder'
      Severity: Minor
      Found in package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py - About 5 hrs to fix

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

            def integrationtest_disconnect_all(self):
                default_network = None
                connector = VirtualSwitchToMachineDisconnectCommand(self.py_vmomi_service,
                                                                    self.resource_connection_details_retriever,
                                                                    self.configurer,
        integration/integration_commands/integration_test_connect_disconnect.py on lines 110..120

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

        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 integrationtest_all_disconnect(self):
                default_network = None
                connector = VirtualSwitchToMachineDisconnectCommand(self.py_vmomi_service,
                                                                    self.resource_connection_details_retriever,
                                                                    self.configurer,
        integration/integration_commands/integration_test_connect_disconnect.py on lines 81..93

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

        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 deploy_clone_from_vm(self, context, deploy_action, cancellation_context):
                """
                Deploy Cloned VM From VM Command, will deploy vm from template
        
                :param CancellationContext cancellation_context:
        package/cloudshell/cp/vcenter/commands/command_orchestrator.py on lines 218..240

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

        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 deploy_from_template(self, context, deploy_action, cancellation_context):
                """
                Deploy From Template Command, will deploy vm from template
        
                :param CancellationContext cancellation_context:
        package/cloudshell/cp/vcenter/commands/command_orchestrator.py on lines 242..264

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

        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 test_search_by_name_flat_object(self):
                def action():
                    return self.pv_service.find_vm_by_name(self.si, 'DC0', 'DC0_C0_RP10_VM24')
        
                self.logger.info(PERFORMANCE_TEST.format('find_vm_by_name', START))
        Severity: Major
        Found in integration/performance/SearchObjectsPerfTest.py and 1 other location - About 4 hrs to fix
        integration/performance/SearchObjectsPerfTest.py on lines 52..62

        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

            def test_find_by_name_nested_object(self):
                def action():
                    # vm name = DC0_C0_RP0_VM0
                    return self.pv_service.find_vm_by_name(self.si, 'DC0/raz_test/raztest2/final', 'DC0_C0_RP0_VM0')
        
        
        Severity: Major
        Found in integration/performance/SearchObjectsPerfTest.py and 1 other location - About 4 hrs to fix
        integration/performance/SearchObjectsPerfTest.py on lines 128..137

        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

        File connect_orchestrator.py has 363 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import traceback
        from multiprocessing.pool import ThreadPool
        
        import jsonpickle
        
        
        Severity: Minor
        Found in package/cloudshell/cp/vcenter/commands/connect_orchestrator.py - About 4 hrs to fix
          Severity
          Category
          Status
          Source
          Language