File: multi-cloud-demo.rst

package info (click to toggle)
python-openstacksdk 4.4.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 13,352 kB
  • sloc: python: 122,960; sh: 153; makefile: 23
file content (813 lines) | stat: -rw-r--r-- 21,458 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
Multi-Cloud Demo
================

This document contains a presentation in `presentty`_ format. If you want to
walk through it like a presentation, install `presentty` and run:

.. code:: bash

    presentty doc/source/user/multi-cloud-demo.rst

The content is hopefully helpful even if it's not being narrated, so it's being
included in the openstacksdk docs.

.. _presentty: https://pypi.org/project/presentty

Who am I?
---------

Monty Taylor

* OpenStack Infra Core
* irc: mordred
* twitter: @e_monty

What are we going to talk about?
--------------------------------

`OpenStackSDK`

* a task and end-user oriented Python library
* abstracts deployment differences
* designed for multi-cloud
* simple to use
* massive scale

  * optional advanced features to handle 20k servers a day

* Initial logic/design extracted from nodepool
* Librified to re-use in Ansible

OpenStackSDK is Free Software
-----------------------------

* https://opendev.org/openstack/openstacksdk
* openstack-discuss@lists.openstack.org
* #openstack-sdks on oftc

This talk is Free Software, too
-------------------------------

* Written for presentty (https://pypi.org/project/presentty)
* doc/source/user/multi-cloud-demo.rst
* examples in examples/cloud
* Paths subject to change - this is the first presentation in tree!

Complete Example
----------------

.. code:: python

  from openstack import cloud as openstack

  # Initialize and turn on debug logging
  openstack.enable_logging(debug=True)

  for cloud_name, region_name in [
      ('my-vexxhost', 'ca-ymq-1'),
      ('my-citycloud', 'Buf1'),
      ('my-internap', 'ams01'),
  ]:
      # Initialize cloud
      cloud = openstack.connect(cloud=cloud_name, region_name=region_name)

      # Upload an image to the cloud
      image = cloud.create_image(
          'devuan-jessie',
          filename='devuan-jessie.qcow2',
          wait=True,
      )

      # Find a flavor with at least 512M of RAM
      flavor = cloud.get_flavor_by_ram(512)

      # Boot a server, wait for it to boot, and then do whatever is needed
      # to get a public ip for it.
      cloud.create_server(
          'my-server',
          image=image,
          flavor=flavor,
          wait=True,
          auto_ip=True,
      )

Let's Take a Few Steps Back
---------------------------

Multi-cloud is easy, but you need to know a few things.

* Terminology
* Config
* OpenStackSDK API

Cloud Terminology
-----------------

Let's define a few terms, so that we can use them with ease:

* `cloud` - logically related collection of services
* `region` - completely independent subset of a given cloud
* `patron` - human who has an account
* `user` - account on a cloud
* `project` - logical collection of cloud resources
* `domain` - collection of users and projects

Cloud Terminology Relationships
-------------------------------

* A `cloud` has one or more `regions`
* A `patron` has one or more `users`
* A `patron` has one or more `projects`
* A `cloud` has one or more `domains`
* In a `cloud` with one `domain` it is named "default"
* Each `patron` may have their own `domain`
* Each `user` is in one `domain`
* Each `project` is in one `domain`
* A `user` has one or more `roles` on one or more `projects`

HTTP Sessions
-------------

* HTTP interactions are authenticated via keystone
* Authenticating returns a `token`
* An authenticated HTTP Session is shared across a `region`

Cloud Regions
-------------

A `cloud region` is the basic unit of REST interaction.

* A `cloud` has a `service catalog`
* The `service catalog` is returned in the `token`
* The `service catalog` lists `endpoint` for each `service` in each `region`
* A `region` is completely autonomous

Users, Projects and Domains
---------------------------

In clouds with multiple domains, project and user names are
only unique within a region.

* Names require `domain` information for uniqueness. IDs do not.
* Providing `domain` information when not needed is fine.
* `project_name` requires `project_domain_name` or `project_domain_id`
* `project_id` does not
* `username` requires `user_domain_name` or `user_domain_id`
* `user_id` does not

Confused Yet?
-------------

Don't worry - you don't have to deal with most of that.

Auth per cloud, select per region
---------------------------------

In general, the thing you need to know is:

* Configure authentication per `cloud`
* Select config to use by `cloud` and `region`

clouds.yaml
-----------

Information about the clouds you want to connect to is stored in a file
called `clouds.yaml`.

`clouds.yaml` can be in your homedir: `~/.config/openstack/clouds.yaml`
or system-wide: `/etc/openstack/clouds.yaml`.

Information in your homedir, if it exists, takes precedence.

Full docs on `clouds.yaml` are at
https://docs.openstack.org/os-client-config/latest/

What about Mac and Windows?
---------------------------

`USER_CONFIG_DIR` is different on Linux, OSX and Windows.

* Linux: `~/.config/openstack`
* OSX: `~/Library/Application Support/openstack`
* Windows: `C:\\Users\\USERNAME\\AppData\\Local\\OpenStack\\openstack`

`SITE_CONFIG_DIR` is different on Linux, OSX and Windows.

* Linux: `/etc/openstack`
* OSX: `/Library/Application Support/openstack`
* Windows: `C:\\ProgramData\\OpenStack\\openstack`

Config Terminology
------------------

For multi-cloud, think of two types:

* `profile` - Facts about the `cloud` that are true for everyone
* `cloud` - Information specific to a given `user`

Apologies for the use of `cloud` twice.

Environment Variables and Simple Usage
--------------------------------------

* Environment variables starting with `OS_` go into a cloud called `envvars`
* If you only have one cloud, you don't have to specify it
* `OS_CLOUD` and `OS_REGION_NAME` are default values for
  `cloud` and `region_name`

TOO MUCH TALKING - NOT ENOUGH CODE
----------------------------------

basic clouds.yaml for the example code
--------------------------------------

Simple example of a clouds.yaml

* Config for a named `cloud` "my-citycloud"
* Reference a well-known "named" profile: `citycloud`
* `os-client-config` has a built-in list of profiles at
  https://docs.openstack.org/openstacksdk/latest/user/config/vendor-support.html
* Vendor profiles contain various advanced config
* `cloud` name can match `profile` name (using different names for clarity)

.. code:: yaml

  clouds:
    my-citycloud:
      profile: citycloud
      auth:
        username: mordred
        project_id: 65222a4d09ea4c68934fa1028c77f394
        user_domain_id: d0919bd5e8d74e49adf0e145807ffc38
        project_domain_id: d0919bd5e8d74e49adf0e145807ffc38

Where's the password?

secure.yaml
-----------

* Optional additional file just like `clouds.yaml`
* Values overlaid on `clouds.yaml`
* Useful if you want to protect secrets more stringently

Example secure.yaml
-------------------

* No, my password isn't XXXXXXXX
* `cloud` name should match `clouds.yaml`
* Optional - I actually keep mine in my `clouds.yaml`

.. code:: yaml

  clouds:
    my-citycloud:
      auth:
        password: XXXXXXXX

more clouds.yaml
----------------

More information can be provided.

* Use v3 of the `identity` API - even if others are present
* Use `https://image-ca-ymq-1.vexxhost.net/v2` for `image` API
  instead of what's in the catalog

.. code:: yaml

    my-vexxhost:
      identity_api_version: 3
      image_endpoint_override: https://image-ca-ymq-1.vexxhost.net/v2
      profile: vexxhost
      auth:
        user_domain_id: default
        project_domain_id: default
        project_name: d8af8a8f-a573-48e6-898a-af333b970a2d
        username: 0b8c435b-cc4d-4e05-8a47-a2ada0539af1

Much more complex clouds.yaml example
-------------------------------------

* Not using a profile - all settings included
* In the `ams01` `region` there are two networks with undiscoverable qualities
* Each one are labeled here so choices can be made
* Any of the settings can be specific to a `region` if needed
* `region` settings override `cloud` settings
* `cloud` does not support `floating-ips`

.. code:: yaml

    my-internap:
      auth:
        auth_url: https://identity.api.cloud.inap.com
        username: api-55f9a00fb2619
        project_name: inap-17037
      identity_api_version: 3
      floating_ip_source: None
      regions:
      - name: ams01
        values:
          networks:
          - name: inap-17037-WAN1654
            routes_externally: true
            default_interface: true
          - name: inap-17037-LAN3631
            routes_externally: false

Complete Example Again
----------------------

.. code:: python

  from openstack import cloud as openstack

  # Initialize and turn on debug logging
  openstack.enable_logging(debug=True)

  for cloud_name, region_name in [
          ('my-vexxhost', 'ca-ymq-1'),
          ('my-citycloud', 'Buf1'),
          ('my-internap', 'ams01')]:
      # Initialize cloud
      cloud = openstack.connect(cloud=cloud_name, region_name=region_name)

      # Upload an image to the cloud
      image = cloud.create_image(
          'devuan-jessie', filename='devuan-jessie.qcow2', wait=True)

      # Find a flavor with at least 512M of RAM
      flavor = cloud.get_flavor_by_ram(512)

      # Boot a server, wait for it to boot, and then do whatever is needed
      # to get a public ip for it.
      cloud.create_server(
          'my-server', image=image, flavor=flavor, wait=True, auto_ip=True)

Step By Step
------------

Import the library
------------------

.. code:: python

  from openstack import cloud as openstack

Logging
-------

* `openstacksdk` uses standard python logging
* ``openstack.enable_logging`` does easy defaults
* Squelches some meaningless warnings

  * `debug`

     * Logs openstacksdk loggers at debug level

  * `http_debug` Implies `debug`, turns on HTTP tracing

.. code:: python

  # Initialize and turn on debug logging
  openstack.enable_logging(debug=True)

Example with Debug Logging
--------------------------

* examples/cloud/debug-logging.py

.. code:: python

  from openstack import cloud as openstack
  openstack.enable_logging(debug=True)

  cloud = openstack.connect(cloud='my-vexxhost', region_name='ca-ymq-1')
  cloud.get_image('Ubuntu 16.04.1 LTS [2017-03-03]')

Example with HTTP Debug Logging
-------------------------------

* examples/cloud/http-debug-logging.py

.. code:: python

  from openstack import cloud as openstack
  openstack.enable_logging(http_debug=True)

  cloud = openstack.connect(
      cloud='my-vexxhost', region_name='ca-ymq-1')
  cloud.get_image('Ubuntu 16.04.1 LTS [2017-03-03]')

Cloud Regions
-------------

* `cloud` constructor needs `cloud` and `region_name`
* `openstack.connect` is a helper factory function

.. code:: python

  for cloud_name, region_name in [
      ('my-vexxhost', 'ca-ymq-1'),
      ('my-citycloud', 'Buf1'),
      ('my-internap', 'ams01')
  ]:
      # Initialize cloud
      cloud = openstack.connect(cloud=cloud_name, region_name=region_name)

Upload an Image
---------------

* Picks the correct upload mechanism
* **SUGGESTION** Always upload your own base images

.. code:: python

      # Upload an image to the cloud
      image = cloud.create_image(
          'devuan-jessie',
          filename='devuan-jessie.qcow2',
          wait=True,
      )

Always Upload an Image
----------------------

Ok. You don't have to. But, for multi-cloud...

* Images with same content are named different on different clouds
* Images with same name on different clouds can have different content
* Upload your own to all clouds, both problems go away
* Download from OS vendor or build with `diskimage-builder`

Find a flavor
-------------

* Flavors are all named differently on clouds
* Flavors can be found via RAM
* `get_flavor_by_ram` finds the smallest matching flavor

.. code:: python

      # Find a flavor with at least 512M of RAM
      flavor = cloud.get_flavor_by_ram(512)

Create a server
---------------

* my-vexxhost

  * Boot server
  * Wait for `status==ACTIVE`

* my-internap

  * Boot server on network `inap-17037-WAN1654`
  * Wait for `status==ACTIVE`

* my-citycloud

  * Boot server
  * Wait for `status==ACTIVE`
  * Find the `port` for the `fixed_ip` for `server`
  * Create `floating-ip` on that `port`
  * Wait for `floating-ip` to attach

.. code:: python

      # Boot a server, wait for it to boot, and then do whatever is needed
      # to get a public ip for it.
      cloud.create_server(
          'my-server', image=image, flavor=flavor, wait=True, auto_ip=True)

Wow. We didn't even deploy Wordpress!
-------------------------------------

Image and Flavor by Name or ID
------------------------------

* Pass string to image/flavor
* Image/Flavor will be found by name or ID
* Common pattern
* examples/cloud/create-server-name-or-id.py

.. code:: python

  from openstack import cloud as openstack

  # Initialize and turn on debug logging
  openstack.enable_logging(debug=True)

  for cloud_name, region_name, image, flavor in [
          ('my-vexxhost', 'ca-ymq-1',
           'Ubuntu 16.04.1 LTS [2017-03-03]', 'v1-standard-4'),
          ('my-citycloud', 'Buf1',
           'Ubuntu 16.04 Xenial Xerus', '4C-4GB-100GB'),
          ('my-internap', 'ams01',
           'Ubuntu 16.04 LTS (Xenial Xerus)', 'A1.4')]:
      # Initialize cloud
      cloud = openstack.connect(cloud=cloud_name, region_name=region_name)

      # Boot a server, wait for it to boot, and then do whatever is needed
      # to get a public ip for it.
      server = cloud.create_server(
          'my-server', image=image, flavor=flavor, wait=True, auto_ip=True)
      print(server.name)
      print(server['name'])
      cloud.pprint(server)
      # Delete it - this is a demo
      cloud.delete_server(server, wait=True, delete_ips=True)

Delete Servers
--------------

* `delete_ips` Delete any `floating_ips` the server may have

.. code:: python

      cloud.delete_server('my-server', wait=True, delete_ips=True)

Image and Flavor by Dict
------------------------

* Pass dict to image/flavor
* If you know if the value is Name or ID
* Common pattern
* examples/cloud/create-server-dict.py

.. code:: python

  from openstack import cloud as openstack

  # Initialize and turn on debug logging
  openstack.enable_logging(debug=True)

  for cloud_name, region_name, image, flavor_id in [
          ('my-vexxhost', 'ca-ymq-1', 'Ubuntu 16.04.1 LTS [2017-03-03]',
           '5cf64088-893b-46b5-9bb1-ee020277635d'),
          ('my-citycloud', 'Buf1', 'Ubuntu 16.04 Xenial Xerus',
           '0dab10b5-42a2-438e-be7b-505741a7ffcc'),
          ('my-internap', 'ams01', 'Ubuntu 16.04 LTS (Xenial Xerus)',
           'A1.4')]:
      # Initialize cloud
      cloud = openstack.connect(cloud=cloud_name, region_name=region_name)

      # Boot a server, wait for it to boot, and then do whatever is needed
      # to get a public ip for it.
      server = cloud.create_server(
          'my-server', image=image, flavor=dict(id=flavor_id),
          wait=True, auto_ip=True)
      # Delete it - this is a demo
      cloud.delete_server(server, wait=True, delete_ips=True)

Munch Objects
-------------

* Behave like a dict and an object
* examples/cloud/munch-dict-object.py

.. code:: python

  from openstack import cloud as openstack
  openstack.enable_logging(debug=True)

  cloud = openstack.connect(cloud='zetta', region_name='no-osl1')
  image = cloud.get_image('Ubuntu 14.04 (AMD64) [Local Storage]')
  print(image.name)
  print(image['name'])

API Organized by Logical Resource
---------------------------------

* list_servers
* search_servers
* get_server
* create_server
* delete_server
* update_server

For other things, it's still {verb}_{noun}

* attach_volume
* wait_for_server
* add_auto_ip

Cleanup Script
--------------

* Sometimes my examples had bugs
* examples/cloud/cleanup-servers.py

.. code:: python

  from openstack import cloud as openstack

  # Initialize and turn on debug logging
  openstack.enable_logging(debug=True)

  for cloud_name, region_name in [
          ('my-vexxhost', 'ca-ymq-1'),
          ('my-citycloud', 'Buf1'),
          ('my-internap', 'ams01')]:
      # Initialize cloud
      cloud = openstack.connect(cloud=cloud_name, region_name=region_name)
      for server in cloud.search_servers('my-server'):
          cloud.delete_server(server, wait=True, delete_ips=True)

Normalization
-------------

* examples/cloud/normalization.py

.. code:: python

  from openstack import cloud as openstack
  openstack.enable_logging()

  cloud = openstack.connect(cloud='fuga', region_name='cystack')
  image = cloud.get_image(
      'Ubuntu 16.04 LTS - Xenial Xerus - 64-bit - Fuga Cloud Based Image')
  cloud.pprint(image)

Strict Normalized Results
-------------------------

* Return only the declared model
* examples/cloud/strict-mode.py

.. code:: python

  from openstack import cloud as openstack
  openstack.enable_logging()

  cloud = openstack.connect(
      cloud='fuga', region_name='cystack', strict=True)
  image = cloud.get_image(
      'Ubuntu 16.04 LTS - Xenial Xerus - 64-bit - Fuga Cloud Based Image')
  cloud.pprint(image)

How Did I Find the Image Name for the Last Example?
---------------------------------------------------

* I often make stupid little utility scripts
* examples/cloud/find-an-image.py

.. code:: python

  from openstack import cloud as openstack
  openstack.enable_logging()

  cloud = openstack.connect(cloud='fuga', region_name='cystack')
  cloud.pprint([
      image for image in cloud.list_images()
      if 'ubuntu' in image.name.lower()])

Added / Modified Information
----------------------------

* Servers need more extra help
* Fetch addresses dict from neutron
* Figure out which IPs are good
* `detailed` - defaults to True, add everything
* `bare` - no extra calls - don't even fix broken things
* `bare` is still normalized
* examples/cloud/server-information.py

.. code:: python

  from openstack import cloud as openstack
  openstack.enable_logging(debug=True)

  cloud = openstack.connect(cloud='my-citycloud', region_name='Buf1')
  try:
      server = cloud.create_server(
          'my-server', image='Ubuntu 16.04 Xenial Xerus',
          flavor=dict(id='0dab10b5-42a2-438e-be7b-505741a7ffcc'),
          wait=True, auto_ip=True)

      print("\n\nFull Server\n\n")
      cloud.pprint(server)

      print("\n\nTurn Detailed Off\n\n")
      cloud.pprint(cloud.get_server('my-server', detailed=False))

      print("\n\nBare Server\n\n")
      cloud.pprint(cloud.get_server('my-server', bare=True))

  finally:
      # Delete it - this is a demo
      cloud.delete_server(server, wait=True, delete_ips=True)

Exceptions
----------

* All openstacksdk exceptions are subclasses of `OpenStackCloudException`
* Direct REST calls throw `OpenStackCloudHTTPError`
* `OpenStackCloudHTTPError` subclasses `OpenStackCloudException`
  and `requests.exceptions.HTTPError`
* `OpenStackCloudURINotFound` for 404
* `OpenStackCloudBadRequest` for 400

User Agent Info
---------------

* Set `app_name` and `app_version` for User Agents
* (ssh ... `region_name` is optional if the cloud has one region)
* examples/cloud/user-agent.py

.. code:: python

  from openstack import cloud as openstack
  openstack.enable_logging(http_debug=True)

  cloud = openstack.connect(
      cloud='datacentred',
      app_name='AmazingApp',
      app_version='1.0',
  )
  cloud.list_networks()

Uploading Large Objects
-----------------------

* swift has a maximum object size
* Large Objects are uploaded specially
* openstacksdk figures this out and does it
* multi-threaded
* examples/cloud/upload-object.py

.. code:: python

  from openstack import cloud as openstack
  openstack.enable_logging(debug=True)

  cloud = openstack.connect(cloud='ovh', region_name='SBG1')
  cloud.create_object(
      container='my-container',
      name='my-object',
      filename='/home/mordred/briarcliff.sh3d',
  )
  cloud.delete_object('my-container', 'my-object')
  cloud.delete_container('my-container')

Uploading Large Objects
-----------------------

* Default max_file_size is 5G
* This is a conference demo
* Let's force a segment_size
* One MILLION bytes
* examples/cloud/upload-object.py

.. code:: python

  from openstack import cloud as openstack
  openstack.enable_logging(debug=True)

  cloud = openstack.connect(cloud='ovh', region_name='SBG1')
  cloud.create_object(
      container='my-container',
      name='my-object',
      filename='/home/mordred/briarcliff.sh3d',
      segment_size=1000000,
  )
  cloud.delete_object('my-container', 'my-object')
  cloud.delete_container('my-container')

Service Conditionals
--------------------

.. code:: python

  from openstack import cloud as openstack
  openstack.enable_logging(debug=True)

  cloud = openstack.connect(cloud='kiss', region_name='region1')
  print(cloud.has_service('network'))
  print(cloud.has_service('container-orchestration'))

Service Conditional Overrides
-----------------------------

* Sometimes clouds are weird and figuring that out won't work

.. code:: python

  from openstack import cloud as openstack
  openstack.enable_logging(debug=True)

  cloud = openstack.connect(cloud='rax', region_name='DFW')
  print(cloud.has_service('network'))

.. code:: yaml

  clouds:
    rax:
      profile: rackspace
      auth:
        username: mordred
        project_id: 245018
      # This is already in profile: rackspace
      has_network: false

FIN
---