Example #1
0
 def setUpClass(cls):
     """Makes default values"""
     cls._mount_points = [MountPoint(name='C:\\', size=42)]
     cls._credentials = Credentials(
         user_name='User',
         password='******',
         domain='xxx.com'
     )
     cls._test_workload = Workload(
         id=None,
         ip='111.11.11',
         credentials=cls._credentials,
         storage=cls._mount_points
     )
     cls._test_migration_target = MigrationTarget(
         cloud_type=CloudType.VSPHERE,
         cloud_credentials=cls._credentials,
         target_vm=cls._test_workload
     )
     cls._test_migration = Migration(
         mount_points=cls._mount_points,
         source=cls._test_workload,
         migration_target=cls._test_migration_target,
         migration_state=MigrationState.NOT_STARTED
     )
     cls.results_mock = CollectionResults()
Example #2
0
    def test_C_dir_not_selected(self):
        mp1 = MountPoint("D:", 10)
        mps = [mp1]
        cr1 = Credentials('usr', 'psw', 'aws.com')
        source = Workload('10.1.1.1', cr1, mps)

        # Migration Target
        mp1_t = MountPoint("E:", 10)
        mps_t = [mp1_t]
        cr2 = Credentials('usr', 'psw', 'azure.com')
        target = MigrationTarget(CloudType.AZURE, cr2,
                                 Workload('10.0.0.0', cr2, mps_t))

        # Start migration
        sel_mnt_pnt = [mp1]
        migration = Migration(sel_mnt_pnt, source, target)
        self.assertRaises(Exception, migration.run())
Example #3
0
    def test_invalid_credentials(self):
        mount_points = [MountPoint(name='C:\\', size=42)]

        with self.assertRaises(Exception):
            Workload(id=None,
                     ip="1.1.1.1",
                     credentials=None,
                     storage=mount_points)
Example #4
0
 def setUpClass(cls):
     """Describe default models needs testing"""
     cls._mount_points = [MountPoint(name='C:\\', size=42)]
     cls._credentials = Credentials(user_name='User',
                                    password='******',
                                    domain='xxx.com')
     cls._test_workload = Workload(id=None,
                                   ip='111.11.11',
                                   credentials=cls._credentials,
                                   storage=cls._mount_points)
Example #5
0
    def test_invalid_ip(self):
        mount_points = [MountPoint(name='C:\\', size=42)]
        credentials = Credentials(user_name='User',
                                  password='******',
                                  domain='xxx.com')

        with self.assertRaises(Exception):
            Workload(id=None,
                     ip=None,
                     credentials=credentials,
                     storage=mount_points)
Example #6
0
 def test_valid_ip_credentials_storage(self):
     mount_points = [MountPoint(name='C:\\', size=42)]
     credentials = Credentials(user_name='User',
                               password='******',
                               domain='xxx.com')
     test_workload = Workload(id=None,
                              ip='111.11.11',
                              credentials=credentials,
                              storage=mount_points)
     self.assertEqual(test_workload.ip, '111.11.11')
     self.assertEqual(test_workload.credentials, credentials)
     self.assertEqual(test_workload.storage, mount_points)
Example #7
0
 def setUpClass(cls):
     """Setup general models for each test"""
     cls._mount_points = [MountPoint(name='C:\\', size=42)]
     cls._credentials = Credentials(user_name='User',
                                    password='******',
                                    domain='xxx.com')
     cls._test_workload = Workload(id=None,
                                   ip='111.11.11',
                                   credentials=cls._credentials,
                                   storage=cls._mount_points)
     cls._test_migration_target = MigrationTarget(
         cloud_type=CloudType.VSPHERE,
         cloud_credentials=cls._credentials,
         target_vm=cls._test_workload)
Example #8
0
from models.migration_target import MigrationTarget, CloudType
from models.mount_point import MountPoint
from models.credentials import Credentials
from models.workload import Workload
from service.migration import Migration

mp1 = MountPoint("D:", 10)
mp2 = MountPoint("C:", 20)
mp3 = MountPoint("E:", 30)
mps = [mp1, mp2, mp3]

# Migration Source
cr1 = Credentials('usr', 'psw', 'aws.com')
source = Workload('10.1.1.1', cr1, mps)
cr1.save()
source.save()

# Migration Target
mp1_t = MountPoint("E:", 10)
mp2_t = MountPoint("C:", 20)
mps_t = [mp1_t, mp2_t]
cr2 = Credentials('usr', 'psw', 'azure.com')
target = MigrationTarget(CloudType.AZURE, cr2,
                         Workload('10.0.0.0', cr2, mps_t))
cr2.save()
target.save()

# Start migration
sel_mnt_pnt = [mp2]
migration = Migration(sel_mnt_pnt, source, target)
migration.run()
Example #9
0
 def test_invalid_size(self):
     with self.assertRaises(Exception):
         MountPoint(name='Good name', size='bad size')
Example #10
0
 def test_invalid_name(self):
     """Test with invalid name"""
     with self.assertRaises(Exception):
         MountPoint(name=None, size=42)
Example #11
0
    def test_valid_name_and_size(self):
        """Test on valid parameters"""
        mount_point = MountPoint(name='C:\\', size=42)

        self.assertEqual(mount_point.name, 'C:\\')
        self.assertEqual(mount_point.size, 42)