Exemplo n.º 1
0
    def test_orchestration_save_snapshot_name_should_contain_full_datetime(
            self):
        # Arrange
        with patch(SAVE_SNAPSHOT) as save_snapshot_mock:
            save_snapshot_mock.return_value = '"new_snapshot"'

            remote_command_context = create_autospec(
                ResourceRemoteCommandContext)
            remote_command_context.resource = create_autospec(
                ResourceContextDetails)
            remote_command_context.resource.fullname = 'vcenter'
            endpoint = create_autospec(ResourceContextDetails)
            endpoint.fullname = 'vm_111'
            endpoint.app_context = create_autospec(AppContext)
            endpoint.app_context.deployed_app_json = '{"vmdetails": {"uid": "vm_uuid1"}}'
            remote_command_context.remote_endpoints = [endpoint]

            # Act
            CommandOrchestrator().orchestration_save(
                context=remote_command_context,
                mode='shallow',
                custom_params=None)

            # Assert
            args, kwargs = save_snapshot_mock.call_args
            self.assertEqual(kwargs['snapshot_name'],
                             "84_12_31 11_12_13_456700")
Exemplo n.º 2
0
 def __init__(self):
     """
     ctor must be without arguments, it is created with reflection at run time
     """
     self.request_parser = DriverRequestParser()
     self.command_orchestrator = CommandOrchestrator(
     )  # type: CommandOrchestrator
     self.deployments = dict()
     self.deployments[
         'vCenter Clone VM From VM'] = self.deploy_clone_from_vm
     self.deployments[
         'VCenter Deploy VM From Linked Clone'] = self.deploy_from_linked_clone
     self.deployments[
         'vCenter VM From Template'] = self.deploy_from_template
     self.deployments['vCenter VM From Image'] = self.deploy_from_image
Exemplo n.º 3
0
 def setUp(self):
     self.resource = create_autospec(ResourceInfo)
     self.resource.ResourceModelName = 'VMwarev Center'
     self.resource.ResourceAttributes = {
         'User': '******',
         'Password': '******',
         'Default dvSwitch': 'switch1',
         'Holding Network': 'anetwork',
         'Default Port Group Location': 'Quali',
         'VM Cluster': 'Quali',
         'VM Location': 'Quali',
         'VM Resource Pool': 'Quali',
         'VM Storage': 'Quali',
         'Shutdown Method': 'hard',
         'OVF Tool Path': 'C\\program files\ovf',
         'Execution Server Selector': '',
         'Reserved Networks': 'vlan65',
         'Default Datacenter': 'QualiSB'
     }
     self.context = Mock()
     session = Mock()
     remote_resource = Mock()
     remote_resource.fullname = 'this is full name of the remote resource'
     remote_resource.uuid = 'this is full uuis of the remote resource'
     self.connection_details = Mock()
     self.context.resource = self.resource
     self.context.remote_endpoints = [self.resource]
     self.command_orchestrator = CommandOrchestrator()
     self.command_orchestrator.command_wrapper.execute_command_with_connection = Mock(
         return_value=True)
     self.command_orchestrator.cs_helper = Mock()
     self.command_orchestrator.cs_helper.get_session = Mock(
         return_value=session)
     self.command_orchestrator.cs_helper.get_connection_details = Mock(
         return_value=self.connection_details)
     self.ports = [Mock()]
     self.command_orchestrator._parse_remote_model = Mock(
         return_value=remote_resource)
Exemplo n.º 4
0
    def test_orchestration_save_double_quotes_in_snapshot_name_should_be_stripped(
            self):
        # Arrange
        with patch(SAVE_SNAPSHOT) as save_snapshot_mock:
            save_snapshot_mock.return_value = '"new_snapshot"'

            remote_command_context = create_autospec(
                ResourceRemoteCommandContext)
            remote_command_context.resource = create_autospec(
                ResourceContextDetails)
            remote_command_context.resource.fullname = 'vcenter'
            endpoint = create_autospec(ResourceContextDetails)
            endpoint.fullname = 'vm_111'
            endpoint.app_context = create_autospec(AppContext)
            endpoint.app_context.deployed_app_json = '{"vmdetails": {"uid": "vm_uuid1"}}'
            remote_command_context.remote_endpoints = [endpoint]

            # Act
            saved_result = CommandOrchestrator().orchestration_save(
                context=remote_command_context,
                mode='shallow',
                custom_params=None)

            # Assert
            save_snapshot_mock.assert_called_once()
            saved_result_dict = jsonpickle.decode(saved_result)
            self.assertEqual(
                saved_result_dict['saved_artifacts_info']['saved_artifact']
                ['artifact_type'], 'vcenter_snapshot')
            self.assertEqual(
                saved_result_dict['saved_artifacts_info']['saved_artifact']
                ['identifier'], 'new_snapshot')
            self.assertEqual(
                saved_result_dict['saved_artifacts_info']['resource_name'],
                'vcenter')
            self.assertIsNotNone(
                saved_result_dict['saved_artifacts_info']['created_date'])
Exemplo n.º 5
0
 def __init__(self):
     """
     ctor must be without arguments, it is created with reflection at run time
     """
     self.command_orchestrator = CommandOrchestrator(
     )  # type: CommandOrchestrator
Exemplo n.º 6
0
    def setUp(self):
        self.deploy_action = DeployApp()
        self.deploy_action.actionId = '0a21384c-5620-4e6a-b162-c726681865a9'
        self.deploy_action.actionParams = DeployAppParams()
        self.deploy_action.actionParams.appName = 'myApp'
        self.deploy_action.actionParams.appResource = AppResourceInfo()
        self.deploy_action.actionParams.appResource.attributes = {
            "Public IP": "",
            "Password": "******",
            "User": "******"
        }
        self.deploy_action.actionParams.deployment = DeployAppDeploymentInfo()
        self.deploy_action.actionParams.deployment.deploymentPath = 'deployment model name'
        self.deploy_action.actionParams.deployment.attributes = {
            "Default Datacenter": "",
            "Auto Power Off": "True",
            "Auto Power On": "True",
            "Wait for IP": "True",
            "VM Cluster": "",
            "VM Location": "",
            "VM Storage": "",
            "VM Resource Pool": "",
            "vCenter Image": "c:\\tinyvm1.ova",
            "vCenter Image Arguments": "",
            "IP Regex": "",
            "Refresh IP Timeout": "600",
            "Auto Delete": "True",
            "Autoload": "True",
            "VCenter VM": "sds",
            "VCenter VM Snapshot": "sds",
            "VCenter Template": "dsds",
            "Behavior during save": "Powered Off"
        }

        self.resource = create_autospec(ResourceInfo)
        self.resource.name = 'Cloud1'
        self.resource.ResourceModelName = 'VMwarev Center'
        self.resource.ResourceAttributes = {
            'User': '******',
            'Password': '******',
            'Default dvSwitch': 'switch1',
            'Holding Network': 'anetwork',
            'Default Port Group Location': 'Quali',
            'VM Cluster': 'Quali',
            'VM Location': 'Quali',
            'VM Resource Pool': 'Quali',
            'VM Storage': 'Quali',
            'Shutdown Method': 'hard',
            'OVF Tool Path': 'C\\program files\ovf',
            'Execution Server Selector': '',
            'Reserved Networks': 'vlan65',
            'Default Datacenter': 'QualiSB'
        }
        self.context = Mock()
        session = Mock()
        remote_resource = Mock()
        remote_resource.fullname = 'this is full name of the remote resource'
        remote_resource.uuid = 'this is full uuis of the remote resource'
        self.connection_details = Mock()
        self.context.resource = self.resource
        self.context.resource.app_context = Mock()
        self.context.remote_endpoints = Mock()
        self.context.remote_endpoints = [self.resource]
        self.command_orchestrator = CommandOrchestrator()
        self.command_orchestrator.command_wrapper.execute_command_with_connection = Mock(
            return_value=DeployAppResult())
        self.ports = [Mock()]
        self.command_orchestrator._parse_remote_model = Mock(
            return_value=remote_resource)