def _getInstanceMetadata(): """ Get and cache metadata about the instance this YOMP server is running on NOTE: This used to be retrieved directly into a global variable, which added significant delays when running unit test on a dev laptop while on a different network (e.g., from home) and there was no way to patch. Caching also helps when debugging in that environment; without it, many of the Web GUI requests take a very long time to complete. :returns: metadata (see instance_utils.getInstanceData) or empty dict if none """ try: return _getInstanceMetadata.instanceMetadata except AttributeError: _getInstanceMetadata.instanceMetadata = ( instance_utils.getInstanceData() or {}) return _getInstanceMetadata.instanceMetadata
def POST(self): url = config.get("usertrack", "wufoo_url") user = config.get("usertrack", "wufoo_user") fields = { 'name': 'Field6', 'company': 'Field3', 'email': 'Field4', 'edition': 'Field8', 'version': 'Field10', 'build': 'Field12', 'accountId': 'Field14', 'uniqueServerId': 'Field16', 'instanceId': 'Field18', 'region': 'Field19', 'instanceType': 'Field21' } payload = {} instanceData = instance_utils.getInstanceData() or {} for datum in instanceData: if datum in fields: payload[fields[datum]] = instanceData[datum] data = json.loads(web.data()) if 'email' in data and len(data['email']): sendWelcomeEmail(data['email']) for datum in data: payload[fields[datum]] = data[datum] payload[fields["uniqueServerId"]] = config.get("usertrack", "YOMP_id") if config.getboolean("usertrack", "send_to_wufoo"): requests.post(url=url, data=payload, auth=(user, '')) for (fieldName, field) in fields.iteritems(): log.info("{TAG:WUFOO.CUST.REG} %s=%s" % (fieldName, payload.get(field))) return web.HTTPError(status="204", data="No Content")
def POST(self): url = config.get("usertrack", "wufoo_url") user = config.get("usertrack", "wufoo_user") fields = { "name": "Field6", "company": "Field3", "email": "Field4", "edition": "Field8", "version": "Field10", "build": "Field12", "accountId": "Field14", "uniqueServerId": "Field16", "instanceId": "Field18", "region": "Field19", "instanceType": "Field21", } payload = {} instanceData = instance_utils.getInstanceData() or {} for datum in instanceData: if datum in fields: payload[fields[datum]] = instanceData[datum] data = json.loads(web.data()) if "email" in data and len(data["email"]): sendWelcomeEmail(data["email"]) for datum in data: payload[fields[datum]] = data[datum] payload[fields["uniqueServerId"]] = config.get("usertrack", "YOMP_id") if config.getboolean("usertrack", "send_to_wufoo"): requests.post(url=url, data=payload, auth=(user, "")) for (fieldName, field) in fields.iteritems(): log.info("{TAG:WUFOO.CUST.REG} %s=%s" % (fieldName, payload.get(field))) return web.HTTPError(status="204", data="No Content")