Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. #!/bin/bash
  2. sudo easy_install-2.y pip
  3. sudo /usr/local/bin/pip2 install librosa
  4.  
  5. try:
  6. clusterId=argv[1]
  7. except:
  8. print("Syntax: emr_install.py [ClusterId]")
  9. import sys
  10. sys.exit(1)
  11.  
  12. emrclient=client('emr')
  13.  
  14. # Get list of core nodes
  15. instances=emrclient.list_instances(ClusterId=clusterId,InstanceGroupTypes=['CORE'])['Instances']
  16. instance_list=[x['Ec2InstanceId'] for x in instances]
  17.  
  18. # Attach tag to core nodes
  19. ec2client=client('ec2')
  20. ec2client.create_tags(Resources=instance_list,Tags=[{"Key":"environment","Value":"coreNodeLibs"}])
  21.  
  22. ssmclient=client('ssm')
  23.  
  24. # Run shell script to install libraries
  25.  
  26. command=ssmclient.send_command(Targets=[{"Key": "tag:environment", "Values":["coreNodeLibs"]}],
  27. DocumentName='AWS-RunShellScript',
  28. Parameters={"commands":["bash /home/hadoop/install_librosa.sh"]},
  29. TimeoutSeconds=3600)['Command']['CommandId']
  30.  
  31. command_status=ssmclient.list_commands(
  32. CommandId=command,
  33. Filters=[
  34. {
  35. 'key': 'Status',
  36. 'value': 'SUCCESS'
  37. },
  38. ]
  39. )['Commands'][0]['Status']
  40.  
  41. time.sleep(30)
  42.  
  43. print("Command:" + command + ": " + command_status)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement