Overview

Skill Level: Intermediate

Prerequisites

Encrypting and uploading the data file is required before importing the data into WMI. You perform this procedure initially when you set up your system. You perform this procedure again each time you update the customer profile data in the system.

Note: The mechanism this tutorial uses for the upload is OpenStack Swift Object Storage. Swift has an upload size limit of 5GB. However, you can use a Swift function to split a larger file and create a manifest file so they can be accessed as one file. For more information, refer to https://docs.openstack.org/developer/swift/overview_large_objects.html.

After completing this procedure, refer to Import Service and API.

Step-by-step

  1. Encrypting the data file

    1. Install cryptography Python package. For example, using pip:
      pip install cryptography
    2. Create a simple Python script to encrypt. For example:
      from cryptography.fernet import Fernet

      key = Fernet.generate_key()
      f = Fernet(key)

      withopen(sys.argv[1], 'r') as input_file, open(sys.argv[2], 'w') as output_file:
      for line in input_file:
      output_file.write(f.encrypt(line) +'n')
      print'Key: '+ key

      Note:
      As shown in this example, you must perform the encryption line by line and not just perform
      encryption on the whole file.

    3. Run script to encrypt. For example, using above script saved as wmiencrypt.py:
      python wmiencrypt.py <inputFile> <outputFile>
  2. Installing and configuring the Swift Command Line Interface

    Note: The following commands may require administrative privileges or use of the sudo command.

    Install the following prerequisite software if not already installed. For more information, refer
    to the OpenStack documentation.

    • Python 2.7 or later
    • The setup tools package
    • The pip package

    Install the Python Swift client by using Python pip:

    pip install python-swiftclient

    Install the Python Keystone client:

    pip install python-keystoneclient
  3. Uploading data using OpenStack Swift Object Storage

    Data exchanged with WMI APIs are done by using a cloud storage account that is provided as part of your WMI subscription. To connect and use your storage, the client must be provided information such as urls, credentials, and other information about your account. The connectivity values for your Object Storage account were provided to your primary account administrator.

    The storage is based on OpenStack Swift Object Storage and can be accessed by using any compatible client application. The API can be accessed by using one of the following methods:

    Method Description Reference documentation
    Swift Command Line Interface (CLI) Easy to use command line interface. Requires Python. http://docs.openstack.org/cli-reference/swift.html
    REST API RESTful API. Compatible with most HTTP clients. http://developer.openstack.org/api-ref/object-storage/index.html

     

    Note: Swift has a upload size limit of 5GB. However, you can use a Swift function to split a larger file and create a manifest file so they can be downloaded as one file. For more information, refer to https://docs.openstack.org/developer/swift/overview_large_objects.html.

  4. Configuring the client

    Connectivity parameters can be passed as command line parameters or set through environment
    variables.

    Following is an example of how to set the connectivity information using environment
    variables:

    
    export OS_USER_ID=24a20b8e4e724f5fa9e7bfdc79ca7e85
    export OS_PASSWORD=aaa55AAAaaaaa]k2
    export OS_PROJECT_ID=383ec90b22ff4ba4a78636f4e989d5b1
    export OS_AUTH_URL=https://identity.open.softlayer.com/v3
    export OS_REGION_NAME=dallas export OS_IDENTITY_API_VERSION=3
    export OS_AUTH_VERSION=3

    Note: Ensure /v3 is included in the auth_url as shown.

  5. Examples using cloud storage

    Note: The example below assume configuration has been set using variables or will be added to command.

    Action Command
    Listing containers swift list
    Creating a container swift post <container_name>
    Listing the content of a container swift list <container_name>
    Adding a file to a container swift upload <container_name> <file_name>
    Adding files larger than 5 GB swift upload <container_name> <file_name> --segment-size <size_in_bytes>
    Downloading a file swift download <container_name> <file_name>

     

Join The Discussion

Your email address will not be published. Required fields are marked *