def main(): # get settings from config file d42_username, d42_password, d42_url,\ ibm_url, debug, retry, order_no_type = config.get_config('ibm') if not ibm_url.startswith('https'): print '[!] Error in config file. IBM URL must start with HTTPS.\n\tExiting...' sys.exit() # init d42 = Device42(d42_username, d42_password, d42_url, debug, retry) ibm = IBM(ibm_url, debug, retry, order_no_type) #ibm.run_warranty_check('8852','0645455') # get data from Device42 orders = d42.get_purchases() already_there = [] dates = {} for order in orders: line_items = order['line_items'] for line_item in line_items: end = line_item['line_end_date'] start = line_item['line_start_date'] devices = line_item['devices'] for device in devices: serial = device['serial_no'] dates.update({serial:[start,end]}) if serial not in already_there: already_there.append(serial) devices = d42.get_serials() items = [[x['device_id'],x['serial_no'],x['manufacturer']] for x in devices['Devices'] if x['serial_no'] and x['manufacturer']] for item in items: d42_id, serial, vendor = item print '\t[+] IBM serial #: %s' % serial """ if 'ibm' in vendor.lower(): #if len(serial) <= 7: # testing only original DELL...remove this warranty = ibm.run_warranty_check(dev_type, serial) if warranty: wend = warranty['line_end_date'] wstart = warranty['line_start_date'] # update or duplicate? Compare warranty dates by serial if serial in already_there: dstart, dend = dates[serial] if dstart == wstart and dend == wend: # duplicate print '[!] Duplicate found. Purchase for SKU "%s" is already uploaded' % serial else: # add new line_item d42.upload_data(warranty) else: # upload new warranty and add it's serial to 'already_there' d42.upload_data(warranty) already_there.append(serial) """ print '[!] IBM warranty check is not implemented yet.'
def main(): # get settings from config file d42_username, d42_password, d42_url,\ hp_url, debug, retry, order_no_type = config.get_config('hp') # init d42 = Device42(d42_username, d42_password, d42_url, debug, retry) hp = HP(hp_url, debug, retry, order_no_type) # get data from Device42 orders = d42.get_purchases() already_there = [] dates = {} if orders: for order in orders: line_items = order['line_items'] for line_item in line_items: end = line_item['line_end_date'] start = line_item['line_start_date'] devices = line_item['devices'] for device in devices: serial = device['serial_no'] dates.update({serial: [start, end]}) if serial not in already_there: already_there.append(serial) devices = d42.get_serials() items = [[x['device_id'], x['serial_no'], x['manufacturer']] for x in devices['Devices'] if x['serial_no'] and x['manufacturer']] for item in items: d42_id, serial, vendor = item print '\t[+] HP serial #: %s' % serial """ if 'hp' in vendor.lower(): #if len(serial) <= 7: # testing only original DELL...remove this warranty = hp.run_warranty_check(serial, product_number) if warranty: wend = warranty['line_end_date'] wstart = warranty['line_start_date'] # update or duplicate? Compare warranty dates by serial if serial in already_there: dstart, dend = dates[serial] if dstart == wstart and dend == wend: # duplicate print '[!] Duplicate found. Purchase for SKU "%s" is already uploaded' % serial else: # add new line_item d42.upload_data(warranty) else: # upload new warranty and add it's serial to 'already_there' d42.upload_data(warranty) already_there.append(serial) """ print '[!] HP warranty check is not implemented yet.'
def main(): # get settings from config file d42_username, d42_password, d42_url,\ hp_url, debug, retry, order_no_type = config.get_config('hp') # init d42 = Device42(d42_username, d42_password, d42_url, debug, retry) hp = HP(hp_url, debug, retry, order_no_type) # get data from Device42 orders = d42.get_purchases() already_there = [] dates = {} if orders: for order in orders: line_items = order['line_items'] for line_item in line_items: end = line_item['line_end_date'] start = line_item['line_start_date'] devices = line_item['devices'] for device in devices: serial = device['serial_no'] dates.update({serial:[start,end]}) if serial not in already_there: already_there.append(serial) devices = d42.get_serials() items = [[x['device_id'],x['serial_no'],x['manufacturer']] for x in devices['Devices'] if x['serial_no'] and x['manufacturer']] for item in items: d42_id, serial, vendor = item print '\t[+] HP serial #: %s' % serial """ if 'hp' in vendor.lower(): #if len(serial) <= 7: # testing only original DELL...remove this warranty = hp.run_warranty_check(serial, product_number) if warranty: wend = warranty['line_end_date'] wstart = warranty['line_start_date'] # update or duplicate? Compare warranty dates by serial if serial in already_there: dstart, dend = dates[serial] if dstart == wstart and dend == wend: # duplicate print '[!] Duplicate found. Purchase for SKU "%s" is already uploaded' % serial else: # add new line_item d42.upload_data(warranty) else: # upload new warranty and add it's serial to 'already_there' d42.upload_data(warranty) already_there.append(serial) """ print '[!] HP warranty check is not implemented yet.'
"""Refresh the authorization token for new credentials.""" import logging import traceback from urllib.parse import parse_qs # noqa pylint: disable=no-name-in-module, import-error from shared import ( create_error_html, extract_and_parse_cookies, get_config, # noqa pylint: disable=import-error get_cookie_headers, http_post_with_retry) LOGGER = logging.getLogger(__name__) CONFIG = get_config() def handler(event, _context): """Handle the authorization refresh. Keyword Args: event: The Lambda Event """ request = event['Records'][0]['cf']['request'] domain_name = request['headers']['host'][0]['value'] redirected_from_uri = 'https://%s' % domain_name try: parsed_qs = parse_qs(request.get('querystring')) requested_uri = parsed_qs.get('requestedUri')[0] current_nonce = parsed_qs.get('nonce')[0]
def main(): # get settings from config file d42_username, d42_password, d42_url,\ dell_api_key, dell_url, debug, retry, order_no_type = config.get_config('dell') # init d42 = Device42(d42_username, d42_password, d42_url, debug, retry) dell = DELL(dell_url, dell_api_key, debug, retry, order_no_type) # get data from Device42 orders = d42.get_purchases() already_there = [] dates = {} if orders and orders.has_key('purchases'): for order in orders['purchases']: if order.has_key('line_items'): line_items = order['line_items'] for line_item in line_items: end = line_item.get('line_end_date') start = line_item.get('line_start_date') devices = line_item.get('devices') if devices: for device in devices: if device.has_key('serial_no'): serial = device['serial_no'] if serial not in already_there: already_there.append(serial) if start and end: dates.update({serial: [start, end]}) devices = d42.get_serials() if devices and devices.has_key('Devices'): items = [[x['device_id'], x['serial_no'], x['manufacturer']] for x in devices['Devices'] if x['serial_no'] and x['manufacturer']] for item in items: try: d42_id, serial, vendor = item print '\t[+] DELL serial #: %s' % serial except ValueError as e: print '\n[!] Error in item: "%s"' % item else: if 'dell' in vendor.lower(): warranty = dell.run_warranty_check(serial) if warranty: wend = warranty.get('line_end_date') wstart = warranty.get('line_start_date') # update or duplicate? Compare warranty dates by serial if serial in already_there: dstart, dend = dates[serial] if dstart == wstart and dend == wend: # duplicate print '[!] Duplicate found. Purchase for SKU "%s" is already uploaded' % serial else: # add new line_item d42.upload_data(warranty) else: # upload new warranty and add it's serial to 'already_there' d42.upload_data(warranty) already_there.append(serial)