def get(self): '''logic to return a list of all available ansible hosts''' hosts = common.get_all_hosts() childgroups = common.get_all_groups() return flask.render_template('addgroup.html', hosts=hosts, childgroups=childgroups)
def get(self): result = common.get_all_groups() if result: data = {"groups": [group for group in result]} else: data = {"groups": ""} return data
def get_availablegroups(self): ''' return all groups this host is not a member of''' allgroups = common.get_all_groups() # build compared list hostname = str(flask.request.form['p_get']) groups = self.get_hostgroups(hostname) s = set(groups) availablegroups = [ x for x in allgroups if x not in s ] return availablegroups
def get_available_parents(self): all_groups = common.get_all_groups() group_name = str(flask.request.form['group_get']) child_groups = self.get_child_groups(group_name) parent_groups = self.get_parent_groups(group_name) c = set(child_groups) p = set(parent_groups) available_parent_groups = [ x for x in all_groups if x not in p and x not in group_name and x not in c ] return available_parent_groups
def get_available_children(self): all_groups = common.get_all_groups() # build compared list groupname = str(flask.request.form['group_get']) child_groups = self.get_child_groups(groupname) parent_groups = self.get_parent_groups(groupname) c = set(child_groups) p = set(parent_groups) available_child_groups = [ x for x in all_groups if x not in c and x not in groupname and x not in p ] return available_child_groups
def get_all_groups(self): result = common.get_all_groups() allgroups = [] group = GetGroup() for item in result: t = {} t["groupname"] = str(item) t["children"] = group.get_group_children(item) t["hosts"] = group.get_group_hosts(item) allgroups.append(t) return allgroups
def post(self): groupname = str(flask.request.form['add_group']) hosts = common.get_all_hosts() childgroups = common.get_all_groups() if len(groupname) == 0: flask.flash('empty groupname') return flask.render_template('addgroup.html', hosts=hosts, childgroups=childgroups) elif groupname == self.get_group_name(groupname): flask.flash('groupname already exists') return flask.render_template('addgroup.html', hosts=hosts, childgroups=childgroups) else: # insert logic to see if group already exists (get_groupname) self.add_group(groupname) flask.flash('Group added successfully') return flask.render_template('addgroup.html', hosts=hosts, childgroups=childgroups)
def get(self): groups = common.get_all_groups() # return everything to the template return flask.render_template('addhost.html', groups=groups)
def get(self): result = common.get_all_groups() allgroups = []