[ https://issues.apache.org/jira/browse/CLOUDSTACK-8677?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14643706#comment-14643706 ]
ASF GitHub Bot commented on CLOUDSTACK-8677: -------------------------------------------- Github user sedukull commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/625#discussion_r35605766 --- Diff: reporter/usage-report-collector.py --- @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +from flask import abort, Flask, request, Response +from elasticsearch import Elasticsearch +import json +import time + +def json_response(response): + return json.dumps(response, indent=2) + "\n", 200, {'Content-Type': 'application/json; charset=utf-8'} + +def generate_app(config=None): + app = Flask(__name__) + + @app.route('/report/<unique_id>', methods=['POST']) + def report(unique_id): + # We expect JSON data, so if the Content-Type doesn't match JSON data we throw an error + if 'Content-Type' in request.headers: + if request.headers['Content-Type'] != 'application/json': + abort(417, "No or incorrect Content-Type header was supplied") + + index = "cloudstack-%s" % time.strftime("%Y.%m.%d", time.gmtime()) + timestamp = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()) + + es = Elasticsearch() + es.indices.create(index=index, ignore=400) + + report = json.loads(request.data) --- End diff -- May be we wanted to add a small check to see report is None and proceed. > Call-home functionality for CloudStack > -------------------------------------- > > Key: CLOUDSTACK-8677 > URL: https://issues.apache.org/jira/browse/CLOUDSTACK-8677 > Project: CloudStack > Issue Type: New Feature > Security Level: Public(Anyone can view this level - this is the > default.) > Components: Management Server > Affects Versions: Future, 4.6.0 > Reporter: Wido den Hollander > Assignee: Wido den Hollander > Fix For: 4.6.0 > > > A call-home feature for the CloudStack management server would send > anonimized reports back to the CloudStack project. > These statistics will contain numbers and details on how CloudStack will be > used. It will NOT contain: > * Hostnames > * IP-Addresses > * Instance names > It will report back: > * Hosts (Number, version, type, hypervisor) > * Clusters (Hypervisor en Management type) > * Primary storage (Type and provider) > * Zones (Network type and providers) > * Instances (Number and types) > This gives the CloudStack project a better insight on how CloudStack is being > used and allows us to develop accordingly. > It will be OPT-OUT, using the "usage.report.interval" users can disable usage > reporting. By default it will run every 7 days and send a JSON document to > https://call-home.cloudstack.org/ -- This message was sent by Atlassian JIRA (v6.3.4#6332)