Example #1
0
 def get_storage_node_by_name(self, name):
     """Get storage node by name(host@backendname)"""
     try:
         storages = list(
             filter(lambda storage: storage.host == name,
                    self.get_storage_node_list()))
         if len(storages) != 1:
             raise exception.StorageNodeNotFound(name=name)
         return storages[0]
     except Exception as exc:
         LOG.exception(exc)
         raise exception.StorageNodeNotFound(name=name)
Example #2
0
 def get_storage_node_by_name(self, name):
     """Get storage node by name(host@backendname)"""
     try:
         storages = [
             storage for storage in self.get_storage_node_list()
             if storage.host == name
         ]
         if len(storages) != 1:
             raise exception.StorageNodeNotFound(name=name)
         return storages[0]
     except Exception as exc:
         LOG.exception(exc)
         raise exception.StorageNodeNotFound(name=name)
Example #3
0
 def get_node_by_pool_name(self, pool_name):
     pool = self._get_by_name(pool_name)
     for node_name in self.neighbors(pool.name):
         node = self._get_by_name(node_name)
         if isinstance(node, element.StorageNode):
             return node
     raise exception.StorageNodeNotFound(name=pool_name)
Example #4
0
 def remove_node(self, node):
     self.assert_node(node)
     try:
         super(StorageModelRoot, self).remove_node(node.host)
     except nx.NetworkXError as exc:
         LOG.exception(exc)
         raise exception.StorageNodeNotFound(name=node.host)
Example #5
0
    def get_node_by_name(self, name):
        """Get a node by node name

        :param node: :py:class:`~.StorageNode` object or node name
        """
        try:
            return self._get_by_name(name.split("#")[0])
        except exception.StorageResourceNotFound:
            raise exception.StorageNodeNotFound(name=name)
Example #6
0
 def create_storage_node(self, name):
     """Create the storage node by querying the Cinder API."""
     try:
         _node = self.cinder.get_storage_node_by_name(name)
         _volume_type = self.cinder.get_volume_type_by_backendname(
             # name is formatted as host@backendname
             name.split('@')[1])
         storage_node = element.StorageNode(host=_node.host,
                                            zone=_node.zone,
                                            state=_node.state,
                                            status=_node.status,
                                            volume_type=_volume_type)
         return storage_node
     except Exception as exc:
         LOG.exception(exc)
         LOG.debug("Could not create storage node %s.", name)
         raise exception.StorageNodeNotFound(name=name)
Example #7
0
 def get_node_by_name(self, name):
     try:
         return self._get_by_name(name.split("#")[0])
     except exception.StorageResourceNotFound:
         raise exception.StorageNodeNotFound(name=name)