Example #1
0
    def assertPutContentRangeResponse(self, vdi_mb, data_size, range_str,
                                      response_status):
        hostname, network, vdi = testsetup.setup_host_and_network(
            templates=1, vdi_mb=vdi_mb)
        transferclient.expose(hostname,
                              vdi_uuid=vdi,
                              network_uuid=network,
                              transfer_mode='http')
        record = transferclient.get_record(hostname, vdi_uuid=vdi)

        headers = {
            'Authorization': auth_header(record['username'],
                                         record['password']),
            'Content-Range': range_str
        }
        data = 'a' * data_size
        conn = httplib.HTTPConnection(record['ip'], record['port'])
        try:
            conn.request('PUT', record['url_path'], data, headers)
            resp = conn.getresponse()
            resp.read(0)
            self.assertEquals(resp.status, response_status)
        finally:
            conn.close()
            clean_up()
Example #2
0
 def testGetRecordRaisesArgumentErrorIfVdiUuidIsMissing(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1,
                                                               vdi_mb=10)
     moreasserts.assertRaisesXenapiFailure(self, 'ArgumentError',
                                           transferclient.get_record,
                                           hostname)
     clean_up()
 def testExposeRaisesArgumentErrorIfNetworkUuidIsMissing(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1,
                                                               vdi_mb=10)
     self.assertRaisesArgumentError(transferclient.expose,
                                    hostname,
                                    vdi_uuid=vdi,
                                    transfer_mode='http')
Example #4
0
def do_put_test(self, vdi_mb, put_data_size, put_offset, check_border_size, unexpose_reexpose=False):
    self.assert_(put_data_size + put_offset <= vdi_mb * M, 'Test has invalid data offsets.')

    lower_border_size = min(put_offset, check_border_size)
    upper_border_size = min(vdi_mb * M - put_offset - put_data_size, check_border_size)

    put_data = 'abcdefgh' * (put_data_size / 8)
    expect_data = ('\0' * lower_border_size) + put_data + ('\0' * upper_border_size)

    hostname, network, vdi = testsetup.setup_host_and_network(templates=1, vdi_mb=vdi_mb)
    transferclient.expose(hostname, vdi_uuid=vdi, network_uuid=network, transfer_mode='http')
    record = transferclient.get_record(hostname, vdi_uuid=vdi)

    put_status, put_headers = http_put(record, put_data, put_offset, vdi_mb * M)
    self.assertEqual(put_status, 200)
    if unexpose_reexpose:
        transferclient.unexpose(hostname, vdi_uuid=vdi)
        transferclient.expose(hostname, vdi_uuid=vdi, network_uuid=network, transfer_mode='http')
        record = transferclient.get_record(hostname, vdi_uuid=vdi)

    get_status, get_headers, get_respdata = http_get(record, (put_offset - lower_border_size, put_offset + put_data_size + upper_border_size))
    self.assert_(get_status == 200 or get_status == 206, 'GET status code %d is not success.' % get_status)
    self.assertEquals(len(get_respdata), len(expect_data))
    self.assertEquals(get_respdata, expect_data)
    clean_up()
Example #5
0
 def testGetRecordWithUnusedVDI(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1, vdi_mb=10)
     # No expose called.
     record = transferclient.get_record(hostname, vdi_uuid=vdi)
     self.assertRecordFields(record, ['status', 'vdi_uuid'])
     self.assertVdiStatus(record, vdi, 'unused')
     clean_up()
Example #6
0
 def testGetRecordWorksWhenMultipleVDIsAreExposed(self):
     hostname, network, vdi1 = testsetup.setup_host_and_network(templates=1,
                                                                vdi_mb=10)
     vdi2 = transferclient.create_vdi(hostname, 'Second Test VDI',
                                      12 * 1024 * 1024)
     vdi3 = transferclient.create_vdi(hostname, 'Third Test VDI',
                                      14 * 1024 * 1024)
     vdi4 = transferclient.create_vdi(hostname, 'Fourth Test VDI',
                                      16 * 1024 * 1024)
     transferclient.expose(hostname,
                           vdi_uuid=vdi2,
                           network_uuid=network,
                           transfer_mode='http')
     transferclient.expose(hostname,
                           vdi_uuid=vdi3,
                           network_uuid=network,
                           transfer_mode='http')
     record1 = transferclient.get_record(hostname, vdi_uuid=vdi1)
     record2 = transferclient.get_record(hostname, vdi_uuid=vdi2)
     record3 = transferclient.get_record(hostname, vdi_uuid=vdi3)
     record4 = transferclient.get_record(hostname, vdi_uuid=vdi4)
     self.assertVdiStatus(record1, vdi1, 'unused')
     self.assertVdiStatus(record2, vdi2, 'exposed')
     self.assertVdiStatus(record3, vdi3, 'exposed')
     self.assertVdiStatus(record4, vdi4, 'unused')
     clean_up()
 def testExposeRaisesConfigurationErrorIfTransferVMTemplateIsMissing(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=0,
                                                               vdi_mb=10)
     self.assertRaisesConfigurationError(transferclient.expose,
                                         hostname,
                                         vdi_uuid=vdi,
                                         network_uuid=network,
                                         transfer_mode='http')
Example #8
0
 def testUnexposeOfUnmountedVDIFailsWithVDINotInUse(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1,
                                                               vdi_mb=10)
     moreasserts.assertRaisesXenapiFailure(self,
                                           'VDINotInUse',
                                           transferclient.unexpose,
                                           hostname,
                                           vdi_uuid=vdi)
Example #9
0
 def testGetRecordWithUnusedVDI(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1,
                                                               vdi_mb=10)
     # No expose called.
     record = transferclient.get_record(hostname, vdi_uuid=vdi)
     self.assertRecordFields(record, ['status', 'vdi_uuid'])
     self.assertVdiStatus(record, vdi, 'unused')
     clean_up()
 def testExposeRaisesArgumentErrorIfTransferModeIsInvalid(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1,
                                                               vdi_mb=10)
     self.assertRaisesArgumentError(transferclient.expose,
                                    hostname,
                                    vdi_uuid=vdi,
                                    network_uuid=network,
                                    transfer_mode='carrierpigeons')
Example #11
0
def create_and_expose(vdi_mb):
    hostname, network, vdi = testsetup.setup_host_and_network(templates=1, vdi_mb=vdi_mb)
    args = {}
    args['vdi_uuid'] = vdi
    args['network_uuid'] = 'management'
    args['transfer_mode'] = 'bits'
    transferclient.expose(hostname, **args)
    return transferclient.get_record(hostname, vdi_uuid=vdi), hostname
Example #12
0
def setup_and_get_record(vdi_mb=VDI_MB, vdi_raw=False):
    hostname, network, vdi = testsetup.setup_host_and_network(templates=1,
                                                              vdi_mb=vdi_mb,
                                                              vdi_raw=vdi_raw)
    transferclient.expose(hostname,
                          vdi_uuid=vdi,
                          network_uuid=network,
                          transfer_mode='bits')
    return transferclient.get_record(hostname, vdi_uuid=vdi)
 def testExposeRaisesArgumentErrorIfTimeoutIsNegative(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1,
                                                               vdi_mb=10)
     self.assertRaisesArgumentError(transferclient.expose,
                                    hostname,
                                    vdi_uuid=vdi,
                                    network_uuid=network,
                                    transfer_mode='http',
                                    timeout_minutes='-60')
Example #14
0
 def testUnexposeOfUnknownVDIFailsWithVDINotFound(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1,
                                                               vdi_mb=10)
     invalid_vdi = vdi[:-6] + 'abcdef'
     moreasserts.assertRaisesXenapiFailure(self,
                                           'VDINotFound',
                                           transferclient.unexpose,
                                           hostname,
                                           vdi_uuid=invalid_vdi)
Example #15
0
 def testHttpServerSSLCertificateMatchesTheOneReturnedByGetRecord(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1, vdi_mb=16)
     transferclient.expose(hostname, vdi_uuid=vdi, network_uuid=network, transfer_mode='http', use_ssl='true')
     record = transferclient.get_record(hostname, vdi_uuid=vdi)
     self.assert_('ssl_cert' in record)
     servercert = get_server_cert(record['ip'], record['port'])
     #Translating '\n' for '|' because newlines won't pass through XenStore - '|' used instead
     translated_cert = servercert.replace("\n","|") + "|"
     self.assertEqual(translated_cert, record['ssl_cert'])
 def testExposeRaisesArgumentErrorIfUseSslIsInvalid(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1,
                                                               vdi_mb=10)
     self.assertRaisesArgumentError(transferclient.expose,
                                    hostname,
                                    vdi_uuid=vdi,
                                    network_uuid=network,
                                    transfer_mode='http',
                                    use_ssl='maybe')
Example #17
0
def setup_and_get_record(timeout_minutes):
    hostname, network, vdi = testsetup.setup_host_and_network(templates=1, vdi_mb=16)
    if timeout_minutes is not None:
        transferclient.expose(hostname, vdi_uuid=vdi, network_uuid=network, transfer_mode='http', timeout_minutes=str(timeout_minutes))
	logging.debug('Timeout Minutes')
	logging.debug(timeout_minutes)
    else:
        transferclient.expose(hostname, vdi_uuid=vdi, network_uuid=network, transfer_mode='http')
    record = transferclient.get_record(hostname, vdi_uuid=vdi)
    return hostname, record
Example #18
0
 def testExposeRaisesArgumentErrorIfNetworkModeIsInvalid(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1, vdi_mb=10)
     self.assertRaisesArgumentError(
         transferclient.expose,
         hostname,
         vdi_uuid=vdi,
         network_uuid=network,
         transfer_mode="http",
         network_mode="randomsetup",
     )
Example #19
0
 def testGetRecordWithBITSExposedVDI(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1, vdi_mb=10)
     transferclient.expose(hostname, vdi_uuid=vdi, network_uuid=network, transfer_mode='bits')
     record = transferclient.get_record(hostname, vdi_uuid=vdi)
     self.assertStandardFields(record)
     self.assertVdiStatus(record, vdi, 'exposed')
     self.assertRecordFields(record, ['url_path', 'url_full'])
     self.assertEqual('bits', record['transfer_mode'])
     self.assertEqual('80', record['port'])  # Standard HTTP port
     clean_up()
Example #20
0
 def testExposeRaisesArgumentErrorIfTimeoutIsNegative(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1, vdi_mb=10)
     self.assertRaisesArgumentError(
         transferclient.expose,
         hostname,
         vdi_uuid=vdi,
         network_uuid=network,
         transfer_mode="http",
         timeout_minutes="-60",
     )
Example #21
0
 def testGetRecordRaisesVDINotFoundIfThereIsNoSuchVDIOnTheHost(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1,
                                                               vdi_mb=10)
     invalidvdi = vdi[:-6] + 'abcdef'
     moreasserts.assertRaisesXenapiFailure(self,
                                           'VDINotFound',
                                           transferclient.get_record,
                                           hostname,
                                           vdi_uuid=invalidvdi)
     clean_up()
Example #22
0
 def testVdiRecordStatusIsUnusedAfterUnexpose(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1,
                                                               vdi_mb=10)
     transferclient.expose(hostname,
                           vdi_uuid=vdi,
                           network_uuid=network,
                           transfer_mode='http')
     transferclient.unexpose(hostname, vdi_uuid=vdi)
     record = transferclient.get_record(hostname, vdi_uuid=vdi)
     self.assertEqual(record['status'], 'unused')
Example #23
0
 def testGet(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1,
                                                               vdi_mb=2)
     transferclient.expose(hostname,
                           vdi_uuid=vdi,
                           network_uuid=network,
                           transfer_mode='http',
                           use_ssl='true')
     record = transferclient.get_record(hostname, vdi_uuid=vdi)
     assertVdiEqualsUsingHttps(self, record, '\0' * (2 * M))
Example #24
0
 def testGetRecordWithISCSIExposedVDI(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1, vdi_mb=10)
     transferclient.expose(hostname, vdi_uuid=vdi, network_uuid=network, transfer_mode='iscsi')
     record = transferclient.get_record(hostname, vdi_uuid=vdi)
     self.assertStandardFields(record)
     self.assertVdiStatus(record, vdi, 'exposed')
     self.assertRecordFields(record, ['iscsi_iqn', 'iscsi_lun', 'iscsi_sn'])
     self.assertEqual('iscsi', record['transfer_mode'])
     self.assertEqual('3260', record['port'])  # Standard iSCSI port
     clean_up()
Example #25
0
def setup_and_get_record(vdi_mb, trans_mode, hostname, vdi_uuid):
    logging.debug("starting function")
    if hostname and vdi_uuid:
        logging.debug("%s %s" % (hostname, vdi_uuid))
        transferclient.expose(hostname, vdi_uuid=vdi_uuid, network_uuid="management", transfer_mode=trans_mode)
    else:
        hostname, network, vdi_uuid = testsetup.setup_host_and_network(templates=1, vdi_mb=vdi_mb)
        transferclient.expose(hostname, vdi_uuid=vdi_uuid, network_uuid=network, transfer_mode=trans_mode)
    record = transferclient.get_record(hostname, vdi_uuid=vdi_uuid)
    return record, hostname
Example #26
0
    def testPut(self):
        hostname, network, vdi = testsetup.setup_host_and_network(templates=1, vdi_mb=16)
        transferclient.expose(hostname, vdi_uuid=vdi, network_uuid=network, transfer_mode='http', use_ssl='true')
        record = transferclient.get_record(hostname, vdi_uuid=vdi)

        data = 'a' * (1*M)
        putstatus, putheaders = https_put(record, data, 2*M, 16*M)
        self.assertEqual(putstatus, 200)

        expecteddata = ('\0' * (2*M)) + data + ('\0' * (13*M))
        assertVdiEqualsUsingHttps(self, record, expecteddata)
Example #27
0
    def testExposeWithParallelGetRecord(self):
        hostname, network, vdi = testsetup.setup_host_and_network(templates=1, vdi_mb=10)
        asyncexpose = ExposeThread(hostname, network, vdi)
        asyncexpose.start()

        record = {'status': 'unused'}
        while record['status'] == 'unused':
            logging.debug('VDI status still unused, getting record')
            record = transferclient.get_record(hostname, vdi_uuid=vdi)

        moreasserts.assertVdiIsZeroUsingHttpGet(self, record, 10)
 def testExposeRaisesArgumentErrorIfNetworkMaskIsMissingForManualMode(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1,
                                                               vdi_mb=10)
     self.assertRaisesArgumentError(transferclient.expose,
                                    hostname,
                                    vdi_uuid=vdi,
                                    network_uuid=network,
                                    transfer_mode='http',
                                    network_mode='manual',
                                    network_ip='192.168.1.42',
                                    network_gateway='192.168.1.1')
Example #29
0
 def testThereAreNoPluggedInVbdsAfterUnexpose(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1, vdi_mb=10)
     transferclient.expose(hostname, vdi_uuid=vdi, network_uuid=network, transfer_mode='http')
     transferclient.unexpose(hostname, vdi_uuid=vdi)
     vbds = vbd_uuids_and_attached_flags_by_vdi_uuid(hostname, vdi)
     for vbd, attached in vbds:
         self.assertFalse(attached, 'VBD %s is still attached' % vbd)
     if vbds:
         logging.info('testThereAreNoPluggedInVbdsAfterUnexpose passed because all %d VBDs are unattached.' % len(vbds))
     else:
         logging.info('testThereAreNoPluggedInVbdsAfterUnexpose passed because there are no VBDs.')
Example #30
0
    def testGetRecordWorksWhenReexposingVDIMultipleTimes(self):
        hostname, network, vdi = testsetup.setup_host_and_network(templates=1, vdi_mb=10)

        transferclient.expose(hostname, vdi_uuid=vdi, network_uuid=network, transfer_mode='http')
        retval = transferclient.unexpose(hostname, vdi_uuid=vdi)
        self.assertEquals(retval, 'OK', 'Unexpose failed, never got to get_record testing.')
        transferclient.expose(hostname, vdi_uuid=vdi, network_uuid=network, transfer_mode='http')

        record = transferclient.get_record(hostname, vdi_uuid=vdi)
        self.assertVdiStatus(record, vdi, 'exposed')
        clean_up()
Example #31
0
 def testExposeRaisesArgumentErrorIfNetworkGatewayIsMissingForManualMode(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1, vdi_mb=10)
     self.assertRaisesArgumentError(
         transferclient.expose,
         hostname,
         vdi_uuid=vdi,
         network_uuid=network,
         transfer_mode="http",
         network_mode="manual",
         network_ip="192.168.1.42",
         network_mask="255.255.255.0",
     )
Example #32
0
    def testExposeWhileHammeringCleanup(self):
        hostname, network, vdi = testsetup.setup_host_and_network(templates=1, vdi_mb=10)
        asyncexpose = ExposeThread(hostname, network, vdi)
        asyncexpose.start()
        # Assumes that transferclient.expose is slow.
        while asyncexpose.isAlive():
            logging.debug('Cleaning up')
            transferclient.cleanup(hostname)
            time.sleep(0.0001)

        record = transferclient.get_record(hostname, vdi_uuid=vdi)
        moreasserts.assertVdiIsZeroUsingHttpGet(self, record, 10)
Example #33
0
    def testSendMultiplePutRequestsInOneHttpsSession(self):
        hostname, network, vdi = testsetup.setup_host_and_network(templates=1, vdi_mb=16)
        transferclient.expose(hostname, vdi_uuid=vdi, network_uuid=network, transfer_mode='http', use_ssl='true')
        record = transferclient.get_record(hostname, vdi_uuid=vdi)

        conn = httplib.HTTPSConnection(record['ip'], int(record['port']))
        try:
            for i in xrange(1, 5):
                data = 'a' * (i * 100*K)
                status, headers = http_test.http_put_request(conn, record, data, i * M * 2 + 234*K, 16*M)
                self.assertEqual(status, 200)
        finally:
            conn.close()
Example #34
0
    def testUnexposeWaitsUntilPartialExposeHasFinished(self):
        hostname, network, vdi = testsetup.setup_host_and_network(templates=1, vdi_mb=10)
        asyncexpose = ExposeThread(hostname, network, vdi)
        asyncexpose.start()

        response = None
        while not response:
            logging.debug('VDI status still unused, unexposing')
            try:
                response = transferclient.unexpose(hostname, vdi_uuid=vdi)
            except XenAPI.Failure, e:
                if e.details[2] != 'VDINotInUse':
                    raise
Example #35
0
    def testParallelExposes(self):
        parallelism = 3
        hostname, network, firstvdi = testsetup.setup_host_and_network(templates=1, vdi_mb=10)

        vdis = [firstvdi] + [transferclient.create_vdi(hostname, 'Test VDI', 10*M) for i in xrange(parallelism - 1)]
        threads = [ExposeThread(hostname, network, vdi) for vdi in vdis]
        for t in threads:
            t.start()
        for t in threads:
            t.join()
        records = [transferclient.get_record(hostname, vdi_uuid=vdi) for vdi in vdis]
        for record in records:
            moreasserts.assertVdiIsZeroUsingHttpGet(self, record, 10)
Example #36
0
 def testGetRecordWithBITSExposedVDI(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1,
                                                               vdi_mb=10)
     transferclient.expose(hostname,
                           vdi_uuid=vdi,
                           network_uuid=network,
                           transfer_mode='bits')
     record = transferclient.get_record(hostname, vdi_uuid=vdi)
     self.assertStandardFields(record)
     self.assertVdiStatus(record, vdi, 'exposed')
     self.assertRecordFields(record, ['url_path', 'url_full'])
     self.assertEqual('bits', record['transfer_mode'])
     self.assertEqual('80', record['port'])  # Standard HTTP port
     clean_up()
Example #37
0
 def testGetRecordWithISCSIExposedVDI(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1,
                                                               vdi_mb=10)
     transferclient.expose(hostname,
                           vdi_uuid=vdi,
                           network_uuid=network,
                           transfer_mode='iscsi')
     record = transferclient.get_record(hostname, vdi_uuid=vdi)
     self.assertStandardFields(record)
     self.assertVdiStatus(record, vdi, 'exposed')
     self.assertRecordFields(record, ['iscsi_iqn', 'iscsi_lun', 'iscsi_sn'])
     self.assertEqual('iscsi', record['transfer_mode'])
     self.assertEqual('3260', record['port'])  # Standard iSCSI port
     clean_up()
Example #38
0
 def testHttpServerSSLCertificateMatchesTheOneReturnedByGetRecord(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1,
                                                               vdi_mb=16)
     transferclient.expose(hostname,
                           vdi_uuid=vdi,
                           network_uuid=network,
                           transfer_mode='http',
                           use_ssl='true')
     record = transferclient.get_record(hostname, vdi_uuid=vdi)
     self.assert_('ssl_cert' in record)
     servercert = get_server_cert(record['ip'], record['port'])
     #Translating '\n' for '|' because newlines won't pass through XenStore - '|' used instead
     translated_cert = servercert.replace("\n", "|") + "|"
     self.assertEqual(translated_cert, record['ssl_cert'])
Example #39
0
    def dotest(self, vdi_mb, responselength, rangebounds):
        hostname, network, vdi = testsetup.setup_host_and_network(templates=1, vdi_mb=vdi_mb)
        transferclient.expose(hostname, vdi_uuid=vdi, network_uuid=network, transfer_mode='http')
        record = transferclient.get_record(hostname, vdi_uuid=vdi)
        status, headers, data = http_get(record, rangebounds)

        if rangebounds is None:
            self.assertEqual(status, httplib.OK)
        else:
            self.assertEqual(status, httplib.PARTIAL_CONTENT)
            self.assert_('content-range' in map(str.lower, headers.iterkeys()))
        self.assertEquals(responselength, len(data))
        self.assertEquals('\0' * responselength, data)
        clean_up()  
Example #40
0
 def testTargetHostUUIDConfig(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1, vdi_mb=10)
     if self.REMOVE_TEMPLATE:
         #Remove the TVM template to catch errors that would occur on first run (when the template doesn't exist)
         testsetup.remove_tvm_template(hostname)
     host_uuid = get_host_uuids(hostname)
     transfer_mode=self.TRANSFER_MODE
     asyncexpose = ExposeThread(hostname, network, vdi, transfer_mode=transfer_mode, target_host_uuid=host_uuid)
     asyncexpose.start()
     while asyncexpose.isAlive():
         time.sleep(1)
     record = transferclient.get_record(hostname, vdi_uuid=vdi)
     logging.debug(record)
     transferclient.unexpose(hostname, vdi_uuid=vdi)
     testsetup.clean_host(hostname)
Example #41
0
def put_vhd(self, file_name, vdi_mb, vdi_raw):
    hostname, network, vdi = testsetup.setup_host_and_network(templates=1, vdi_mb=vdi_mb, vdi_raw=vdi_raw)    
    args = {'vdi_uuid': vdi, 'network_uuid':network, 'transfer_mode':'bits'}
    print "Putting %s"  % (file_name)
    #Calculate allocated blocks for the sake of sparseness
    args['vhd_blocks'] = get_encoded_bitmap_from_file(file_name)

    logging.debug(args['vhd_blocks'])
    args['vhd_uuid'] = vdi #just take anything for test purposes

    transferclient.expose(hostname, **args)
    record = transferclient.get_record(hostname, vdi_uuid=vdi)
    
    bits_upload_vhd(record, file_name)
    return record
 def testExposeRaisesArgumentErrorIfArgumentStartsWithMinus(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1,
                                                               vdi_mb=10)
     self.assertRaisesArgumentError(transferclient.expose,
                                    hostname,
                                    vdi_uuid=vdi,
                                    network_uuid=network,
                                    transfer_mode='http',
                                    network_mac='-otherwiseok')
     self.assertRaisesArgumentError(transferclient.expose,
                                    hostname,
                                    vdi_uuid=vdi,
                                    network_uuid=network,
                                    transfer_mode='http',
                                    network_mac='--otherwiseok')
 def testExposeRaisesArgumentErrorIfNetworkPortIsInvalid(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1,
                                                               vdi_mb=10)
     self.assertRaisesArgumentError(transferclient.expose,
                                    hostname,
                                    vdi_uuid=vdi,
                                    network_uuid=network,
                                    transfer_mode='http',
                                    network_port='notanumber')
     self.assertRaisesArgumentError(transferclient.expose,
                                    hostname,
                                    vdi_uuid=vdi,
                                    network_uuid=network,
                                    transfer_mode='http',
                                    network_port='-12345')
Example #44
0
 def testGetRecordWorksWhenMultipleVDIsAreExposed(self):
     hostname, network, vdi1 = testsetup.setup_host_and_network(templates=1, vdi_mb=10)
     vdi2 = transferclient.create_vdi(hostname, 'Second Test VDI', 12 * 1024 * 1024)
     vdi3 = transferclient.create_vdi(hostname, 'Third Test VDI', 14 * 1024 * 1024)
     vdi4 = transferclient.create_vdi(hostname, 'Fourth Test VDI', 16 * 1024 * 1024)
     transferclient.expose(hostname, vdi_uuid=vdi2, network_uuid=network, transfer_mode='http')
     transferclient.expose(hostname, vdi_uuid=vdi3, network_uuid=network, transfer_mode='http')
     record1 = transferclient.get_record(hostname, vdi_uuid=vdi1)
     record2 = transferclient.get_record(hostname, vdi_uuid=vdi2)
     record3 = transferclient.get_record(hostname, vdi_uuid=vdi3)
     record4 = transferclient.get_record(hostname, vdi_uuid=vdi4)
     self.assertVdiStatus(record1, vdi1, 'unused')
     self.assertVdiStatus(record2, vdi2, 'exposed')
     self.assertVdiStatus(record3, vdi3, 'exposed')
     self.assertVdiStatus(record4, vdi4, 'unused')
     clean_up()
Example #45
0
    def testPut(self):
        hostname, network, vdi = testsetup.setup_host_and_network(templates=1,
                                                                  vdi_mb=16)
        transferclient.expose(hostname,
                              vdi_uuid=vdi,
                              network_uuid=network,
                              transfer_mode='http',
                              use_ssl='true')
        record = transferclient.get_record(hostname, vdi_uuid=vdi)

        data = 'a' * (1 * M)
        putstatus, putheaders = https_put(record, data, 2 * M, 16 * M)
        self.assertEqual(putstatus, 200)

        expecteddata = ('\0' * (2 * M)) + data + ('\0' * (13 * M))
        assertVdiEqualsUsingHttps(self, record, expecteddata)
 def testExposeRaisesArgumentErrorIfNetworkPortIsNot3260ForISCSITransferMode(
         self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1,
                                                               vdi_mb=10)
     self.assertRaisesArgumentError(transferclient.expose,
                                    hostname,
                                    vdi_uuid=vdi,
                                    network_uuid=network,
                                    transfer_mode='iscsi',
                                    network_port='80')
     self.assertRaisesArgumentError(transferclient.expose,
                                    hostname,
                                    vdi_uuid=vdi,
                                    network_uuid=network,
                                    transfer_mode='iscsi',
                                    network_port='3261')
Example #47
0
    def assertPutContentRangeResponse(self, vdi_mb, data_size, range_str, response_status):
        hostname, network, vdi = testsetup.setup_host_and_network(templates=1, vdi_mb=vdi_mb)
        transferclient.expose(hostname, vdi_uuid=vdi, network_uuid=network, transfer_mode='http')
        record = transferclient.get_record(hostname, vdi_uuid=vdi)

        headers = {'Authorization': auth_header(record['username'], record['password']),
                   'Content-Range': range_str}
        data = 'a' * data_size
        conn = httplib.HTTPConnection(record['ip'], record['port'])
        try:
            conn.request('PUT', record['url_path'], data, headers)
            resp = conn.getresponse()
            resp.read(0)
            self.assertEquals(resp.status, response_status)
        finally:
            conn.close()
            clean_up()
Example #48
0
 def testExposeRaisesArgumentErrorIfArgumentStartsWithMinus(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1, vdi_mb=10)
     self.assertRaisesArgumentError(
         transferclient.expose,
         hostname,
         vdi_uuid=vdi,
         network_uuid=network,
         transfer_mode="http",
         network_mac="-otherwiseok",
     )
     self.assertRaisesArgumentError(
         transferclient.expose,
         hostname,
         vdi_uuid=vdi,
         network_uuid=network,
         transfer_mode="http",
         network_mac="--otherwiseok",
     )
Example #49
0
 def testExposeRaisesArgumentErrorIfNetworkPortIsInvalid(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1, vdi_mb=10)
     self.assertRaisesArgumentError(
         transferclient.expose,
         hostname,
         vdi_uuid=vdi,
         network_uuid=network,
         transfer_mode="http",
         network_port="notanumber",
     )
     self.assertRaisesArgumentError(
         transferclient.expose,
         hostname,
         vdi_uuid=vdi,
         network_uuid=network,
         transfer_mode="http",
         network_port="-12345",
     )
Example #50
0
 def testExposeRaisesArgumentErrorIfNetworkPortIsNot3260ForISCSITransferMode(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1, vdi_mb=10)
     self.assertRaisesArgumentError(
         transferclient.expose,
         hostname,
         vdi_uuid=vdi,
         network_uuid=network,
         transfer_mode="iscsi",
         network_port="80",
     )
     self.assertRaisesArgumentError(
         transferclient.expose,
         hostname,
         vdi_uuid=vdi,
         network_uuid=network,
         transfer_mode="iscsi",
         network_port="3261",
     )
Example #51
0
    def testExposeRaisesConfigurationErrorIfVMFailsToReportIPAddress(self):
        logging.info('This is a flaky test, as it depends on the Transfer VM startup and DHCP response ' +
                     'being slow enough to find and hard_shutdown this VM before the IP is reported.')

        hostname, network, vdi = testsetup.setup_host_and_network(templates=1, vdi_mb=10, dangerous_test=True)
        output = []
        asyncexpose = AssertReturningExposeThread(hostname, network, vdi, self, output)
        asyncexpose.start()

        while asyncexpose.isAlive():
            stop_running_vms(hostname)
            time.sleep(0.0001)

        self.assertEqual(1, len(output))
        if output[0] is not None:
            if isinstance(output[0], Exception):
                raise output[0]
            else:
                self.fail('Got unexpected output from async expose thread: %r' % output[0])
Example #52
0
 def testExposeRaisesArgumentErrorIfArgumentsHaveInvalidCharacters(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1, vdi_mb=10)
     self.assertRaisesArgumentError(
         transferclient.expose, hostname, vdi_uuid=vdi + "@", network_uuid=network, transfer_mode="http"
     )
     # network_mac has no additional validation except allowed characters
     self.assertRaisesArgumentError(
         transferclient.expose, hostname, vdi_uuid=vdi, network_uuid=network, transfer_mode="http", network_mac="%"
     )
     self.assertRaisesArgumentError(
         transferclient.expose, hostname, vdi_uuid=vdi, network_uuid=network, transfer_mode="http", network_mac="a a"
     )
     self.assertRaisesArgumentError(
         transferclient.expose, hostname, vdi_uuid=vdi, network_uuid=network, transfer_mode="http", network_mac='a"'
     )
     self.assertRaisesArgumentError(
         transferclient.expose, hostname, vdi_uuid=vdi, network_uuid=network, transfer_mode="http", network_mac="a'"
     )
     self.assertRaisesArgumentError(
         transferclient.expose, hostname, vdi_uuid=vdi, network_uuid=network, transfer_mode="http", network_mac="a\\"
     )
Example #53
0
 def testGetRecordRaisesVDINotFoundIfThereIsNoSuchVDIOnTheHost(self):
     hostname, network, vdi = testsetup.setup_host_and_network(templates=1, vdi_mb=10)
     invalidvdi = vdi[:-6] + 'abcdef'
     moreasserts.assertRaisesXenapiFailure(self, 'VDINotFound', transferclient.get_record,
                                           hostname, vdi_uuid=invalidvdi)
     clean_up()