Пример #1
0
from iomate.iomate_app import Blueprint, render_template, request, flash, redirect, login_required, db
from iomate.models import Servers

servers = Blueprint('servers', __name__)


@servers.route("/servers", methods=['GET', 'POST'])
@login_required
def servers_view():
    error = None
    if request.method == 'GET':
        return render_template('servers.html', servers=Servers.query.all())
    elif request.method == 'POST':
        if 'server_add' in request.form:
            if not request.form['server_hostname'] or not request.form[
                    'server_ipaddress'] or not request.form[
                        'server_subnet'] or not request.form[
                            'server_gateway'] or not request.form[
                                'server_username'] or not request.form[
                                    'server_password']:
                return "<div class='alert alert-danger' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>ERROR</div>"
            else:
                server = Servers(request.form['server_hostname'],
                                 request.form['server_ipaddress'],
                                 request.form['server_subnet'],
                                 request.form['server_gateway'],
                                 request.form['server_username'],
                                 request.form['server_password'])
                db.session.add(server)
                db.session.commit()
                return "<div class='alert alert-success' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>Server Added</div>"
Пример #2
0
from iomate.iomate_app import Blueprint, render_template, request, flash, redirect, login_required, db
from iomate.models import Ips

ips = Blueprint('ips', __name__)


@ips.route("/ips", methods=['GET', 'POST'])
@login_required
def ips_view():
    error = None
    if request.method == 'GET':
        return render_template('ips.html', ipss=Ips.query.all())
    elif request.method == 'POST':
        if 'ips_add' in request.form:
            if not request.form['ips_hostname'] or not request.form[
                    'ips_ipaddress'] or not request.form[
                        'ips_subnet'] or not request.form[
                            'ips_gateway'] or not request.form[
                                'ips_username'] or not request.form[
                                    'ips_password']:
                return "<div class='alert alert-danger' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>ERROR</div>"
            else:
                ips = Ips(request.form['ips_hostname'],
                          request.form['ips_ipaddress'],
                          request.form['ips_subnet'],
                          request.form['ips_gateway'],
                          request.form['ips_username'],
                          request.form['ips_password'])
                db.session.add(ips)
                db.session.commit()
                return "<div class='alert alert-success' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>IPS Added</div>"
Пример #3
0
import jenkins
import codecs
import salt.client
import salt.config
import salt.wheel

from iomate.saltstack import wheel, local
from iomate.iomate_app import Blueprint, render_template, request, flash, redirect, login_required, db, os, roles_required
from iomate.models import System_vm_profiles, Saltstack_pxe_nodes

##IMPORT FROM IOMATE GLOBAL##
#from iomate.iomate_global import srvjenkins
#from iomate.iomate_global import get_deploy_device_last_build_log
#from iomate.iomate_global import get_deploy_device_get_job_info

deploy_vm_system = Blueprint('deploy_vm_system', __name__)

### LOCAL CONFIG ###
#opts = salt.config.master_config('/etc/salt/master')
#wheel = salt.wheel.WheelClient(opts)
#local = salt.client.LocalClient()


@deploy_vm_system.route("/deploy-vm-system", methods=['GET', 'POST'])
@login_required
#@roles_required('admin')
def deploy_vm_system_view():
    error = None
    if request.method == 'GET':
        #        socketio.start_background_task(cct_swx, '/dev/ttyUSB0', 'sw1usbsignal', 'sw1portsignal')
        #        socketio.start_background_task(cct_swx, '/dev/ttyUSB1', 'sw2usbsignal', 'sw2portsignal')
Пример #4
0
from iomate.iomate_app import Blueprint, render_template, request, flash, redirect, login_required, db
from iomate.models import Vstorage

vstorage = Blueprint('vstorage', __name__)


@vstorage.route("/vstorage", methods=['GET', 'POST'])
@login_required
def vstorage_view():
    error = None
    if request.method == 'GET':
        return render_template('vstorage.html', vstorages=Vstorage.query.all())
    elif request.method == 'POST':
        if 'vstorage_add' in request.form:
            if not request.form['vstorage_name']:
                return "<div class='alert alert-danger' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>ERROR</div>"
            else:
                vstorage = Vstorage(request.form['vstorage_name'])
                db.session.add(vstorage)
                db.session.commit()
                return "<div class='alert alert-success' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>vStorage Added</div>"
        elif 'vstorage_edit' in request.form:
            if not request.form['vstorage_name']:
                return "<div class='alert alert-danger' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>ERROR</div>"
            else:
                vstorage_id = request.form.get('id')
                vstorage = Vstorage.query.filter_by(id=vstorage_id).one()
                vstorage.name = request.form['vstorage_name']
                db.session.add(vstorage)
                db.session.commit()
                return "<div class='alert alert-success' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>vStorage Edited</div>"
Пример #5
0
from iomate.iomate_app import Blueprint, render_template, request, flash, redirect, login_required, db
from iomate.models import Vsswitch

vswitch = Blueprint('vswitch', __name__)


@vswitch.route("/vswitch", methods=['GET', 'POST'])
@login_required
def vswitch_view():
    error = None
    if request.method == 'GET':
        return render_template('vswitch.html', vss=Vsswitch.query.all())
    elif request.method == 'POST':
        if 'vs_add' in request.form:
            if not request.form['vs_name'] or not request.form[
                    'vs_ipaddress'] or not request.form[
                        'vs_subnet'] or not request.form[
                            'vs_gateway'] or not request.form[
                                'vs_nic1'] or not request.form['vs_nic2']:
                return "<div class='alert alert-danger' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>ERROR</div>"
            else:
                vs = Vsswitch(request.form['vs_name'],
                              request.form['vs_ipaddress'],
                              request.form['vs_subnet'],
                              request.form['vs_gateway'],
                              request.form['vs_nic1'], request.form['vs_nic2'])
                db.session.add(vs)
                db.session.commit()
                return "<div class='alert alert-success' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>vS Added</div>"
        elif 'vs_edit' in request.form:
            if not request.form['vs_name'] or not request.form[
Пример #6
0
from jinja2 import Environment, FileSystemLoader
import jenkins
import codecs

from iomate.iomate_app import Blueprint, render_template, request, flash, redirect, login_required, os, socketio, roles_required
from iomate.models import Switches, Switch1_24_port, Switch2_24_port, Switch1_48_port, Switch2_48_port, Customer_sw

##IMPORT FROM IOMATE GLOBAL##
from iomate.iomate_global import srvjenkins
from iomate.iomate_global import get_deploy_device_last_build_log
from iomate.iomate_global import get_deploy_device_get_job_info
from iomate.iomate_global import cct_swx

deploy_switch = Blueprint('deploy_switch', __name__)

### LOCAL CONFIG ###
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
TEMPLATE_DIR = 'templates/configuration_templates/pyserial'
TEMPLATE_CONFIG = os.path.join(BASE_DIR, TEMPLATE_DIR)


@deploy_switch.route("/deploy-switch", methods=['GET', 'POST'])
@login_required
@roles_required('admin')
def deploy_switch_view():
    error = None
    if request.method == 'GET':
        socketio.start_background_task(cct_swx, '/dev/ttyUSB0', 'sw1usbsignal',
                                       'sw1portsignal')
        socketio.start_background_task(cct_swx, '/dev/ttyUSB1', 'sw2usbsignal',
                                       'sw2portsignal')
Пример #7
0
from iomate.iomate_app import Blueprint, render_template, request, flash, redirect, login_required, db
from iomate.models import Nas

nas = Blueprint('nas', __name__)

@nas.route("/nas", methods=['GET', 'POST'])
@login_required
def nas_view():
    error = None
    if request.method == 'GET':
        return render_template('nas.html', nass=Nas.query.all())
    elif request.method == 'POST':
        if 'nas_add' in request.form:
            if not request.form['nas_hostname'] or not request.form['nas_ipaddress'] or not request.form['nas_subnet'] or not request.form['nas_gateway'] or not request.form['nas_port'] or not request.form['nas_provider'] or not request.form['nas_username'] or not request.form['nas_password']:
                return "<div class='alert alert-danger' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>ERROR</div>"
            else:
                nas = Nas(request.form['nas_hostname'], request.form['nas_ipaddress'], request.form['nas_subnet'], request.form['nas_gateway'], request.form['nas_port'], request.form['nas_provider'], request.form['nas_username'], request.form['nas_password'])
                db.session.add(nas)
                db.session.commit()
                return "<div class='alert alert-success' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>NAS Added</div>"
        elif 'nas_edit' in request.form:
            if not request.form['nas_hostname'] or not request.form['nas_ipaddress'] or not request.form['nas_subnet'] or not request.form['nas_gateway'] or not request.form['nas_port'] or not request.form['nas_provider'] or not request.form['nas_username'] or not request.form['nas_password']:
                return "<div class='alert alert-danger' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>ERROR</div>"
            else:
                nas_id = request.form.get('id')
                nas = Nas.query.filter_by(id=nas_id).one()
                nas.hostname=request.form['nas_hostname']
                nas.ipaddress=request.form['nas_ipaddress']
                nas.subnet=request.form['nas_subnet']
                nas.gateway=request.form['nas_gateway']
                nas.port=request.form['nas_port']
Пример #8
0
from distutils.util import strtobool

from iomate.iomate_app import Blueprint, render_template, request, flash, redirect, login_required, roles_required, db, encrypt_password, SQLAlchemyUserDatastore
from iomate.models import User, Role

users = Blueprint('users', __name__)

### FLASK - SECURITY ###
user_datastore = SQLAlchemyUserDatastore(db, User, Role)


@users.route("/users", methods=['GET', 'POST'])
@login_required
@roles_required('admin')
def users_view():
    error = None
    if request.method == 'GET':
        return render_template('users.html',
                               users=User.query.all(),
                               roles=Role.query.all())
    elif request.method == 'POST':
        if 'user_add' in request.form:
            if not request.form['user_email'] or not request.form[
                    'user_name'] or not request.form[
                        'user_password'] or not request.form[
                            'user_active'] or not request.form['user_role']:
                return "<div class='alert alert-danger' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>ERROR</div>"
            else:
                #                user = User(request.form['user_email'], request.form['user_name'], request.form['user_password'], request.form['user_active'], request.form['user_role'])
                rola_id = request.form['user_role']
                rola_string = Role.query.filter_by(id=rola_id).one()
Пример #9
0
from werkzeug.utils import secure_filename
from iomate.iomate_app import app, Blueprint, render_template, request, flash, redirect, login_required, db, os, verify_password, current_user
from iomate.models import User

profile = Blueprint('profile', __name__)

### PROFILE PIC UPLOAD ###
ALLOWED_EXTENSIONS = set(['png', 'jpg', 'jpeg', 'gif'])


def allowed_file(filename):
    return '.' in filename and filename.rsplit(
        '.', 1)[1].lower() in ALLOWED_EXTENSIONS


@profile.route("/profile", methods=['GET', 'POST'])
@login_required
def profile_view():
    error = None
    if request.method == 'GET':
        page = request.args.get('page')
        return render_template('profile.html', page=page)
    elif request.method == 'POST':
        # check if the post request has the file part
        if 'profile_change_pic' in request.form:
            if 'file' not in request.files:
                flash(
                    'Please make sure you are submitting a file part request!',
                    'warning')
                return redirect(request.url)
            file = request.files['file']
Пример #10
0
from iomate.iomate_app import Blueprint, render_template, request, flash, redirect, login_required, db
from iomate.models import Templates

templates = Blueprint('templates', __name__)


@templates.route("/templates", methods=['GET', 'POST'])
@login_required
def templates_view():
    error = None
    if request.method == 'GET':
        return render_template('templates.html',
                               templates=Templates.query.all())
    elif request.method == 'POST':
        if 'template_add' in request.form:
            if not request.form['template_name'] or not request.form[
                    'template_path']:
                return "<div class='alert alert-danger' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>ERROR</div>"
            else:
                template = Templates(request.form['template_name'],
                                     request.form['template_path'])
                db.session.add(template)
                db.session.commit()
                return "<div class='alert alert-success' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>Template Added</div>"
        elif 'template_edit' in request.form:
            if not request.form['template_name'] or not request.form[
                    'template_path']:
                return "<div class='alert alert-danger' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>ERROR</div>"
            else:
                template_id = request.form.get('id')
                template = Templates.query.filter_by(id=template_id).one()
Пример #11
0
from iomate.iomate_app import Blueprint, render_template, request, flash, redirect, login_required, roles_required, db, os
from iomate.models import Saltstack_pxe_nodes
import salt.config
import salt.wheel
import salt.client

saltstack = Blueprint('saltstack', __name__)

### LOCAL CONFIG ###
opts = salt.config.master_config('/etc/salt/master')
wheel = salt.wheel.WheelClient(opts)
local = salt.client.LocalClient()


def salt_service_check():
    PATH = '/var/run/salt-master.pid'
    if os.path.isfile(PATH) and os.access(PATH, os.R_OK):
        return "RUNNING"
    else:
        return "STOPPED"


def salt_keys_accepted():
    ret_acc = wheel.cmd('key.list', ['accepted'])
    #    return ret_acc['minions']
    return ret_acc


def salt_keys_unaccepted():
    ret_unacc = wheel.cmd('key.list', ['unaccepted'])
    #    return ret_unacc['minions_pre']
Пример #12
0
from iomate.iomate_app import Blueprint, render_template, request, flash, redirect, login_required, db
from iomate.models import Snapshots

snapshots = Blueprint('snapshots', __name__)

@snapshots.route("/snapshots", methods=['GET', 'POST'])
@login_required
def snapshots_view():
    error = None
    if request.method == 'GET':
        return render_template('snapshots.html', snapshots=Snapshots.query.all())
    elif request.method == 'POST':
        if 'snapshot_add' in request.form:
            if not request.form['snapshot_name'] or not request.form['snapshot_path']:
                return "<div class='alert alert-danger' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>ERROR</div>"
            else:
                snapshot = Snapshots(request.form['snapshot_name'], request.form['snapshot_path'])
                db.session.add(snapshot)
                db.session.commit()
                return "<div class='alert alert-success' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>Snapshot Added</div>"
        elif 'snapshot_edit' in request.form:
            if not request.form['snapshot_name'] or not request.form['snapshot_path']:
                return "<div class='alert alert-danger' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>ERROR</div>"
            else:
                snapshot_id = request.form.get('id')
                snapshot = Snapshots.query.filter_by(id=snapshot_id).one()
                snapshot.name=request.form['snapshot_name']
                snapshot.path=request.form['snapshot_path']
                db.session.add(snapshot)
                db.session.commit()
                return "<div class='alert alert-success' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>Snapshot Edited</div>"
Пример #13
0
from iomate.iomate_app import Blueprint, render_template, request, flash, redirect, login_required

##IMPORT FROM IOMATE GLOBAL##
from iomate.iomate_global import get_deploy_device_last_build_log
from iomate.iomate_global import get_deploy_device_get_job_info

statistics = Blueprint('statistics', __name__)


@statistics.route("/statistics", methods=['GET', 'POST'])
@login_required
def statistics_view():
    deploy_sw_1 = get_deploy_device_last_build_log('deploy_sw_1')
    deploy_sw_1_job_info = get_deploy_device_get_job_info('deploy_sw_1')
    return render_template('statistics.html',
                           deploy_sw_1=deploy_sw_1,
                           deploy_sw_1_job_info=deploy_sw_1_job_info)
Пример #14
0
from iomate.iomate_app import Blueprint, render_template, request, flash, redirect, login_required, db
from iomate.models import Racks

racks = Blueprint('racks', __name__)


@racks.route('/racks', methods=['GET', 'POST'])
@login_required
def racks_view():
    error = None
    if request.method == 'GET':
        return render_template('racks.html', racks=Racks.query.all())
    elif request.method == 'POST':
        if 'rack_add' in request.form:
            if not request.form['rack_name'] or not request.form[
                    'rack_location']:
                return "<div class='alert alert-danger' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>ERROR</div>"
            else:
                rack = Racks(request.form['rack_name'],
                             request.form['rack_location'])
                db.session.add(rack)
                db.session.commit()
                return "<div class='alert alert-success' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>Rack Added</div>"
        elif 'rack_edit' in request.form:
            if not request.form['rack_name'] or not request.form[
                    'rack_location']:
                return "<div class='alert alert-danger' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>ERROR</div>"
            else:
                rack_id = request.form.get('id')
                rack = Racks.query.filter_by(id=rack_id).one()
                rack.name = request.form['rack_name']
Пример #15
0
from jinja2 import Environment, FileSystemLoader
from distutils.util import strtobool
from iomate.iomate_app import Blueprint, render_template, request, flash, redirect, login_required, db, os
from iomate.models import Switches, Firewalls, Esxis, Servers, Dedicatedsan, Vlans, Switch1_24_port, Customer_sw, Firewall1_interfaces, Firewall2_interfaces, Port_channels_fw1, Subnets
#from iomate.models import Firewalls, Vlans, Subnets 

design_fw1 = Blueprint('design_fw1', __name__)

### LOCAL CONFIG ###
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
TEMPLATE_DIR = 'templates/configuration_templates/pyserial'
TEMPLATE_CONFIG = os.path.join(BASE_DIR, TEMPLATE_DIR)

### DESIGN_FW1 ###
@design_fw1.route("/design-fw1", methods=['GET', 'POST'])
@login_required
def design_fw1_view():
    error = None
    if request.method == 'GET':
        file = open("output/customer-sw-1-24-portconfig.deploy", "r")
        lines = file.readlines()
#        return render_template('design-fw1.html', fws=Firewalls.query.all(), vlans=Vlans.query.all())
        return render_template('design-fw1.html', subnets=Subnets.query.all(), pochanns=Port_channels_fw1.query.all(), pos=Firewall1_interfaces.query.filter(Firewall1_interfaces.group).all(), fw_interfaces=Firewall1_interfaces.query.all(), customer_sws=Customer_sw.query.all(), vlans=Vlans.query.all(), lines=lines)
    elif request.method == 'POST':
        if 'design_fw1_port_channel_save' in request.form:
            if not request.form['design_fw1_port_channel_mode'] or not request.form.getlist['design_fw1_port_channel_interfaces']:
                flash('Please fill all fields before sending a request !','danger')
                return redirect(request.url)
            else:
                flash('Saved','success')
                return redirect(request.url)
Пример #16
0
from jinja2 import Environment, FileSystemLoader
import jenkins
import codecs

from iomate.iomate_app import Blueprint, render_template, request, flash, redirect, login_required, os, socketio
from iomate.models import Customer_sw

##IMPORT FROM IOMATE GLOBAL##
from iomate.iomate_global import srvjenkins
from iomate.iomate_global import get_deploy_device_last_build_log
from iomate.iomate_global import get_deploy_device_get_job_info

deploy_phy_system = Blueprint('deploy_phy_system', __name__)

### LOCAL CONFIG ###


@deploy_phy_system.route("/deploy-phy-system", methods=['GET', 'POST'])
@login_required
def deploy_phy_switch_view():
    error = None
    if request.method == 'GET':
        #        socketio.start_background_task(cct_swx, '/dev/ttyUSB0', 'sw1usbsignal', 'sw1portsignal')
        #        socketio.start_background_task(cct_swx, '/dev/ttyUSB1', 'sw2usbsignal', 'sw2portsignal')
        #        deploy_sw_1_baseconfig = get_deploy_device_last_build_log('deploy_sw_1_baseconfig')
        #        deploy_sw_1_baseconfig_job_info = get_deploy_device_get_job_info('deploy_sw_1_baseconfig')
        #        deploy_sw_1_portconfig = get_deploy_device_last_build_log('deploy_sw_1_portconfig')
        #        deploy_sw_1_portconfig_job_info = get_deploy_device_get_job_info('deploy_sw_1_portconfig')
        #        deploy_sw_1_singleport = get_deploy_device_last_build_log('deploy_sw_1_singleport')
        #        deploy_sw_1_singleport_job_info = get_deploy_device_get_job_info('deploy_sw_1_singleport')
        return render_template('deploy-phy-system.html',
Пример #17
0
from iomate.iomate_app import app, Blueprint, render_template, request, flash, redirect, login_required, roles_required, db, os
from iomate.models import Isos
import xmlrpclib
from xmlrpclib import *
import re
import fileinput

cobblered = Blueprint('cobblered', __name__)

### LOCAL CONFIG ###
BASE_DIR = os.path.abspath(os.path.dirname(__file__))

### COBBLER ###
##TO DO: redo cobbler_server with BootAPI()
cobbler_server = xmlrpclib.Server("http://192.168.1.83/cobbler_api")
token = cobbler_server.login("cobbler", "cobbler")


def cobbler_config_replace(string, var):
    cobbler_config_file = fileinput.FileInput("/etc/cobbler/dhcp.template",
                                              inplace=True)
    for line in cobbler_config_file:
        line = re.sub(
            r"(" + string + ")+\s+\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}[^0-9]",
            string + " " + var + " ", line.rstrip())
        print(line)


#cobbler_config_replace("netmask", "netmask 255.0.0.0 ")

Пример #18
0
from iomate.iomate_app import Blueprint, render_template, request, flash, redirect, login_required, db
from iomate.models import Routers

routers = Blueprint('routers', __name__)


@routers.route("/routers", methods=['GET', 'POST'])
@login_required
def routers_view():
    error = None
    if request.method == 'GET':
        return render_template('routers.html', routers=Routers.query.all())
    elif request.method == 'POST':
        if 'router_add' in request.form:
            if not request.form['router_hostname'] or not request.form[
                    'router_ipaddress'] or not request.form[
                        'router_subnet'] or not request.form[
                            'router_gateway'] or not request.form[
                                'router_mgmtport']:
                return "<div class='alert alert-danger' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>ERROR</div>"
            else:
                router = Routers(request.form['router_hostname'],
                                 request.form['router_ipaddress'],
                                 request.form['router_subnet'],
                                 request.form['router_gateway'],
                                 request.form['router_mgmtport'])
                db.session.add(router)
                db.session.commit()
                return "<div class='alert alert-success' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>Router Added</div>"
        elif 'router_edit' in request.form:
            if not request.form['router_hostname'] or not request.form[
Пример #19
0
from iomate.iomate_app import Blueprint, render_template, request, flash, redirect, login_required, db
from iomate.models import Firewalls

firewalls = Blueprint('firewalls', __name__)


@firewalls.route("/firewalls", methods=['GET', 'POST'])
@login_required
def firewalls_view():
    error = None
    if request.method == 'GET':
        return render_template('firewalls.html', fws=Firewalls.query.all())
    elif request.method == 'POST':
        if 'fw_add' in request.form:
            if not request.form['fw_hostname'] or not request.form[
                    'fw_ipaddress'] or not request.form[
                        'fw_subnet'] or not request.form[
                            'fw_gateway'] or not request.form[
                                'fw_mgmtnetwork'] or not request.form[
                                    'fw_mgmtsubnet']:
                return "<div class='alert alert-danger' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>ERROR</div>"
            else:
                fw = Firewalls(request.form['fw_hostname'],
                               request.form['fw_ipaddress'],
                               request.form['fw_subnet'],
                               request.form['fw_gateway'],
                               request.form['fw_mgmtnetwork'],
                               request.form['fw_mgmtsubnet'])
                db.session.add(fw)
                db.session.commit()
                return "<div class='alert alert-success' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>Firewall Added</div>"
Пример #20
0
from iomate.iomate_app import Blueprint, render_template, request, flash, redirect, login_required, db
from iomate.models import Sharedsan

sharedsan = Blueprint('sharedsan', __name__)


@sharedsan.route("/sharedsan", methods=['GET', 'POST'])
@login_required
def sharedsan_view():
    error = None
    if request.method == 'GET':
        return render_template('sharedsan.html',
                               sharedsans=Sharedsan.query.all())
    elif request.method == 'POST':
        if 'sharedsan_add' in request.form:
            if not request.form['sharedsan_lunname'] or not request.form[
                    'sharedsan_lunsize']:
                return "<div class='alert alert-danger' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>ERROR</div>"
            else:
                sharedsan = Sharedsan(request.form['sharedsan_lunname'],
                                      request.form['sharedsan_lunsize'])
                db.session.add(sharedsan)
                db.session.commit()
                return "<div class='alert alert-success' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>SharedSAN Added</div>"
        elif 'sharedsan_edit' in request.form:
            if not request.form['sharedsan_lunname'] or not request.form[
                    'sharedsan_lunsize']:
                return "<div class='alert alert-danger' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>ERROR</div>"
            else:
                sharedsan_id = request.form.get('id')
                sharedsan = Sharedsan.query.filter_by(id=sharedsan_id).one()
Пример #21
0
from iomate.iomate_app import Blueprint, render_template, request, flash, redirect, login_required, db
from iomate.models import Dedicatedsan

dedicatedsan = Blueprint('dedicatedsan', __name__)


@dedicatedsan.route("/dedicatedsan", methods=['GET', 'POST'])
@login_required
def dedicatedsan_view():
    error = None
    if request.method == 'GET':
        return render_template('dedicatedsan.html',
                               dedicatedsans=Dedicatedsan.query.all())
    elif request.method == 'POST':
        if 'dedicatedsan_add' in request.form:
            if not request.form['dedicatedsan_hostname'] or not request.form[
                    'dedicatedsan_ipaddress'] or not request.form[
                        'dedicatedsan_subnet'] or not request.form[
                            'dedicatedsan_gateway'] or not request.form[
                                'dedicatedsan_port'] or not request.form[
                                    'dedicatedsan_provider'] or not request.form[
                                        'dedicatedsan_username'] or not request.form[
                                            'dedicatedsan_password']:
                return "<div class='alert alert-danger' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>ERROR</div>"
            else:
                dedicatedsan = Dedicatedsan(
                    request.form['dedicatedsan_hostname'],
                    request.form['dedicatedsan_ipaddress'],
                    request.form['dedicatedsan_subnet'],
                    request.form['dedicatedsan_gateway'],
                    request.form['dedicatedsan_port'],
Пример #22
0
from werkzeug.utils import secure_filename
from iomate.iomate_app import app, Blueprint, render_template, request, flash, redirect, login_required, db, os
from iomate.models import Isos

isos = Blueprint('isos', __name__)

### ISO UPLOAD ###
ALLOWED_EXTENSIONS_ISO = set(['iso', 'ISO'])


def allowed_file_iso(filename):
    return '.' in filename and filename.rsplit(
        '.', 1)[1].lower() in ALLOWED_EXTENSIONS_ISO


@isos.route("/isos", methods=['GET', 'POST'])
@login_required
def isos_view():
    error = None
    if request.method == 'GET':
        return render_template('isos.html', isos=Isos.query.all())
    elif request.method == 'POST':
        if 'iso_add' in request.form:
            if not request.form['iso_name']:
                return "<div class='alert alert-danger' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>ERROR</div>"
            else:
                iso = Isos(request.form['iso_name'])
                db.session.add(iso)
                db.session.commit()
                return "<div class='alert alert-success' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>ISO Added</div>"
        elif 'iso_edit' in request.form:
Пример #23
0
#import napalm.base.helpers
#from napalm.base import NetworkDriver
#from napalm.base.utils import py23_compat
##from napalm.base.exceptions import ConnectionException
#from napalm.base.exceptions import CommandErrorException
#import napalm.base.constants as c

from iomate.iomate_app import Blueprint, render_template, request, flash, redirect, login_required, roles_required, db, os
from iomate.models import Esxis, Servers, Saltstack_pxe_nodes, Customer_sw, Switch1_24_port, Switch1_48_port, Switch2_24_port, Switch2_48_port, System_phy_profiles, System_vm_profiles
#import xmlrpclib
#from xmlrpclib import *
import cobbler.api as capi
import re
import time

system_phy_profiles = Blueprint('system_phy_profiles', __name__)

### LOCAL CONFIG ###
# Custom filter method
#def regex_replace(s, find, replace):
#    """A non-optimal implementation of a regex filter"""
#    return re.sub(find, replace, s)
#
#jinja_environment.filters['regex_replace'] = regex_replace

cobbler_server = capi.BootAPI(is_cobblerd=True)
#cobbler_server = xmlrpclib.Server("http://192.168.1.83/cobbler_api")
#token = cobbler_server.login("cobbler", "cobbler")

### NAPALM ###
import napalm
Пример #24
0
from iomate.iomate_app import Blueprint, render_template, request, flash, redirect, login_required, db
from iomate.models import Vcenter

vcenter = Blueprint('vcenter', __name__)


@vcenter.route("/vcenter", methods=['GET', 'POST'])
@login_required
def vcenter_view():
    error = None
    if request.method == 'GET':
        return render_template('vcenter.html', vcs=Vcenter.query.all())
    elif request.method == 'POST':
        if 'vc_add' in request.form:
            if not request.form['vc_hostname'] or not request.form[
                    'vc_ipaddress'] or not request.form[
                        'vc_subnet'] or not request.form[
                            'vc_gateway'] or not request.form[
                                'vc_username'] or not request.form[
                                    'vc_password']:
                return "<div class='alert alert-danger' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>ERROR</div>"
            else:
                vc = Vcenter(request.form['vc_hostname'],
                             request.form['vc_ipaddress'],
                             request.form['vc_subnet'],
                             request.form['vc_gateway'],
                             request.form['vc_username'],
                             request.form['vc_password'])
                db.session.add(vc)
                db.session.commit()
                return "<div class='alert alert-success' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>vCenter Added</div>"
Пример #25
0
from jinja2 import Environment, FileSystemLoader
from distutils.util import strtobool
from iomate.iomate_app import Blueprint, render_template, request, flash, redirect, login_required, db, os
from iomate.models import Switches, Firewalls, Esxis, Servers, Dedicatedsan, Vlans, Switch2_24_port, Customer_sw

design_sw2_24 = Blueprint('design_sw2_24', __name__)

### LOCAL CONFIG ###
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
TEMPLATE_DIR = 'templates/configuration_templates/pyserial'
TEMPLATE_CONFIG = os.path.join(BASE_DIR, TEMPLATE_DIR)

### DESIGN_SW2_24_port ###
@design_sw2_24.route("/design-sw2-24", methods=['GET', 'POST'])
@login_required
def design_switch2_24_port_view():
    error = None
    if request.method == 'GET':
        file = open("output/customer-sw-2-24-portconfig.deploy", "r")
        lines = file.readlines()
        return render_template('design-sw2-24.html', customer_sws=Customer_sw.query.all(), sws=Switches.query.all(), fws=Firewalls.query.all(), esxis=Esxis.query.all(), servers=Servers.query.all(), dedicatedsans=Dedicatedsan.query.all(), vlans=Vlans.query.all(), switch2_24_ports=Switch2_24_port.query.all(), lines=lines)
    elif request.method == 'POST':
        if 'port_config_switch2_24_port_save' in request.form:
            if not request.form['id'] or not request.form['port_device'] or not request.form['port_device_port'] or not request.form['port_mode'] or not request.form['port_vlan'] or not request.form['port_pxe_boot']:
                flash('Please fill all fields before sending a request !','danger')
                return redirect(request.url)
            else:
                if request.form['port_mode'] == 'None' and request.form['port_vlan'] == 'None':
                    port_id = request.form.get('id')
                    port = Switch2_24_port.query.filter_by(id=port_id).one()
                    port.devicename=request.form['port_device']
Пример #26
0
from iomate.iomate_app import Blueprint, render_template, request, flash, redirect, login_required, db
from iomate.models import VirtualMachines

virtualmachines = Blueprint('virtualmachines', __name__)


@virtualmachines.route("/virtualmachines", methods=['GET', 'POST'])
@login_required
def virtualmachines_view():
    error = None
    if request.method == 'GET':
        return render_template('virtualmachines.html',
                               vms=VirtualMachines.query.all())
    elif request.method == 'POST':
        if 'vm_add' in request.form:
            if not request.form['vm_hostname'] or not request.form[
                    'vm_ipaddress'] or not request.form[
                        'vm_subnet'] or not request.form[
                            'vm_gateway'] or not request.form[
                                'vm_portgroup'] or not request.form[
                                    'vm_username'] or not request.form[
                                        'vm_password']:
                return "<div class='alert alert-danger' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>ERROR</div>"
            else:
                vm = VirtualMachines(
                    request.form['vm_hostname'], request.form['vm_ipaddress'],
                    request.form['vm_subnet'], request.form['vm_gateway'],
                    request.form['vm_portgroup'], request.form['vm_username'],
                    request.form['vm_password'])
                db.session.add(vm)
                db.session.commit()
Пример #27
0
from jinja2 import Environment, FileSystemLoader
from iomate.iomate_app import Blueprint, render_template, request, flash, redirect, login_required, db, os
from iomate.models import Switches, Vlans, Customer_sw

switches = Blueprint('switches', __name__)

### LOCAL CONFIG ###
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
TEMPLATE_DIR = 'templates/configuration_templates/pyserial'
TEMPLATE_CONFIG = os.path.join(BASE_DIR, TEMPLATE_DIR)


@switches.route("/switches", methods=['GET', 'POST'])
@login_required
def switches_view():
    error = None
    if request.method == 'GET':
        file_switch1 = open("output/customer-sw-1-baseconfig.deploy", "r")
        lines_switch1 = file_switch1.readlines()
        file_switch2 = open("output/customer-sw-2-baseconfig.deploy", "r")
        lines_switch2 = file_switch2.readlines()
        return render_template('switches.html',
                               sws=Switches.query.all(),
                               vlans=Vlans.query.all(),
                               customer_sws=Customer_sw.query.all(),
                               lines_switch1=lines_switch1,
                               lines_switch2=lines_switch2)
    elif request.method == 'POST':
        if 'sw_add' in request.form:
            if not request.form['sw_hostname'] or not request.form[
                    'sw_ipaddress'] or not request.form[
Пример #28
0
from iomate.iomate_app import Blueprint, render_template, request, flash, redirect, login_required, db
from iomate.models import Subnets, Vlans

subnets = Blueprint('subnets', __name__)


@subnets.route("/subnets", methods=['GET', 'POST'])
@login_required
def subnets_view():
    error = None
    if request.method == 'GET':
        return render_template('subnets.html',
                               subnets=Subnets.query.all(),
                               vlans=Vlans.query.all())
    elif request.method == 'POST':
        if 'subnet_add' in request.form:
            if not request.form['subnet_name'] or not request.form[
                    'subnet_network'] or not request.form['subnet_mask']:
                return "<div class='alert alert-danger' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>ERROR</div>"
            else:
                subnet = Subnets(request.form['subnet_name'],
                                 request.form['subnet_network'],
                                 request.form['subnet_mask'])
                db.session.add(subnet)
                db.session.commit()
                return "<div class='alert alert-success' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>Subnet Added</div>"
        elif 'subnet_edit' in request.form:
            if not request.form['subnet_name'] or not request.form[
                    'subnet_network'] or not request.form['subnet_mask']:
                return "<div class='alert alert-danger' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>ERROR</div>"
            else:
Пример #29
0
from iomate.iomate_app import Blueprint, render_template, request, flash, redirect, login_required, db
from iomate.models import Esxis

esxi = Blueprint('esxi', __name__)


@esxi.route("/esxi", methods=['GET', 'POST'])
@login_required
def esxi_view():
    error = None
    if request.method == 'GET':
        return render_template('esxi.html', esxis=Esxis.query.all())
    elif request.method == 'POST':
        if 'esxi_add' in request.form:
            if not request.form['esxi_hostname'] or not request.form[
                    'esxi_ipaddress'] or not request.form[
                        'esxi_subnet'] or not request.form[
                            'esxi_gateway'] or not request.form[
                                'esxi_username'] or not request.form[
                                    'esxi_password']:
                return "<div class='alert alert-danger' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>ERROR</div>"
            else:
                esxi = Esxis(request.form['esxi_hostname'],
                             request.form['esxi_ipaddress'],
                             request.form['esxi_subnet'],
                             request.form['esxi_gateway'],
                             request.form['esxi_username'],
                             request.form['esxi_password'])
                db.session.add(esxi)
                db.session.commit()
                return "<div class='alert alert-success' role='alert'><a href='#' class='close' data-dismiss='alert'>&times;</a>ESXi Added</div>"
Пример #30
0
from jinja2 import Environment, FileSystemLoader
import jenkins
import codecs

from iomate.iomate_app import Blueprint, render_template, request, flash, redirect, login_required, os

##IMPORT FROM IOMATE GLOBAL##
from iomate.iomate_global import srvjenkins
from iomate.iomate_global import get_deploy_device_last_build_log
from iomate.iomate_global import get_deploy_device_get_job_info

livecd = Blueprint('livecd', __name__)

### LOCAL CONFIG ###
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
TEMPLATE_DIR_SALTSTACK = 'templates/configuration_templates/livecd'
TEMPLATE_CONFIG_SALTSTACK = os.path.join(BASE_DIR, TEMPLATE_DIR_SALTSTACK)


@livecd.route("/livecd", methods=['GET', 'POST'])
@login_required
def livecd_view():
    error = None
    if request.method == 'GET':
        file = open("output/hextrimos.cfg", "r")
        lines = file.readlines()
        build_hextrimos_iso = get_deploy_device_last_build_log(
            'build_hextrimos_iso')
        build_hextrimos_iso_info = get_deploy_device_get_job_info(
            'build_hextrimos_iso')
        convert_hextrimos_to_pxeboot = get_deploy_device_last_build_log(