in bicep/files-to-load/cyclecloud_install.py [0:0]
def create_user_credential(username, public_key=None):
create_user(username)
public_key = create_keypair(username, public_key)
credential_record = {
"PublicKey": public_key,
"AdType": "Credential",
"CredentialType": "PublicKey",
"Name": username + "/public"
}
credential_data_file = os.path.join(tmpdir, "credential.json")
print("Creating cred file: {}".format(credential_data_file))
with open(credential_data_file, 'w') as fp:
json.dump(credential_record, fp)
config_path = os.path.join(cycle_root, "config/data/")
print("Copying config to {}".format(config_path))
_catch_sys_error(["chown", "cycle_server:cycle_server", credential_data_file])
# Don't use copy2 here since ownership matters
# copy2(credential_data_file, config_path)
_catch_sys_error(["mv", credential_data_file, config_path])