/** * Makes clod credentials entity for specified platform * * @param string $platform Cloud credentials platform * @param array $parameters Array of cloud credentials parameters * @param int $status optional Cloud credentials status * * @return Entity\CloudCredentials Returns new cloud credentials entity * * @throws Exception */ public function makeCloudCredentials($platform, $parameters, $status = Entity\CloudCredentials::STATUS_ENABLED) { $cloudCredentials = new Entity\CloudCredentials(); $cloudCredentials->envId = $this->env->id; $cloudCredentials->accountId = $this->env->getAccountId(); $cloudCredentials->cloud = $platform; $cloudCredentials->name = "{$this->env->id}-{$this->env->getAccountId()}-{$platform}-" . \Scalr::GenerateUID(true); $cloudCredentials->status = $status; try { $this->db->BeginTrans(); $cloudCredentials->save(); $cloudCredentials->properties->saveSettings($parameters); $cloudCredentials->bindToEnvironment($this->env); $this->db->CommitTrans(); } catch (Exception $e) { $this->db->RollbackTrans(); throw $e; } $cloudCredentials->cache($this->env->getContainer()); return $cloudCredentials; }