Remove openstack_cloud factory function
This is mostly mechanical as these are no longer needed. Change-Id: I632675506bef591704068d17ec3dfad963a4c4b5
This commit is contained in:
parent
0a6083b876
commit
958a35a5ca
17
README.rst
17
README.rst
@ -65,13 +65,6 @@ and provides different argument defaults where needed for compatibility.
|
|||||||
Similarly future releases of os-client-config will provide a compatibility
|
Similarly future releases of os-client-config will provide a compatibility
|
||||||
layer shim around ``openstack.config``.
|
layer shim around ``openstack.config``.
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
The ``openstack.cloud.OpenStackCloud`` object and the
|
|
||||||
``openstack.connection.Connection`` object are going to be merged. It is
|
|
||||||
recommended to not write any new code which consumes objects from the
|
|
||||||
``openstack.cloud`` namespace until that merge is complete.
|
|
||||||
|
|
||||||
.. _nodepool: https://docs.openstack.org/infra/nodepool/
|
.. _nodepool: https://docs.openstack.org/infra/nodepool/
|
||||||
.. _Ansible OpenStack Modules: http://docs.ansible.com/ansible/latest/list_of_cloud_modules.html#openstack
|
.. _Ansible OpenStack Modules: http://docs.ansible.com/ansible/latest/list_of_cloud_modules.html#openstack
|
||||||
.. _Session: http://docs.python-requests.org/en/master/user/advanced/#session-objects
|
.. _Session: http://docs.python-requests.org/en/master/user/advanced/#session-objects
|
||||||
@ -143,20 +136,20 @@ Create a server using objects configured with the ``clouds.yaml`` file:
|
|||||||
# Initialize and turn on debug logging
|
# Initialize and turn on debug logging
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
|
|
||||||
# Initialize cloud
|
# Initialize connection
|
||||||
# Cloud configs are read with openstack.config
|
# Cloud configs are read with openstack.config
|
||||||
cloud = openstack.cloud.openstack_cloud(cloud='mordred')
|
conn = openstack.connect(cloud='mordred')
|
||||||
|
|
||||||
# Upload an image to the cloud
|
# Upload an image to the cloud
|
||||||
image = cloud.create_image(
|
image = conn.create_image(
|
||||||
'ubuntu-trusty', filename='ubuntu-trusty.qcow2', wait=True)
|
'ubuntu-trusty', filename='ubuntu-trusty.qcow2', wait=True)
|
||||||
|
|
||||||
# Find a flavor with at least 512M of RAM
|
# Find a flavor with at least 512M of RAM
|
||||||
flavor = cloud.get_flavor_by_ram(512)
|
flavor = conn.get_flavor_by_ram(512)
|
||||||
|
|
||||||
# Boot a server, wait for it to boot, and then do whatever is needed
|
# Boot a server, wait for it to boot, and then do whatever is needed
|
||||||
# to get a public ip for it.
|
# to get a public ip for it.
|
||||||
cloud.create_server(
|
conn.create_server(
|
||||||
'my-server', image=image, flavor=flavor, wait=True, auto_ip=True)
|
'my-server', image=image, flavor=flavor, wait=True, auto_ip=True)
|
||||||
|
|
||||||
Links
|
Links
|
||||||
|
@ -72,7 +72,7 @@ Complete Example
|
|||||||
('my-citycloud', 'Buf1'),
|
('my-citycloud', 'Buf1'),
|
||||||
('my-internap', 'ams01')]:
|
('my-internap', 'ams01')]:
|
||||||
# Initialize cloud
|
# Initialize cloud
|
||||||
cloud = openstack.openstack_cloud(cloud=cloud_name, region_name=region_name)
|
cloud = openstack.connect(cloud=cloud_name, region_name=region_name)
|
||||||
|
|
||||||
# Upload an image to the cloud
|
# Upload an image to the cloud
|
||||||
image = cloud.create_image(
|
image = cloud.create_image(
|
||||||
@ -324,7 +324,7 @@ Complete Example Again
|
|||||||
('my-citycloud', 'Buf1'),
|
('my-citycloud', 'Buf1'),
|
||||||
('my-internap', 'ams01')]:
|
('my-internap', 'ams01')]:
|
||||||
# Initialize cloud
|
# Initialize cloud
|
||||||
cloud = openstack.openstack_cloud(cloud=cloud_name, region_name=region_name)
|
cloud = openstack.connect(cloud=cloud_name, region_name=region_name)
|
||||||
|
|
||||||
# Upload an image to the cloud
|
# Upload an image to the cloud
|
||||||
image = cloud.create_image(
|
image = cloud.create_image(
|
||||||
@ -376,7 +376,7 @@ Example with Debug Logging
|
|||||||
from openstack import cloud as openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(
|
cloud = openstack.connect(
|
||||||
cloud='my-vexxhost', region_name='ca-ymq-1')
|
cloud='my-vexxhost', region_name='ca-ymq-1')
|
||||||
cloud.get_image('Ubuntu 16.04.1 LTS [2017-03-03]')
|
cloud.get_image('Ubuntu 16.04.1 LTS [2017-03-03]')
|
||||||
|
|
||||||
@ -390,7 +390,7 @@ Example with HTTP Debug Logging
|
|||||||
from openstack import cloud as openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging(http_debug=True)
|
openstack.enable_logging(http_debug=True)
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(
|
cloud = openstack.connect(
|
||||||
cloud='my-vexxhost', region_name='ca-ymq-1')
|
cloud='my-vexxhost', region_name='ca-ymq-1')
|
||||||
cloud.get_image('Ubuntu 16.04.1 LTS [2017-03-03]')
|
cloud.get_image('Ubuntu 16.04.1 LTS [2017-03-03]')
|
||||||
|
|
||||||
@ -398,7 +398,7 @@ Cloud Regions
|
|||||||
=============
|
=============
|
||||||
|
|
||||||
* `cloud` constructor needs `cloud` and `region_name`
|
* `cloud` constructor needs `cloud` and `region_name`
|
||||||
* `openstack.openstack_cloud` is a helper factory function
|
* `openstack.connect` is a helper factory function
|
||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
@ -407,7 +407,7 @@ Cloud Regions
|
|||||||
('my-citycloud', 'Buf1'),
|
('my-citycloud', 'Buf1'),
|
||||||
('my-internap', 'ams01')]:
|
('my-internap', 'ams01')]:
|
||||||
# Initialize cloud
|
# Initialize cloud
|
||||||
cloud = openstack.openstack_cloud(cloud=cloud_name, region_name=region_name)
|
cloud = openstack.connect(cloud=cloud_name, region_name=region_name)
|
||||||
|
|
||||||
Upload an Image
|
Upload an Image
|
||||||
===============
|
===============
|
||||||
@ -497,7 +497,7 @@ Image and Flavor by Name or ID
|
|||||||
('my-internap', 'ams01',
|
('my-internap', 'ams01',
|
||||||
'Ubuntu 16.04 LTS (Xenial Xerus)', 'A1.4')]:
|
'Ubuntu 16.04 LTS (Xenial Xerus)', 'A1.4')]:
|
||||||
# Initialize cloud
|
# Initialize cloud
|
||||||
cloud = openstack.openstack_cloud(cloud=cloud_name, region_name=region_name)
|
cloud = openstack.connect(cloud=cloud_name, region_name=region_name)
|
||||||
|
|
||||||
# Boot a server, wait for it to boot, and then do whatever is needed
|
# Boot a server, wait for it to boot, and then do whatever is needed
|
||||||
# to get a public ip for it.
|
# to get a public ip for it.
|
||||||
@ -544,7 +544,7 @@ Image and Flavor by Dict
|
|||||||
('my-internap', 'ams01', 'Ubuntu 16.04 LTS (Xenial Xerus)',
|
('my-internap', 'ams01', 'Ubuntu 16.04 LTS (Xenial Xerus)',
|
||||||
'A1.4')]:
|
'A1.4')]:
|
||||||
# Initialize cloud
|
# Initialize cloud
|
||||||
cloud = openstack.openstack_cloud(cloud=cloud_name, region_name=region_name)
|
cloud = openstack.connect(cloud=cloud_name, region_name=region_name)
|
||||||
|
|
||||||
# Boot a server, wait for it to boot, and then do whatever is needed
|
# Boot a server, wait for it to boot, and then do whatever is needed
|
||||||
# to get a public ip for it.
|
# to get a public ip for it.
|
||||||
@ -565,7 +565,7 @@ Munch Objects
|
|||||||
from openstack import cloud as openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(cloud='zetta', region_name='no-osl1')
|
cloud = openstack.connect(cloud='zetta', region_name='no-osl1')
|
||||||
image = cloud.get_image('Ubuntu 14.04 (AMD64) [Local Storage]')
|
image = cloud.get_image('Ubuntu 14.04 (AMD64) [Local Storage]')
|
||||||
print(image.name)
|
print(image.name)
|
||||||
print(image['name'])
|
print(image['name'])
|
||||||
@ -604,7 +604,7 @@ Cleanup Script
|
|||||||
('my-citycloud', 'Buf1'),
|
('my-citycloud', 'Buf1'),
|
||||||
('my-internap', 'ams01')]:
|
('my-internap', 'ams01')]:
|
||||||
# Initialize cloud
|
# Initialize cloud
|
||||||
cloud = openstack.openstack_cloud(cloud=cloud_name, region_name=region_name)
|
cloud = openstack.connect(cloud=cloud_name, region_name=region_name)
|
||||||
for server in cloud.search_servers('my-server'):
|
for server in cloud.search_servers('my-server'):
|
||||||
cloud.delete_server(server, wait=True, delete_ips=True)
|
cloud.delete_server(server, wait=True, delete_ips=True)
|
||||||
|
|
||||||
@ -619,7 +619,7 @@ Normalization
|
|||||||
from openstack import cloud as openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging()
|
openstack.enable_logging()
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(cloud='fuga', region_name='cystack')
|
cloud = openstack.connect(cloud='fuga', region_name='cystack')
|
||||||
image = cloud.get_image(
|
image = cloud.get_image(
|
||||||
'Ubuntu 16.04 LTS - Xenial Xerus - 64-bit - Fuga Cloud Based Image')
|
'Ubuntu 16.04 LTS - Xenial Xerus - 64-bit - Fuga Cloud Based Image')
|
||||||
cloud.pprint(image)
|
cloud.pprint(image)
|
||||||
@ -635,7 +635,7 @@ Strict Normalized Results
|
|||||||
from openstack import cloud as openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging()
|
openstack.enable_logging()
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(
|
cloud = openstack.connect(
|
||||||
cloud='fuga', region_name='cystack', strict=True)
|
cloud='fuga', region_name='cystack', strict=True)
|
||||||
image = cloud.get_image(
|
image = cloud.get_image(
|
||||||
'Ubuntu 16.04 LTS - Xenial Xerus - 64-bit - Fuga Cloud Based Image')
|
'Ubuntu 16.04 LTS - Xenial Xerus - 64-bit - Fuga Cloud Based Image')
|
||||||
@ -652,7 +652,7 @@ How Did I Find the Image Name for the Last Example?
|
|||||||
from openstack import cloud as openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging()
|
openstack.enable_logging()
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(cloud='fuga', region_name='cystack')
|
cloud = openstack.connect(cloud='fuga', region_name='cystack')
|
||||||
cloud.pprint([
|
cloud.pprint([
|
||||||
image for image in cloud.list_images()
|
image for image in cloud.list_images()
|
||||||
if 'ubuntu' in image.name.lower()])
|
if 'ubuntu' in image.name.lower()])
|
||||||
@ -673,7 +673,7 @@ Added / Modified Information
|
|||||||
from openstack import cloud as openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(cloud='my-citycloud', region_name='Buf1')
|
cloud = openstack.connect(cloud='my-citycloud', region_name='Buf1')
|
||||||
try:
|
try:
|
||||||
server = cloud.create_server(
|
server = cloud.create_server(
|
||||||
'my-server', image='Ubuntu 16.04 Xenial Xerus',
|
'my-server', image='Ubuntu 16.04 Xenial Xerus',
|
||||||
@ -715,7 +715,7 @@ User Agent Info
|
|||||||
from openstack import cloud as openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging(http_debug=True)
|
openstack.enable_logging(http_debug=True)
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(
|
cloud = openstack.connect(
|
||||||
cloud='datacentred', app_name='AmazingApp', app_version='1.0')
|
cloud='datacentred', app_name='AmazingApp', app_version='1.0')
|
||||||
cloud.list_networks()
|
cloud.list_networks()
|
||||||
|
|
||||||
@ -733,7 +733,7 @@ Uploading Large Objects
|
|||||||
from openstack import cloud as openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(cloud='ovh', region_name='SBG1')
|
cloud = openstack.connect(cloud='ovh', region_name='SBG1')
|
||||||
cloud.create_object(
|
cloud.create_object(
|
||||||
container='my-container', name='my-object',
|
container='my-container', name='my-object',
|
||||||
filename='/home/mordred/briarcliff.sh3d')
|
filename='/home/mordred/briarcliff.sh3d')
|
||||||
@ -754,7 +754,7 @@ Uploading Large Objects
|
|||||||
from openstack import cloud as openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(cloud='ovh', region_name='SBG1')
|
cloud = openstack.connect(cloud='ovh', region_name='SBG1')
|
||||||
cloud.create_object(
|
cloud.create_object(
|
||||||
container='my-container', name='my-object',
|
container='my-container', name='my-object',
|
||||||
filename='/home/mordred/briarcliff.sh3d',
|
filename='/home/mordred/briarcliff.sh3d',
|
||||||
@ -770,7 +770,7 @@ Service Conditionals
|
|||||||
from openstack import cloud as openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(cloud='kiss', region_name='region1')
|
cloud = openstack.connect(cloud='kiss', region_name='region1')
|
||||||
print(cloud.has_service('network'))
|
print(cloud.has_service('network'))
|
||||||
print(cloud.has_service('container-orchestration'))
|
print(cloud.has_service('container-orchestration'))
|
||||||
|
|
||||||
@ -784,7 +784,7 @@ Service Conditional Overrides
|
|||||||
from openstack import cloud as openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(cloud='rax', region_name='DFW')
|
cloud = openstack.connect(cloud='rax', region_name='DFW')
|
||||||
print(cloud.has_service('network'))
|
print(cloud.has_service('network'))
|
||||||
|
|
||||||
.. code:: yaml
|
.. code:: yaml
|
||||||
|
@ -20,7 +20,7 @@ for cloud_name, region_name in [
|
|||||||
('my-citycloud', 'Buf1'),
|
('my-citycloud', 'Buf1'),
|
||||||
('my-internap', 'ams01')]:
|
('my-internap', 'ams01')]:
|
||||||
# Initialize cloud
|
# Initialize cloud
|
||||||
cloud = openstack.openstack_cloud(
|
cloud = openstack.connect(
|
||||||
cloud=cloud_name, region_name=region_name)
|
cloud=cloud_name, region_name=region_name)
|
||||||
for server in cloud.search_servers('my-server'):
|
for server in cloud.search_servers('my-server'):
|
||||||
cloud.delete_server(server, wait=True, delete_ips=True)
|
cloud.delete_server(server, wait=True, delete_ips=True)
|
||||||
|
@ -23,7 +23,7 @@ for cloud_name, region_name, image, flavor_id in [
|
|||||||
('my-internap', 'ams01', 'Ubuntu 16.04 LTS (Xenial Xerus)',
|
('my-internap', 'ams01', 'Ubuntu 16.04 LTS (Xenial Xerus)',
|
||||||
'A1.4')]:
|
'A1.4')]:
|
||||||
# Initialize cloud
|
# Initialize cloud
|
||||||
cloud = openstack.openstack_cloud(
|
cloud = openstack.connect(
|
||||||
cloud=cloud_name, region_name=region_name)
|
cloud=cloud_name, region_name=region_name)
|
||||||
|
|
||||||
# Boot a server, wait for it to boot, and then do whatever is needed
|
# Boot a server, wait for it to boot, and then do whatever is needed
|
||||||
|
@ -23,7 +23,7 @@ for cloud_name, region_name, image, flavor in [
|
|||||||
('my-internap', 'ams01',
|
('my-internap', 'ams01',
|
||||||
'Ubuntu 16.04 LTS (Xenial Xerus)', 'A1.4')]:
|
'Ubuntu 16.04 LTS (Xenial Xerus)', 'A1.4')]:
|
||||||
# Initialize cloud
|
# Initialize cloud
|
||||||
cloud = openstack.openstack_cloud(
|
cloud = openstack.connect(
|
||||||
cloud=cloud_name, region_name=region_name)
|
cloud=cloud_name, region_name=region_name)
|
||||||
cloud.delete_server('my-server', wait=True, delete_ips=True)
|
cloud.delete_server('my-server', wait=True, delete_ips=True)
|
||||||
|
|
||||||
|
@ -13,6 +13,6 @@
|
|||||||
from openstack import cloud as openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(
|
cloud = openstack.connect(
|
||||||
cloud='my-vexxhost', region_name='ca-ymq-1')
|
cloud='my-vexxhost', region_name='ca-ymq-1')
|
||||||
cloud.get_image('Ubuntu 16.04.1 LTS [2017-03-03]')
|
cloud.get_image('Ubuntu 16.04.1 LTS [2017-03-03]')
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
from openstack import cloud as openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging()
|
openstack.enable_logging()
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(cloud='fuga', region_name='cystack')
|
cloud = openstack.connect(cloud='fuga', region_name='cystack')
|
||||||
cloud.pprint([
|
cloud.pprint([
|
||||||
image for image in cloud.list_images()
|
image for image in cloud.list_images()
|
||||||
if 'ubuntu' in image.name.lower()])
|
if 'ubuntu' in image.name.lower()])
|
||||||
|
@ -13,6 +13,6 @@
|
|||||||
from openstack import cloud as openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging(http_debug=True)
|
openstack.enable_logging(http_debug=True)
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(
|
cloud = openstack.connect(
|
||||||
cloud='my-vexxhost', region_name='ca-ymq-1')
|
cloud='my-vexxhost', region_name='ca-ymq-1')
|
||||||
cloud.get_image('Ubuntu 16.04.1 LTS [2017-03-03]')
|
cloud.get_image('Ubuntu 16.04.1 LTS [2017-03-03]')
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
from openstack import cloud as openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(cloud='ovh', region_name='SBG1')
|
cloud = openstack.connect(cloud='ovh', region_name='SBG1')
|
||||||
image = cloud.get_image('Ubuntu 16.10')
|
image = cloud.get_image('Ubuntu 16.10')
|
||||||
print(image.name)
|
print(image.name)
|
||||||
print(image['name'])
|
print(image['name'])
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
from openstack import cloud as openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging()
|
openstack.enable_logging()
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(cloud='fuga', region_name='cystack')
|
cloud = openstack.connect(cloud='fuga', region_name='cystack')
|
||||||
image = cloud.get_image(
|
image = cloud.get_image(
|
||||||
'Ubuntu 16.04 LTS - Xenial Xerus - 64-bit - Fuga Cloud Based Image')
|
'Ubuntu 16.04 LTS - Xenial Xerus - 64-bit - Fuga Cloud Based Image')
|
||||||
cloud.pprint(image)
|
cloud.pprint(image)
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
import openstack
|
import openstack
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(cloud='my-citycloud', region_name='Buf1')
|
cloud = openstack.connect(cloud='my-citycloud', region_name='Buf1')
|
||||||
try:
|
try:
|
||||||
server = cloud.create_server(
|
server = cloud.create_server(
|
||||||
'my-server', image='Ubuntu 16.04 Xenial Xerus',
|
'my-server', image='Ubuntu 16.04 Xenial Xerus',
|
||||||
|
@ -13,5 +13,5 @@
|
|||||||
import openstack
|
import openstack
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(cloud='rax', region_name='DFW')
|
cloud = openstack.connect(cloud='rax', region_name='DFW')
|
||||||
print(cloud.has_service('network'))
|
print(cloud.has_service('network'))
|
||||||
|
@ -13,6 +13,6 @@
|
|||||||
import openstack
|
import openstack
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(cloud='kiss', region_name='region1')
|
cloud = openstack.connect(cloud='kiss', region_name='region1')
|
||||||
print(cloud.has_service('network'))
|
print(cloud.has_service('network'))
|
||||||
print(cloud.has_service('container-orchestration'))
|
print(cloud.has_service('container-orchestration'))
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
import openstack
|
import openstack
|
||||||
openstack.enable_logging()
|
openstack.enable_logging()
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(
|
cloud = openstack.connect(
|
||||||
cloud='fuga', region_name='cystack', strict=True)
|
cloud='fuga', region_name='cystack', strict=True)
|
||||||
image = cloud.get_image(
|
image = cloud.get_image(
|
||||||
'Ubuntu 16.04 LTS - Xenial Xerus - 64-bit - Fuga Cloud Based Image')
|
'Ubuntu 16.04 LTS - Xenial Xerus - 64-bit - Fuga Cloud Based Image')
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
import openstack
|
import openstack
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(cloud='ovh', region_name='SBG1')
|
cloud = openstack.connect(cloud='ovh', region_name='SBG1')
|
||||||
cloud.create_object(
|
cloud.create_object(
|
||||||
container='my-container', name='my-object',
|
container='my-container', name='my-object',
|
||||||
filename='/home/mordred/briarcliff.sh3d',
|
filename='/home/mordred/briarcliff.sh3d',
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
import openstack
|
import openstack
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(cloud='ovh', region_name='SBG1')
|
cloud = openstack.connect(cloud='ovh', region_name='SBG1')
|
||||||
cloud.create_object(
|
cloud.create_object(
|
||||||
container='my-container', name='my-object',
|
container='my-container', name='my-object',
|
||||||
filename='/home/mordred/briarcliff.sh3d',
|
filename='/home/mordred/briarcliff.sh3d',
|
||||||
|
@ -13,6 +13,6 @@
|
|||||||
import openstack
|
import openstack
|
||||||
openstack.enable_logging(http_debug=True)
|
openstack.enable_logging(http_debug=True)
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(
|
cloud = openstack.connect(
|
||||||
cloud='datacentred', app_name='AmazingApp', app_version='1.0')
|
cloud='datacentred', app_name='AmazingApp', app_version='1.0')
|
||||||
cloud.list_networks()
|
cloud.list_networks()
|
||||||
|
@ -52,17 +52,3 @@ def openstack_clouds(
|
|||||||
except keystoneauth1.exceptions.auth_plugins.NoMatchingPlugin as e:
|
except keystoneauth1.exceptions.auth_plugins.NoMatchingPlugin as e:
|
||||||
raise OpenStackCloudException(
|
raise OpenStackCloudException(
|
||||||
"Invalid cloud configuration: {exc}".format(exc=str(e)))
|
"Invalid cloud configuration: {exc}".format(exc=str(e)))
|
||||||
|
|
||||||
|
|
||||||
def openstack_cloud(
|
|
||||||
config=None, strict=False, app_name=None, app_version=None, **kwargs):
|
|
||||||
# Late import while we unwind things
|
|
||||||
from openstack import connection
|
|
||||||
if not config:
|
|
||||||
config = _get_openstack_config(app_name, app_version)
|
|
||||||
try:
|
|
||||||
cloud_region = config.get_one(**kwargs)
|
|
||||||
except keystoneauth1.exceptions.auth_plugins.NoMatchingPlugin as e:
|
|
||||||
raise OpenStackCloudException(
|
|
||||||
"Invalid cloud configuration: {exc}".format(exc=str(e)))
|
|
||||||
return connection.Connection(config=cloud_region, strict=strict)
|
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
__all__ = ['OpenStackInventory']
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
|
|
||||||
from openstack.config import loader
|
from openstack.config import loader
|
||||||
|
@ -263,12 +263,12 @@ class OpenStackCloud(_normalize.Normalizer):
|
|||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
cloud = openstack.cloud.openstack_cloud(cloud='example')
|
conn = openstack.connect(cloud='example')
|
||||||
# Work normally
|
# Work normally
|
||||||
servers = cloud.list_servers()
|
servers = conn.list_servers()
|
||||||
cloud2 = cloud.connect_as(username='different-user', password='')
|
conn2 = conn.connect_as(username='different-user', password='')
|
||||||
# Work as different-user
|
# Work as different-user
|
||||||
servers = cloud2.list_servers()
|
servers = conn2.list_servers()
|
||||||
|
|
||||||
:param kwargs: keyword arguments can contain anything that would
|
:param kwargs: keyword arguments can contain anything that would
|
||||||
normally go in an auth dict. They will override the same
|
normally go in an auth dict. They will override the same
|
||||||
@ -342,7 +342,7 @@ class OpenStackCloud(_normalize.Normalizer):
|
|||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
cloud = openstack.cloud.openstack_cloud(cloud='example')
|
cloud = openstack.connect(cloud='example')
|
||||||
# Work normally
|
# Work normally
|
||||||
servers = cloud.list_servers()
|
servers = cloud.list_servers()
|
||||||
cloud2 = cloud.connect_as_project('different-project')
|
cloud2 = cloud.connect_as_project('different-project')
|
||||||
|
@ -18,8 +18,8 @@ import testtools
|
|||||||
|
|
||||||
import openstack
|
import openstack
|
||||||
import openstack.cloud
|
import openstack.cloud
|
||||||
from openstack.cloud import exc
|
|
||||||
from openstack.cloud import meta
|
from openstack.cloud import meta
|
||||||
|
from openstack.config import exceptions as occ_exc
|
||||||
from openstack.tests import fakes
|
from openstack.tests import fakes
|
||||||
from openstack.tests.unit import base
|
from openstack.tests.unit import base
|
||||||
|
|
||||||
@ -551,6 +551,6 @@ class TestBogusAuth(base.TestCase):
|
|||||||
cloud_config_fixture='clouds_cache.yaml')
|
cloud_config_fixture='clouds_cache.yaml')
|
||||||
|
|
||||||
def test_get_auth_bogus(self):
|
def test_get_auth_bogus(self):
|
||||||
with testtools.ExpectedException(exc.OpenStackCloudException):
|
with testtools.ExpectedException(occ_exc.OpenStackConfigException):
|
||||||
openstack.cloud.openstack_cloud(
|
openstack.connect(
|
||||||
cloud='_bogus_test_', config=self.config)
|
cloud='_bogus_test_', config=self.config)
|
||||||
|
@ -50,7 +50,7 @@ class TestOpenStackCloudOperatorNoAuth(base.RequestsMockTestCase):
|
|||||||
# with 'v1'. As such, since we are overriding the endpoint,
|
# with 'v1'. As such, since we are overriding the endpoint,
|
||||||
# we must explicitly do the same as we move away from the
|
# we must explicitly do the same as we move away from the
|
||||||
# client library.
|
# client library.
|
||||||
self.cloud_noauth = openstack.cloud.openstack_cloud(
|
self.cloud_noauth = openstack.connect(
|
||||||
auth_type='none',
|
auth_type='none',
|
||||||
baremetal_endpoint_override="https://bare-metal.example.com/v1")
|
baremetal_endpoint_override="https://bare-metal.example.com/v1")
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ class TestOpenStackCloudOperatorNoAuth(base.RequestsMockTestCase):
|
|||||||
|
|
||||||
The old way of doing this was to abuse admin_token.
|
The old way of doing this was to abuse admin_token.
|
||||||
"""
|
"""
|
||||||
self.cloud_noauth = openstack.cloud.openstack_cloud(
|
self.cloud_noauth = openstack.connect(
|
||||||
auth_type='admin_token',
|
auth_type='admin_token',
|
||||||
auth=dict(
|
auth=dict(
|
||||||
endpoint='https://bare-metal.example.com/v1',
|
endpoint='https://bare-metal.example.com/v1',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user