Creating a profile to use the cpd-cli management commands

Before you can complete certain setup and management tasks for IBM® Software Hub, you must create a profile so that you can run cpd-cli commands.

Before you begin

Download and install Version 14.2.2 of the cpd-cli command-line utility. For more information, see Installing the IBM Software Hub command-line interface (cpd-cli).

About this task

Any user who plans to complete the following tasks must create a profile.

A profile enables the cpd-cli to verify that you are an IBM Software Hub user and that you have the appropriate permissions to complete a specific task.

If you are an administrator of multiple instances of IBM Software Hub, you must create profile for each instance.

If an instance of IBM Software Hub has multiple administrators, each administrator can create a profile.

Note: The following examples use the recommended installation environment variables.

It is strongly recommended that you use a script to create environment variables with the correct values for your environment. For more information, see Setting up installation environment variables.

Procedure

  1. Generate the API key that you need for user authentication by going to your Profile and settings page in the web client and clicking Generate API key.
    This API key does not expire. The configuration information is stored in $HOME/.cpd-cli/config.
  2. Set the following environment variables.
    1. Set the API_KEY to the API key that you obtained in the preceding step.
      export API_KEY=<api-key>
    2. Set the CPD_USERNAME environment variable to your username.
      export CPD_USERNAME=<user-name>
    3. Set the LOCAL_USER environment variable to the name that you want to use for the local user configuration.
      export LOCAL_USER=<local-user>
    4. Set the CPD_PROFILE_NAME environment variable to the name that you want to use for the profile.
      export CPD_PROFILE_NAME=<cpd-profile-name>
    5. Set the CPD_PROFILE_URL environment variable to the URL of the instance that you want to connect to.
      export CPD_PROFILE_URL=<cpd-url>

      To get the URL of the web client, run the following command.

      oc get route cpd \
      --namespace=${PROJECT_CPD_INST_OPERANDS}

      The command returns output with the following format.

      cpd-namespace.apps.OCP-default-domain

      Add https:// to the value that is returned.

      For example, https://cpd-namespace.apps.OCP-default-domain.
  3. Create a local user configuration to store your username and API key by using the config users set command.
    cpd-cli config users set ${LOCAL_USER} \
    --username ${CPD_USERNAME} \
    --apikey ${API_KEY}

    Anytime you regenerate your API key, you must rerun this command to update your local user configuration.

  4. Create a profile to store the URL and to associate the profile with your local user configuration by using the config profiles set command.
    cpd-cli config profiles set ${CPD_PROFILE_NAME} \
    --user ${LOCAL_USER} \
    --url ${CPD_PROFILE_URL}
    For example:
    users:
    - name: 682-d-engineer_1
      user:
        username: cpadmin
        apikey: {base64: c1BPZnhRZ1pyTEVyeWdkdUpEdGtqT3lpMTdpcm9HWm5JSDcza3VDcQ==}
    - name: my_profile
      profile:
        type: private
        url: https://cpd-cpd-instance.apps.ivt564.cp.example.ibm.com
        user: 682-d-engineer_1
    ....

Results

You can now run cpd-cli commands with this profile as shown in the following example.

cpd-cli service-instance list \
--profile=${CPD_PROFILE_NAME}