Пример #1
0
def show_info():
    logging.info(f'Script version: {script_version}')

    vbox_version = vm_functions.virtualbox_version(strip_newline=1,
                                                   strip_build=1)[1]
    logging.info(f'VirtualBox version: {vbox_version}\n')

    # Check for VirtualBox version
    if check_version:
        print(f'Script version: {script_version}')
        conn = http.client.HTTPSConnection("download.virtualbox.org")
        conn.request("GET", "/virtualbox/LATEST-STABLE.TXT")
        r1 = conn.getresponse()
        if r1.status == 200:
            latest_version = r1.read().rstrip().decode("utf-8")
            if latest_version == vbox_version:
                logging.debug('Using latest VirtualBox version.')
            else:
                logging.info(
                    f'New version of VirtualBox available: {latest_version}.')
        else:
            logging.warning('Unable to check for VirtualBox version.')

    logging.info(f'VMs: {vms_list}')
    logging.info(f'Snapshots: {snapshots_list}\n')
    result = support_functions.file_info(filename)
    if result[0] != 0:
        logging.error('Error while processing file. Exiting.')
        exit(1)
    return result[1], result[2], result[3]
Пример #2
0
 def test01_file_info(self):
     result = support_functions.file_info(file_good)
     self.assertEqual(result[0], 0)
     self.assertEqual(
         result[1],
         '736330aaa3a4683d3cc866153510763351a60062a236d22b12f4fe0f10853582')
     self.assertEqual(result[2], '9052d06c6ac53471f8496263f8fef2eb')
     self.assertEqual(result[3], 1070)
Пример #3
0
 def test01_file_info(self):
     result = support_functions.file_info(file_good)
     self.assertEqual(result[0], 0)
     self.assertEqual(
         result[1],
         'f2d2638afb528c7476c9ee8e83ddb20e686b0b05f53f2f966fd9eb962427f8aa')
     self.assertEqual(result[2], '374fb48a959a96ce92ae0e4346763293')
     self.assertEqual(result[3], 1070)
Пример #4
0
def show_info():
    logging.info(f'Script version: {script_version}')
    logging.info(
        f'VirtualBox version: {vm_functions.virtualbox_version(strip_newline=1)[1]}\n'
    )

    logging.info(f'VMs: {vms_list}')
    logging.info(f'Snapshots: {snapshots_list}\n')
    result = support_functions.file_info(filename, show_info)
    if result != 0:
        logging.error('Error while processing file. Exiting.')
        exit(1)
Пример #5
0
ui = args.ui
vm_login = args.login
vm_password = args.password
remote_folder = args.remote_folder
vm_network_state = args.network
vm_resolution = args.resolution
# support_functions options
show_info = args.info
# vm_functions options
vm_functions.vboxmanage_path = args.vboxmanage

logging.info(
    f'VirtualBox version: {vm_functions.vm_version()[1].rstrip()}; Script version: 0.6.1'
)
logging.info(f'VMs: {vms_list}; Snapshots: {snapshots_list}\n')
result = support_functions.file_info(filename, show_info)
if result != 0:
    logging.error('Error while processing file. Exiting.')
    exit(1)


# Main routines
def main_routine(vm, snapshots_list):
    for snapshot in snapshots_list:
        task_name = f'{vm}_{snapshot}'
        logging.info(f'{vm}({snapshot}): Task started')

        # Stop VM, restore snapshot, start VM
        vm_functions.vm_stop(vm)
        time.sleep(3)
        result = vm_functions.vm_restore(vm, snapshot)
Пример #6
0
 def test02_file_info_nonexisted(self):
     result = support_functions.file_info(file_bad)
     self.assertEqual(result, 1)
Пример #7
0
 def test_file_info(self):
     result = support_functions.file_info('../putty.exe')
     self.assertEqual(result, 0)