Exemple #1
0
    def _sort(self):

        self.deals = multikeysort(self.deals, ['cate',
                                               'subcate',
                                               '-value',
                                               '-price',
                                               'url'])
def vmGetPhysicalMachine(instanceDetails):

	memory = int(instanceDetails['ram'])
	cpu = int(instanceDetails['cpu'])

	machines = DBSession.machine_info.find()
	machines = multikeysort(machines,['cpus','memory'])
	for machine in machines:
		if cpu <= int(machine['cpus']) and memory <= int(machine['memory']):
			if memory < 2047:
				return int(machine['_id'])
			elif memory >= 2047 and machine['arch'] == 'x86_64':
				return int(machine['_id'])
	return 0