Пример #1
0
 def _list_links(self) -> ViewOnlyDict:
     link_id_list = self.graph_model.get_all_network_links()
     ret = dict()
     for nid in link_id_list:
         n = self._get_link_by_id(nid)
         ret[n.name] = n
     return ViewOnlyDict(ret)
Пример #2
0
 def __list_interfaces(self) -> ViewOnlyDict:
     """
     List all interfaces of the network service as a dictionary
     :return:
     """
     node_id_list = self.topo.graph_model.get_all_ns_or_link_connection_points(link_id=self.node_id)
     ret = dict()
     for nid in node_id_list:
         c = self.__get_interface_by_id(nid)
         ret[c.name] = c
     return ViewOnlyDict(ret)
Пример #3
0
 def __list_sites(self) -> ViewOnlyDict:
     """
     List site information
     :return:
     """
     node_id_list = self.graph_model.get_all_composite_nodes()
     ret = dict()
     for nid in node_id_list:
         n = self._get_node_by_id(nid)
         ret[n.name] = n
     return ViewOnlyDict(ret)
Пример #4
0
 def _list_links(self) -> ViewOnlyDict:
     """
     List all Links in the topology as a dictionary organized by Link name.
     :return:
     """
     link_id_list = self.graph_model.get_all_network_links()
     ret = dict()
     for nid in link_id_list:
         n = self._get_link_by_id(nid)
         ret[n.name] = n
     return ViewOnlyDict(ret)
 def __read_catalog() -> ViewOnlyDict:
     if InstanceCatalog.__catalog_instance is None:
         catalog_file = os.path.join(os.path.dirname(__file__), 'data',
                                     'instance_sizes.json')
         with open(catalog_file) as f:
             catalog = json.load(f)
         assert isinstance(catalog, dict)
         InstanceCatalog.__catalog_instance = {
             k: Capacities(**v)
             for (k, v) in catalog.items()
         }
     return ViewOnlyDict(InstanceCatalog.__catalog_instance)
Пример #6
0
 def __list_interfaces(self) -> ViewOnlyDict:
     """
     List all interfaces of the component as a dictionary
     :return:
     """
     node_id_list = self.topo.graph_model.get_all_node_or_component_connection_points(
         parent_node_id=self.node_id)
     # Could consider using frozendict here
     ret = dict()
     for nid in node_id_list:
         i = self.__get_interface_by_id(nid)
         ret[i.name] = i
     return ViewOnlyDict(ret)
Пример #7
0
 def _list_network_services(self) -> ViewOnlyDict:
     """
     List all NetworkServices in the topology as a dictionary organized by name.
     Modifying the dictionary will not affect the underlying model, but modifying
     NetworkServices in the dictionary will.
     :return:
     """
     node_id_list = self.graph_model.get_all_network_service_nodes()
     ret = dict()
     for nid in node_id_list:
         n = self._get_ns_by_id(nid)
         ret[n.name] = n
     return ViewOnlyDict(ret)
Пример #8
0
 def __list_direct_interfaces(self) -> ViewOnlyDict:
     """
     List all directly-attached interfaces of the node as a dictionary
     :return:
     """
     # immediately-attached interfaces
     node_if_list = self.topo.graph_model.get_all_node_or_component_connection_points(
         parent_node_id=self.node_id)
     ret = dict()
     for nid in node_if_list:
         i = self.__get_interface_by_id(nid)
         ret[i.name] = i
     return ViewOnlyDict(ret)
 def __list_components(self) -> ViewOnlyDict:
     """
     List all Components children of a node in the topology as a dictionary
     organized by component name. Modifying the dictionary will not affect
     the underlying model, but modifying Components in the dictionary will.
     :return:
     """
     node_id_list = self.topo.graph_model.get_all_composite_node_components(parent_node_id=self.node_id)
     ret = dict()
     for nid in node_id_list:
         c = self._get_component_by_id(nid)
         ret[c.name] = c
     return ViewOnlyDict(ret)
Пример #10
0
 def facilities(self) -> ViewOnlyDict or None:
     """
     Return facilities connected in this topology. Facilities should NOT be composite nodes in the ad.
     :return:
     """
     fac_ids = self.graph_model.get_all_nodes_by_class_and_type(label=ABCPropertyGraph.CLASS_NetworkNode,
                                                                ntype=str(NodeType.Facility))
     if fac_ids is None:
         return None
     ret = dict()
     for nid in fac_ids:
         n = self._get_node_by_id(nid)
         ret[n.name] = n
     return ViewOnlyDict(ret)
Пример #11
0
 def __list_network_services(self) -> ViewOnlyDict:
     """
     List all network service children of a node as a dictionary organized
     by network service name. Modifying the dictionary will not affect
     the underlying model, but modifying NetworkServices in the dictionary will.
     :return:
     """
     node_id_list = self.topo.graph_model.get_all_network_node_or_component_nss(
         parent_node_id=self.node_id)
     ret = dict()
     for nid in node_id_list:
         c = self.__get_ns_by_id(nid)
         ret[c.name] = c
     return ViewOnlyDict(ret)
 def __list_interfaces(self) -> ViewOnlyDict:
     """
     List all interfaces of composite node ignoring the components
     :return:
     """
     # immediately-attached interfaces only for composite nodes
     # FIXME: note that due to interface name collisions this may not return
     # all the interfaces. Better to use list_of_interfaces
     node_if_list = self.topo.graph_model.get_all_node_or_component_connection_points(parent_node_id=self.node_id)
     direct_interfaces = dict()
     for nid in node_if_list:
         i = self.__get_interface_by_id(nid)
         direct_interfaces[i.name] = i
     return ViewOnlyDict(direct_interfaces)
Пример #13
0
 def _list_nodes(self) -> ViewOnlyDict:
     """
     List all NetworkNodes in the topology as a dictionary
     organized by node name. Modifying the dictionary will not affect
     the underlying model, but modifying Nodes in the dictionary will.
     :return:
     """
     node_id_list = self.graph_model.get_all_network_nodes()
     ret = dict()
     for nid in node_id_list:
         n = self._get_node_by_id(nid)
         # exclude Facility nodes
         if n.type != NodeType.Facility:
             ret[n.name] = n
     return ViewOnlyDict(ret)
Пример #14
0
 def __list_interfaces(self) -> ViewOnlyDict:
     """
     List all interfaces of node and its components
     :return:
     """
     # immediately-attached interfaces
     # FIXME: note that because there could be a collision on interface name, this
     # may produce invalid results sometimes. Better to use list_of_interfaces
     node_if_list = self.topo.graph_model.get_all_node_or_component_connection_points(
         parent_node_id=self.node_id)
     direct_interfaces = dict()
     for nid in node_if_list:
         i = self.__get_interface_by_id(nid)
         direct_interfaces[i.name] = i
     cdict = self.__list_components()
     for k, v in cdict.items():
         comp_interfaces = v.interfaces
         direct_interfaces.update(comp_interfaces)
     return ViewOnlyDict(direct_interfaces)
Пример #15
0
    def search_catalog(self, *, ctype: ComponentType) -> ViewOnlyDict:
        """
        Provide a dictionaty of matching component models and their details
        based on component type
        :param ctype:
        :return:
        """
        catalog = self.__read_catalog()
        matching_components = list()
        for c in catalog:
            if str(ctype) == c['Type']:
                matching_components.append(c)

        if len(matching_components) == 0:
            raise CatalogException(
                f'Unable to find type {ctype} in the catalog')
        ret = dict()
        for c in matching_components:
            ret[c['Model']] = c['Details']
        return ViewOnlyDict(ret)