← Back
Editing: state.py
# Copyright (C) 2023 Canonical, Ltd. # Author: Lukas Märdian <slyon@ubuntu.com> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 3. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # from enum import IntEnum from io import StringIO import os from typing import IO from ._netplan_cffi import ffi, lib from .netdef import NetDefinition, NetDefinitionIterator from .parser import Parser from ._utils import _checked_lib_call # class NETPLAN_STORAGE(IntEnum): # ETC = 0 # RUN = 1 # LIB = 2 class State(): def __init__(self): self._ptr = lib.netplan_state_new() def __del__(self): ref = ffi.new('NetplanState **', self._ptr) lib.netplan_state_clear(ref) def __getitem__(self, netdef_id: str): ptr = lib.netplan_state_get_netdef(self._ptr, netdef_id.encode('utf-8')) if not ptr: raise IndexError() return NetDefinition(self, ptr) def __len__(self): return lib.netplan_state_get_netdefs_size(self._ptr) def import_parser_results(self, parser: Parser): _checked_lib_call(lib.netplan_state_import_parser_results, self._ptr, parser._ptr) # def write_yaml(filter: str, default_filename: str = None, # storage: NETPLAN_STORAGE = NETPLAN_STORAGE.ETC, rootdir str = None): # # TODO: https://bugs.launchpad.net/netplan/+bug/2003727 # raise NotImplementedError def _write_yaml_file(self, filename: str = None, rootdir: str = None): name = filename.encode('utf-8') if filename else ffi.NULL root = rootdir.encode('utf-8') if rootdir else ffi.NULL _checked_lib_call(lib.netplan_state_write_yaml_file, self._ptr, name, root) def _update_yaml_hierarchy(self, default_filename: str, rootdir: str = None): name = default_filename.encode('utf-8') root = rootdir.encode('utf-8') if rootdir else ffi.NULL _checked_lib_call(lib.netplan_state_update_yaml_hierarchy, self._ptr, name, root) def _dump_yaml(self, output_file: IO): if isinstance(output_file, StringIO): fd = os.memfd_create(name='netplan_temp_file') _checked_lib_call(lib.netplan_state_dump_yaml, self._ptr, fd) size = os.lseek(fd, 0, os.SEEK_CUR) os.lseek(fd, 0, os.SEEK_SET) data = os.read(fd, size) os.close(fd) output_file.write(data.decode('utf-8')) else: fd = output_file.fileno() _checked_lib_call(lib.netplan_state_dump_yaml, self._ptr, fd) @property def backend(self) -> str: return ffi.string(lib.netplan_backend_name(lib.netplan_state_get_backend(self._ptr))).decode('utf-8') @property def netdefs(self) -> NetDefinitionIterator: return dict((nd.id, nd) for nd in NetDefinitionIterator(self, None)) @property def ethernets(self) -> NetDefinitionIterator: return dict((nd.id, nd) for nd in NetDefinitionIterator(self, "ethernets")) @property def modems(self) -> NetDefinitionIterator: return dict((nd.id, nd) for nd in NetDefinitionIterator(self, "modems")) @property def wifis(self) -> NetDefinitionIterator: return dict((nd.id, nd) for nd in NetDefinitionIterator(self, "wifis")) @property def vlans(self) -> NetDefinitionIterator: return dict((nd.id, nd) for nd in NetDefinitionIterator(self, "vlans")) @property def bridges(self) -> NetDefinitionIterator: return dict((nd.id, nd) for nd in NetDefinitionIterator(self, "bridges")) @property def bonds(self) -> NetDefinitionIterator: return dict((nd.id, nd) for nd in NetDefinitionIterator(self, "bonds")) @property def dummy_devices(self) -> NetDefinitionIterator: return dict((nd.id, nd) for nd in NetDefinitionIterator(self, "dummy-devices")) @property def tunnels(self) -> NetDefinitionIterator: return dict((nd.id, nd) for nd in NetDefinitionIterator(self, "tunnels")) @property def virtual_ethernets(self) -> NetDefinitionIterator: return dict((nd.id, nd) for nd in NetDefinitionIterator(self, "virtual-ethernets")) @property def vrfs(self) -> NetDefinitionIterator: return dict((nd.id, nd) for nd in NetDefinitionIterator(self, "vrfs")) @property def ovs_ports(self) -> NetDefinitionIterator: return dict((nd.id, nd) for nd in NetDefinitionIterator(self, "_ovs-ports")) @property def nm_devices(self) -> NetDefinitionIterator: return dict((nd.id, nd) for nd in NetDefinitionIterator(self, "nm-devices"))
Mainco
https://validator.w3.org/feed/docs/rss2.html
WHALESPRAY CRACK-3 TINTA LIMPIADORA 400ML VERDE WS-3050-S
WHALESPRAY CRACK-2 TINTA REVELADORA 400ML BLANCO WS-1821-S
WHALESPRAY CRACK-1 TINTA PENETRANTE 400ML ROJO WS-1820-S
VIDRIO PARA MIRILLA TUBULAR TEMPLADO 4″
VIDRIO PARA MIRILLA TUBULAR TEMPLADO 21/2″
VIDRIO PARA MIRILLA TEMPLADO DN100 TIPO FLANGE ALTA PRESION
VIDRIO PARA MIRILLA TEMPLADO DN100
VASTAGO MOVIL P/BASE CUADRADA DE 11/2″
VARILLA PARA BOQUILLA SERIE DH/DS SS304 CON BOQUILLA DE PULVERIZADOR AJUSTABLE DE 3PIES
VARILLA LISA REDONDA SS304 3/8″
VARILLA LISA REDONDA SS304 3/4″
VARILLA LISA REDONDA SS304 3/16″
VARILLA LISA REDONDA SS304 1/8″
VARILLA LISA REDONDA SS304 1/4″
VARILLA LISA REDONDA SS304 1/2″
VALVULA SACAMUESTRAS CLAMP 1″-11/2″ SS316L JUNTA SILICON 10 BAR (120°C)
VALVULA SACAMUESTRAS ASEPTICA FARMA SOLDABLE 1″ DQW-01
VALVULA SACAMUESTRAS ASEPTICA FARMA CLAMP 2″ DQW-03 SS316L
VALVULA SACAMUESTRAS 3/4″ IQY-02 SS316L
VALVULA SACAMUESTRAS 1/4″ IQY-02 SS316L
VALVULA SACAMUESTRAS 1/2″ IQY-02 SS316L
VALVULA RETENCION WAFER 8″ H/FUNDIDO DISCO-DOBLE CF8M ASIENTO BUNA 16 BAR (-10°C-100°C)
VALVULA RETENCION WAFER 8″ CF8M DISCO-DOBLE CF8M ASIENTO VITON 25 BAR (-20°C-180°C)
VALVULA RETENCION WAFER 8″ CF8M DISCO CF8M ASIENTO VITON 16 BAR (-20°C-180°C)
VALVULA RETENCION WAFER 6″ H/FUNDIDO DISCO-DOBLE CF8M ASIENTO BUNA 16 BAR (-10°C-100°C)
VALVULA RETENCION WAFER 6″ CF8M DISCO-DOBLE CF8M ASIENTO VITON 25 BAR (-20°C-180°C)
VALVULA RETENCION WAFER 6″ CF8M DISCO CF8M ASIENTO VITON 16 BAR (-20°C-180°C)
VALVULA RETENCION WAFER 4″ H/FUNDIDO DISCO-DOBLE CF8M ASIENTO BUNA 16 BAR (-10°C-100°C)
VALVULA RETENCION WAFER 4″ CF8M DISCO-DOBLE CF8M ASIENTO VITON 25 BAR (-20°C-180°C)
VALVULA RETENCION WAFER 4″ CF8M DISCO CF8M ASIENTO VITON 16 BAR (-20°C-180°C)
VALVULA RETENCION WAFER 4″ CF8M DISCO CF8M 40 BAR (-20°C-240°C)
VALVULA RETENCION WAFER 3″ H/FUNDIDO DISCO-DOBLE CF8M ASIENTO BUNA 16 BAR (-10°C-100°C)
VALVULA RETENCION WAFER 3″ CF8M DISCO-DOBLE CF8M ASIENTO VITON 25 BAR (-20°C-180°C)
VALVULA RETENCION WAFER 3″ CF8M DISCO CF8M ASIENTO VITON 16 BAR (-20°C-180°C)
VALVULA RETENCION WAFER 3″ CF8M DISCO CF8M 40 BAR (-20°C-240°C)
VALVULA RETENCION WAFER 2″ CF8M DISCO CF8M ASIENTO VITON 16 BAR (-20°C-180°C)
VALVULA RETENCION WAFER 2″ CF8M DISCO CF8M 40 BAR (-20°C-240°C)
VALVULA RETENCION WAFER 1″ CF8M DISCO CF8M 40 BAR (-20°C-240°C)
VALVULA RETENCION SOLDABLE-SOCKET 2″ A/FORJADO PISTON F6A JUNTA SS304 140 BAR (-29°C-420°C)
VALVULA RETENCION SOLDABLE-SOCKET 11/2″ A/FORJADO PISTON F6A JUNTA SS304 140 BAR (-29°C-420°C)
VALVULA RETENCION SOLDABLE-SOCKET 1″ A/FORJADO PISTON F6A JUNTA SS304 140 BAR (-29°C-420°C)
VALVULA RETENCION SOLDABLE DN100 SS316L DISCO SS316L JUNTA EPDM 10 BAR (-10°C-120°C)
VALVULA RETENCION SOLDABLE 6″ SS316
VALVULA RETENCION SOLDABLE 4″ SS316
VALVULA RETENCION SOLDABLE 4″ SS304 DISCO SS304 JUNTA SILICON 10 BAR (-10°C-120°C)
VALVULA RETENCION SOLDABLE 3″ SS304 DISCO SS304 JUNTA SILICON 10 BAR (-10°C-120°C)
VALVULA RETENCION SOLDABLE 11/2″ SS316 JUNTA VITON
VALVULA RETENCION SOLDABLE 11/2″ SS316
Inicio
Blog