Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
truenas-rk3588
truenas
Commits
5f3f9553
Commit
5f3f9553
authored
2 years ago
by
themylogin
Browse files
Options
Download
Email Patches
Plain Diff
Cleanup bootenv.py
parent
a1c5fb8a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/middlewared/middlewared/plugins/bootenv.py
+11
-14
src/middlewared/middlewared/plugins/bootenv.py
with
11 additions
and
14 deletions
+11
-14
src/middlewared/middlewared/plugins/bootenv.py
View file @
5f3f9553
...
...
@@ -3,7 +3,7 @@ from middlewared.schema import accepts, Bool, Datetime, Dict, Int, returns, Str
from
middlewared.service
import
(
CallError
,
CRUDService
,
ValidationErrors
,
filterable
,
item_method
,
job
)
from
middlewared.utils
import
filter_list
,
osc
,
Popen
,
run
from
middlewared.utils
import
filter_list
,
Popen
,
run
from
datetime
import
datetime
...
...
@@ -18,7 +18,7 @@ class BootEnvService(CRUDService):
datastore_primary_key_type
=
'string'
cli_namespace
=
'system.bootenv'
BE_TOOL
=
'zectl'
if
osc
.
IS_LINUX
else
'beadm'
BE_TOOL
=
'zectl'
ENTRY
=
Dict
(
'bootenv_entry'
,
Str
(
'id'
),
...
...
@@ -61,8 +61,8 @@ class BootEnvService(CRUDService):
'activated'
:
'n'
in
fields
[
1
].
lower
(),
'can_activate'
:
False
,
'mountpoint'
:
fields
[
2
],
'space'
:
None
if
osc
.
IS_LINUX
else
fields
[
3
]
,
'created'
:
datetime
.
strptime
(
fields
[
3
if
osc
.
IS_LINUX
else
4
],
'%Y-%m-%d %H:%M'
),
'space'
:
None
,
'created'
:
datetime
.
strptime
(
fields
[
3
],
'%Y-%m-%d %H:%M'
),
'keep'
:
False
,
'rawspace'
:
None
}
...
...
@@ -140,13 +140,10 @@ class BootEnvService(CRUDService):
be
[
'space'
]
=
f
'
{
round
(
float
(
be
[
"space"
][:
-
1
]),
2
)
}{
be
[
"space"
][
-
1
]
}
'
if
osc
.
IS_FREEBSD
:
be
[
'can_activate'
]
=
'truenas:kernel_version'
not
in
ds
[
'properties'
]
if
osc
.
IS_LINUX
:
be
[
'can_activate'
]
=
(
'truenas:kernel_version'
in
ds
[
'properties'
]
or
'truenas:12'
in
ds
[
'properties'
]
)
be
[
'can_activate'
]
=
(
'truenas:kernel_version'
in
ds
[
'properties'
]
or
'truenas:12'
in
ds
[
'properties'
]
)
results
.
append
(
be
)
return
filter_list
(
results
,
filters
,
options
)
...
...
@@ -165,7 +162,7 @@ class BootEnvService(CRUDService):
try
:
subprocess
.
run
([
self
.
BE_TOOL
,
'activate'
,
oid
],
capture_output
=
True
,
text
=
True
,
check
=
True
)
except
subprocess
.
CalledProcessError
as
cpe
:
raise
CallError
(
f
'Failed to activate BE:
{
cpe
.
stdout
.
strip
()
}
'
)
raise
CallError
(
f
'Failed to activate BE:
{
cpe
.
stdout
.
strip
()
+
cpe
.
stderr
.
strip
()
}
'
)
else
:
return
True
...
...
@@ -220,7 +217,7 @@ class BootEnvService(CRUDService):
args
+=
[
'-e'
,
os
.
path
.
join
(
await
self
.
middleware
.
call
(
'boot.pool_name'
),
'ROOT'
,
source
)
if
osc
.
IS_LINUX
else
source
)
,
]
args
.
append
(
data
[
'name'
])
try
:
...
...
@@ -252,7 +249,7 @@ class BootEnvService(CRUDService):
async
def
_clean_be_name
(
self
,
verrors
,
schema
,
name
):
beadm_names
=
(
await
(
await
Popen
(
f
"
{
self
.
BE_TOOL
}
list -H | awk '{{print $
{
1
if
osc
.
IS_LINUX
else
7
}
}}'"
,
f
"
{
self
.
BE_TOOL
}
list -H | awk '{{print $
1
}}'"
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
...
...
This diff is collapsed.
Click to expand it.
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