def delete_access_key(self, access_key): self.init_iam self.init_access_keys key_names = filter(lambda x: x['key'] == access_key, self.access_keys) iam = get_root_IAM_connection() if len(key_names): iam.delete_access_key(access_key, self.user_name) audit_log("Deleted access key %s" % (access_key)) dbh.execute("BEGIN EXCLUSIVE") dbh.execute(""" DELETE FROM access_keys WHERE access_key=? AND user_name=? """, [access_key, self.user_name]) dbh.execute("COMMIT")
def delete_access_key(self, access_key): self.init_iam self.init_access_keys key_names = filter(lambda x: x['key'] == access_key, self.access_keys) iam = get_root_IAM_connection() if len(key_names): iam.delete_access_key(access_key, self.user_name) audit_log("Deleted access key %s" % (access_key)) dbh.execute("BEGIN EXCLUSIVE") dbh.execute( """ DELETE FROM access_keys WHERE access_key=? AND user_name=? """, [access_key, self.user_name]) dbh.execute("COMMIT")
def create_access_key(self): iam_root = get_root_IAM_connection() response = iam_root.create_access_key(self.user_name) audit_log("Creating access key %s for %s" % ( self.user_name, response.access_key_id )) dbh.execute("BEGIN EXCLUSIVE") dbh.execute(""" INSERT OR IGNORE INTO access_keys ( user_name, access_key, secret_access_key ) VALUES (?, ?, ?) """, [self.user_name, str(response.access_key_id), str(response.secret_access_key)]) dbh.execute("COMMIT") self.init_access_keys()
def create_access_key(self): iam_root = get_root_IAM_connection() response = iam_root.create_access_key(self.user_name) audit_log("Creating access key %s for %s" % (self.user_name, response.access_key_id)) dbh.execute("BEGIN EXCLUSIVE") dbh.execute( """ INSERT OR IGNORE INTO access_keys ( user_name, access_key, secret_access_key ) VALUES (?, ?, ?) """, [ self.user_name, str(response.access_key_id), str(response.secret_access_key) ]) dbh.execute("COMMIT") self.init_access_keys()
def make_user(user_name): audit_log("Creating user %s" % (user_name)) iam_root = get_root_IAM_connection() iam_delete_user(iam_root, user_name) iam_root.create_user(user_name) iam_root.add_user_to_group("students", user_name) iam_root.put_user_policy( user_name, "%s-user" % (user_name), simplejson.dumps(simplejson.loads(get_user_policy(user_name)))) password = random_password() iam_root.create_login_profile(user_name, password) now = datetime.datetime.utcnow().isoformat() dbh.execute("BEGIN EXCLUSIVE") dbh.execute( """ INSERT OR REPLACE INTO users (user_name, create_time, create_account, login_password) VALUES (?, ?, ?, ?) """, [user_name, now, real_username(), password]) dbh.execute("COMMIT;") user = User(user_name) return user
def make_user(user_name): audit_log("Creating user %s" % (user_name)) iam_root = get_root_IAM_connection() iam_delete_user(iam_root, user_name) iam_root.create_user(user_name) iam_root.add_user_to_group("students", user_name) iam_root.put_user_policy( user_name, "%s-user" % (user_name), simplejson.dumps(simplejson.loads(get_user_policy(user_name))) ) password = random_password() iam_root.create_login_profile(user_name, password) now = datetime.datetime.utcnow().isoformat() dbh.execute("BEGIN EXCLUSIVE") dbh.execute(""" INSERT OR REPLACE INTO users (user_name, create_time, create_account, login_password) VALUES (?, ?, ?, ?) """, [user_name, now, real_username(), password]) dbh.execute("COMMIT;") user = User(user_name) return user
def delete_user(user_name): iam_delete_user(get_root_IAM_connection(), user_name) dbh.execute("BEGIN EXCLUSIVE") dbh.execute("""DELETE FROM users WHERE user_name = ?""", [user_name]) dbh.execute("COMMIT")