change_personality 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # Copyright 2020 Dell Inc. or its subsidiaries. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. #!/bin/bash
  15. #Usage: change_personality <k|s> <node_name>
  16. # k = Kubernetes
  17. # s = Slurm
  18. new_personality=$1
  19. dnsdomain=`dnsdomainname`
  20. shift
  21. if [ $new_personality == "k" ]
  22. then
  23. # Change Personality to Kubernetes
  24. echo "[INFO] Changing personality to Kubernetes"
  25. for node in $*
  26. do
  27. echo -n "$node"
  28. scontrol update nodename=$node state=DRAIN reason="used for k8s"
  29. kubectl uncordon $node.$dnsdomain > /dev/null
  30. echo " [OK]"
  31. done
  32. elif [ $new_personality == "s" ]
  33. then
  34. # Change Personality to Slurm
  35. echo "[INFO] Changing personality to Slurm"
  36. for node in $*
  37. do
  38. echo -n "$node"
  39. kubectl cordon $node.$dnsdomain > /dev/null
  40. scontrol update nodename=$node state=IDLE reason="used for Slurm"
  41. echo " [OK]"
  42. done
  43. else
  44. echo "[ERROR] $new_personality is not a valid personality. Use 'k' or 's'"
  45. fi