Minor fixes to examples
* Fix typo in authenticate * Add comments to head command * Fix name of head method * Use find_resource_cls for lists Change-Id: If4bb485088460151916e1d2b9b5fe80ad150dcff
This commit is contained in:
parent
c873ef693b
commit
966beafd97
@ -14,7 +14,7 @@
|
||||
Authentication example
|
||||
|
||||
To authenticate you must have the environment variables set or use the
|
||||
command line options. This is a good example to start wtih because once
|
||||
command line options. This is a good example to start with because once
|
||||
you know you can authenticate, you can perform other operations that
|
||||
require authentication. Refer to the example common.py for the environment
|
||||
variables or command line options to use.
|
||||
|
@ -10,13 +10,21 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""
|
||||
Example Head Command
|
||||
|
||||
For example:
|
||||
python -m examples.head openstack/image/v1/image.py \
|
||||
--data 9d7d22d0-7d43-481f-a7eb-d93ea2791409
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
||||
from examples import common
|
||||
from examples import session
|
||||
|
||||
|
||||
def run_get(opts):
|
||||
def run_head(opts):
|
||||
sess = session.make_session(opts)
|
||||
cls = common.find_resource_cls(opts)
|
||||
data = common.get_data_option(opts)
|
||||
@ -28,4 +36,4 @@ def run_get(opts):
|
||||
|
||||
if __name__ == "__main__":
|
||||
opts = common.setup()
|
||||
sys.exit(common.main(opts, run_get))
|
||||
sys.exit(common.main(opts, run_head))
|
||||
|
@ -16,19 +16,9 @@ from examples import common
|
||||
from examples import session
|
||||
|
||||
|
||||
def make_resource(opts):
|
||||
argument = opts.argument
|
||||
args = argument.rpartition('.')
|
||||
from_str = args[0]
|
||||
class_str = args[2]
|
||||
__import__(from_str)
|
||||
mod = sys.modules[from_str]
|
||||
return getattr(mod, class_str)
|
||||
|
||||
|
||||
def run_list(opts):
|
||||
sess = session.make_session(opts)
|
||||
cls = make_resource(opts)
|
||||
cls = common.find_resource_cls(opts)
|
||||
for obj in cls.list(sess):
|
||||
print(str(obj))
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user