Ejemplo n.º 1
0
def send_status(post_data):
    """
    Due to the potentially sensitive nature of TAC case data, it is necessary (for the time being) to limit CASE API
    access to Cisco employees and contractors, until such time as a more appropriate authentication method can be added
    """
    # Check if user is cisco.com
    person_id = post_data["data"]["personId"]
    email = get_email(person_id)
    if not check_cisco_user(email):
        return "Sorry, CASE API access is limited to Cisco Employees for the time being"

    # Determine the Spark Room to send reply to
    room_id = post_data["data"]["roomId"]

    # Get the details about the message that was sent.
    message_id = post_data["data"]["id"]
    message_in = spark.messages.get(message_id)
    content = extract_message("/title", message_in.text)

    # Find case number
    case_number = get_case_number(content, room_id)

    if case_number:
        # Create case object
        case = CaseDetail(get_case_details(case_number))
        if case.count > 0:
            # Get case status and severity
            case_status = case.status
            case_severity = case.severity
            if "Closed" in case_status:
                message = "Status for SR {} is {}".format(
                    case_number, case_status)
            else:
                message = "Status for SR {} is {} and Severity is {}".format(
                    case_number, case_status, case_severity)
Ejemplo n.º 2
0
def send_owner(post_data):
    """
    Due to the potentially sensitive nature of TAC case data, it is necessary (for the time being) to limit CASE API
    access to Cisco employees and contractors, until such time as a more appropriate authentication method can be added
    """
    # Check if user is cisco.com
    person_id = post_data["data"]["personId"]
    email = get_email(person_id)
    if not check_cisco_user(email):
        return "Sorry, CASE API access is limited to Cisco Employees for the time being"

    # Determine the Spark Room to send reply to
    room_id = post_data["data"]["roomId"]

    # Get the details about the message that was sent.
    message_id = post_data["data"]["id"]
    message_in = spark.messages.get(message_id)
    content = extract_message("/owner", message_in.text)

    # Find case number
    case_number = get_case_number(content, room_id)

    if case_number:
        # Create case object
        case = CaseDetail(get_case_details(case_number))
        if case.count > 0:
            # Get owner info from case
            owner_id = case.owner_id
            owner_first = case.owner_first
            owner_last = case.owner_last
            owner_email = case.owner_email

            message = "Case owner for SR {} is: {} {} ({})".format(
                case_number, owner_first, owner_last, owner_email)
Ejemplo n.º 3
0
def send_feedback(post_data, type):
    # Determine the Spark Room to send reply to
    room_id = post_data["data"]["roomId"]

    # Get the details about the message that was sent.
    message_id = post_data["data"]["id"]
    message_in = spark.messages.get(message_id)
    content = extract_message("/feedback", message_in.text)

    # Get personId of the person submitting feedback
    person_id = post_data["data"]["personId"]

    if type == "feedback":
        email = get_email(person_id)
        if content:
            message = "User {} provided the following feedback:<br>{}".format(
                email, content)
        else:
            message = None
    elif type == "reply":
        message = "Thank you. Your feedback has been sent to developers"
    else:
        message = None

    return message
Ejemplo n.º 4
0
def send_updated(post_data):
    """
    Due to the potentially sensitive nature of TAC case data, it is necessary (for the time being) to limit CASE API
    access to Cisco employees and contractors, until such time as a more appropriate authentication method can be added
    """
    # Check if user is cisco.com
    person_id = post_data["data"]["personId"]
    email = get_email(person_id)
    if not check_cisco_user(email):
        return "Sorry, CASE API access is limited to Cisco Employees for the time being"

    # Determine the Spark Room to send reply to
    room_id = post_data["data"]["roomId"]

    message_id = post_data["data"]["id"]
    message_in = spark.messages.get(message_id)
    content = extract_message("/updated", message_in.text)

    # Find case number
    case_number = get_case_number(content, room_id)

    if case_number:
        # Create case object
        case = CaseDetail(get_case_details(case_number))
        if case.count > 0:
            # Get the update datetime from the case details
            case_update_date = case.updated
            case_update_date = datetime.strptime(case_update_date,
                                                 '%Y-%m-%dT%H:%M:%SZ')
            message = "Last update for SR {} was: {}".format(
                case_number, case_update_date)

            # Get time delta between last updated and now
            current_time = datetime.now()
            current_time = current_time.replace(microsecond=0)
            time_delta = current_time - case_update_date
            status = case.status
            if "Closed" in status:
                message = message + "<br>Case is now Closed, {} since case closure".format(
                    time_delta)
            else:
                # If case hasn't been updated in 3 days, make the text bold
                if time_delta > timedelta(3):
                    message = message + "<br>**{} since last update**".format(
                        time_delta)
                else:
                    message = message + "<br>{} since last update".format(
                        time_delta)
Ejemplo n.º 5
0
def send_bug(post_data):
    """
    Due to the potentially sensitive nature of TAC case data, it is necessary (for the time being) to limit CASE API
    access to Cisco employees and contractors, until such time as a more appropriate authentication method can be added
    """
    # Check if user is cisco.com
    person_id = post_data["data"]["personId"]
    email = get_email(person_id)
    if not check_cisco_user(email):
        return "Sorry, CASE API access is limited to Cisco Employees for the time being"

    # Determine the Spark Room to send reply to
    room_id = post_data["data"]["roomId"]

    # Get the details about the message that was sent.
    message_id = post_data["data"]["id"]
    message_in = spark.messages.get(message_id)
    content = extract_message("/bug", message_in.text)

    # Find case number
    case_number = get_case_number(content, room_id)

    # Define URL for RMA lookup link
    bug_url = "https://bst.cloudapps.cisco.com/bugsearch/bug/"
    internal_bug_url = "http://cdets.cisco.com/apps/dumpcr?&content=summary&format=html&identifier="

    if case_number:
        # Create case object
        case = CaseDetail(get_case_details(case_number))
        if case.count > 0:
            # Get Bugs from case
            bugs = case.bugs
            if bugs is not None:
                if type(bugs) is list:
                    message = "The Bugs for SR {} are:\n".format(case_number)
                    for b in bugs:
                        message = message + "* {} (<a href=\"{}{}\">external</a> | <a href=\"{}{}\">internal</a>)\n".format(
                            b, bug_url, b, internal_bug_url, b)
                else:
                    message = "The Bug for SR {} is: {} (<a href=\"{}{}\">external</a> | <a href=\"{}{}\">internal</a>)".format(
                        case_number, bugs, bug_url, bugs, internal_bug_url,
                        bugs)
            else:
                message = "There are no Bugs for SR {}".format(case_number)
Ejemplo n.º 6
0
def send_rma_numbers(post_data):
    """
    Due to the potentially sensitive nature of TAC case data, it is necessary (for the time being) to limit CASE API
    access to Cisco employees and contractors, until such time as a more appropriate authentication method can be added
    """
    # Check if user is cisco.com
    person_id = post_data["data"]["personId"]
    email = get_email(person_id)
    if not check_cisco_user(email):
        return "Sorry, CASE API access is limited to Cisco Employees for the time being"

    # Determine the Spark Room to send reply to
    room_id = post_data["data"]["roomId"]

    # Get the details about the message that was sent.
    message_id = post_data["data"]["id"]
    message_in = spark.messages.get(message_id)
    content = extract_message("/rma", message_in.text)

    # Find case number
    case_number = get_case_number(content, room_id)

    # Define URL for RMA lookup link
    rma_url = "http://msvodb.cloudapps.cisco.com/support/serviceordertool/orderDetails.svo?orderNumber="

    if case_number:
        # Create case object
        case = CaseDetail(get_case_details(case_number))
        if case.count > 0:
            # Get RMAs from case
            rmas = case.rmas
            if rmas is not None:
                if type(rmas) is list:
                    message = "The RMAs for SR {} are:\n".format(case_number)
                    for r in rmas:
                        message = message + "* <a href=\"{}{}\">{}</a>\n".format(
                            rma_url, r, r)
                else:
                    message = "The RMA for SR {} is: <a href=\"{}{}\">{}</a>".format(
                        case_number, rma_url, rmas, rmas)
            else:
                message = "There are no RMAs for SR {}".format(case_number)
Ejemplo n.º 7
0
def send_device(post_data):
    """
    Due to the potentially sensitive nature of TAC case data, it is necessary (for the time being) to limit CASE API
    access to Cisco employees and contractors, until such time as a more appropriate authentication method can be added
    """
    # Check if user is cisco.com
    person_id = post_data["data"]["personId"]
    email = get_email(person_id)
    if not check_cisco_user(email):
        return "Sorry, CASE API access is limited to Cisco Employees for the time being"

    # Determine the Spark Room to send reply to
    room_id = post_data["data"]["roomId"]

    message_id = post_data["data"]["id"]
    message_in = spark.messages.get(message_id)
    content = extract_message("/device", message_in.text)

    # Find case number
    case_number = get_case_number(content, room_id)

    if case_number:
        # Create case object
        case = CaseDetail(get_case_details(case_number))
        if case.count > 0:
            # Get device info from case
            device_serial = case.serial
            device_hostname = case.hostname
            if device_serial:
                message = "Device serial number for SR {} is: {}".format(
                    case_number, device_serial)
            else:
                message = "Device serial number for SR {} is not provided".format(
                    case_number)
            if device_hostname:
                message = message + "<br>Device hostname is {}".format(
                    device_hostname)
            else:
                message = message + "<br>Device hostname not provided"