Пример #1
0
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#

import sys
import json

from dc2.web.live.startup.globals import app
from dc2.web.live.startup.globals import api

try:
    from flask.ext.restful import Resource as RestResource
    from flask.ext.restful.utils import cors
except ImportError as e:
    print(e)
    sys.exit(1)


class DHCPNetworks(RestResource):

    @cors.crossdomain(origin='*')
    def get(self):
        dhcpdata = app.config['DC2Backend'].dc2.dhcp.mgmt.list()
        return json.dumps(dhcpdata), 200


api.add_resource(DHCPNetworks, '/api/v1/dhcp/networks')
Пример #2
0
import json

from dc2.web.live.startup.globals import app
from dc2.web.live.startup.globals import api
from dc2.web.live.startup.globals import socketio

try:
    from flask import request
    from flask.ext.restful import Resource as RestResource
    from flask.ext.restful.utils import cors
except ImportError as e:
    print('{0}: {1}'.format(__file__, e))
    sys.exit(1)


class RestEvents(RestResource):

    @cors.crossdomain(origin="*")
    def post(self):
        pass


class EventDiscoveredRack(RestEvents):

    @cors.crossdomain(origin="*")
    def post(self):
        print(request.json)
        return request.json, 200

api.add_resource(EventDiscoveredRack, '/api/v1/events/discover/racks')