def setup_key_pair(self, context):
        key_name = '%s%s' % (context.project_id, FLAGS.vpn_key_suffix)
        try:
            result = cloud._gen_key(context, context.user_id, key_name)
            private_key = result['private_key']
            key_dir = os.path.join(FLAGS.keys_path, context.user_id)
            if not os.path.exists(key_dir):
                os.makedirs(key_dir)
            key_path = os.path.join(key_dir, '%s.pem' % key_name)
            with open(key_path, 'w') as f:
                f.write(private_key)
        except (exception.Duplicate, os.error, __HOLE__):
            pass
        return key_name
dataset/ETHPy150Open nii-cloud/dodai-compute/nova/cloudpipe/pipelib.py/CloudPipe.setup_key_pair