Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
EasyCloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DSDF
EasyCloud
Commits
f4b9b05d
Commit
f4b9b05d
authored
4 years ago
by
sguazt
Browse files
Options
Downloads
Patches
Plain Diff
Added missing file
parent
78fad39b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/openstack_openstacksdk/res_viewer.py
+55
-0
55 additions, 0 deletions
modules/openstack_openstacksdk/res_viewer.py
with
55 additions
and
0 deletions
modules/openstack_openstacksdk/res_viewer.py
0 → 100644
+
55
−
0
View file @
f4b9b05d
"""
EasyCloud OpenStack Resources ID Viewer
"""
from
gnocchiclient.v1
import
client
from
keystoneauth1
import
loading
__author__
=
"
Davide Monfrecola, Stefano Garione, Giorgio Gambino, Luca Banzato
"
__copyright__
=
"
Copyright (C) 2019
"
__credits__
=
[
"
Andrea Lombardo
"
,
"
Irene Lovotti
"
]
__license__
=
"
GPL v3
"
__version__
=
"
0.10.0
"
__maintainer__
=
"
Luca Banzato
"
__email__
=
"
20005492@studenti.uniupo.it
"
__status__
=
"
Prototype
"
############################
# To be filled by the user #
############################
AUTH_URL
=
""
USERNAME
=
""
PASSWORD
=
""
PROJECT_ID
=
""
REGION_NAME
=
""
############################
print
(
"
\n
OpenStack Resources ID Viewer
\n
"
)
# Authentication
_loader
=
loading
.
get_plugin_loader
(
'
password
'
)
_auth
=
_loader
.
load_from_options
(
auth_url
=
AUTH_URL
,
username
=
USERNAME
,
password
=
PASSWORD
,
project_id
=
PROJECT_ID
,
user_domain_name
=
"
default
"
)
gnocchi_client
=
client
.
Client
(
adapter_options
=
{
"
region_name
"
:
REGION_NAME
},
session_options
=
{
"
auth
"
:
_auth
})
# Instance ID request
instance_id
=
str
(
input
(
"
Insert the instance id:
"
))
try
:
# Get resources for a specified instance (can raise an exception)
resources
=
gnocchi_client
.
resource
.
get
(
"
generic
"
,
instance_id
)
# Print metrics if available
if
"
metrics
"
in
resources
:
metrics
=
resources
[
"
metrics
"
]
i
=
0
print
(
"
\n
Metrics available for instance
"
+
instance_id
+
"
:
\n
"
)
for
key
,
value
in
metrics
.
items
():
print
((
"
ID: %-25s - Name: %-25s
"
%
(
value
,
key
)))
print
(
""
)
else
:
print
(
"
No metrics available for instance
"
+
instance_id
)
except
Exception
as
e
:
print
(
"
An error has occourred while fetching metrics details:
"
+
str
(
e
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment