Skip to content

Commit

Permalink
Merge pull request #9 from dga-nagra/system_info
Browse files Browse the repository at this point in the history
Started typing for system info (not all information are done)
  • Loading branch information
divad1196 authored Sep 17, 2024
2 parents 142f50a + 0d16d52 commit ce95d19
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/gitleaks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ jobs:
with:
fetch-depth: 0
- uses: gitleaks/gitleaks-action@v2
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE }} # Only required for Organizations, not personal accounts.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE }} # Only required for Organizations, not personal accounts.
6 changes: 5 additions & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@

name: Upload Python Package

on: [pull_request, workflow_dispatch]
on:
workflow_dispatch:
push:
branches:
- main

permissions:
contents: read
Expand Down
10 changes: 9 additions & 1 deletion pa_api/xmlapi/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -936,13 +936,21 @@ def get_vpn_flows(self, name=None):
entries = self._raw_get_vpn_flows(name=name).xpath(".//IPSec/entry")
return [types.VPNFlow.from_xml(e) for e in entries]

def system_info(self):
def _raw_system_info(self):
"""
Returns informations about the system as a XML object.
"""
cmd = "<show><system><info></info></system></show>"
return self.operation(cmd)

def system_info(self) -> types.operations.SystemInfo:
"""
Returns informations about the system as a XML object.
"""
xml = self._raw_system_info()
info = xml.xpath("./result/system")[0]
return types.operations.SystemInfo.from_xml(info)

def _raw_system_resources(self):
"""
Get the system resouces as a XML object.
Expand Down
1 change: 1 addition & 0 deletions pa_api/xmlapi/types/operations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
from .device import Device, HAInfo, VPNFlow
from .job import Job, JobResult
from .software import SoftwareVersion
from .system import SystemInfo
19 changes: 19 additions & 0 deletions pa_api/xmlapi/types/operations/system.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from pydantic import ConfigDict, Field

from pa_api.xmlapi.types.utils import (
String,
XMLBaseModel,
)


class SystemInfo(XMLBaseModel):
model_config = ConfigDict(populate_by_name=True, extra="allow")

hostname: String
ip_address: String = Field(alias="ip-address")
netmask: String
mac_address: String = Field(alias="mac-address")
devicename: String
serial: String
model: String
sw_version: String = Field(alias="sw-version")
11 changes: 7 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ charset-normalizer==3.3.2 ; python_version >= "3.7" and python_full_version < "4
--hash=sha256:fb69256e180cb6c8a894fee62b3afebae785babc1ee98b81cdf68bbca1987f33 \
--hash=sha256:fd1abc0d89e30cc4e02e4064dc67fcc51bd941eb395c502aac3ec19fab46b519 \
--hash=sha256:ff8fa367d09b717b2a17a052544193ad76cd49979c805768879cb63d9ca50561
idna==3.8 ; python_version >= "3.7" and python_full_version < "4.0.0" \
--hash=sha256:050b4e5baadcd44d760cedbd2b8e639f2ff89bbc7a5730fcc662954303377aac \
--hash=sha256:d838c2c0ed6fced7693d5e8ab8e734d5f8fda53a039c0164afb0b82e771e3603
idna==3.10 ; python_version >= "3.7" and python_full_version < "4.0.0" \
--hash=sha256:12f65c9b470abda6dc35cf8e63cc574b1c52b11df2c86030af0ac09b01b13ea9 \
--hash=sha256:946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3
importlib-metadata==6.7.0 ; python_version == "3.7" \
--hash=sha256:1aaf550d4f73e5d6783e7acb77aec43d49da8017410afae93822cc9cca98c4d4 \
--hash=sha256:cb52082e659e97afc5dac71e79de97d8681de3aa07ff18578330904a9d18e5b5
Expand Down

0 comments on commit ce95d19

Please sign in to comment.