OXIESEC PANEL
- Current Dir:
/
/
usr
/
lib
/
python3
/
dist-packages
/
azurelinuxagent
/
common
Server IP: 10.0.0.4
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
10/14/2020 08:39:36 AM
rwxr-xr-x
📄
__init__.py
630 bytes
11/07/2019 12:36:56 AM
rw-r--r--
📁
__pycache__
-
10/14/2020 08:39:36 AM
rwxr-xr-x
📄
cgroup.py
8.6 KB
11/07/2019 12:36:56 AM
rw-r--r--
📄
cgroupapi.py
25.69 KB
11/07/2019 12:36:56 AM
rw-r--r--
📄
cgroupconfigurator.py
9.27 KB
11/07/2019 12:36:56 AM
rw-r--r--
📄
cgroupstelemetry.py
7.47 KB
11/07/2019 12:36:56 AM
rw-r--r--
📄
conf.py
11.08 KB
11/07/2019 12:36:56 AM
rw-r--r--
📄
datacontract.py
2.6 KB
11/07/2019 12:36:56 AM
rw-r--r--
📄
dhcp.py
14.58 KB
11/07/2019 12:36:56 AM
rw-r--r--
📄
errorstate.py
1.12 KB
11/07/2019 12:36:56 AM
rw-r--r--
📄
event.py
19.03 KB
11/07/2019 12:36:56 AM
rw-r--r--
📄
exception.py
6.38 KB
11/07/2019 12:36:56 AM
rw-r--r--
📄
future.py
3.08 KB
11/07/2019 12:36:56 AM
rw-r--r--
📄
logger.py
7.64 KB
11/07/2019 12:36:56 AM
rw-r--r--
📁
osutil
-
10/14/2020 08:39:36 AM
rwxr-xr-x
📁
protocol
-
10/14/2020 08:39:36 AM
rwxr-xr-x
📄
rdma.py
16.13 KB
11/07/2019 12:36:56 AM
rw-r--r--
📄
telemetryevent.py
1.52 KB
11/07/2019 12:36:56 AM
rw-r--r--
📁
utils
-
10/14/2020 08:39:36 AM
rwxr-xr-x
📄
version.py
7.36 KB
11/07/2019 12:36:56 AM
rw-r--r--
Editing: datacontract.py
Close
# Microsoft Azure Linux Agent # # Copyright 2019 Microsoft Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Requires Python 2.6+ and Openssl 1.0+ # from azurelinuxagent.common.exception import ProtocolError import azurelinuxagent.common.logger as logger """ Base class for data contracts between guest and host and utilities to manipulate the properties in those contracts """ class DataContract(object): pass class DataContractList(list): def __init__(self, item_cls): self.item_cls = item_cls def validate_param(name, val, expected_type): if val is None: raise ProtocolError("{0} is None".format(name)) if not isinstance(val, expected_type): raise ProtocolError(("{0} type should be {1} not {2}" "").format(name, expected_type, type(val))) def set_properties(name, obj, data): if isinstance(obj, DataContract): validate_param("Property '{0}'".format(name), data, dict) for prob_name, prob_val in data.items(): prob_full_name = "{0}.{1}".format(name, prob_name) try: prob = getattr(obj, prob_name) except AttributeError: logger.warn("Unknown property: {0}", prob_full_name) continue prob = set_properties(prob_full_name, prob, prob_val) setattr(obj, prob_name, prob) return obj elif isinstance(obj, DataContractList): validate_param("List '{0}'".format(name), data, list) for item_data in data: item = obj.item_cls() item = set_properties(name, item, item_data) obj.append(item) return obj else: return data def get_properties(obj): if isinstance(obj, DataContract): data = {} props = vars(obj) for prob_name, prob in list(props.items()): data[prob_name] = get_properties(prob) return data elif isinstance(obj, DataContractList): data = [] for item in obj: item_data = get_properties(item) data.append(item_data) return data else: return obj