11. Stockage objet OpenStack

Swift est déployé avec DevStack

1. Architecture de stockage


2. Opérations sur Swift

2.1. Variables d'environnement

stack@st-vbx-1:~/devstack$ . openrc admin
WARNING: setting legacy OS_TENANT_NAME to support cli tools.

2.2. Identification du service Swift

stack@st-vbx-1:~/devstack$ openstack service list
| ID                               | Name     | Type         |
| 98f67c545a464020b362c01a9f40ef9a | keystone | identity     |
| c5b21d9b34eb4567a90819975dc0fe59 | swift    | object-store |

2.3. Détails sur le service Swift

stack@st-vbx-1:~/devstack$ swift stat
               Account: AUTH_c577f605ac144d15b11a1bdbf246d677
            Containers: 0
               Objects: 0
                 Bytes: 0
       X-Put-Timestamp: 1552074251.40737
           X-Timestamp: 1552074251.40737
            X-Trans-Id: txd3774930977a456b84ae0-005c82c60a
          Content-Type: text/plain; charset=utf-8
X-Openstack-Request-Id: txd3774930977a456b84ae0-005c82c60a

2.4. Ligne de commande Swift

stack@st-vbx-1:~/devstack$ swift
usage: swift [--version] [--help] [--os-help] [--snet] [--verbose]
             [--debug] [--info] [--quiet] [--auth <auth_url>]
             [--auth-version <auth_version> |
                 --os-identity-api-version <auth_version> ]
             [--user <username>]
             [--key <api_key>] [--retries <num_retries>]
             [--os-username <auth-user-name>]
             [--os-password <auth-password>]
             [--os-user-id <auth-user-id>]
             [--os-user-domain-id <auth-user-domain-id>]
             [--os-user-domain-name <auth-user-domain-name>]
             [--os-tenant-id <auth-tenant-id>]
             [--os-tenant-name <auth-tenant-name>]
             [--os-project-id <auth-project-id>]
             [--os-project-name <auth-project-name>]
             [--os-project-domain-id <auth-project-domain-id>]
             [--os-project-domain-name <auth-project-domain-name>]
             [--os-auth-url <auth-url>]
             [--os-auth-token <auth-token>]
             [--os-storage-url <storage-url>]
             [--os-region-name <region-name>]
             [--os-service-type <service-type>]
             [--os-endpoint-type <endpoint-type>]
             [--os-cacert <ca-certificate>]
             [--os-cert <client-certificate-file>]
             [--os-key <client-certificate-key-file>]
             <subcommand> [--help] [<subcommand options>]

Command-line interface to the OpenStack Swift API.

Positional arguments:
    delete               Delete a container or objects within a container.
    download             Download objects from containers.
    list                 Lists the containers for the account or the objects
                         for a container.
    post                 Updates meta information for the account, container,
                         or object; creates containers if not present.
    copy                 Copies object, optionally adds meta
    stat                 Displays information for the account, container,
                         or object.
    upload               Uploads files or directories to the given container.
    capabilities         List cluster capabilities.
    tempurl              Create a temporary URL.
    auth                 Display auth related environment variables.
    bash_completion      Outputs option and flag cli data ready for

  swift download --help

  swift -A https://api.example.com/v1.0 \
      -U user -K api_key stat -v

  swift --os-auth-url https://api.example.com/v2.0 \
      --os-tenant-name tenant \
      --os-username user --os-password password list

  swift --os-auth-url https://api.example.com/v3 --auth-version 3\
      --os-project-name project1 --os-project-domain-name domain1 \
      --os-username user --os-user-domain-name domain1 \
      --os-password password list

  swift --os-auth-url https://api.example.com/v3 --auth-version 3\
      --os-project-id 0123456789abcdef0123456789abcdef \
      --os-user-id abcdef0123456789abcdef0123456789 \
      --os-password password list

  swift --os-auth-token 6ee5eb33efad4e45ab46806eac010566 \
      --os-storage-url \

  swift list --lh

optional arguments:
  --version             show programs version number and exit
  -h, --help
  --os-help             Show OpenStack authentication options.
  -s, --snet            Use SERVICENET internal network.
  -v, --verbose         Print more info.
  --debug               Show the curl commands and results of all http queries
                        regardless of result status.
  --info                Show the curl commands and results of all http queries
                        which return an error.
  -q, --quiet           Suppress status output.
  -A=AUTH, --auth=AUTH  URL for obtaining an auth token.
  -V=AUTH_VERSION, --auth-version=AUTH_VERSION, --os-identity-api-version=AUTH_VERSION
                        Specify a version for authentication. Defaults to
                        env[ST_AUTH_VERSION], env[OS_AUTH_VERSION],
                        env[OS_IDENTITY_API_VERSION] or 1.0.
  -U=USER, --user=USER  User name for obtaining an auth token.
  -K=KEY, --key=KEY     Key for obtaining an auth token.
  -R=RETRIES, --retries=RETRIES
                        The number of times to retry a failed connection.
  --insecure            Allow swiftclient to access servers without having to
                        verify the SSL certificate. Defaults to
                        env[SWIFTCLIENT_INSECURE] (set to 'true' to enable).
  --no-ssl-compression  This option is deprecated and not used anymore. SSL
                        compression should be disabled by default by the
                        system SSL library.
  --force-auth-retry    Force a re-auth attempt on any error other than 401
  --prompt              Prompt user to enter a password which overrides any
                        password supplied via --key, --os-password or
                        environment variables.

2.5. Création d'un centeneur

stack@st-vbx-1:~/devstack$ swift post TestContainer
stack@st-vbx-1:~/devstack$ swift list

2.6. Placement d'un fichier

stack@st-vbx-1:~/devstack$ echo "$(date)" >> testSwift.txt
stack@st-vbx-1:~/devstack$ swift upload TestContainer testSwift.txt
stack@st-vbx-1:~/devstack$ swift list TestContainer

2.7. Copie d'un conteneur

stack@st-vbx-1:~/devstack$ swift post DestContainer
stack@st-vbx-1:~/devstack$ swift post SourceContainer
stack@st-vbx-1:~/devstack$ swift upload SourceContainer testSwift.txt
stack@st-vbx-1:~/devstack$ swift copy -d /DestContainer/testSwift.txt SourceContainer testSwift.txt
created container DestContainer
SourceContainer/testSwift.txt copied to /DestContainer/testSwift.txt

2.8. Suppression d'un conteneur

stack@st-vbx-1:~/devstack$ swift delete TestContainer testSwift.txt
stack@st-vbx-1:~/devstack$ swift delete TestContainer

2.9. Paramètres d'authentification

stack@st-vbx-1:~/devstack$ swift auth
export OS_AUTH_TOKEN=gAAAAABcgscqmz4NNH2RdJSwHUx3a65nE5855iBSgJQ_Ehd9w09zrlfZmI8s3ZMiOhmdBBn6tIkRNPRfvmNY9Wo06JwijX_A9H83TJjnKD_oRMul6gqUii5FTlDECKQSv4TWPgzuyRKWrwpKhOxzpUEb-Xb5crvZoMWfMsusQDyeqm8b_I4JjEk

2.10. Téléchargement d'un fichier

stack@st-vbx-1:~/devstack$ swift download DestContainer testSwift.txt
testSwift.txt [auth 0.343s, headers 0.530s, total 0.531s, 0.000 MB/s]