示例#1
0
    def test_delete(self):
        # arrange
        uuid = 'uuid'
        network_name = 'network_name'

        network = Mock()
        network.name = network_name
        si = Mock()
        vm = Mock()
        vm.network = [network]

        connection_detail = Mock()
        connection_detail.host = Mock()
        connection_detail.username = Mock()
        connection_detail.password = Mock()
        connection_detail.port = Mock()

        pv_service = Mock()
        pv_service.connect = Mock(return_value=si)
        pv_service.find_by_uuid = Mock(return_value=vm)

        connector = VirtualSwitchToMachineDisconnectCommand(
            pv_service, Mock(), 'anetwork')

        # act
        res = connector.disconnect(si, uuid, network_name)

        # assert
        self.assertTrue(
            pv_service.connect.called_with(connection_detail.host,
                                           connection_detail.username,
                                           connection_detail.password,
                                           connection_detail.port))
        self.assertTrue(pv_service.find_by_uuid.called_with(si, uuid))
        self.assertTrue(res)
示例#2
0
    def test_delete_all(self):
        # arrange
        uuid = 'uuid'
        si = Mock()
        vm = Mock()

        connection_detail = Mock()
        connection_detail.host = Mock()
        connection_detail.username = Mock()
        connection_detail.password = Mock()
        connection_detail.port = Mock()

        pv_service = Mock()
        pv_service.connect = Mock(return_value=si)
        pv_service.find_by_uuid = Mock(return_value=vm)

        connector = VirtualSwitchToMachineDisconnectCommand(
            pv_service, Mock(), 'anetwork')
        # virtual_switch_to_machine_connector.remove_interfaces_from_vm = Mock(return_value=True)
        connector.get_network_by_name = lambda x, y: Mock()

        # act
        res = connector.disconnect(si, uuid)
        # assert
        self.assertTrue(
            pv_service.connect.called_with(connection_detail.host,
                                           connection_detail.username,
                                           connection_detail.password,
                                           connection_detail.port))
        self.assertTrue(pv_service.find_by_uuid.called_with(si, uuid))
        # self.assertTrue(virtual_switch_to_machine_connector.remove_interfaces_from_vm.called_with(vm))
        self.assertTrue(res)
    def test_delete(self):
        # arrange
        uuid = 'uuid'
        network_name = 'network_name'

        network = Mock()
        network.name = network_name
        si = Mock()
        vm = Mock()
        vm.network = [network]

        connection_detail = Mock()
        connection_detail.host = Mock()
        connection_detail.username = Mock()
        connection_detail.password = Mock()
        connection_detail.port = Mock()

        pv_service = Mock()
        pv_service.connect = Mock(return_value=si)
        pv_service.find_by_uuid = Mock(return_value=vm)

        connector = VirtualSwitchToMachineDisconnectCommand(pv_service, Mock(), 'anetwork')

        # act
        res = connector.disconnect(si, uuid, network_name)

        # assert
        self.assertTrue(pv_service.connect.called_with(connection_detail.host,
                                                       connection_detail.username,
                                                       connection_detail.password,
                                                       connection_detail.port))
        self.assertTrue(pv_service.find_by_uuid.called_with(si, uuid))
        self.assertTrue(res)
    def test_delete_all(self):
        # arrange
        uuid = 'uuid'
        si = Mock()
        vm = Mock()

        connection_detail = Mock()
        connection_detail.host = Mock()
        connection_detail.username = Mock()
        connection_detail.password = Mock()
        connection_detail.port = Mock()

        pv_service = Mock()
        pv_service.connect = Mock(return_value=si)
        pv_service.find_by_uuid = Mock(return_value=vm)

        connector = VirtualSwitchToMachineDisconnectCommand(pv_service, Mock(), 'anetwork')
        # virtual_switch_to_machine_connector.remove_interfaces_from_vm = Mock(return_value=True)
        connector.get_network_by_name = lambda x, y: Mock()

        # act
        res = connector.disconnect(si, uuid)
        # assert
        self.assertTrue(pv_service.connect.called_with(connection_detail.host,
                                                       connection_detail.username,
                                                       connection_detail.password,
                                                       connection_detail.port))
        self.assertTrue(pv_service.find_by_uuid.called_with(si, uuid))
        # self.assertTrue(virtual_switch_to_machine_connector.remove_interfaces_from_vm.called_with(vm))
        self.assertTrue(res)
    def integrationtest_disconnect(self):
        default_network = None
        connector = VirtualSwitchToMachineDisconnectCommand(self.py_vmomi_service,
                                                            self.resource_connection_details_retriever,
                                                            self.configurer,
                                                            default_network)

        self.vm_uuid = self.vm_uuid or self.get_vm_uuid(self.py_vmomi_service, self.virtual_machine_name)
        print "DISCONNECT. Machine: '{}' UUID: [{}]".format(self.virtual_machine_name, self.vm_uuid)

        #result = connector.disconnect(self.vcenter_name, self.vm_uuid, self.dv_port_group_name)
        result = connector.disconnect(self.vcenter_name, self.vm_uuid, self.standard_network_name)

        print result
示例#6
0
    def integrationtest_disconnect(self):
        default_network = None
        connector = VirtualSwitchToMachineDisconnectCommand(
            self.py_vmomi_service, self.resource_connection_details_retriever,
            self.configurer, default_network)

        self.vm_uuid = self.vm_uuid or self.get_vm_uuid(
            self.py_vmomi_service, self.virtual_machine_name)
        print "DISCONNECT. Machine: '{}' UUID: [{}]".format(
            self.virtual_machine_name, self.vm_uuid)

        #result = connector.disconnect(self.vcenter_name, self.vm_uuid, self.dv_port_group_name)
        result = connector.disconnect(self.vcenter_name, self.vm_uuid,
                                      self.standard_network_name)

        print result