def _start_workers(self, num):
     # basic parameters
     image = self._nc.images.find(name="G14Worker")
     flavor = self._nc.flavors.find(name="m1.medium")
     cloud_init = "#!/bin/bash \n" + \
                  " cd /home/ubuntu/airfoil-cloud-simulator \n" + \
                  "git reset --hard && git pull \n" + \
                  "echo '" + self._config.key + "' >> key.aes\n" + \
                  "echo '" + self._config.iv + "' >> iv.txt\n"\
                  " su -c 'celery -A workertasks worker -b amqp://cloudworker:[email protected]" + \
                  server_ip() + "//' ubuntu"
     for i in xrange(0, int(num)):
         name = "g14worker" + str(uuid.uuid1())
         server = self._nc.servers.create(name, image, flavor, userdata=cloud_init)
         DBUtil.execute_command(self._db_name,
                                "INSERT INTO Workers(id, name, initialized, started, active) VALUES (?,?, 'false', ?, ?)",
                                (server.id, name, time.time(), time.time()))
    def _convert_user_params_to_tasks(user_params, job):
        """

        :param model.UserParameters.UserParameters user_params: UserParameters
        :param uuid.UUID job: uuid.UUID
        :return: model.Task.Task[]
        """
        tasks = []
        compute_parameters = ComputeParameters(user_params.num_samples, user_params.viscosity, user_params.speed,
                                               user_params.time, server_ip())
        angles = numpy.arange(user_params.min_angle, user_params.max_angle, user_params.step)
        for angle in angles:
            model_parameters = ModelParameters(user_params.naca4, job, angle, user_params.num_nodes,
                                               user_params.refinement_level)
            task = Task(None, None, model_parameters, compute_parameters, None)
            tasks.append(task)
        model_parameters = ModelParameters(user_params.naca4, job, user_params.max_angle, user_params.num_nodes,
                                           user_params.refinement_level)
        task = Task(None, None, model_parameters, compute_parameters, None)
        tasks.append(task)
        return tasks