roles = config.get('roles', []) for role in roles: links[role] = 'http://%s' % ip return util.make_json_response( 200, {"status": "OK", "dashboardlinks": links} ) util.add_resource(SwitchList, '/switches') util.add_resource(Switch, '/switches/<string:switch_id>') util.add_resource(MachineList, '/machines') util.add_resource(Machine, '/machines/<string:machine_id>') util.add_resource(Cluster, '/clusters', '/clusters/<string:cluster_id>', '/clusters/<string:cluster_id>/<string:resource>') util.add_resource(ClusterHostConfig, '/clusterhosts/<string:host_id>/config', '/clusterhosts/<string:host_id>/config/<string:subkey>') util.add_resource(ClusterHost, '/clusterhosts/<string:host_id>') util.add_resource(HostInstallingProgress, '/clusterhosts/<string:host_id>/progress') util.add_resource(ClusterInstallingProgress, '/clusters/<string:cluster_id>/progress') util.add_resource(DashboardLinks, '/dashboardlinks') if __name__ == '__main__': app.run(debug=True)
{}).get('interfaces', {}).get('management', {}).get('ip', '') roles = config.get('roles', []) for role in roles: links[role] = 'http://%s' % ip return util.make_json_response(200, { "status": "OK", "dashboardlinks": links }) util.add_resource(SwitchList, '/switches') util.add_resource(Switch, '/switches/<string:switch_id>') util.add_resource(MachineList, '/machines') util.add_resource(Machine, '/machines/<string:machine_id>') util.add_resource(Cluster, '/clusters', '/clusters/<string:cluster_id>', '/clusters/<string:cluster_id>/<string:resource>') util.add_resource(ClusterHostConfig, '/clusterhosts/<string:host_id>/config', '/clusterhosts/<string:host_id>/config/<string:subkey>') util.add_resource(ClusterHost, '/clusterhosts/<string:host_id>') util.add_resource(HostInstallingProgress, '/clusterhosts/<string:host_id>/progress') util.add_resource(ClusterInstallingProgress, '/clusters/<string:cluster_id>/progress') util.add_resource(DashboardLinks, '/dashboardlinks') if __name__ == '__main__': app.run(debug=True)
# # 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. """main script to start an instance of compass server .""" import logging from compass.api import app from compass.utils import flags from compass.utils import logsetting flags.add('server_host', help='server host address', default='0.0.0.0') flags.add_bool('debug', help='run in debug mode', default=True) if __name__ == '__main__': flags.init() logsetting.init() logging.info('run server') app.run(host=flags.OPTIONS.server_host, debug=flags.OPTIONS.debug)
@login_required def patch_machine(): """patch machine.""" data = _get_request_data() return utils.make_json_response( 200, machine_api.patch_machine( current_user, machine_id, **data ) ) @app.route("/machines/<int:machine_id>", methods=['DELETE']) @log_user_action @login_required def delete_machine(machine_id): """Delete machine.""" data = _get_request_data() return utils.make_json_response( 200, machine_api.del_machine( current_user, machine_id, **data ) ) if __name__ == '__main__': flags.init() logsetting.init() app.run(host='0.0.0.0')
message="Successfully!"), HostState(id=4, state="ERROR", progress=0.5, message="Failed!"), HostState(id=5, state="READY", progress=1.0, message="Successfully!"), HostState(id=6, state="ERROR", progress=1.0, message="Failed!") ] session.add_all(host_states) if __name__ == '__main__': db_url, port = sys.argv[1:] print db_url try: database.init(db_url) database.create_db() except Exception as error: print "=====> Failed to create database" print error try: setupDb() except Exception as error: print "setupDb=====>Failed to setup database" print error print "Starting server ....." print "port is ", port app.run(use_reloader=False, host="0.0.0.0", port=port)