Exemplo n.º 1
0
def write_tokens(deployment, token, refresh_token, public_key, keycloak_host, studio_host):
    dirpath = os.path.expanduser('~/.scaleout/'+deployment)
    if not os.path.exists(dirpath):
        os.mkdir(dirpath)
    dep_config = {'access_token': token,
                  'refresh_token': refresh_token,
                  'public_key': public_key,
                  'keycloak_url': keycloak_host,
                  'studio_url': studio_host}
    status = dump_to_file(dep_config, 'user', dirpath)
    if not status:
        logger.info('Could not write tokens -- failed to write to file.')
Exemplo n.º 2
0
def write_stackn_config(updated_values):
    dirpath = os.path.expanduser('~/.scaleout/')
    if os.path.exists(dirpath+'stackn.json'):
        stackn_config, load_status = load_from_file('stackn', dirpath)
        if not load_status:
            print('Failed to load stackn config (~/.scaleout/stackn.json)')
            return False
    else:
        stackn_config = dict()

    for key, value in updated_values.items():
        stackn_config[key] = value
    
    status = dump_to_file(stackn_config, 'stackn', dirpath)
    if not status:
        logger.info('Failed to update config -- could not write to file.')
Exemplo n.º 3
0
 def set_project(self, project_name):
     # Set active project
     stackn_config, load_status = sauth.get_stackn_config()
     if not load_status:
         print('Failed to load STACKn config.')
         return False
     active_dir = stackn_config['active']
     project_dir = os.path.expanduser('~/.scaleout/' + active_dir +
                                      '/projects')
     proj_path = project_dir + '/' + project_name + '.json'
     # Update STACKN config
     stackn_config['active_project'] = project_name
     sauth.write_stackn_config(stackn_config)
     if not os.path.exists(proj_path):
         if not os.path.exists(project_dir):
             os.makedirs(project_dir)
         # Fetch and write project settings file
         print('Writing new project config file.')
         project = self.get_projects({'name': project_name})
         status = dump_to_file(project, project_name, project_dir)
         if not status:
             print('Failed to set project -- could not write to config.')