def _add_server_in_servers(self, ip, user_info):
        server = Servers(name=user_info['name'], address=ip)
        org = Organisations.query.get(user_info['organisation_id'])
        user = User.query.get(user_info['user_id'])

        server.login = '******'
        server.password = '******'
        server.users = [user]
        server.organisation_id = org.id

        db.session.add(server)
        db.session.commit()
Ejemplo n.º 2
0
def getServers():
	response = [ 
		  { "sid" : x.sid,
		    "servername" : x.servername,
		    "ipaddress" : x.ipaddress,
		    "serverkey" : x.serverkey,
		    "status" : x.status} for x in Servers.getAllservers() ]

	return jsonify(response)
Ejemplo n.º 3
0
def server_add():
    form = ServersForm()
    if not current_user.is_root:
        form.organisations.query_factory = lambda: Organisations.query.filter(Organisations.id == current_user.organisation_id).all()
        form.organisations.allow_blank = False

    if form.validate_on_submit():
        server = Servers(form.name.data, form.address.data,
                         form.login.data, form.password.data)

        users = _add_users(form)
        server.users = users
        server.organisation_id = form.organisations.data.id
        server.protocol = form.protocol.data

        db.session.add(server)
        db.session.commit()
        flash(_('Server added'))
        return redirect(url_for("servers.server"))
    return render_template('server_add.html', form=form)
Ejemplo n.º 4
0
    def _add_server_in_servers(self, ip, user_info):
        server = Servers(name=user_info['name'], address=ip)
        org = Organisations.query.get(user_info['organisation_id'])
        user = User.query.get(user_info['user_id'])

        server.login = '******'
        server.password = '******'
        server.users = [user]
        server.organisation_id = org.id

        db.session.add(server)
        db.session.commit()
Ejemplo n.º 5
0
def generateTemplate(serverid):
	serverKey = Servers.getServerById(serverid)[0].serverkey
	template = TEMPLATEPATH.format(serverid)
	with open(template,'w') as f:
		f.write(defaultHeading(serverKey,"S"))
		f.write('\n{0}'.format(commentGen("GROUPS")))
		for x in Groups.getAGroupByServerId(serverid):

			if x.remarks:
				f.write('\n{0}'.format(commentGen(x.remarks)))
			aclname = ''
			if x.aclid:
				aclname = x.groups.aclname
			f.write(group(x.groupname,x.defaultservice,x.services,x.parent,x.member,aclname,x.logintype,x.remarks))
			f.write('\n')
		f.write(userHeading())
		f.write('\n{0}'.format(commentGen("USERSLIST")))
		for d in Users.getUsersByServerId(serverid):
			f.write(users(d.username,d.users.groupname))