Skip to content

Commit

Permalink
Handle sudo and refactor ssh method
Browse files Browse the repository at this point in the history
Signed-off-by: Partho Sarthi <[email protected]>
  • Loading branch information
parthosa committed Sep 19, 2023
1 parent 97386ec commit c445c6a
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def pull_cluster_props_by_args(self, args: dict) -> str:
return json.dumps(raw_prop_container.props)
return cluster_described

def _build_ssh_cmd_prefix_for_node(self, node: ClusterNode) -> str:
def _build_cmd_ssh_prefix_for_node(self, node: ClusterNode) -> str:
port = self.env_vars.get('sshPort')
key_file = self.env_vars.get('sshKeyFile')
prefix_args = ['ssh',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def pull_cluster_props_by_args(self, args: dict) -> str:
self.logger.error('Invalid arguments to pull the cluster properties')
return self.run_sys_cmd(get_cluster_cmd)

def _build_ssh_cmd_prefix_for_node(self, node: ClusterNode) -> str:
def _build_cmd_ssh_prefix_for_node(self, node: ClusterNode) -> str:
port = self.env_vars.get('sshPort')
key_file = self.env_vars.get('sshKeyFile')
prefix_args = ['ssh',
Expand Down
2 changes: 1 addition & 1 deletion user_tools/src/spark_rapids_pytools/cloud_api/dataproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def exec_platform_describe_accelerator(self,
self.get_env_var('zone')]
return self.run_sys_cmd(cmd_args)

def _build_ssh_cmd_prefix_for_node(self, node: ClusterNode) -> str:
def _build_cmd_ssh_prefix_for_node(self, node: ClusterNode) -> str:
pref_args = ['gcloud',
'compute', 'ssh',
node.name,
Expand Down
2 changes: 1 addition & 1 deletion user_tools/src/spark_rapids_pytools/cloud_api/emr.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def pull_cluster_props_by_args(self, args: dict) -> str:
return EMRPlatform.process_raw_cluster_prop(raw_prop_container)
return cluster_described

def _build_ssh_cmd_prefix_for_node(self, node: ClusterNode) -> str:
def _build_cmd_ssh_prefix_for_node(self, node: ClusterNode) -> str:
# get the pem file
pem_file_path = self.env_vars.get('keyPairPath')
prefix_args = ['ssh',
Expand Down
4 changes: 2 additions & 2 deletions user_tools/src/spark_rapids_pytools/cloud_api/sp_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ def append_to_cmd(original_cmd, extra_args: list) -> Any:
sys_cmd = SysCmd().build(cmd_args)
return sys_cmd.exec()

def _build_ssh_cmd_prefix_for_node(self, node: ClusterNode) -> str:
def _build_cmd_ssh_prefix_for_node(self, node: ClusterNode) -> str:
del node # Unused by super method.
return ''

Expand All @@ -479,7 +479,7 @@ def _construct_ssh_cmd_with_prefix(self, prefix: str, remote_cmd: str) -> str:
return f'{prefix} {remote_cmd}'

def ssh_cmd_node(self, node: ClusterNode, ssh_cmd: str, cmd_input: str = None) -> str:
prefix_cmd = self._build_ssh_cmd_prefix_for_node(node=node)
prefix_cmd = self._build_cmd_ssh_prefix_for_node(node=node)
full_ssh_cmd = self._construct_ssh_cmd_with_prefix(prefix=prefix_cmd, remote_cmd=ssh_cmd)
return self.run_sys_cmd(full_ssh_cmd, cmd_input=cmd_input)

Expand Down
16 changes: 13 additions & 3 deletions user_tools/src/spark_rapids_pytools/resources/collect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,20 @@ if command -v lshw ; then
else
# Downgrade to 'lspci'
if [[ "$PLATFORM_TYPE" == *"databricks"* ]]; then
sudo apt install -y pciutils
lspci | { grep 'Ethernet controller' || true; } >> $OUTPUT_NODE_INFO
if command -v sudo ; then
sudo apt install -y pciutils
fi
if command -v lspci ; then
lspci | { grep 'Ethernet controller' || true; } >> $OUTPUT_NODE_INFO
else
echo 'not found' >> $OUTPUT_NODE_INFO
fi
elif [ "$PLATFORM_TYPE" == "emr" ]; then
/usr/sbin/lspci | { grep 'Ethernet controller' || true; } >> $OUTPUT_NODE_INFO
if command -v /usr/sbin/lspci ; then
/usr/sbin/lspci | { grep 'Ethernet controller' || true; } >> $OUTPUT_NODE_INFO
else
echo 'not found' >> $OUTPUT_NODE_INFO
fi
fi
fi

Expand Down

0 comments on commit c445c6a

Please sign in to comment.