Skip to content

Commit

Permalink
Fix create_env.py script to use non-DEFAULT stage type
Browse files Browse the repository at this point in the history
  • Loading branch information
gzpcho committed May 22, 2024
1 parent 1776041 commit d2baf69
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 28 deletions.
10 changes: 5 additions & 5 deletions deploy-board/tools/commons.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -37,13 +37,13 @@ def gen_random_num(size=8, chars=string.digits):
return ''.join(random.choice(chars) for _ in range(size))


def create_env(name, stage):
def create_env(name: str, stage: str):
request = {}
request["envName"] = name
request["stageName"] = stage
request["stageType"]= "DEFAULT"
request["stageType"]= "PRODUCTION"
env = environs_helper.create_env(REQUEST, request)
print("Successfully created env %s." % env['id'])
print(f"Successfully created env {env['id']}")
return env


Expand Down
36 changes: 15 additions & 21 deletions deploy-board/tools/create_env.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,21 @@
# limitations under the License.

#!/usr/bin/env python3
import commons
from deploy_board.webapp.helpers import environs_helper
from commons import create_env, REQUEST

environs_helper = commons.get_environ_helper()


def main():
if __name__ == "__main__":
for x in range(1, 3):
name = "sample-service-%d" % x
name = f"sample-service-{x}"
stage = "canary"
commons.create_env(name, stage)
hosts = ["sample-host1", "sample-host2"]
environs_helper.update_env_capacity(commons.REQUEST, name, stage,
capacity_type="HOST", data=hosts)
stage = "prod"
commons.create_env(name, stage)
groups = ["sample-group1", "sample-group2"]
environs_helper.update_env_capacity(commons.REQUEST, name, stage, data=groups)


if __name__ == "__main__":
try:
main()
except Exception as e:
print(e.message)
try:
create_env(name, stage)
hosts = ["sample-host1", "sample-host2"]
environs_helper.update_env_capacity(REQUEST, name, stage,
capacity_type="HOST", data=hosts)
stage = "prod"
create_env(name, stage)
groups = ["sample-group1", "sample-group2"]
environs_helper.update_env_capacity(REQUEST, name, stage, data=groups)
except Exception as e:
print(e)
8 changes: 6 additions & 2 deletions deploy-board/tools/run.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#!/bin/bash
#!/usr/bin/env bash

set -euxo pipefail

export TELETRAAN_SERVICE_URL=http://localhost:8011
export TELETRAAN_SERVICE_VERSION=v1

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
TARGET=$DIR/$1
shift
PYTHONPATH=$DIR/.. python $TARGET $*
PYTHONPATH=$DIR/.. python3 $TARGET $*

0 comments on commit d2baf69

Please sign in to comment.