Welcome to shade’s documentation!¶
Contents:
Introduction¶
Warning
shade has been superceded byopenstacksdk and no longer takes newfeatures. The existing code will continue to be maintained indefinitelyfor bugfixes as necessary, but improvements will be deferred toopenstacksdk. Please update your applications to useopenstacksdkdirectly.
shade is a simple client library for interacting with OpenStack clouds. Thekey word here issimple. Clouds can do many many many things - but there areprobably only about 10 of them that most people care about with anyregularity. If you want to do complicated things, you should probably usethe lower level client libraries - or even the REST API directly. However,if what you want is to be able to write an application that talks to cloudsno matter what crazy choices the deployer has made in an attempt to bemore hipster than their self-entitled narcissist peers, then shade is for you.
shade started its life as some code inside of ansible. ansible has a bunchof different OpenStack related modules, and there was a ton of duplicatedcode. Eventually, between refactoring that duplication into an internallibrary, and adding logic and features that the OpenStack Infra team haddeveloped to run client applications at scale, it turned out that we’d writtennine-tenths of what we’d need to have a standalone library.
Example¶
Sometimes an example is nice.
Create a
clouds.ymlfile:clouds:mordred:region_name:RegionOneauth:username:'mordred'password:XXXXXXXproject_name:'shade'auth_url:'https://montytaylor-sjc.openstack.blueboxgrid.com:5001/v2.0'
Please note:os-client-config will look for a file called
clouds.yamlin the following locations:Current Directory
~/.config/openstack/etc/openstack
More information athttps://pypi.org/project/os-client-config
Create a server withshade, configured with the
clouds.ymlfile:importshade# Initialize and turn on debug loggingshade.simple_logging(debug=True)# Initialize cloud# Cloud configs are read with os-client-configcloud=shade.openstack_cloud(cloud='mordred')# Upload an image to the cloudimage=cloud.create_image('ubuntu-trusty',filename='ubuntu-trusty.qcow2',wait=True)# Find a flavor with at least 512M of RAMflavor=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)
