Skip to content

Commit a3ddf9c

Browse files
Merge branch 'feature/ecos-w25-augment' into development
2 parents 2f87ad6 + 331b484 commit a3ddf9c

6 files changed

Lines changed: 274 additions & 3 deletions

File tree

pyedgeconnect/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,10 +1328,13 @@ def __init__(
13281328
self.logger.addHandler(self.console_handler)
13291329

13301330
# Imported methods
1331+
from .ecos._disk_usage import get_appliance_disk_usage
1332+
from .ecos._dns import get_appliance_dns_config, set_appliance_dns_config
13311333
from .ecos._gms import assign_orchestrator, get_orchestrator
13321334
from .ecos._interfaces import get_appliance_interfaces
13331335
from .ecos._license import is_reboot_required
13341336
from .ecos._login import login, logout
1337+
from .ecos._memory import get_appliance_memory
13351338
from .ecos._network_interfaces import (
13361339
get_appliance_network_interfaces,
13371340
modify_network_interfaces,
@@ -1343,3 +1346,4 @@ def __init__(
13431346
get_appliance_stats_minute_file,
13441347
get_appliance_stats_minute_range,
13451348
)
1349+
from .ecos._time import get_appliance_time

pyedgeconnect/ecos/_disk_usage.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# MIT License
2+
# (C) Copyright 2022 Hewlett Packard Enterprise Development LP.
3+
#
4+
# diskUsage : Available disk space
5+
6+
7+
def get_appliance_disk_usage(
8+
self,
9+
) -> dict:
10+
"""Get the disk usage of the appliance
11+
12+
.. list-table::
13+
:header-rows: 1
14+
15+
* - Swagger Section
16+
- Method
17+
- Endpoint
18+
* - diskUsage
19+
- GET
20+
- /diskUsage
21+
22+
:return: Returns dictionary of current appliance disk usage \n
23+
* keyword **<directory name>** (`dict`): Directory disk
24+
utilization, e.g. ``/`` or ``/dev`` etc. \n
25+
* keyword **1k-blocks** (`int`): The number of 1k-blocks
26+
* keyword **used** (`int`): Size of used space, KB
27+
* keyword **available** (`int`): Size of available space, KB
28+
* keyword **usedpercent** (`int`): Percent of used space
29+
* keyword **filesystem** (`str`): Name of the filesystem
30+
:rtype: dict
31+
"""
32+
return self._get("/diskUsage")

pyedgeconnect/ecos/_dns.py

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
# MIT License
2+
# (C) Copyright 2022 Hewlett Packard Enterprise Development LP.
3+
#
4+
# dns : DNS server and domain
5+
6+
7+
def get_appliance_dns_config(
8+
self,
9+
) -> dict:
10+
"""Get the current DNS IP address and domain names configured for
11+
your appliance
12+
13+
.. list-table::
14+
:header-rows: 1
15+
16+
* - Swagger Section
17+
- Method
18+
- Endpoint
19+
* - dns
20+
- GET
21+
- /resolver
22+
23+
:return: Returns dictionary of current appliance dns configuration\n
24+
* keyword **domain_search** (`dict`): Domain search settings \n
25+
* keyword **<Order of search 1-6>** (`dict`): \n
26+
* keyword **self** (`int`): Order of Domain Name, which
27+
should be the same as this entry's key
28+
* keyword **domainname** (`str`): Search Domain
29+
* keyword **nameserver** (`dict`): Name server settings \n
30+
* keyword **1** (`dict`): Primary name server\n
31+
* keyword **self** (`int`): Order of Name Server, which
32+
should be the same as this entry's key
33+
* keyword **address** (`str`): IP of DNS Server
34+
* keyword **vrf_id** (`int`): Segment ID, which default
35+
value is 0
36+
* keyword **srcinf** (`str`): Source Interface, which
37+
default value is any
38+
* keyword **2** (`dict`): Secondary name server\n
39+
* keyword **self** (`int`): Order of Name Server, which
40+
should be the same as this entry's key
41+
* keyword **address** (`str`): IP of DNS Server
42+
* keyword **vrf_id** (`int`): Segment ID, which default
43+
value is 0
44+
* keyword **srcinf** (`str`): Source Interface, which
45+
default value is any
46+
* keyword **3** (`dict`): Tertiary name server\n
47+
* keyword **self** (`int`): Order of Name Server, which
48+
should be the same as this entry's key
49+
* keyword **address** (`str`): IP of DNS Server
50+
* keyword **vrf_id** (`int`): Segment ID, which default
51+
value is 0
52+
* keyword **srcinf** (`str`): Source Interface, which
53+
default value is any
54+
:rtype: dict
55+
"""
56+
return self._get("/resolver")
57+
58+
59+
def set_appliance_dns_config(
60+
self,
61+
domain_search_settings: dict,
62+
primary_ns_address: str,
63+
primary_ns_vrf_id: int,
64+
primary_ns_source_interface: str,
65+
secondary_ns_address: str,
66+
secondary_ns_vrf_id: int,
67+
secondary_ns_source_interface: str,
68+
tertiary_ns_address: str,
69+
tertiary_ns_vrf_id: int,
70+
tertiary_ns_source_interface: str,
71+
) -> dict:
72+
"""Get the current DNS IP address and domain names configured for
73+
your appliance
74+
75+
.. list-table::
76+
:header-rows: 1
77+
78+
* - Swagger Section
79+
- Method
80+
- Endpoint
81+
* - dns
82+
- POST
83+
- /resolver
84+
85+
Example:
86+
87+
.. code-block:: python
88+
89+
domain_search_settings = {
90+
"1": {
91+
"self": 1,
92+
"domainname": "my.search.domain",
93+
},
94+
}
95+
96+
ec.set_appliance_dns_config(
97+
domain_search_settings = domain_search_settings,
98+
primary_ns_address = "192.0.2.100",
99+
primary_ns_vrf_id = 0,
100+
primary_ns_source_interface = "mgmt0",
101+
secondary_ns_address = "192.0.2.200",
102+
secondary_ns_vrf_id = 0,
103+
secondary_ns_source_interface = "",
104+
tertiary_ns_address = "",
105+
tertiary_ns_vrf_id = 0,
106+
tertiary_ns_source_interface = "",
107+
)
108+
109+
:param domain_search_settings: Domain search settings dictionary
110+
object. Up to 6 can be specified, each with a key of the
111+
order they should be applied (1-6). Example below \n
112+
* keyword **1** (`dict`): Search domain object \n
113+
* keyword **self** (`int`): Numeric ID, same as key
114+
* keyword **domainname** (`str`): Search domain,
115+
e.g. ``my.search.domain``
116+
:type domain_search_settings: dict
117+
:param primary_ns_address: Primary DNS server IP address
118+
:type primary_ns_address: str
119+
:param primary_ns_vrf_id: Segment/VRF ID to reach Primary DNS
120+
server, e.g. ``0`` for Default VRF
121+
:type primary_ns_vrf_id: int
122+
:param primary_ns_source_interface: Interface to reach Primary
123+
DNS server, e.g. ``mgmt0`` or ``lan0``
124+
:type primary_ns_source_interface: str
125+
:param secondary_ns_address: Secondary DNS server IP address
126+
:type secondary_ns_address: str
127+
:param secondary_ns_vrf_id: Segment/VRF ID to reach Secondary
128+
DNS server, e.g. ``0`` for Default VRF
129+
:type secondary_ns_vrf_id: int
130+
:param secondary_ns_source_interface: Interface to reach
131+
Secondary DNS server, e.g. ``mgmt0`` or ``lan0``
132+
:type secondary_ns_source_interface: str
133+
:param tertiary_ns_address: Tertiary DNS server IP address
134+
:type tertiary_ns_address: str
135+
:param tertiary_ns_vrf_id: Segment/VRF ID to reach Tertiary DNS
136+
server, e.g. ``0`` for Default VRF
137+
:type tertiary_ns_vrf_id: int
138+
:param tertiary_ns_source_interface: Interface to reach Tertiary
139+
DNS server, e.g. ``mgmt0`` or ``lan0``
140+
:type tertiary_ns_source_interface: str
141+
:return: Returns True/False based on successful call
142+
:rtype: bool
143+
"""
144+
data = {
145+
"domain_search": domain_search_settings,
146+
"nameserver": {
147+
"1": {
148+
"self": 1,
149+
"address": primary_ns_address,
150+
"vrf_id": primary_ns_vrf_id,
151+
"srcinf": primary_ns_source_interface,
152+
},
153+
"2": {
154+
"self": 2,
155+
"address": secondary_ns_address,
156+
"vrf_id": secondary_ns_vrf_id,
157+
"srcinf": secondary_ns_source_interface,
158+
},
159+
"3": {
160+
"self": 3,
161+
"address": tertiary_ns_address,
162+
"vrf_id": tertiary_ns_vrf_id,
163+
"srcinf": tertiary_ns_source_interface,
164+
},
165+
},
166+
}
167+
168+
return self._post(
169+
"/resolver",
170+
data=data,
171+
return_type="bool",
172+
)

pyedgeconnect/ecos/_memory.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# MIT License
2+
# (C) Copyright 2022 Hewlett Packard Enterprise Development LP.
3+
#
4+
# memory : Get memory related information
5+
6+
7+
def get_appliance_memory(
8+
self,
9+
) -> dict:
10+
"""Get appliance memory related information
11+
12+
.. list-table::
13+
:header-rows: 1
14+
15+
* - Swagger Section
16+
- Method
17+
- Endpoint
18+
* - memory
19+
- GET
20+
- /memory
21+
22+
:return: Returns dictionary of current memory utilization on
23+
appliance, all units in bytes \n
24+
* keyword **total** (`int`): Total memory
25+
* keyword **free** (`int`): Free memory
26+
* keyword **buffers** (`int`): Buffers memory
27+
* keyword **cached** (`int`): Cached memory
28+
* keyword **used** (`int`): Used memory
29+
* keyword **swapTotal** (`int`): Swap total memory
30+
* keyword **swapFree** (`int`): Swap free memory
31+
* keyword **swapUsed** (`int`): Swap used memory
32+
:rtype: dict
33+
"""
34+
return self._get("/memory")

pyedgeconnect/ecos/_statistics.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ def get_appliance_stats_minute_range(self) -> dict:
2727
2828
:return: Dictionary of newest and oldest minute stat times \n
2929
* keyword **newest** (`int`): Epoch seconds timestamp of latest
30-
available appliance minute data
30+
available appliance minute data
3131
* keyword **oldest** (`int`): Epoch seconds timestamp of oldest
32-
available appliance minute data
32+
available appliance minute data
3333
:rtype: dict
3434
"""
3535
return self._get("/stats/minuteRange")
@@ -59,7 +59,8 @@ def get_appliance_stats_minute_file(
5959
file has a header which describes the statistics contained in the
6060
file.
6161
62-
.. code:: python
62+
.. code-block:: python
63+
6364
import tarfile
6465
from pyedgeconnect import EdgeConnect
6566
ec = EdgeConnect(ec_ip)

pyedgeconnect/ecos/_time.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# MIT License
2+
# (C) Copyright 2022 Hewlett Packard Enterprise Development LP.
3+
#
4+
# time : Current time
5+
6+
7+
def get_appliance_time(
8+
self,
9+
) -> dict:
10+
"""Get the current time on the appliance
11+
12+
.. list-table::
13+
:header-rows: 1
14+
15+
* - Swagger Section
16+
- Method
17+
- Endpoint
18+
* - time
19+
- GET
20+
- /time
21+
22+
:return: Returns dictionary of current appliance time \n
23+
* keyword **current** (`int`): Current unix epoch time in
24+
milliseconds
25+
* keyword **gmtOffset** (`int`): Hours offset from GMT
26+
:rtype: dict
27+
"""
28+
return self._get("/time")

0 commit comments

Comments
 (0)