Skip to content

Commit

Permalink
NAS-133691 / 25.04 / Convert ipmi.is_loaded to new API (#15450)
Browse files Browse the repository at this point in the history
* add ipmi.py to new api

* convert plugins/ipmi.py to new api
  • Loading branch information
yocalebo authored Jan 21, 2025
1 parent 66fd4ea commit f8ae8c8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/middlewared/middlewared/api/v25_04_0/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from .ftp import * # noqa
from .group import * # noqa
from .initshutdownscript import * # noqa
from .ipmi import * # noqa
from .iscsi_auth import * # noqa
from .iscsi_extent import * # noqa
from .iscsi_global import * # noqa
Expand Down
9 changes: 9 additions & 0 deletions src/middlewared/middlewared/api/v25_04_0/ipmi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from middlewared.api.base import BaseModel


class IPMIIsLoadedArgs(BaseModel):
pass


class IPMIIsLoadedResult(BaseModel):
result: bool
10 changes: 7 additions & 3 deletions src/middlewared/middlewared/plugins/ipmi.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os

from middlewared.schema import accepts, returns, Bool
from middlewared.api import api_method
from middlewared.api.current import IPMIIsLoadedArgs, IPMIIsLoadedResult
from middlewared.service import Service


Expand All @@ -9,8 +10,11 @@ class IPMIService(Service):
class Config:
cli_namespace = 'system.ipmi'

@accepts(roles=['READONLY_ADMIN'])
@returns(Bool('ipmi_loaded'))
@api_method(
IPMIIsLoadedArgs,
IPMIIsLoadedResult,
roles=['READONLY_ADMIN']
)
def is_loaded(self):
"""Returns a boolean value indicating if /dev/ipmi0 is loaded."""
return os.path.exists('/dev/ipmi0')
Expand Down

0 comments on commit f8ae8c8

Please sign in to comment.