/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = DcmdTaskServicePool::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'task_id' => $this->task_id, 'svr_pool_id' => $this->svr_pool_id, 'undo_node' => $this->undo_node, 'doing_node' => $this->doing_node, 'finish_node' => $this->finish_node, 'fail_node' => $this->fail_node, 'ignored_fail_node' => $this->ignored_fail_node, 'ignored_doing_node' => $this->ignored_doing_node, 'utime' => $this->utime, 'ctime' => $this->ctime, 'opr_uid' => $this->opr_uid]);
     $query->andFilterWhere(['like', 'task_cmd', $this->task_cmd])->andFilterWhere(['like', 'svr_pool', $this->svr_pool])->andFilterWhere(['like', 'env_ver', $this->env_ver])->andFilterWhere(['like', 'repo', $this->repo])->andFilterWhere(['like', 'run_user', $this->run_user]);
     return $dataProvider;
 }
Пример #2
0
 public function actionSelectServicePoolNode($task_id)
 {
     ///获取已有的设备ip
     $query = DcmdTaskNode::find()->andWhere(['task_id' => $task_id])->asArray()->all();
     $exist_ips = array();
     foreach ($query as $item) {
         array_push($exist_ips, $item['ip']);
     }
     $task_service_pool = DcmdTaskServicePool::find()->andWhere(['task_id' => $task_id])->asArray()->all();
     $service_pool = array();
     foreach ($task_service_pool as $item) {
         $node = array();
         $node['svr_pool_id'] = $item['svr_pool_id'];
         $node['svr_pool'] = $item['svr_pool'];
         $node['ip'] = array();
         $svr_pool_node = DcmdServicePoolNode::find()->andWhere(['svr_pool_id' => $item['svr_pool_id']])->asArray()->all();
         foreach ($svr_pool_node as $ip) {
             if (array_key_exists($ip['ip'], $exist_ips)) {
                 continue;
             }
             array_push($node['ip'], $ip['ip']);
         }
         array_push($service_pool, $node);
     }
     return $this->render('select_service_pool_node', ['service_pool' => $service_pool, 'task_id' => $task_id, 'task_name' => "task_name"]);
 }
 public function actionDel($task_id)
 {
     $svr_pool_array = array();
     $query = DcmdTaskServicePool::find()->andWhere(['task_id' => $task_id])->asArray()->all();
     foreach ($query as $item) {
         $svr_pool_array[$item['svr_pool']] = $item['svr_pool'];
     }
     if (Yii::$app->request->post() && array_key_exists('selection', Yii::$app->request->post())) {
         $ret_msg = "";
         $query = DcmdCenter::findOne(['master' => 1]);
         if ($query) {
             list($host, $port) = explode(':', $query["host"]);
             $select = Yii::$app->request->post()['selection'];
             foreach ($select as $subtask_id) {
                 $reply = execTaskCmd($host, $port, $task_id, Yii::$app->user->getId(), 17, $subtask_id);
                 if ($reply->getState() == 0) {
                     $ret_msg .= $subtask_id . ":删除成功 ";
                 } else {
                     $ret_msg .= $subtask_id . ":删除失败:" . $reply->getErr() . " ";
                 }
             }
         } else {
             $ret_msg = "删除失败:无法获取Center!";
         }
         Yii::$app->getSession()->setFlash('success', $ret_msg);
     }
     $params = array();
     $params['DcmdTaskNodeSearch'] = array('task_id' => $task_id);
     if (array_key_exists('DcmdTaskNodeSearch', Yii::$app->request->queryParams)) {
         $params['DcmdTaskNodeSearch'] = Yii::$app->request->queryParams['DcmdTaskNodeSearch'] + $params['DcmdTaskNodeSearch'];
     }
     $searchModel = new DcmdTaskNodeSearch();
     $dataProvider = $searchModel->search($params, 20);
     return $this->render('delete', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'task_id' => $task_id, 'svr_pool' => $svr_pool_array]);
 }
 public function actionServicePoolState($task_id)
 {
     $query = DcmdTaskServicePool::find()->andWhere(['task_id' => $task_id]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $task = DcmdTask::findOne($task_id);
     $searchModel = new DcmdTaskServicePoolSearch();
     $this->layout = false;
     return $this->render('service_pool_state_list', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'task_id' => $task_id, 'task' => $task]);
 }