def create_hbase_policy(self): print "Creating hbase policy, please input" def trueOrfalse(input_str): if input_str.lower() in ("yes", "y"): return True else: return False try: policy_data = { "repositoryType" : "hbase", "repositoryName" : get_input("Repository name"), "policyName" : get_input("Policy name"), "tables" : get_input("Table name(s)", hint="comma seperated list", default="*"), "columnFamilies" : get_input("Column familie(s)", hint="comma seperated list", default="*"), "columns" : get_input("Column(s)", hint="comma seperated list", default="*"), "description": get_input("Description", default=""), "isEnabled": get_input("Enabled?", hint="Yes/No", default="Yes", convert=trueOrfalse), "isAuditEnabled":get_input("Auditable?", hint="Yes/No", default="Yes", convert=trueOrfalse), "isRecursive": get_input("Recursive?", hint="Yes/No", default="No", convert=trueOrfalse), "tableType": "Inclusion", "columnType": "Inclusion", } permmap_list = [] while True: perm_map = self.get_permission_map("Read", "Write", "Create", "Admin") if len(perm_map["permList"]) == 0: break permmap_list.append(perm_map) policy_data["permMapList"] = permmap_list self.do_echo( self.__create_policy(policy_data)) except KeyboardInterrupt: print "Control-C" except Exception as e: print e
def get_permission_map(*perms): to_list = lambda s: s.replace(",", " ").split() print "Please input a permission map:" permlist = "/".join(perms) perm_map ={"userList" : get_input("User(s)", hint="comma seperated list", default="", convert=to_list), "groupList" : get_input("Group(s)", hint="comma seperated list", default="", convert=to_list), "permList": get_input("Permissions", hint="comma seperated list of %s" % permlist, default="", convert=to_list) } return perm_map