本文整理汇总了Python中utils.get_free_port函数的典型用法代码示例。如果您正苦于以下问题:Python get_free_port函数的具体用法?Python get_free_port怎么用?Python get_free_port使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_free_port函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUpModule
def setUpModule():
global test_server, model, host, port, ssl_port
utils.patch_auth()
host = '127.0.0.1'
port = utils.get_free_port('http')
ssl_port = utils.get_free_port('https')
test_server = utils.run_server(host, port, ssl_port, test_mode=True)
示例2: setUpModule
def setUpModule():
global test_server, model, host, port, ssl_port
patch_auth(sudo=False)
model = mockmodel.MockModel('/tmp/obj-store-test')
host = '127.0.0.1'
port = get_free_port('http')
ssl_port = get_free_port('https')
test_server = run_server(host, port, ssl_port, test_mode=True, model=model)
示例3: setup_server
def setup_server(environment='development'):
global test_server, model, host, port, ssl_port
patch_auth()
host = '127.0.0.1'
port = get_free_port('http')
ssl_port = get_free_port('https')
test_server = run_server(host, port, ssl_port, test_mode=True,
environment=environment)
示例4: test_vm_livemigrate_persistent_API
def test_vm_livemigrate_persistent_API(self):
patch_auth()
inst = model.Model(libvirt_uri='qemu:///system',
objstore_loc=self.tmp_store)
host = '127.0.0.1'
port = get_free_port('http')
ssl_port = get_free_port('https')
cherrypy_port = get_free_port('cherrypy_port')
with RollbackContext() as rollback:
test_server = run_server(host, port, ssl_port, test_mode=True,
cherrypy_port=cherrypy_port, model=inst)
rollback.prependDefer(test_server.stop)
self.request = partial(request, host, ssl_port)
self.create_vm_test()
rollback.prependDefer(utils.rollback_wrapper, self.inst.vm_delete,
u'test_vm_migrate')
# removing cdrom because it is not shared storage and will make
# the migration fail
dev_list = self.inst.vmstorages_get_list('test_vm_migrate')
self.inst.vmstorage_delete('test_vm_migrate', dev_list[0])
try:
self.inst.vm_start('test_vm_migrate')
except Exception, e:
self.fail('Failed to start the vm, reason: %s' % e.message)
migrate_url = "/plugins/kimchi/vms/%s/migrate" % 'test_vm_migrate'
req = json.dumps({'remote_host': KIMCHI_LIVE_MIGRATION_TEST,
'user': 'root'})
resp = self.request(migrate_url, req, 'POST')
self.assertEquals(202, resp.status)
task = json.loads(resp.read())
wait_task(self._task_lookup, task['id'])
task = json.loads(
self.request(
'/plugins/kimchi/tasks/%s' % task['id'],
'{}'
).read()
)
self.assertEquals('finished', task['status'])
try:
remote_conn = self.get_remote_conn()
rollback.prependDefer(remote_conn.close)
remote_vm = remote_conn.lookupByName('test_vm_migrate')
self.assertTrue(remote_vm.isPersistent())
remote_vm.destroy()
remote_vm.undefine()
except Exception, e:
self.fail('Migration test failed: %s' % e.message)
示例5: setUpModule
def setUpModule():
global test_server, model, host, port, ssl_port
utils.patch_auth()
model = kimchi.mockmodel.MockModel('/tmp/obj-store-test')
host = '127.0.0.1'
port = utils.get_free_port('http')
ssl_port = utils.get_free_port('https')
test_server = utils.run_server(host, port, ssl_port, test_mode=True,
model=model)
示例6: setUp
def setUp(self):
global host, port, ssl_port, model, test_server
cherrypy.request.headers = {'Accept': 'application/json'}
model = kimchi.mockmodel.MockModel('/tmp/obj-store-test')
patch_auth()
port = get_free_port('http')
ssl_port = get_free_port('https')
host = '127.0.0.1'
test_server = run_server(host, port, ssl_port, test_mode=True,
model=model)
示例7: setUpModule
def setUpModule():
global test_server, model, host, port, ssl_port, cherrypy_port
patch_auth()
model = Model(None, "/tmp/obj-store-test")
host = "127.0.0.1"
port = get_free_port("http")
ssl_port = get_free_port("https")
cherrypy_port = get_free_port("cherrypy_port")
test_server = run_server(host, port, ssl_port, test_mode=True, cherrypy_port=cherrypy_port, model=model)
示例8: setup_server
def setup_server(environment='development'):
global test_server, model, host, port, ssl_port
patch_auth()
model = kimchi.mockmodel.MockModel('/tmp/obj-store-test')
host = '127.0.0.1'
port = get_free_port('http')
ssl_port = get_free_port('https')
test_server = run_server(host, port, ssl_port, test_mode=True, model=model,
environment=environment)
示例9: setUpModule
def setUpModule():
global test_server, model, host, ssl_port, tmpfile
patch_auth()
tmpfile = tempfile.mktemp()
model = MockModel(tmpfile)
host = "127.0.0.1"
port = get_free_port("http")
ssl_port = get_free_port("https")
cherrypy_port = get_free_port("cherrypy_port")
test_server = run_server(host, port, ssl_port, test_mode=True, cherrypy_port=cherrypy_port, model=model)
示例10: setUpModule
def setUpModule():
global host, port, ssl_port, model, test_server, fake_iso
cherrypy.request.headers = {"Accept": "application/json"}
model = mockmodel.MockModel("/tmp/obj-store-test")
patch_auth()
port = get_free_port("http")
ssl_port = get_free_port("https")
host = "127.0.0.1"
test_server = run_server(host, port, ssl_port, test_mode=True, model=model)
fake_iso = "/tmp/fake.iso"
open(fake_iso, "w").close()
示例11: setUpModule
def setUpModule():
global test_server, model, host, port, ssl_port, cherrypy_port, tmpfile
utils.patch_auth()
tmpfile = tempfile.mktemp()
host = '127.0.0.1'
port = utils.get_free_port('http')
ssl_port = utils.get_free_port('https')
cherrypy_port = utils.get_free_port('cherrypy_port')
test_server = utils.run_server(host, port, ssl_port, test_mode=True,
cherrypy_port=cherrypy_port)
示例12: setUpModule
def setUpModule():
global test_server, model, host, port, ssl_port, cherrypy_port
patch_auth()
model = Model(None, '/tmp/obj-store-test')
host = '127.0.0.1'
port = get_free_port('http')
ssl_port = get_free_port('https')
cherrypy_port = get_free_port('cherrypy_port')
test_server = run_server(host, port, ssl_port, test_mode=True,
cherrypy_port=cherrypy_port, model=model)
示例13: setUpModule
def setUpModule():
global host, port, ssl_port, model, test_server, fake_iso
cherrypy.request.headers = {'Accept': 'application/json'}
model = kimchi.mockmodel.MockModel('/tmp/obj-store-test')
patch_auth()
port = get_free_port('http')
ssl_port = get_free_port('https')
host = '127.0.0.1'
test_server = run_server(host, port, ssl_port, test_mode=True,
model=model)
fake_iso = '/tmp/fake.iso'
open(fake_iso, 'w').close()
示例14: setUpModule
def setUpModule():
global test_server, model, host, port, ssl_port
patch_auth(sudo=False)
model = kimchi.mockmodel.MockModel('/tmp/obj-store-test')
host = '127.0.0.1'
port = get_free_port('http')
ssl_port = get_free_port('https')
test_server = run_server(host, port, ssl_port, test_mode=True, model=model)
# Create fake ISO to do the tests
construct_fake_iso(fake_iso, True, '12.04', 'ubuntu')
示例15: setUpModule
def setUpModule():
global test_server, model, host, port, ssl_port, cherrypy_port
patch_auth()
model = kimchi.mockmodel.MockModel('/tmp/obj-store-test')
host = '127.0.0.1'
port = get_free_port('http')
ssl_port = get_free_port('https')
cherrypy_port = get_free_port('cherrypy_port')
test_server = run_server(host, port, ssl_port, test_mode=True,
cherrypy_port=cherrypy_port, model=model)
# Create fake ISO to do the tests
iso_gen.construct_fake_iso(fake_iso, True, '12.04', 'ubuntu')
iso_gen.construct_fake_iso("/var/lib/libvirt/images/fedora.iso", True,
"17", "fedora")