Skip to content

Commit

Permalink
ADD new fields
Browse files Browse the repository at this point in the history
  • Loading branch information
pencinarsanz-atos committed Oct 27, 2021
1 parent de84a76 commit c63c51e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 26 deletions.
12 changes: 7 additions & 5 deletions evolved5g/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ def generate(ctx,no_input, repo_name, package_name, template):

@cli.command()
@click.option('--mode',type=click.Choice(['build', 'deploy','destroy'], case_sensitive=False))
@click.option('--repo',type=str, help='Enter repo name')
@click.pass_context
def run_pipeline(ctx, mode):
def run_pipeline(ctx, mode, repo):
"""
"""
ctx.obj["helper"].run_pipeline(mode)
ctx.obj["helper"].run_pipeline(mode,repo)

@cli.command()
def check_pipeline():
@click.option('--id',type=int, help='Enter pipeline id')
@click.pass_context
def check_pipeline(ctx, id):
"""
"""
cli_helper = CLI_helper()
cli_helper.check_pipeline()
ctx.obj["helper"].check_pipeline(id)
26 changes: 5 additions & 21 deletions evolved5g/cli_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,43 +30,27 @@ def generate(self, no_input, repo_name, package_name, template):
location = "gh:EVOLVED-5G/template"
cookiecutter_generate(location, no_input=no_input) #extra_context=extra)

# def curl(self, tokeng, branchorpipe, mode):

# self.header = { "content-Type":"application/json", "accept": "application/json", "Authorization": tokeng }

# if mode == "build" or mode == "deploy" or mode == "destroy":
# repo = input("Please write down your repo:\n")
# data = '{ "instance": "pro-dcip-evol5-01.hi.inet", "job": "dummy-netapp/'+ mode +'", "parameters": { "VERSION": "1.0", "GIT_URL": "https://github.com/EVOLVED-5G/' + repo +'", "GIT_BRANCH": "' + branchorpipe + '"} }'
# resp = requests.post(self.url_curl, headers=self.header, data=data)

# return (resp.json()["id"])

# if mode == "check":
# resp = requests.get(f"{self.url_curl}/{branchorpipe}", headers=self.header)

# return (resp.json())

def generate_token(self):

self.header = { "content-Type":"application/json", "accept": None, "Authorization": None }
data = '{ "username": "usu_Evolved5g", "password": "evolved5g" }'
resp = requests.post(self.url_token, headers=self.header, data=data)
return(resp.json()["access_token"])

def run_pipeline(self, mode):
def run_pipeline(self, mode, repo):
"""Run the build pipeline for the EVOLVED-5G NetApp"""
self.header = { "content-Type":"application/json", "accept": "application/json", "Authorization": self.generate_token() }
repo = input("Please write down your repo:\n")
# repo = input("Please write down your repo:\n")
data = '{ "instance": "pro-dcip-evol5-01.hi.inet", "job": "dummy-netapp/'+ mode +'", "parameters": { "VERSION": "1.0", "GIT_URL": "https://github.com/EVOLVED-5G/' + repo +'", "GIT_BRANCH": "' + self.branch + '"} }'
resp = requests.post(self.url_curl, headers=self.header, data=data)
echo(resp.json()["id"])

def check_pipeline(self):
def check_pipeline(self, id):

"""Check the status of the pipeline for the EVOLVED-5G NetApp"""
self.header = { "content-Type":"application/json", "accept": "application/json", "Authorization": self.generate_token() }
pipelineid = input("Please write down the pipeline ID you want to check:\n")
resp = requests.get(f"{self.url_curl}/{pipelineid}", headers=self.header)
# pipelineid = input("Please write down the pipeline ID you want to check:\n")
resp = requests.get(f"{self.url_curl}/{id}", headers=self.header)
result = resp.json()

if result["status"] == "QUEUED":
Expand Down

0 comments on commit c63c51e

Please sign in to comment.