Commit 8872a7ff authored by Yas Naoi's avatar Yas Naoi Committed by Yas Naoi
Browse files

Issue #3322808 by yas, baldwinlouie: Add default permissions for OpenStack quotas

parent 4be1ea2d
Loading
Loading
Loading
Loading
+49 −30
Original line number Diff line number Diff line
@@ -67,6 +67,42 @@ function cloud_orchestrator_install() {
  user_role_revoke_permissions(RoleInterface::ANONYMOUS_ID, ['access content']);
}

/**
 * Helper function to update dashboards.
 */
function cloud_orchestrator_update_dashboards() {
  $files = [
    'page_manager.page_variant.dashboard-panels_variant-0.yml',
    'page_manager.page_variant.all_dashboard-panels_variant-0.yml',
    'page_manager.page_variant.kubernetes_dashboard-panels_variant-0.yml',
  ];
  cloud_orchestrator_update_yml_definitions($files, 'install');
}

/**
 * Import default content into the site.
 */
function cloud_orchestrator_import_content() {
  $files = [
    'welcome_page.yml',
  ];
  $path = \Drupal::moduleHandler()->getModule('cloud_orchestrator')->getPath();
  foreach ($files as $file) {
    $content_path = $path . '/default_content/' . $file;
    if (file_exists($content_path) && ($handle = fopen($content_path, 'r')) !== FALSE) {
      $contents = fread($handle, filesize($content_path));
      if (!empty($contents)) {
        $data = Yaml::decode($contents);
        $entity = \Drupal::entityTypeManager()
          ->getStorage('node')
          ->create($data);
        $entity->save();
      }
    }
  }

}

/**
 * Enable bootstrap_cloud's main_menu block and disable the tools blocks.
 */
@@ -246,37 +282,20 @@ function cloud_orchestrator_update_8406() {
}

/**
 * Helper function to update dashboards.
 * Update OpenStack quota permissions.
 */
function cloud_orchestrator_update_dashboards() {
  $files = [
    'page_manager.page_variant.dashboard-panels_variant-0.yml',
    'page_manager.page_variant.all_dashboard-panels_variant-0.yml',
    'page_manager.page_variant.kubernetes_dashboard-panels_variant-0.yml',
  ];
  cloud_orchestrator_update_yml_definitions($files, 'install');
}
function cloud_orchestrator_update_8407() {
  user_role_grant_permissions('authenticated', [
    'list openstack quota',
    'view openstack quota',
  ]);

/**
 * Import default content into the site.
 */
function cloud_orchestrator_import_content() {
  $files = [
    'welcome_page.yml',
  ];
  $path = \Drupal::moduleHandler()->getModule('cloud_orchestrator')->getPath();
  foreach ($files as $file) {
    $content_path = $path . '/default_content/' . $file;
    if (file_exists($content_path) && ($handle = fopen($content_path, 'r')) !== FALSE) {
      $contents = fread($handle, filesize($content_path));
      if (!empty($contents)) {
        $data = Yaml::decode($contents);
        $entity = \Drupal::entityTypeManager()
          ->getStorage('node')
          ->create($data);
        $entity->save();
      }
    }
  }
  user_role_grant_permissions('cloud_admin', [
    'edit openstack quota',
  ]);

  user_role_grant_permissions('cloud_operator', [
    'edit openstack quota',
  ]);

}
+2 −0
Original line number Diff line number Diff line
@@ -262,6 +262,7 @@ permissions:
  - 'list openstack network'
  - 'list openstack network interface'
  - 'list openstack port'
  - 'list openstack quota'
  - 'list openstack router'
  - 'list openstack security group'
  - 'list openstack snapshots'
@@ -280,6 +281,7 @@ permissions:
  - 'view aws cloud instance type prices'
  - 'view aws cloud provider'
  - 'view cloud orchestrator dashboard'
  - 'view openstack quota'
  - 'view own aws cloud availability zone'
  - 'view own aws cloud carrier gateway'
  - 'view own aws cloud elastic ip'
+1 −0
Original line number Diff line number Diff line
@@ -163,6 +163,7 @@ permissions:
  - 'edit aws cloud service provider'
  - 'edit cloud config entities'
  - 'edit cloud service providers'
  - 'edit openstack quota'
  - 'launch approved cloud server template'
  - 'launch cloud server template'
  - 'revert all cloud config revisions'
+1 −0
Original line number Diff line number Diff line
@@ -137,6 +137,7 @@ permissions:
  - 'edit aws cloud network interface'
  - 'edit aws cloud provider'
  - 'edit aws cloud security group'
  - 'edit openstack quota'
  - 'revert all cloud config revisions'
  - 'revert all cloud project revisions'
  - 'revert all cloud server template revisions'