-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Community ignore ui on 17.3.31 #538
base: master
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,8 @@ | |
from cloudify import ctx | ||
|
||
ctx.download_resource( | ||
join('components', 'utils.py'), | ||
join(dirname(__file__), 'utils.py')) | ||
join('components', 'utils.py'), | ||
join(dirname(__file__), 'utils.py')) | ||
import utils # NOQA | ||
|
||
STAGE_SERVICE_NAME = 'stage' | ||
|
@@ -22,6 +22,8 @@ def install_stage(): | |
|
||
nodejs_source_url = ctx_properties['nodejs_tar_source_url'] | ||
stage_source_url = ctx_properties['stage_tar_source_url'] | ||
print "stage_source_url={0}".format(stage_source_url) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove print |
||
ctx.instance.runtime_properties['ignore_ui'] = 'False' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps call the runtime property: "skip_stage_installation" and set it to 'true' |
||
|
||
# injected as an input to the script | ||
ctx.instance.runtime_properties['influxdb_endpoint_ip'] = \ | ||
|
@@ -42,25 +44,30 @@ def install_stage(): | |
utils.mkdir(stage_home) | ||
utils.mkdir(stage_log_path) | ||
|
||
utils.create_service_user(stage_user, stage_home) | ||
|
||
ctx.logger.info('Installing NodeJS...') | ||
nodejs = utils.download_cloudify_resource(nodejs_source_url, | ||
STAGE_SERVICE_NAME) | ||
utils.untar(nodejs, nodejs_home) | ||
|
||
ctx.logger.info('Installing Cloudify Stage (UI)...') | ||
stage = utils.download_cloudify_resource(stage_source_url, | ||
STAGE_SERVICE_NAME) | ||
utils.untar(stage, stage_home) | ||
|
||
ctx.logger.info('Fixing permissions...') | ||
utils.chown(stage_user, stage_group, stage_home) | ||
utils.chown(stage_user, stage_group, nodejs_home) | ||
utils.chown(stage_user, stage_group, stage_log_path) | ||
|
||
utils.logrotate(STAGE_SERVICE_NAME) | ||
utils.systemd.configure(STAGE_SERVICE_NAME) | ||
stage = utils.download_cloudify_resource( | ||
stage_source_url, STAGE_SERVICE_NAME, avoid_failure=True) | ||
if not stage: | ||
ctx.instance.runtime_properties['ignore_ui'] = 'True' | ||
print "***ignore ui***" | ||
ignore_ui = ctx.instance.runtime_properties['ignore_ui'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. skip_stage_installation... |
||
print ctx.instance.runtime_properties['ignore_ui'].__class__ | ||
print "ignore_ui={0}".format(ignore_ui) | ||
if ignore_ui != 'True': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe in order not to get all the script indented just do something like: if skip_stage_installation: |
||
print "**inside if**" | ||
utils.create_service_user(stage_user, stage_home) | ||
ctx.logger.info('Installing NodeJS...') | ||
nodejs = utils.download_cloudify_resource(nodejs_source_url, | ||
STAGE_SERVICE_NAME) | ||
utils.untar(nodejs, nodejs_home) | ||
utils.untar(stage, stage_home) | ||
ctx.logger.info('Fixing permissions...') | ||
utils.chown(stage_user, stage_group, stage_home) | ||
utils.chown(stage_user, stage_group, nodejs_home) | ||
utils.chown(stage_user, stage_group, stage_log_path) | ||
|
||
utils.logrotate(STAGE_SERVICE_NAME) | ||
utils.systemd.configure(STAGE_SERVICE_NAME) | ||
|
||
|
||
def main(): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,12 +5,14 @@ | |
from cloudify import ctx | ||
|
||
ctx.download_resource( | ||
join('components', 'utils.py'), | ||
join(dirname(__file__), 'utils.py')) | ||
join('components', 'utils.py'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why? |
||
join(dirname(__file__), 'utils.py')) | ||
import utils # NOQA | ||
|
||
STAGE_SERVICE_NAME = 'stage' | ||
|
||
|
||
ctx.logger.info('Starting Stage (UI) Service...') | ||
utils.start_service(STAGE_SERVICE_NAME) | ||
ignore_ui = ctx.instance.runtime_properties['ignore_ui'] | ||
print "ignore_ui={0}".format(ignore_ui) | ||
if ignore_ui != 'True': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. skip_stage_installation = 'skip_stage_installation' in ctx.instance.runtime_properties if skip_stage_installation: |
||
ctx.logger.info('Starting Stage (UI) Service...') | ||
utils.start_service(STAGE_SERVICE_NAME) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -405,26 +405,33 @@ def get_file_name_from_url(url): | |
return os.path.basename(disassembled.path) | ||
|
||
|
||
def download_cloudify_resource(url, service_name, destination=None): | ||
def download_cloudify_resource( | ||
url, service_name, destination=None, avoid_failure=False): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. avoid_failure -> raise_error_on_failure=True |
||
"""Downloads a resource and saves it as a cloudify resource. | ||
|
||
The resource will be saved under the appropriate service resource path and | ||
will be used in case of operation execution failure after the resource has | ||
already been downloaded. | ||
""" | ||
if destination: | ||
source_res_path, _ = resource_factory.create(url, | ||
destination, | ||
service_name, | ||
source_resource=True, | ||
render=False) | ||
copy(source_res_path, destination) | ||
else: | ||
res_name = os.path.basename(url) | ||
source_res_path, _ = resource_factory.create(url, res_name, | ||
service_name, | ||
source_resource=True, | ||
render=False) | ||
try: | ||
if destination: | ||
source_res_path, _ = resource_factory.create(url, | ||
destination, | ||
service_name, | ||
source_resource=True, | ||
render=False) | ||
copy(source_res_path, destination) | ||
else: | ||
res_name = os.path.basename(url) | ||
source_res_path, _ = resource_factory.create(url, res_name, | ||
service_name, | ||
source_resource=True, | ||
render=False) | ||
except Exception: | ||
# print "source_res_path={0}".format(source_res_path) | ||
if avoid_failure: | ||
return None | ||
|
||
return source_res_path | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you change the indentation?