Commit d1c2dae0 authored by xiaohua guan's avatar xiaohua guan Committed by Yas Naoi
Browse files

Issue #3272419 by Xiaohua Guan, yas: Support to run the operations from Cloud...

Issue #3272419 by Xiaohua Guan, yas: Support to run the operations from Cloud Orchestrator master to workers (OpenStack Security Group) (Create and Delete)
parent 3f1a8933
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -181,6 +181,10 @@ class OpenStackSecurityGroupCreateForm extends SecurityGroupCreateForm {
    $this->ec2Service = $this->openStackServiceFactory->get($entity->getCloudContext());
    parent::save($form, $form_state);

    if (!empty($result['SendToWorker'])) {
      return;
    }

    if ($this->ec2Service instanceof OpenStackRestService) {
      $this->updateNameAndCreatedByTags($entity, $entity->getGroupId());
    }
+3 −3
Original line number Diff line number Diff line
@@ -452,10 +452,10 @@ class OpenStackRestServiceMock extends OpenStackService {
   * @param array $params
   *   Parameters to pass to the API.
   *
   * @return array
   * @return array|null
   *   Succeeded or failed.
   */
  public function deleteSecurityGroup(array $params = []): array {
  public function deleteSecurityGroup(array $params = []): ?array {
    return $this->getMockData(__FUNCTION__);
  }

+26 −5
Original line number Diff line number Diff line
@@ -1906,7 +1906,13 @@ class OpenStackService extends CloudServiceBase implements OpenStackServiceInter
   * @return array
   *   The security group create API response.
   */
  public function createSecurityGroup(array $params = []) {
  public function createSecurityGroup(array $params = []): array {
    if ($this->isWorkerResource()) {
      $this->saveOperation(__FUNCTION__, [$params], 'updateSecurityGroups');

      return ['SendToWorker' => TRUE];
    }

    $this->loadCredentials();
    $project_id = $this->credentials['project_id'];

@@ -1945,7 +1951,13 @@ class OpenStackService extends CloudServiceBase implements OpenStackServiceInter
   * @return array
   *   The security group update API response.
   */
  public function updateSecurityGroup(array $params = []) {
  public function updateSecurityGroup(array $params = []): array {
    if ($this->isWorkerResource()) {
      $this->saveOperation(__FUNCTION__, [$params], 'updateSecurityGroups');

      return ['SendToWorker' => TRUE];
    }

    $this->loadCredentials();
    $project_id = $this->credentials['project_id'];

@@ -1980,10 +1992,16 @@ class OpenStackService extends CloudServiceBase implements OpenStackServiceInter
   * @param array $params
   *   Parameters to pass to the API.
   *
   * @return bool
   * @return array|null
   *   Succeeded or failed.
   */
  public function deleteSecurityGroup(array $params = []) {
  public function deleteSecurityGroup(array $params = []): ?array {
    if ($this->isWorkerResource()) {
      $this->saveOperation(__FUNCTION__, [$params], 'updateSecurityGroups');

      return ['SendToWorker' => TRUE];
    }

    $this->loadCredentials();

    $credentials = [
@@ -1993,7 +2011,7 @@ class OpenStackService extends CloudServiceBase implements OpenStackServiceInter

    $response = $this->getClient($credentials);

    return $response['status_code'] === 204;
    return $response['status_code'] === 204 ? ['Success' => TRUE] : NULL;
  }

  /**
@@ -3242,6 +3260,9 @@ class OpenStackService extends CloudServiceBase implements OpenStackServiceInter
   *   indicates success so failure.
   */
  public function updateSecurityGroupEntities(array $params = [], $clear = TRUE, $entity_type = '', $cloud_context = '', $update = TRUE): bool {
    if ($this->isWorkerResource()) {
      return TRUE;
    }

    $cloud_config = $this->entityTypeManager
      ->getStorage('cloud_config')