Esempio n. 1
0
    def test_init_full_args(self):
        source_ip = "10.92.248.123"
        source_username = "******"
        source_password = "******"  # poorest password ever
        source_domain = "ASIA"

        source_credentials = Credentials(source_username, source_password,
                                         source_domain)
        source = Workload(source_ip)
        source.set_credentials(source_credentials)

        target_ip = "221.122.34.23"
        target_username = "******"
        target_password = "******"  # another poorest password ever
        target_domain = "AMER"

        target_credentials = Credentials(target_username, target_password,
                                         target_domain)
        target_vm = Workload(target_ip)
        target_vm.set_credentials(target_credentials)

        target = MigrationTarget(cloud_type=CloudType.AZURE)
        target.set_target_vm(target_vm)

        migration = Migration(source, target)

        self.assertEquals(migration.source, source)
        self.assertEquals(migration.target, target)
        self.assertEquals(migration.state, MigrationState.NOT_STARTED)
Esempio n. 2
0
    def test_init_partial_args(self):
        source_ip = "10.92.248.123"
        source_username = "******"
        source_password = "******"  # poorest password ever
        source_domain = "ASIA"

        source_credentials = Credentials(source_username, source_password,
                                         source_domain)
        source = Workload(source_ip)
        source.set_credentials(source_credentials)

        migration = Migration(source)
        self.assertEquals(migration.source, source)
        self.assertIsNone(migration.target)
        self.assertEquals(migration.state, MigrationState.NOT_DEFINED)
Esempio n. 3
0
def run_migrator():
    """ This is a command-line based application runner.
	
		Think of this as a tester for the application with certain scenarios simulated.
		Refer to the rest_runner.py which provides RESTful services for interactive API calls.
	"""

    # let's setup the source workload first
    source_ip = "10.92.248.123"
    source_username = "******"
    source_password = "******"  # poorest password ever
    source_domain = "ASIA"

    source_credentials = Credentials(source_username, source_password,
                                     source_domain)
    source = Workload(source_ip)
    source.set_credentials(source_credentials)

    storage_list = [MountPoint("C:\\", 238590), MountPoint("D:\\", 43785638)]
    source.set_storage_list(storage_list)

    # now setup target
    target_ip = "221.122.34.23"
    target_username = "******"
    target_password = "******"  # another poorest password ever
    target_domain = "AMER"

    target_credentials = Credentials(target_username, target_password,
                                     target_domain)
    target_vm = Workload(target_ip)
    target_vm.set_credentials(target_credentials)

    target = MigrationTarget(cloud_type=CloudType.AZURE)
    target.set_target_vm(target_vm)

    # time to run migration
    migration = Migration(source, target)
    migration.add_mountpoint(MountPoint("C:\\", 238590))
    migration.run()
Esempio n. 4
0
    def test_add_mountpoint(self):
        source_ip = "10.92.248.123"
        source_username = "******"
        source_password = "******"  # poorest password ever
        source_domain = "ASIA"

        source_credentials = Credentials(source_username, source_password,
                                         source_domain)
        source = Workload(source_ip)
        source.set_credentials(source_credentials)
        source.set_storage_list(
            [MountPoint("C:\\", 3785863),
             MountPoint("D:\\", 3785863)])

        target_ip = "221.122.34.23"
        target_username = "******"
        target_password = "******"  # another poorest password ever
        target_domain = "AMER"

        target_credentials = Credentials(target_username, target_password,
                                         target_domain)
        target_vm = Workload(target_ip)
        target_vm.set_credentials(target_credentials)

        target = MigrationTarget(cloud_type=CloudType.AZURE)
        target.set_target_vm(target_vm)

        migration = Migration(source, target)

        self.assertEquals(len(migration.source.storage), 2)

        with self.assertRaises(MigrationException):
            migration.add_mountpoint(MountPoint("E:\\", 837579))
        self.assertEquals(len(migration.selected_mountpoints), 0)

        migration.add_mountpoint(MountPoint("D:\\", 837579))
        self.assertEquals(len(migration.selected_mountpoints), 1)

        self.assertEquals(migration.state, MigrationState.NOT_STARTED)
Esempio n. 5
0
from flask import Flask, request, jsonify
from com.direqlink.migration.migrator import Workload, MigrationTarget, Migration
from com.direqlink.migration.credentials import Credentials
from com.direqlink.migration.mountpoint import MountPoint
from com.direqlink.migration.constants import CloudType
from com.direqlink.util.utilities import EnumUtil
from threading import Thread
import json

app = Flask(__name__)
migration = Migration()


@app.route("/", methods=["GET"])
def home():
    """ Returns the content for index page.
	
		Lists the available services.
		POST calls need the values with names mentioned in the brackets.
		
		Refer to curl.txt for samples.
	"""
    return """<h1>Welcome to DireqLink Data Migration</h1><br/>
				<p>Following endpoints are available</p>
				<ul>
					<li>[POST] 		register-source(ip, username, password, domain, storage_list)</li>
					<li>[POST] 		register-target(ip, username, password, domain, cloud_type)</li>
					<li>[POST] 		add-mountpoint(name, size)</li>
					<li>[GET] 		selected-mountpoints()</li>
					<li>[GET/POST] 	start-migration()</li>
					<li>[GET]  		migration-status()</li>
Esempio n. 6
0
 def test_init_no_args(self):
     migration = Migration()
     self.assertIsNone(migration.source)
     self.assertIsNone(migration.target)
     self.assertEquals(migration.state, MigrationState.NOT_DEFINED)