
import sys

import os_client_config

from examples import common
from openstack import connection


def make_connection(opts):
    occ = os_client_config.OpenStackConfig()
    cloud = occ.get_one_cloud(opts.cloud, opts)
    auth = cloud.config['auth']
    if 'insecure' in cloud.config:
        auth['verify'] = cloud.config['insecure']
    conn = connection.Connection(preference=opts.user_preferences, **auth)
    return conn


def run_connection(opts):
    conn = make_connection(opts)
    print("Connection: %s" % conn)
    for flavor in conn.compute.flavors():
        print(flavor.id + " " + flavor.name)
    return


if __name__ == "__main__":
    opts = common.setup()
    sys.exit(common.main(opts, run_connection))


import sys

import os_client_config

from examples import common
from openstack import connection


def make_connection(opts):
    occ = os_client_config.OpenStackConfig()
    cloud = occ.get_one_cloud(opts.cloud, opts)
    opts.user_preferences.set_region(opts.user_preferences.ALL, cloud.region)
    auth = cloud.config['auth']
    if 'insecure' in cloud.config:
        auth['verify'] = cloud.config['insecure']
    conn = connection.Connection(preference=opts.user_preferences, **auth)
    return conn


def run_connection(opts):
    conn = make_connection(opts)
    print("Connection: %s" % conn)
    for flavor in conn.compute.flavors():
        print(flavor.id + " " + flavor.name)
    return


if __name__ == "__main__":
    opts = common.setup()
    sys.exit(common.main(opts, run_connection))

Enable occ cloud region for example
Enable occ cloud region for example

Change-Id: I4f6fb7840b684e024ceca37bc5b7e2c858574665

  
  import sys
  
  import os_client_config
  
  from examples import common
  from openstack import connection
  
  
  def make_connection(opts):
      occ = os_client_config.OpenStackConfig()
      cloud = occ.get_one_cloud(opts.cloud, opts)
+     opts.user_preferences.set_region(opts.user_preferences.ALL, cloud.region)
      auth = cloud.config['auth']
      if 'insecure' in cloud.config:
          auth['verify'] = cloud.config['insecure']
      conn = connection.Connection(preference=opts.user_preferences, **auth)
      return conn
  
  
  def run_connection(opts):
      conn = make_connection(opts)
      print("Connection: %s" % conn)
      for flavor in conn.compute.flavors():
          print(flavor.id + " " + flavor.name)
      return
  
  
  if __name__ == "__main__":
      opts = common.setup()
      sys.exit(common.main(opts, run_connection))
  
Enable occ cloud region for example
## Code Before:

import sys

import os_client_config

from examples import common
from openstack import connection


def make_connection(opts):
    occ = os_client_config.OpenStackConfig()
    cloud = occ.get_one_cloud(opts.cloud, opts)
    auth = cloud.config['auth']
    if 'insecure' in cloud.config:
        auth['verify'] = cloud.config['insecure']
    conn = connection.Connection(preference=opts.user_preferences, **auth)
    return conn


def run_connection(opts):
    conn = make_connection(opts)
    print("Connection: %s" % conn)
    for flavor in conn.compute.flavors():
        print(flavor.id + " " + flavor.name)
    return


if __name__ == "__main__":
    opts = common.setup()
    sys.exit(common.main(opts, run_connection))

## Instruction:
Enable occ cloud region for example
## Code After:

import sys

import os_client_config

from examples import common
from openstack import connection


def make_connection(opts):
    occ = os_client_config.OpenStackConfig()
    cloud = occ.get_one_cloud(opts.cloud, opts)
    opts.user_preferences.set_region(opts.user_preferences.ALL, cloud.region)
    auth = cloud.config['auth']
    if 'insecure' in cloud.config:
        auth['verify'] = cloud.config['insecure']
    conn = connection.Connection(preference=opts.user_preferences, **auth)
    return conn


def run_connection(opts):
    conn = make_connection(opts)
    print("Connection: %s" % conn)
    for flavor in conn.compute.flavors():
        print(flavor.id + " " + flavor.name)
    return


if __name__ == "__main__":
    opts = common.setup()
    sys.exit(common.main(opts, run_connection))
