コード例 #1
0
ファイル: add_group.py プロジェクト: allanice001/autobot
 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)
コード例 #2
0
 def get(self):
     result = common.get_all_hosts()
     if result:
         data = {"hosts": [host for host in result]}
     else:
         data = {"hosts": ""}
     return data
コード例 #3
0
 def get_all_hosts(self):
     result = common.get_all_hosts()
     all_hosts = {}
     host = GetHost()
     for item in result:
         item_groups = host.get_host_groups(item)
         all_hosts[item] = [str(x) for x in item_groups]
     return all_hosts
コード例 #4
0
 def get_availablehosts(self):
     ''' return all hosts not a member of this group'''
     allhosts = common.get_all_hosts()
     # build compared list
     groupname = str(flask.request.form['group_get'])
     hosts = self.get_grouphosts(groupname)
     if hosts:
         s = set(hosts)
         avaiblable = [x for x in allhosts if x not in s]
         return avaiblable
     return allhosts
コード例 #5
0
ファイル: add_group.py プロジェクト: allanice001/autobot
 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)