Using the drupal-config commands

You can use the drupal-config commands to list, get the values of, set values, create new, and delete the Drupal configuration objects on your Developer Portal service.

For example, you can use the drupal-config commands to disable CSS and JS aggregation to help with twig debug, see Example.

  1. Log in as Provider org:
    apic login --server management_server --realm provider/identity_provider --username provider_username --password provider_password
    You can determine which identity provider to use in the --realm parameter by entering the following command to see a list of all available identity providers (you do not need to be logged in to use this command):
    apic identity-providers:list --scope provider --server mgmt_endpoint_url --fields title,realm
    For example:
    apic identity-providers:list --scope provider --server myserver.com --fields title,realm 
    total_results: 2
    results:
      - title: Cloud Manager User Registry
        realm: provider/default-idp-2
      - title: Corporate LDAP user registry
        realm: provider/corporate-ldap
    The title value should enable you to determine which identity provider to use; you can then copy the corresponding --realm parameter directly from the displayed realm value. For any identity providers that were created by your administrator after API Connect was installed, the names will have been determined at creation time. The default API Manager Local User Registry for login as a member of a provider organization is default-idp-2.

    For full details of the apic login command, see Logging in to a management server.

  2. List all of the available Drupal config for a site.
    apic --mode portaladmin drupal-config:list --server management_server --catalog catalogid/name --org orgid/name --format format_type
    • management_server is the endpoint URL of the management server (required).
    • catalogid/name is the ID or name of the catalog that the site belongs to (required).
    • orgid/name is the ID or name of the provider organization that the catalog belongs to (required).
    • format_type is the output format. Can be json, yaml, go-template=..., go-template-file=.... Defaults to yaml.
    For example:
    apic --mode portaladmin drupal-config:list --server my.management.server.com --org ibm --catalog portal-test --format yaml
    admin_toolbar_tools.settings:
      name: admin_toolbar_tools.settings
    adminimal_admin_toolbar.settings:
      name: adminimal_admin_toolbar.settings
    advagg.settings:
      name: advagg.settings
    advagg_css_minify.settings:
      name: advagg_css_minify.settings
    advagg_js_minify.settings:
      name: advagg_js_minify.settings
    autologout.settings:
      name: autologout.settings
    ...
    Note that the example has been reduced as the full response is very large.
  3. List a specific Drupal config for a site.
    apic --mode portaladmin drupal-config:list --server management_server --catalog catalogid/name --org orgid/name --prefix config_prefix --format format_type
    • config_prefix is the prefix of the Drupal config, for example system. If omitted, the command returns all config names in the system.
    For example:
    apic --mode portaladmin drupal-config:list --server my.management.server.com --org ibm --catalog portal-test --format yaml --prefix system.theme
    system.theme:
      name: system.theme
    system.theme.global:
      name: system.theme.global
  4. Update a Drupal config key value.
    apic --mode portaladmin drupal-config:set -server management_server --catalog catalogid/name --org orgid/name  --config_name config_name --config_key config_key --config_value config_value
    • config_name is the name of the Drupal config object, for example system.site (required).
    • config_key is the Drupal config key, for example page.front (required).
    • config_value is the value to assign to the config key (required).
    For example, to set the default theme to bartik:
    apic --mode portaladmin drupal-config:set --server my.management.server.com --org ibm --catalog portal-test --config_name system.theme --config_key default --config_value bartik
    // Do you want to update default key in system.theme config?: yes.
  5. Create a new Drupal config key and set the value.
    apic --mode portaladmin drupal-config:set -server management_server --catalog catalogid/name --org orgid/name  --config_name config_name --config_key new_config_key --config_value new_config_value
    For example, to create a new config key and set the value in the system.site config object:
    apic --mode portaladmin drupal-config:set --server my.management.server.com --org ibm --catalog portal-test --config_name system.site --config_key new_key --config_value new_value
    // new_key key does not exist in system.site config. Do you want to create a new config key?: yes.
  6. Get all of the key values for a Drupal config object.
    apic --mode portaladmin drupal-config:get --server management_server --catalog catalogid/name --org orgid/name  --format format_type --config_name config_name
    For example, to find out what themes are available:
    apic --mode portaladmin drupal-config:get --server my.management.server.com --org ibm --catalog portal-test --format json --config_name system.theme
    {
        "admin": "seven",
        "default": "bartik",
        "_core": {
            "default_config_hash": "fOjer9hADYYnbCJVZMFZIIM1azTFWyg84ZkFDHfAbUg"
        },
        "defaultplus": "bartisk"
    }
  7. Get the value of a specific key for a Drupal config object.
    apic --mode portaladmin drupal-config:get --server management_server --catalog catalogid/name --org orgid/name  --format format_type --config_name config_name --config_key config_key
    For example, to find out what the default theme is:
    apic --mode portaladmin drupal-config:get --server my.management.server.com --org ibm --catalog portal-test --format json --config_name system.theme --config_key default
    {
        "system.theme:default": "bartik"
    }
  8. Delete a Drupal config object, or a specific config key and its value.
    apic --mode portaladmin drupal-config:delete --server management_server --catalog catalogid/name --org orgid/name  --config_name config_name --config_key config_key
    • config_key is the Drupal config key, for example page.front (optional).
    For example, to delete the config key new_key and its value:
    apic --mode portaladmin drupal-config:delete --server my.management.server.com --org ibm --catalog portal-test --config_name system.site --config_key new_key
    The config object/value was successfully deleted.

Example

The following scenario gives an example of how to turn off CSS and JS aggregation to help with twig debug. However, on a production system aggregation should be enabled for performance reasons.

  1. Check the settings for performance, which include settings for CSS and JS aggregation:
    apic --mode portaladmin drupal-config:get --server management_server --catalog catalogid/name --org orgid/name --config_name system.performance 
  2. Check the settings for advanced aggregation:
    apic --mode portaladmin drupal-config:get --server management_server --catalog catalogid/name --org orgid/name --config_name advagg.settings
  3. Turn off CSS aggregation:
    apic --mode portaladmin drupal-config:set --server management_server --catalog catalogid/name --org orgid/name --config_name system.performance --config_key css.preprocess --config_value 0
  4. Turn off JS aggregation:
    apic --mode portaladmin drupal-config:set --server management_server --catalog catalogid/name --org orgid/name --config_name system.performance --config_key js.preprocess --config_value 0
  5. Turn off advanced aggregation (this setting is needed for the previous aggregation settings to apply):
    apic --mode portaladmin drupal-config:set --server management_server --catalog catalogid/name --org orgid/name --config_name advagg.settings --config_key enabled --config_value 0
  6. Then, rebuild the cache:
    apic --mode portaladmin site:cache-rebuild  --server management_server --catalog catalogid/name --org orgid/name
When loading the site in a browser, you should now see CSS and JS aggregation is disabled when using development tools for site debug or customization.
Note:
  • Disabling aggregation affects site performance, so if the site goes into production remember to turn aggregation back on again.
  • Although the settings are shown as true or false, to set them by using the drupal-config:set command, you must apply a value of 1 for true, and 0 for false.