• CLI

sdk
  1. Help Center
  2. CLI
  3. Developer Guide
  4. SDK
  5. Python
  6. Usage

Usage

Configuration on the Client

Some functions supported by SDK can be enabled or disabled through configuration.

Sample code

conn = connection.Connection(auth_url=auth_url,
                             user_domain_id=userDomainId,
                             project_id=projectId,
                             username=username,
                             password=password,
                             verify=False)

Currently, the following custom parameters are supported.

Parameter

Default Value

Function Description

Remarks

verify

True

SSL check

You are advised to set verify to True.

Service Endpoint Configuration

When using SDK to invoke cloud service APIs, you need to obtain the address (endpoint) of each cloud service.

You can use Python SDK to automatically obtain the endpoints or manually encode the endpoints.

The following are examples of manually encoding endpoints for cloud services:

os.environ.setdefault(
    'OS_CLOUD_EYE_ENDPOINT_OVERRIDE',
    'https://ces.example.com/V1.0/%(project_id)s'
)
os.environ.setdefault(
    'OS_AUTO_SCALING_ENDPOINT_OVERRIDE',
    ('https://as.example.com'
     '/autoscaling-api/v1/%(project_id)s')
)
os.environ.setdefault(
    'OS_DNS_ENDPOINT_OVERRIDE',
    'https://dns.example.com/v2'
)
os.environ.setdefault(
    'OS_VOLUME_BACKUP_ENDPOINT_OVERRIDE',
    'https://vbs.example.com/v2/%(project_id)s'
)
os.environ.setdefault(
    'OS_LOAD_BALANCER_ENDPOINT_OVERRIDE',
    'https://elb.example.com/v1.0/%(project_id)s'
)
os.environ.setdefault(
    'OS_MAP_REDUCE_ENDPOINT_OVERRIDE',
    'https://mrs.example.com/v1.1/%(project_id)s'
)
os.environ.setdefault(
    'OS_CTS_ENDPOINT_OVERRIDE',
    'https://cts.example.com/v1.0/%(project_id)s'
)
os.environ.setdefault(
    'OS_SMN_ENDPOINT_OVERRIDE',
    'https://smn.example.com/v2/%(project_id)s'
)
os.environ.setdefault(
    'OS_MAAS_ENDPOINT_OVERRIDE',
    'https://maas.example.com/v1/%(project_id)s'
)
os.environ.setdefault(
    'OS_KMS_ENDPOINT_OVERRIDE',
    'https://kms.example.com/v1.0/%(project_id)s'
)
os.environ.setdefault(
    'OS_ANTI_DDOS_ENDPOINT_OVERRIDE',
    'https://antiddos.example.com/v1/%(project_id)s'
)
os.environ.setdefault(
    'OS_DMS_ENDPOINT_OVERRIDE',
    'https://dms.example.com/v1.0/%(project_id)s'
)
os.environ.setdefault(
    'OS_RDSV1_ENDPOINT_OVERRIDE',
    'https://rds.example.com/rds/v1/%(project_id)s'
)
os.environ.setdefault(
    'OS_CDN_ENDPOINT_OVERRIDE', 
    'https://cdn.example.com/v1.0'
)
  • example in the preceding code is in the Region.Cloud platform domain name format. For details about the parameters, see here.
  • In the preceding code, you do not need to replace the project_id value with the actual value.
  • Click here to obtain a complete code example of using Python SDK for reference.

Fault Locating

To enable the debugging function using Python SDK, add the following code to the application:

from openstack import utils
utils.enable_logging(debug=True,stream=sys.stdout)