def node_destroy(provider=None, region=None, node_id=None): account = request.args.get('account', session.get('default_account')) provider_info = get_provider_info(provider, session.get('organization').name, account) if provider_info.get('provider'): provider_id = provider_info.get('provider_id') provider_key = provider_info.get('provider_key') cloud.destroy_node(provider, region, provider_id, provider_key, node_id) flash(messages.INSTANCE_DESTROYED) current_app.logger.info('{0} ({1}) destroyed node {2} in {3} ({4})'.format(session.get('user').username, \ session.get('organization').name, node_id, provider, region)) return redirect(url_for('nodes.index', region=region))
def decorated(*args, **kwargs): # load provider info org = Organization.get_by_name(kwargs.get("organization")) org_name = None if org: org_name = org.name info = get_provider_info(kwargs.get("provider"), org_name, kwargs.get("account")) session["provider_info"] = info # check for info ; if missing return error if not info.get("provider_id") or not info.get("provider_key"): data = {"error": "Invalid or missing provider account information"} return generate_api_response(data, 400) return f(*args, **kwargs)
def nodes(provider=None, region=None): account = request.args.get('account', session.get('default_account')) nodes = None provider_info = get_provider_info(provider, session.get('organization').name, account) if provider_info.get('provider'): provider_id = provider_info.get('provider_id') provider_key = provider_info.get('provider_key') nodes = cloud.get_nodes(provider, region, provider_id, provider_key) ctx = { 'provider': provider, 'region': region, 'nodes': nodes, } return render_template('nodes/_nodes.html', **ctx)
def node_set_roles(provider=None, region=None, node_id=None): account = request.args.get('account', session.get('default_account')) provider_info = get_provider_info(provider, session.get('organization').name, account) node_data = None roles = request.form.get('roles', '').split() if provider_info.get('provider'): provider_id = provider_info.get('provider_id') provider_key = provider_info.get('provider_key') node_data = NodeData.get_by_node_id(node_id) node_data.roles = roles node_data.save() current_app.logger.info('{0} ({1}) updated roles for node {2} in {3} ({4}): {5}'.format(session.get('user').username, \ session.get('organization').name, node_id, provider, region, roles)) flash(messages.NODE_ROLES_UPDATED) return redirect(url_for('nodes.index', region=region))
def node_roles(provider=None, region=None, node_id=None): account = request.args.get('account', session.get('default_account')) provider_info = get_provider_info(provider, session.get('organization').name, account) node_data = None if provider_info.get('provider'): provider_id = provider_info.get('provider_id') provider_key = provider_info.get('provider_key') node_data = NodeData.get_by_node_id(node_id) if not node_data: node_data = NodeData() node_data.node_id = node_id node_data.save() ctx = { 'provider': provider, 'provider_info': provider_info, 'region': region, 'node_id': node_id, 'node_data': node_data, } return render_template('nodes/_node_roles.html', **ctx)
def node_launch(provider=None, region=None): nodes = None account = request.args.get('account', session.get('default_account')) provider_info = get_provider_info(provider, session.get('organization').name, account) if provider_info.get('provider'): provider_id = provider_info.get('provider_id') provider_key = provider_info.get('provider_key') if request.method == 'POST': node_name = request.form.get('name') node_image_id = request.form.get('image') node_size_id = request.form.get('size') keypair = request.form.get('keypair', None) security_groups = request.form.get('security_groups', None) try: cloud.launch_node(provider, region, provider_id, provider_key, node_name, \ node_image_id, node_size_id, keypair=keypair, security_groups=security_groups) current_app.logger.info('{0} ({1}) launched node {2} ({3}) in {4} ({5})'.format(session.get('user').username, \ session.get('organization').name, node_name, node_image_id, provider, region)) flash(messages.INSTANCE_LAUNCHED) except Exception, e: flash(e, 'error') return redirect(url_for('nodes.index', region=region))