Esempio n. 1
0
def Worker(manifest):
	uname = 'ubuntu'
	passwd = '1qazxcvbNM'
	port = 22
	ret = conn.run_instances(
		image_id='trustysrvx64e',
		cpu=1,
		memory=1024,
		login_mode='passwd',
		login_passwd='1qazxcvbNM',
		vxnets=['vxnet-0']
	)
	instance = ret.get('instances')[0]
	time.sleep(10)
	ret = conn.allocate_eips(
		bandwidth=bandwidth_limit,
		billing_mode='bandwidth'
	)
	eip_id = ret.get('eips')[0]
	time.sleep(10)
	ret = conn.associate_eip(
		eip=eip_id,
		instance=instance,
	)
	time.sleep(10)
	ret = conn.describe_eips(
		eips = [eip_id]
	)
	eip = ret.get('eip_set')[0].get('eip_addr')
	time.sleep(10)
	d = {}
	d['hostname'] = instance
	d['in_ipaddr'] = eip
	d['ex_ipaddr'] = eip
	d['port'] = 22
	d['username'] = uname
	d['password'] = passwd
	ds = []
	ds.append(d)
	ssh = SSH(ds)
	ssh.upload(join(__file__, 'Spider.py'), '/tmp/Spider.py')
	ret = manifest.pop(1)
	for _ in ret:
		ssh.cmd('echo "%s" >> /tmp/manifest.txt' % _, True)
	if std:
		ssh.cmd('python /tmp/Spider.py -h %s -i %s -t %s -p %s -e %s -w %s' % (instance, eip_id, TOKEN, eip, me_ip, mwp), True)
	else:
		ssh.cmd('python /tmp/Spider.py -h %s -i %s -t %s -p %s -e %s -w %s' % (instance, eip_id, TOKEN, eip, me_ip, mwp), True)