Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nmvetcli-mirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
JetBrains YouTrack
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
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
KSZK
Sysadmin
nmvetcli-mirror
Commits
64946077
Commit
64946077
authored
8 years ago
by
Christoph Hellwig
Browse files
Options
Downloads
Patches
Plain Diff
pep8
Signed-off-by:
Christoph Hellwig
<
hch@lst.de
>
parent
1ad60d72
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
nvmet/nvme.py
+18
-18
18 additions, 18 deletions
nvmet/nvme.py
nvmetcli
+9
-7
9 additions, 7 deletions
nvmetcli
with
27 additions
and
25 deletions
nvmet/nvme.py
+
18
−
18
View file @
64946077
...
...
@@ -73,26 +73,26 @@ class CFSNode(object):
if
mode
not
in
[
'
any
'
,
'
lookup
'
,
'
create
'
]:
raise
CFSError
(
"
Invalid mode: %s
"
%
mode
)
if
self
.
exists
and
mode
==
'
create
'
:
raise
CFSError
(
"
This %s already exists in configFS
"
%
self
.
__class__
.
__name__
)
raise
CFSError
(
"
This %s already exists in configFS
"
%
self
.
__class__
.
__name__
)
elif
not
self
.
exists
and
mode
==
'
lookup
'
:
raise
CFSNotFound
(
"
No such %s in configfs: %s
"
%
(
self
.
__class__
.
__name__
,
self
.
path
))
raise
CFSNotFound
(
"
No such %s in configfs: %s
"
%
(
self
.
__class__
.
__name__
,
self
.
path
))
if
not
self
.
exists
:
try
:
os
.
mkdir
(
self
.
path
)
except
:
raise
CFSError
(
"
Could not create %s in configFS
"
%
self
.
__class__
.
__name__
)
raise
CFSError
(
"
Could not create %s in configFS
"
%
self
.
__class__
.
__name__
)
def
_exists
(
self
):
return
os
.
path
.
isdir
(
self
.
path
)
def
_check_self
(
self
):
if
not
self
.
exists
:
raise
CFSNotFound
(
"
This %s does not exist in configFS
"
%
self
.
__class__
.
__name__
)
raise
CFSNotFound
(
"
This %s does not exist in configFS
"
%
self
.
__class__
.
__name__
)
def
list_attrs
(
self
,
group
,
writable
=
None
):
'''
...
...
@@ -184,7 +184,8 @@ class CFSNode(object):
with
open
(
path
,
'
w
'
)
as
file_fd
:
file_fd
.
write
(
str
(
value
))
except
Exception
as
e
:
raise
CFSError
(
"
Cannot enable attribute %s: %s (%s)
"
%
(
self
.
path
,
e
,
value
))
raise
CFSError
(
"
Cannot enable attribute %s: %s (%s)
"
%
(
self
.
path
,
e
,
value
))
self
.
_enable
=
value
def
delete
(
self
):
...
...
@@ -197,7 +198,7 @@ class CFSNode(object):
os
.
rmdir
(
self
.
path
)
path
=
property
(
_get_path
,
doc
=
"
Get the configFS object path.
"
)
doc
=
"
Get the configFS object path.
"
)
exists
=
property
(
_exists
,
doc
=
"
Is True as long as the underlying configFS object exists.
"
+
"
If the underlying configFS objects gets deleted
"
...
...
@@ -236,7 +237,7 @@ class Root(CFSNode):
if
not
os
.
path
.
isdir
(
self
.
configfs_dir
):
raise
CFSError
(
"
%s does not exist. Giving up.
"
%
self
.
configfs_dir
)
self
.
configfs_dir
)
self
.
_path
=
self
.
configfs_dir
self
.
_create_in_cfs
(
'
lookup
'
)
...
...
@@ -259,7 +260,7 @@ class Root(CFSNode):
yield
Subsystem
(
d
,
'
lookup
'
)
subsystems
=
property
(
_list_subsystems
,
doc
=
"
Get the list of Subsystems.
"
)
doc
=
"
Get the list of Subsystems.
"
)
def
save_to_file
(
self
,
savefile
=
None
):
'''
...
...
@@ -320,7 +321,7 @@ class Root(CFSNode):
return
errors
def
restore_from_file
(
self
,
savefile
=
None
,
clear_existing
=
True
,
abort_on_error
=
False
):
abort_on_error
=
False
):
'''
Restore the configuration from a file in json format.
Returns a list of non-fatal errors. If abort_on_error is set,
...
...
@@ -397,7 +398,7 @@ class Subsystem(CFSNode):
super
(
Subsystem
,
self
).
delete
()
namespaces
=
property
(
_list_namespaces
,
doc
=
"
Get the list of Namespaces for the Subsystem.
"
)
doc
=
"
Get the list of Namespaces for the Subsystem.
"
)
@classmethod
def
setup
(
cls
,
t
,
err_func
):
...
...
@@ -478,7 +479,7 @@ class Namespace(CFSNode):
self
.
_nsid
=
nsid
self
.
_path
=
"
%s/namespaces/%d
"
%
(
self
.
subsystem
.
path
,
self
.
nsid
)
self
.
_create_in_cfs
(
mode
)
self
.
get_enable
()
# XXX should move to baseclass
self
.
get_enable
()
# XXX should move to baseclass
def
_get_subsystem
(
self
):
return
self
.
_subsystem
...
...
@@ -487,9 +488,8 @@ class Namespace(CFSNode):
return
self
.
_nsid
subsystem
=
property
(
_get_subsystem
,
doc
=
"
Get the parent Subsystem object.
"
)
nsid
=
property
(
_get_nsid
,
doc
=
"
Get the NSID as an int.
"
)
doc
=
"
Get the parent Subsystem object.
"
)
nsid
=
property
(
_get_nsid
,
doc
=
"
Get the NSID as an int.
"
)
@classmethod
def
setup
(
cls
,
subsys
,
n
,
err_func
):
...
...
This diff is collapsed.
Click to expand it.
nvmetcli
+
9
−
7
View file @
64946077
...
...
@@ -38,10 +38,11 @@ class UINode(configshell.node.ConfigNode):
def
_init_group
(
self
,
group
):
setattr
(
self
.
__class__
,
"
ui_getgroup_%s
"
%
group
,
lambda
self
,
attr
:
self
.
cfnode
.
get_attr
(
group
,
attr
))
lambda
self
,
attr
:
self
.
cfnode
.
get_attr
(
group
,
attr
))
setattr
(
self
.
__class__
,
"
ui_setgroup_%s
"
%
group
,
lambda
self
,
attr
,
value
:
self
.
cfnode
.
set_attr
(
group
,
attr
,
value
))
lambda
self
,
attr
,
value
:
self
.
cfnode
.
set_attr
(
group
,
attr
,
value
))
attrs
=
self
.
cfnode
.
list_attrs
(
group
)
attrs_ro
=
self
.
cfnode
.
list_attrs
(
group
,
writable
=
False
)
...
...
@@ -51,7 +52,7 @@ class UINode(configshell.node.ConfigNode):
name
=
"
ui_desc_%s
"
%
group
t
,
d
=
getattr
(
self
.
__class__
,
name
,
{}).
get
(
attr
,
(
'
string
'
,
''
))
self
.
define_config_group_param
(
group
,
attr
,
t
,
d
,
writable
)
def
refresh
(
self
):
self
.
_children
=
set
([])
...
...
@@ -87,7 +88,8 @@ class UINode(configshell.node.ConfigNode):
class
UIRootNode
(
UINode
):
def
__init__
(
self
,
shell
):
UINode
.
__init__
(
self
,
'
/
'
,
parent
=
None
,
cfnode
=
nvme
.
Root
(),
shell
=
shell
)
UINode
.
__init__
(
self
,
'
/
'
,
parent
=
None
,
cfnode
=
nvme
.
Root
(),
shell
=
shell
)
def
refresh
(
self
):
self
.
_children
=
set
([])
...
...
@@ -293,8 +295,8 @@ def main():
shell
=
configshell
.
shell
.
ConfigShell
(
'
~/.nvmetcli
'
)
UIRootNode
(
shell
)
except
Exception
as
msg
:
shell
.
log
.
error
(
str
(
msg
))
return
shell
.
log
.
error
(
str
(
msg
))
return
while
not
shell
.
_exit
:
try
:
...
...
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