how to change smslib outbound text - sendmessage

I change the message as you can see on my codes but the receiver receives different message. as you can see on my results below the message sent was "test message". pls pls need help:(
OutboundNotification outboundNotification = new OutboundNotification();
System.out.println("Example: Send message from a serial gsm modem.");
System.out.println(Library.getLibraryDescription());
System.out.println("Version: " + Library.getLibraryVersion());
SerialModemGateway gateway = new SerialModemGateway("modem.com1","COM6",115200, "Huawei", "");
gateway.setInbound(true);
gateway.setOutbound(true);
gateway.setSimPin("0000");
Service.getInstance().setOutboundMessageNotification(outboundNotification);
Service.getInstance().addGateway(gateway);
Service.getInstance().startService();
System.out.println();
System.out.println("Modem Information:");
System.out.println(" Manufacturer: " + gateway.getManufacturer());
System.out.println(" Model: " + gateway.getModel());
System.out.println(" Serial No: " + gateway.getSerialNo());
System.out.println(" SIM IMSI: " + gateway.getImsi());
System.out.println(" Signal Level: " + gateway.getSignalLevel() + " dBm");
System.out.println(" Battery Level: " + gateway.getBatteryLevel() + "%");
System.out.println();
// Send a message synchronously.
OutboundMessage msg = new OutboundMessage("09085928249", "que onda como andas!");
Service.getInstance().sendMessage(msg);
System.out.println(msg);
System.out.println("Now Sleeping - Hit <enter> to terminate.");
System.in.read();
Service.getInstance().stopService();
}
result
Gateway Id: modem.com1
Message Id: 0
Message UUID: eeecf9ba-5cb6-49f3-a20f-4e1901e2527a
Encoding: 7-bit
Date: Thu Jan 26 18:24:18 CST 2017
SMSC Ref No: 95
Recipient: +639085928249
Dispatch Date: Thu Jan 26 18:24:22 CST 2017
Message Status: SENT
Failure Cause: NO_ERROR
Validity Period (Hours): -1
Status Report: false
Source / Destination Ports: -1 / -1
Flash SMS: false
Text: Test Message
PDU data: D4F29C0E6A96E7F3F0B90C
Scheduled Delivery: null

Related

Sql server connection lost error received from databricks. Will connection pooling be useful?

My databricks notebook randomly gives error 107: Transport connection error connection timed out for MySQL server. Once in 50 runs the system receives this type of an error.
From databricks I am trying to access the SQL server. I am only using one SQL server. The SQL server has configurations stored in tables that I need in data ricks to do compute. Also audit tables are present on SQL server, so through databricks I'm inserting records in SQL database after every process.
When I reached out to Microsoft with this error they suggested to use connection pooling to mitigate the error. Will connection pooling help or should I try something else?
The code used to connect to MySQL is below:
def execute_query_mysql(self, query, get_single_result=None):
""" Module for executing queries"""
mysql_connection = None
try:
status_message = "Starting function to execute a MySQLquery : "+str(query)
logger.info(status_message, extra=self.execution_context.get_context())
if query:
query = query.strip()
mysql_connection = self.get_my_sql_connection()
cursor = mysql_connection.cursor(dictionary=True)
status_message = "Created connection to MySQL"
#logger.debug(status_message, extra=self.execution_context.get_context())
status_message = "Executing query on MySQL"
#logger.debug(status_message, extra=self.execution_context.get_context())
if query.lower().startswith("select"):
cursor.execute(query)
if get_single_result:
result = cursor.fetchone()
else:
result = cursor.fetchall()
elif query.lower().startswith("insert into"):
result = cursor.execute(query)
if result != 0:
result = cursor.lastrowid
cursor.execute("commit")
else:
cursor.execute(query)
cursor.execute("commit")
result = ""
#closing Mysql connections
mysql_connection.close()
cursor.close()
status_message = "Executed query on MySQL with result : " + str(result)
logger.debug(status_message, extra=self.execution_context.get_context())
return result
except Exception as exception:
error = "ERROR in " + self.execution_context.get_context_param("current_module") + \
" ERROR MESSAGE: " + str(traceback.format_exc())
self.execution_context.set_context({"traceback": error})
logger.error(error, extra=self.execution_context.get_context())
raise exception
def get_my_sql_connection(self):
"""Module for getting mySQL connection"""
try:
status_message = "Starting function to fetch my-sql connection"
logger.info(status_message, extra=self.execution_context.get_context())
secret = json.loads(json.dumps(self.configuration.get_configuration([CommonConstants.ENVIRONMENT_PARAMS_KEY, "di_keys"])))
host = secret["mysql_host"]
user = secret["mysql_username"]
encoded_password = secret["mysql_password"]
password = self.decrypt_value(encoded_password)
port = secret["mysql_port"]
db = secret["mysql_db"]
ssl_ca_file_path = self.configuration.get_configuration(
[CommonConstants.ENVIRONMENT_PARAMS_KEY, "mysql_certificate_file_path"])
if len(host) == 0 or len(user) == 0 or len(password) == 0 or len(db) == 0 \
or len(port) == 0:
status_message = "Invalid configurations for " + MODULE_NAME + " in " + \
CommonConstants.ENVIRONMENT_CONFIG_FILE
logger.error(status_message, extra=self.execution_context.get_context())
raise Exception
if ssl_ca_file_path:
mysql_connection = connection.MySQLConnection(
host=host, user=user, passwd=password, db=db, port=int(port),
ssl_verify_cert=True, ssl_ca=ssl_ca_file_path, connect_timeout=6000)
else:
mysql_connection = connection.MySQLConnection(
host=host, user=user, passwd=password, db=db, port=int(port))
status_message = "Connection to MySQL successful"
return mysql_connection
except Exception as exception:
error = "ERROR in " + self.execution_context.get_context_param("current_module") + \
" ERROR MESSAGE: " + str(exception)
self.execution_context.set_context({"traceback": error})
logger.error(error, extra=self.execution_context.get_context())
raise exception
def decrypt_value(self, encoded_string):
"""
Purpose : This method decrypts encoded string
Input : encoded value
Output : decrypted value
"""
try:
status_message = "Started decoding for value:" + encoded_string
#logger.debug(status_message, extra=self.execution_context.get_context())
decoded_string = base64.b64decode(encoded_string).decode()
status_message = "Completed decoding value"
#logger.info(status_message, extra=self.execution_context.get_context())
return decoded_string
except Exception as exception:
status_message = "Error occured in decrypting value"
error = "ERROR in " + self.execution_context.get_context_param("module_name") + \
" ERROR MESSAGE: " + str(traceback.format_exc())
self.execution_context.set_context({"traceback": error})
logger.error(status_message, extra=self.execution_context.get_context())
raise exception

How do I need to format my message to fill subject and body in automated email script?

I am trying to set up an automated alert emailing system for a project and I can format the email properly when it's plain text but when I try to add variables it won't format properly. I am pulling data from a JSON file and I can pull the data I just can't combine it with the email inside the triple quotes (""").
Here is the plain text
message = """\
Subject: AMLD Alert
Something is wrong."""
But when I add in my variables it will not fill in the body, but the subject will.
message = 'Subject: AMLD Alert for ' + d[0]['Project Name'] + ' Project'
'Car: ' + d[0]['CarID'] +' Driven by: ' + d[0]['DriverID'] + ' is sending alert '+ d[0]['Message']
Here is the entire script if it will help.
import json
import smtplib
import ssl
import socket
socket.getaddrinfo('localhost', 8080)
#Webiste use to help me build script
#https://realpython.com/python-send-email/
port = 587 # For starttls
smtp_server = "smtp.outlook.com"
sender_email = "MyWorkOutlookEmail" # Enter your address
password = 'Password'
receiver_email = "MyPersonalGmail" # Enter receiver address
context = ssl.create_default_context()
#Start of ITTT Code
with open('C:/Python/Messaging/Mes_V1.json') as f:
d = json.load(f)
if d[0]['Alert'] == "High":
print('Sending high alert email...\n')
message = 'Subject: AMLD Alert for ' + d[0]['Project Name'] + ' Project'
'Car: ' + d[0]['CarID'] +' Driven by: ' + d[0]['DriverID'] + ' is sending alert '+ d[0]['Message']
elif d[0]['Alert'] == "Medium":
print('Sending medium alert email...\n')
else:
print('Sending low alert email...\n')
context = ssl.create_default_context()
with smtplib.SMTP(smtp_server, port) as server:
print('Connecting to Server...\n')
server.starttls(context=context)
print('Logging in...\n')
server.login(sender_email, password)
server.sendmail(sender_email, receiver_email, message)
print('Email sent.\n')
I'm not sure if Outlook is affecting it in any way or if I need to format the message differently, any help would be very appreciated!

Display text as html in Razor page

I've just started using Blazor and Razor pages.. it's a lot better than my old plain html pages I was building. But I'm having a problem converting my strings of html I build into actual HTML. Now, this works if I copy and paste my string and save that as an html page. It displays as html no problem. However, when I try to get my Razor page to display it, it displays as plain text. Even trying the trick:
<div>
#(new HtmlString(htmlString))
</div>
displays plain text. This is going to be painful as it's kind of long, but here is the string I'm trying to convert:
"<pre><br><b>STATION INFO</b><br><br> Extension: 34263 Lock Messages? n BCC: 0 <br> Type: 9630 Security Code: 12345 TN: 1<br> Port: S17746 Coverage Path 1: 132 COR: 44<br> Name: Lastname, Firstname Coverage Path 2: COS: 1<br><br><b>STATION OPTIONS</b><br> Time of Day Lock Table: <br> Loss Group: 19 Personalized Ringing Pattern: 1<br> Message Lamp Ext: 34263<br> Speakerphone: 2-way Mute Button Enabled? y<br> Display Language: english Expansion Module? <br> Survivable GK Node Name: <br> Survivable COR: internal Media Complex Ext: <br> Survivable Trunk Dest? IP SoftPhone? y<br><br> IP Video Softphone? n<br><br> Customizable Labels? y<br><br><br> <b>FEATURE OPTIONS</b><br><br> LWC Reception: spe Auto Select Any Idle Appearance? n<br> LWC Activation? y Coverage Msg Retrieval? y<br> LWC Log External Calls? n Auto Answer: none<br> CDR Privacy? n Data Restriction? n<br> Redirect Notification? y Idle Appearance Preference? n<br> Per Button Ring Control? n Bridged Idle Line Preference? n<br> Bridged Call Alerting? n Restrict Last Appearance? y<br> Active Station Ringing: continuous<br> EMU Login Allowed? n<br> H.320 Conversion? n Per Station CPN - Send Calling Number? y<br> Service Link Mode: as-needed EC500 State: unknown<br> Multimedia Mode: enhanced Audible Message Waiting? n<br> MWI Served User Type: sip-adjunct Display Client Redirection? n</pre><br>"
it's being built by my method that returns a string. For fun, here is my method:
public static string CreateStationString(List<StarfishStation> html)
{
var myHTML1 =
"<pre>" + "<br>" +
"<b>STATION INFO</b>" + "<br>" +
"" + "<br>" +
" Extension: " + html[0].DeftyExtension.PadRight(29, ' ') + "Lock Messages? " + html[0].DeftyMessagelock.PadRight(9, ' ') + "BCC: 0 <br>" +
" Type: " + html[0].DeftyDisplaysettype.PadRight(29, ' ') + "Security Code: " + html[0].DeftySecuritycode.PadRight(10, ' ') + "TN: " + html[0].DeftyTenantpartitionnumber + "<br>" +
" Port: " + html[0].DeftyPort.PadRight(27, ' ') + "Coverage Path 1: " + html[0].DeftyCoveragepath.PadRight(9, ' ') + "COR: " + html[0].DeftyCor + "<br>" +
" Name: " + html[0].DeftyName.PadRight(27, ' ') + "Coverage Path 2: " + html[0].DeftyCoverage2path.PadRight(9, ' ') + "COS: " + html[0].DeftyCos + "<br><br>" +
"<b>STATION OPTIONS</b>" + "<br>" +
" Time of Day Lock Table: <br>" +
" Loss Group: " + html[0].DeftyLossgroup + " Personalized Ringing Pattern: " + html[0].DeftyPersonalizedringpattern + "<br>" +
" Message Lamp Ext: " + html[0].DeftyMessagewaitlamplextension + "<br>" +
" Speakerphone: " + html[0].DeftySpeakerphone + " Mute Button Enabled? " + html[0].DeftyMutebutton + "<br>" +
" Display Language: " + html[0].DeftyLanguage.PadRight(32, ' ') + "Expansion Module? " + html[0].DeftyExpansionmodule + "<br>" +
" Survivable GK Node Name: <br>" +
" Survivable COR: internal Media Complex Ext: <br>" +
" Survivable Trunk Dest? IP SoftPhone? " + html[0].DeftyIpsoftphone + "<br>" +
"" + "<br>" +
" IP Video Softphone? n<br>" +
"<br>" +
" Customizable Labels? y<br><br>" +
"<br>" +
" <b>FEATURE OPTIONS</b><br><br>" +
" LWC Reception: " + html[0].DeftyLwcreception.PadRight(20, ' ') + "Auto Select Any Idle Appearance? " + html[0].DeftyIdleappearancepreference + "<br>" +
" LWC Activation? " + html[0].DeftyLwcactivation.PadRight(29, ' ') + "Coverage Msg Retrieval? " + html[0].DeftyCoveragemessageretrieval + "<br>" +
" LWC Log External Calls? " + html[0].DeftyLwclogexterncall.PadRight(40, ' ') + "Auto Answer: " + html[0].DeftyAutoanswer + "<br>" +
" CDR Privacy? " + html[0].DeftyCdrprivacy.PadRight(35, ' ') + "Data Restriction? " + html[0].DeftyDatarestriction + "<br>" +
" Redirect Notification? " + html[0].DeftyRedirectnotification.PadRight(25, ' ') + "Idle Appearance Preference? " + html[0].DeftyIdleappearancepreference + "<br>" +
" Per Button Ring Control? " + html[0].DeftyPerbuttonnringcontrol.PadRight(23, ' ') + "Bridged Idle Line Preference? n" + "<br>" +
" Bridged Call Alerting? " + html[0].DeftyBridgecallalerting.PadRight(27, ' ') + "Restrict Last Appearance? " + html[0].DeftyRestrictlastappearance + "<br>" +
" Active Station Ringing: " + html[0].DeftyActivestationringing + "<br>" +
" EMU Login Allowed? " + html[0].DeftyEMULoginAllowed + "<br>" +
" H.320 Conversion? " + html[0].DeftyH320conv.PadRight(14, ' ') + "Per Station CPN - Send Calling Number? " + html[0].DeftyCpnrestriction + "<br>" +
" Service Link Mode: " + html[0].DeftyServicelinkmode.PadRight(31, ' ') + "EC500 State: unknown<br>" + //check ec500
" Multimedia Mode: " + html[0].DeftyMultimediamode.PadRight(28, ' ') + "Audible Message Waiting? " + html[0].DeftyAudiblemessagewaiting + "<br>" +
" MWI Served User Type: " + html[0].DeftyMessagewaitindicatortype.PadRight(25, ' ') + "Display Client Redirection? n</pre><br>";
return myHTML1;
}
When I look at the frame source, here's what I see:
<div>
<pre><br><b>STATION INFO</b><br><br> Extension: 34263 Lock Messages? n BCC: 0 <br> Type: 9630 Security Code: 12345 TN: 1<br> Port: S17746 Coverage Path 1: 132 COR: 44<br> Name: Lastname Firstname Coverage Path 2: COS: 1<br><br><b>STATION OPTIONS</b><br> Time of Day Lock Table: <br> Loss Group: 19 Personalized Ringing Pattern: 1<br> Message Lamp Ext: 34263<br> Speakerphone: 2-way Mute Button Enabled? y<br> Display Language: english Expansion Module? <br> Survivable GK Node Name: <br> Survivable COR: internal Media Complex Ext: <br> Survivable Trunk Dest? IP SoftPhone? y<br><br> IP Video Softphone? n<br><br> Customizable Labels? y<br><br><br> <b>FEATURE OPTIONS</b><br><br> LWC Reception: spe Auto Select Any Idle Appearance? n<br> LWC Activation? y Coverage Msg Retrieval? y<br> LWC Log External Calls? n Auto Answer: none<br> CDR Privacy? n Data Restriction? n<br> Redirect Notification? y Idle Appearance Preference? n<br> Per Button Ring Control? n Bridged Idle Line Preference? n<br> Bridged Call Alerting? n Restrict Last Appearance? y<br> Active Station Ringing: continuous<br> EMU Login Allowed? n<br> H.320 Conversion? n Per Station CPN - Send Calling Number? y<br> Service Link Mode: as-needed EC500 State: unknown<br> Multimedia Mode: enhanced Audible Message Waiting? n<br> MWI Served User Type: sip-adjunct Display Client Redirection? n</pre><br>
</div>
Sorry this is so long.. but can anyone please help me out?
Thanks!
Dave M.
Wow ok.. so stumbled upon the answer:
<div>
#((MarkupString)htmlString)
</div>
instead of:
<div>
#(new HtmlString(htmlString))
</div>
found the answer here: Convert plain text with html tags to html string and render it in Blazor

Device dependency in ZABBIX 4.2

Suppose the following scenario in using Zabbix 4.2. We have a core switch, two distributed switches and 20 access switches, where the distributed switches are connected to the core and 10 access switches are connected to each distributed switch. I am monitoring all of them using SNMP v2c and using the template cisco switches (the official one). Now the problem arises as I cannot define device dependency in zabbix easily. By easily, I mean that if a distributed switch goes out, I want to have the alarm for that device and not for all access switches connected to it. I could define it as follows. Change the triggers for each device and made them dependent on the corresponding trigger for distributed switches. However, this is too time consuming. What should I do? Any help is appreciated.
You are right, there isn't an easy way to set this kind of dependancy.
I had to manage the same situation a while ago and I wrote a python dependancy setter which uses a "dependent hostgroup <--> master host" logic.
You can modify it to fit your needs (see masterTargetTriggerDescription and slaveTargetTriggerDescription for the dependancy targets), it works but contains little error checking: use at your own risk!
import csv
import re
import json
from zabbix.api import ZabbixAPI
# Zabbix Server endpoint
zabbixServer = 'https://yourzabbix/zabbix/'
zabbixUser = 'admin'
zabbixPass = 'zabbix'
zapi = ZabbixAPI(url=zabbixServer, user=zabbixUser, password=zabbixPass)
# Hostgrop variables - to reference IDs while building API parameters
hostGroupNames = [] # list = array
hostGroupId = {} # dict = associative array
# Csv file for dep settings - see the format:
"""
Hostgroup;Master
ACCESS_1;DistSwitch1
ACCESS_2;DistSwitch1
ACCESS_5;DistSwitch2
ACCESS_6;DistSwitch2
DIST;CoreSwitch1
"""
fileName = 'dependancy.csv'
masterTargetTriggerDescription = '{HOST.NAME} is unavailable by ICMP'
slaveTargetTriggerDescription = '{HOST.NAME} is unavailable by ICMP|Zabbix agent on {HOST.NAME} is unreachable'
# Read CSV file
hostFile = open(fileName)
hostReader = csv.reader(hostFile, delimiter=';', quotechar='|')
hostData = list(hostReader)
# CSV Parsing
for line in hostData:
hostgroupName = line[0]
masterName = line[1]
slaveIds = []
masterId = zapi.get_id('host', item=masterName, with_id=False, hostid=None)
hostGroupId = zapi.get_id('hostgroup', item=hostgroupName, with_id=False, hostid=None)
masterTriggerObj = zapi.trigger.get(hostids=masterId, filter=({'description': masterTargetTriggerDescription}) )
print "Group: " + hostgroupName + " - ID: " + str(hostGroupId)
print "Master host: " + masterName + " - ID: " + str(masterId)
print "Master trigger: " + masterTriggerObj[0]['description'] + " - ID: " + str(masterTriggerObj[0]['triggerid'])
# cycle through slave hosts
hostGroupObj = zapi.hostgroup.get(groupids=hostGroupId, selectHosts='extend')
for host in hostGroupObj[0]['hosts']:
#exclude master
if host['hostid'] != str(masterId):
print " - Host Name: " + host['name'] + " - ID: " + host['hostid'] + " - MASTER: " + str(masterId)
# cycle for all slave's triggers
slaveTargetTriggerObj = zapi.trigger.get(hostids=host['hostid'])
#print json.dumps(slaveTargetTriggerObj)
for slaveTargetTrigger in slaveTargetTriggerObj:
# search for dependancy targets
if re.search(slaveTargetTriggerDescription, slaveTargetTrigger['description'] ,re.IGNORECASE):
print " - Trigger: " + slaveTargetTrigger['description'] + " - ID: " + slaveTargetTrigger['triggerid']
# Clear existing dep. from the trigger, then create the new dep.
clear = zapi.trigger.deletedependencies(triggerid=slaveTargetTrigger['triggerid'].encode())
result = zapi.trigger.adddependencies(triggerid=slaveTargetTrigger['triggerid'].encode(), dependsOnTriggerid=masterTriggerObj[0]['triggerid'])
print "----------------------------------------"
print ""
I updated the code contributed by Simone Zabberoni and rewritten it to work with Python 3, PyZabbix, and YAML.
#!/usr/bin/python3
import re
import yaml
#https://pypi.org/project/py-zabbix/
from pyzabbix import ZabbixAPI
# Zabbix Server endpoint
zabbix_server = 'https://zabbix.example.com/zabbix/'
zabbix_user = 'zbxuser'
zabbix_pass = 'zbxpassword'
# Create ZabbixAPI class instance
zapi = ZabbixAPI(zabbix_server)
# Enable HTTP auth
zapi.session.auth = (zabbix_user, zabbix_pass)
# Login (in case of HTTP Auth, only the username is needed, the password, if passed, will be ignored)
zapi.login(zabbix_user, zabbix_pass)
# Hostgrop variables - to reference IDs while building API parameters
hostGroupNames = [] # list = array
hostGroupId = {} # dict = associative array
# yaml file for dep settings - see the format:
"""
pvebar16 CTs:
master: pvebar16.example.com
masterTargetTriggerDescription: 'is unavailable by ICMP'
slaveTargetTriggerDescription: 'is unavailable by ICMP|Zabbix agent is unreachable for 5 minutes'
"""
fileName = 'dependancy.yml'
with open('dependancy.yml') as f:
hostData = yaml.load(f)
for groupyml in hostData.keys():
masterTargetTriggerDescription = hostData[groupyml]['masterTargetTriggerDescription']
slaveTargetTriggerDescription = hostData[groupyml]['slaveTargetTriggerDescription']
masterName = hostData[groupyml]['master']
hostgroupName = groupyml
slaveIds = []
masterId = zapi.host.get(filter={'host': masterName},output=['hostid'])[0]['hostid']
hostGroupId = zapi.hostgroup.get(filter={'name': hostgroupName},output=['groupid'])[0]['groupid']
masterTriggerObj = zapi.trigger.get(host=masterName, filter={'description': masterTargetTriggerDescription}, output=['triggerid','description'])
print("Group: " + hostgroupName + " - ID: " + str(hostGroupId))
print("Master host: " + masterName + " - ID: " + str(masterId))
print("Master trigger: " + masterTriggerObj[0]['description'] + " - ID: " + str(masterTriggerObj[0]['triggerid']))
# cycle through slave hosts
hostGroupObj = zapi.hostgroup.get(groupids=hostGroupId, selectHosts='extend')
for host in hostGroupObj[0]['hosts']:
#exclude master
if host['hostid'] != str(masterId):
print(" - Host Name: " + host['name'] + " - ID: " + host['hostid'] + " - MASTER: " + str(masterId))
# cycle for all slave's triggers
slaveTargetTriggerObj = zapi.trigger.get(hostids=host['hostid'])
for slaveTargetTrigger in slaveTargetTriggerObj:
# search for dependancy targets
if re.search(slaveTargetTriggerDescription, slaveTargetTrigger['description'] ,re.IGNORECASE):
print(" - Trigger: " + slaveTargetTrigger['description'] + " - ID: " + slaveTargetTrigger['triggerid'])
# Clear existing dep. from the trigger, then create the new dep.
clear = zapi.trigger.deletedependencies(triggerid=slaveTargetTrigger['triggerid'])
result = zapi.trigger.adddependencies(triggerid=slaveTargetTrigger['triggerid'], dependsOnTriggerid=masterTriggerObj[0]['triggerid'])
print("----------------------------------------")
print("")

EMR Job Failing

Folks,
The following python script is terminating with
job state = FAILED
and
Last State Change: Access denied checking streaming input path: s3n://elasticmapreduce/samples/wordcount/input/
Code:
import boto
import boto.emr
from boto.emr.step import StreamingStep
from boto.emr.bootstrap_action import BootstrapAction
import time
S3_BUCKET="mytesetbucket123asdf"
conn = boto.connect_emr()
step = StreamingStep(
name='Wordcount',
mapper='s3n://elasticmapreduce/samples/wordcount/wordSplitter.py',
reducer='aggregate',
input='s3n://elasticmapreduce/samples/wordcount/input/',
output='s3n://' + S3_BUCKET + '/wordcount/output/2013-10-25')
jobid = conn.run_jobflow(
name="test",
log_uri="s3://" + S3_BUCKET + "/logs/",
visible_to_all_users="True",
steps = [step],)
state = conn.describe_jobflow(jobid).state
print "job state = ", state
print "job id = ", jobid
while state != u'COMPLETED':
print time.localtime()
time.sleep(10)
state = conn.describe_jobflow(jobid).state
print conn.describe_jobflow(jobid)
print "job state = ", state
print "job id = ", jobid
print "final output can be found in s3://" + S3_BUCKET + "/output" + TIMESTAMP
print "try: $ s3cmd sync s3://" + S3_BUCKET + "/output" + TIMESTAMP + " ."
The problem is somewhere in boto... If we specify IAM user instead of using Roles, job works perfectly. EMR supports IAM Roles ofcourse... and the IAM role we tested with has full rights to execute any task, so its not a mis-configuration issue...