blob: aa3e642caa39bf686b149d8633150fd26e569968 [file] [log] [blame]
#!/usr/bin/env python3
#
# Copyright 2022 The Fuchsia Authors
#
# 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.
from antlion import logger, signals
class NetstackControllerError(signals.ControllerError):
pass
class NetstackController:
"""Contains methods related to netstack, to be used in FuchsiaDevice object"""
def __init__(self, fuchsia_device):
self.device = fuchsia_device
self.log = logger.create_tagged_trace_logger(
f"NetstackController for FuchsiaDevice | {self.device.ip}"
)
def list_interfaces(self):
"""Retrieve netstack interfaces from netstack facade
Returns:
List of dicts, one for each interface, containing interface
information
"""
response = self.device.sl4f.netstack_lib.netstackListInterfaces()
if response.get("error"):
raise NetstackControllerError(
f"Failed to get network interfaces list: {response['error']}"
)
return response["result"]