cloud:recipe:coding
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| cloud:recipe:coding [2020/05/14 14:06] – [Sample Configuration File] chudler | cloud:recipe:coding [2020/05/14 18:32] (current) – chudler | ||
|---|---|---|---|
| Line 48: | Line 48: | ||
| </ | </ | ||
| - | The main flaw here is that you are using your University credentials | + | The main flaw here is that you are taking risks by storing |
| + | |||
| + | < | ||
| + | openstack application credential create --secret sekret --role member --expiration 2020-10-10: | ||
| + | </ | ||
| =====Testing and Usage===== | =====Testing and Usage===== | ||
| Ensure you can load the python module | Ensure you can load the python module | ||
| Line 67: | Line 71: | ||
| ======Demo Code====== | ======Demo Code====== | ||
| - | The following code shows how to create and destroy a server, and obtain information about Networks, Images, and Flavors. Consult the [[ https:// | + | The following |
| - | < | + | For your learning, contrast this with the equivalent actions that are taken in the [[ cloud:cli | Command Line Usage Guide ]]. |
| + | |||
| + | < | ||
| import openstack | import openstack | ||
| from openstack.config import loader | from openstack.config import loader | ||
| + | # to enable debug logging | ||
| # openstack.enable_logging(True) | # openstack.enable_logging(True) | ||
| config = loader.OpenStackConfig() | config = loader.OpenStackConfig() | ||
| Line 79: | Line 86: | ||
| # print(flavor.name) | # print(flavor.name) | ||
| image = cloud.get_image(' | image = cloud.get_image(' | ||
| + | # pretty print | ||
| # cloud.pprint(image) | # cloud.pprint(image) | ||
| - | # network = cloud.network.find_network(' | ||
| network = cloud.get_network(' | network = cloud.get_network(' | ||
| - | # cloud.pprint(network) | ||
| try: | try: | ||
| server = cloud.create_server(' | server = cloud.create_server(' | ||
| - | # cloud.pprint(server) | ||
| - | # cloud.pprint(cloud.get_server(' | ||
| - | cloud.pprint(cloud.get_server(' | ||
| finally: | finally: | ||
| cloud.delete_server(' | cloud.delete_server(' | ||
| </ | </ | ||
/var/lib/dokuwiki/data/attic/cloud/recipe/coding.1589483201.txt.gz · Last modified: 2020/05/14 14:06 by chudler