mirror of
https://github.com/Telecominfraproject/oopt-gnpy.git
synced 2025-11-01 02:28:05 +00:00
YANG: loading and storing topologies
GNPy's in-memory representation is closely modeled on the legacy JSON files. Everything is a node, and the edges hold no data. In our YANG models this is different, and all Fiber instances are stored as links. Originally I wanted to be smart with Fused nodes and automatically remove them "when they are not needed". In legacy JSON, the `Fused` thingy was sometimes placed as a magic clue to signify that no EDFA can be put on that particular place. This is not needed in YANG, so I wanted to remove these extra Fused nodes, but boy, was it a deep hole to dig myself in. FIXME: EDFAs are still placed even though the docs say otherwise! Change-Id: I27bd9414e8237d94b980a200ce9f9792602b5430
This commit is contained in:
@@ -32,7 +32,7 @@ from gnpy.topology.spectrum_assignment import build_oms_list, pth_assign_spectru
|
||||
from gnpy.tools.json_io import load_equipment, load_network, load_json, load_requests, save_network, \
|
||||
requests_from_json, disjunctions_from_json, save_json
|
||||
from gnpy.tools.plots import plot_baseline, plot_results
|
||||
from gnpy.yang.io import load_from_yang, save_equipment
|
||||
from gnpy.yang.io import load_from_yang, save_to_json
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
_examples_dir = Path(__file__).parent.parent / 'example-data'
|
||||
@@ -140,7 +140,8 @@ def transmission_main_example(args=None):
|
||||
with open(args.from_yang, 'r') as f:
|
||||
raw_json = json.load(f)
|
||||
(equipment, network) = load_from_yang(raw_json)
|
||||
network = _load_network_legacy(args.topology, equipment, args.save_network_before_autodesign)
|
||||
if args.save_network_before_autodesign is not None:
|
||||
save_network(network, args.save_network_before_autodesign)
|
||||
else:
|
||||
(equipment, network) = load_common_data(args.equipment, args.topology, args.sim_params, args.save_network_before_autodesign)
|
||||
|
||||
@@ -468,9 +469,13 @@ def convert_to_yang(args=None):
|
||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
|
||||
)
|
||||
_parser_add_equipment(parser)
|
||||
parser.add_argument('--topology', type=Path, metavar='NETWORK-TOPOLOGY.(json|xls|xlsx)',
|
||||
help='Input network topology')
|
||||
|
||||
args = parser.parse_args(args if args is not None else sys.argv[1:])
|
||||
|
||||
equipment = load_equipment(args.equipment)
|
||||
data = save_equipment(equipment)
|
||||
network = load_network(args.topology, equipment) if args.topology is not None else None
|
||||
|
||||
data = save_to_json(equipment, network)
|
||||
print(json.dumps(data, indent=2))
|
||||
|
||||
Reference in New Issue
Block a user