Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(linstor): add network path api in linstor-manager #61

Open
wants to merge 1 commit into
base: 2.30.8-8.2-linstor-fixes-staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 77 additions & 1 deletion drivers/linstor-manager
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,77 @@ def set_node_preferred_interface(session, args):
raise XenAPIPlugin.Failure('-1', [str(e)])
return str(True)

def list_network_path(session, args):
group_name = args["groupName"]

linstor = LinstorVolumeManager(
get_controller_uri(),
group_name,
logger=util.SMlog
)
try:
return str(linstor.list_node_path())
except Exception as e:
raise XenAPIPlugin.Failure('-1', [str(e)])

def get_network_path(session, args):
group_name = args["groupName"]
node1 = args["node1"]
node2 = args["node2"]

linstor = LinstorVolumeManager(
get_controller_uri(),
group_name,
logger=util.SMlog
)
try:
return str(linstor.get_node_path(node1, node2))
except Exception as e:
raise XenAPIPlugin.Failure('-1', [str(e)])

def set_network_path(session, args):
group_name = args["groupName"]
hostname1 = args["node1"]
hostname2 = args["node2"]
network_name = args["network"]

linstor = LinstorVolumeManager(
get_controller_uri(),
group_name,
logger=util.SMlog
)
ret_list = []
try:
list_resp = linstor.set_node_path(hostname1, hostname2, network_name)
for resp in list_resp:
if(resp.is_error()):
raise XenAPIPlugin.Failure('-1', [str(resp)])
ret_list.append(str(resp))

except Exception as e:
raise XenAPIPlugin.Failure('-1', [str(e)])
return str(ret_list)

def destroy_network_path(session, args):
group_name = args["groupName"]
hostname1 = args["node1"]
hostname2 = args["node2"]

linstor = LinstorVolumeManager(
get_controller_uri(),
group_name,
logger=util.SMlog
)
ret_list = []
try:
list_resp = linstor.destroy_node_path(hostname1, hostname2)
for resp in list_resp:
if(resp.is_error()):
raise XenAPIPlugin.Failure('-1', [str(resp)])
ret_list.append(str(resp))
except Exception as e:
raise XenAPIPlugin.Failure('-1', [str(e)])
return str(ret_list)

if __name__ == '__main__':
XenAPIPlugin.dispatch({
Expand Down Expand Up @@ -1238,5 +1309,10 @@ if __name__ == '__main__':
'modifyNodeInterface': modify_node_interface,
'listNodeInterfaces': list_node_interfaces,
'getNodePreferredInterface': get_node_preferred_interface,
'setNodePreferredInterface': set_node_preferred_interface
'setNodePreferredInterface': set_node_preferred_interface,

'listNetworkPath': list_network_path,
'getNetworkPath': get_network_path,
'setNetworkPath': set_network_path,
'destroyNetworkPath': destroy_network_path
})
46 changes: 46 additions & 0 deletions drivers/linstorvolumemanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
PLUGIN = 'linstor-manager'


PATH_NAME = "xostor"

# ==============================================================================

def get_local_volume_openers(resource_name, volume):
Expand Down Expand Up @@ -1620,6 +1622,50 @@ def set_node_preferred_interface(self, node_name, name):
'Failed to set preferred node interface on `{}`: {}'.format(node_name, error_str)
)

def list_node_path(self):
result = self._linstor.node_conn_list()
errors = self._filter_errors(result)
if errors:
error_str = self._get_error_str(errors)
raise LinstorVolumeManagerError(
'Failed to list node connection: {}'.format(error_str)
)
return result

def get_node_path(self, hostname1, hostname2):
result = self._linstor.node_conn_list_specific_pair(node_a=hostname1, node_b=hostname2)
errors = self._filter_errors(result)
if errors:
error_str = self._get_error_str(errors)
raise LinstorVolumeManagerError(
'Failed to get node connection for `{}` <-> `{}`: {}'.format(hostname1, hostname2, error_str)
)
return result

def set_node_path(self, hostname1, hostname2, network_name):
property_name1 = "Paths/{netname}/{node_name}".format(netname=PATH_NAME, node_name=hostname1)
property_name2 = "Paths/{netname}/{node_name}".format(netname=PATH_NAME, node_name=hostname2)
result = self._linstor.node_conn_modify(hostname1, hostname2, property_dict={property_name1: network_name, property_name2: network_name}, delete_props=None)
errors = self._filter_errors(result)
if errors:
error_str = self._get_error_str(errors)
raise LinstorVolumeManagerError(
'Failed to set node connection `{}` <-> `{}`: {}'.format(hostname1, hostname2, error_str)
)
return result

def destroy_node_path(self, hostname1, hostname2):
property_name1 = "Paths/{netname}/{node_name}".format(netname=PATH_NAME, node_name=hostname1)
property_name2 = "Paths/{netname}/{node_name}".format(netname=PATH_NAME, node_name=hostname2)
result = self._linstor.node_conn_modify(hostname1, hostname2, property_dict=None, delete_props=[property_name1, property_name2])
errors = self._filter_errors(result)
if errors:
error_str = self._get_error_str(errors)
raise LinstorVolumeManagerError(
'Failed to destroy node connection `{}` <-> `{}`: {}'.format(hostname1, hostname2, error_str)
)
return result

def get_nodes_info(self):
"""
Get all nodes + statuses, used or not by the pool.
Expand Down