Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
infrastructure
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
argo
infrastructure
Commits
f39cc43d
Commit
f39cc43d
authored
May 29, 2018
by
Swann Perarnau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[feature] Add general helper script
Add a script to help with general configuration issues.
parent
2f654ad9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
98 additions
and
0 deletions
+98
-0
README.markdown
README.markdown
+16
-0
chi-mngmt.py
chi-mngmt.py
+82
-0
No files found.
README.markdown
View file @
f39cc43d
...
...
@@ -33,6 +33,22 @@ specified as the `--region` option for all operations in a specific site. If
you don't want to repeat this option everytime, set the
`OS_REGION_NAME`
environment variable.
# General Help
The
`chi-mngmt.py`
script contains a few commands to help you figure out if
your configuration is working properly, or access specific information about a
region.
> ./chi-mngmt.py list-clouds
> ./chi-mngmt.py list-keys
In general the scripts included in this repo are here to simplify access to the
openstack tools. But if you need to do something more complex, you can always
rely on the openstack GUI or CLI directly. The
`pipenv`
setup will give you
access to the
`openstack`
command in particular. You can have this tool use the
same
`clouds.yaml`
configuration by using the
`--os-cloud`
and
`--os-region`
options.
# Lease Management
Chameleon requires that a lease is created before we can boot nodes. You can
...
...
chi-mngmt.py
0 → 100755
View file @
f39cc43d
#!/usr/bin/env python
import
argparse
import
json
import
logging
import
os
import
os_client_config
from
blazarclient
import
client
as
blazar_client
import
shade
def
get_cloud_config
(
region
=
None
):
"""Retrieve the config in clouds.yaml."""
config
=
os_client_config
.
OpenStackConfig
()
return
config
.
get_one
(
'chameleon'
,
region_name
=
region
)
def
get_shade_client
(
region
=
None
):
cloud
=
get_cloud_config
(
region
)
return
shade
.
OpenStackCloud
(
cloud_config
=
cloud
)
def
get_blazar_client
(
region
=
None
):
"""Retrieve a client to blazar based on clouds.yaml config."""
cloud_config
=
get_cloud_config
(
region
)
session
=
cloud_config
.
get_session
()
# blazar acces
return
blazar_client
.
Client
(
1
,
session
=
session
,
service_type
=
'reservation'
)
def
do_listclouds
(
argv
):
"""List available clouds."""
config
=
os_client_config
.
OpenStackConfig
()
clouds
=
config
.
get_all
()
if
not
clouds
:
print
(
"No cloud in the clouds.yaml definition."
)
else
:
for
cloud
in
clouds
:
print
(
json
.
dumps
(
cloud
.
config
,
indent
=
4
))
def
do_listkeys
(
argv
):
"""List keys in a cloud."""
shade_client
=
get_shade_client
(
argv
.
region
)
ret
=
shade_client
.
list_keypairs
()
if
ret
:
for
k
in
ret
:
print
(
json
.
dumps
(
k
,
indent
=
4
))
else
:
print
(
"No keypair found."
)
def
main
():
parser
=
argparse
.
ArgumentParser
(
description
=
'Chameleon General Helper'
)
parser
.
add_argument
(
'--region'
,
default
=
os
.
environ
.
get
(
'OS_REGION_NAME'
),
help
=
'Region name (in clouds.yaml)'
)
parser
.
add_argument
(
'--debug'
,
help
=
"Print debugging output"
,
action
=
'store_true'
)
subparsers
=
parser
.
add_subparsers
(
title
=
'Commands'
,
dest
=
'command'
)
subparsers
.
required
=
True
# create a lease
parser_listclouds
=
subparsers
.
add_parser
(
"list-clouds"
,
help
=
"List available clouds"
)
parser_listclouds
.
set_defaults
(
func
=
do_listclouds
)
parser_listkeys
=
subparsers
.
add_parser
(
"list-keys"
,
help
=
"List available keypairs"
)
parser_listkeys
.
set_defaults
(
func
=
do_listkeys
)
args
=
parser
.
parse_args
()
if
args
.
debug
:
logger
=
logging
.
getLogger
(
'keystoneauth'
)
logger
.
addHandler
(
logging
.
StreamHandler
())
logger
.
setLevel
(
logging
.
DEBUG
)
args
.
func
(
args
)
if
__name__
==
'__main__'
:
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment