anaconda / ae5-tools

A command-line tool for scripting AE5 actions
https://www.anaconda.com/enterprise/
BSD 3-Clause "New" or "Revised" License
9 stars 8 forks source link

Enable Sample Gallery operations #77

Open AlbertDeFusco opened 4 years ago

AlbertDeFusco commented 4 years ago

Here's the current known procedure to promote a project to the sample gallery.

  1. Create the desired project
  2. Share the project with all (or desired users)
  3. Use ae5-tools to promote to the sample gallery.
from ae5_tools.api import AEUserSession
import json

ae5 = AEUserSession('ae540-40.training.anaconda.com', 'anaconda-enterprise', 'anaconda-enterprise')

download_url = ae5.revision_info('user01/Untitled Project')['url']

new_sample_project = {}
new_sample_project['id'] = 'new-project'
new_sample_project['name'] = 'New Sample Project'
new_sample_project['description'] = 'My sample project'
new_sample_project['owner'] = 'anaconda-enterprise'
new_sample_project['download_url'] = download_url

ae5._post('sample_projects', data=json.dumps(new_sample_project))
AlbertDeFusco commented 4 years ago

Updated

  1. as root create the following directory on AE Master /opt/anaconda/storage/object/anaconda-objects/global
  2. as root copy project archive to the AE Master node in the /opt/anaconda/storage/object/anaconda-objects/global directory
  3. The URL for the archives placed in this directory is https://<domain>/platform/storage/api/v1/global/objects/<filename>

With ae5-tools you will need to login as an ae-admin user.

from ae5_tools.api import AEUserSession
import json

DOMAIN = '<your ae5 hostname>'
FILENAME = '<file name of project uploaded to master node>'

ae5 = AEUserSession(DOMAIN, 'anaconda-enterprise', 'anaconda-enterprise')

download_url = f'https://{DOMAIN}/platform/storage/api/v1/global/objects/{FILENAME}'

new_sample_project = {}
new_sample_project['id'] = '<short-name-for-project>'
new_sample_project['name'] = '<full-name-for-project>'
new_sample_project['description'] = '<project-description>'
new_sample_project['owner'] = 'anaconda-enterprise'
new_sample_project['download_url'] = download_url
new_sample_project['is_template'] = False  # set to True to add to Create Project list

ae5._post('sample_projects', data=json.dumps(new_sample_project))