console-cli.py

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

console-cli.py

chaoyang ma
I want to use command line in linux box to operate the process of glu.
Basically type in a new version of artifact, and then it will update the version in groovy file and then load the glu script and then start execute.

Any example of how to use this console-cli.py to do this?

Thanks,
Reply | Threaded
Open this post in threaded view
|

Re: console-cli.py

sodul
You will need to wrap code around console-cli.py:

import json
import subprocess

model_text = subprocess.check_output([
    'console-cli.py', '-u', glu_user, '-x', 'glu_password, '-c', glu_host, '-b', '-f', fabric, 'status'])
model = json.loads(model_text)
new_model = update_model(model, new_versions)

json_filename = 'x.json'
with open(json_filename, 'wb') as json_file:
    json.dump(new_model, json_file, sort_keys=True, indent=4)
subprocess.check_output([
    'console-cli.py', '-u', glu_user, '-x', 'glu_password, '-c', glu_host, '-b', '-f', fabric,
    'load', '-M', json_filename
])

This is an example on how you would call the console-cli.py script to read the old model and push the new one from a python script. How you implement update_model() is entirely your call since there are several approaches you can take. The simplest one is probably to do a simple search and replace on the plain text (bypass the json parsing), you can traverse the json tree and update the version strings where needed, or more complex but more 'scalable' generate the new model from scratch every time.

My approach is to load the existing version numbers, merge it with the versions passed on the command line, and create a brand new model from there. This allows me to add remove agents from the model automatically, as well as only specify what components need to change and keep the other ones to the same versions. It requires more infrastructure though.

I do not have more code to share unfortunately.
Reply | Threaded
Open this post in threaded view
|

Re: console-cli.py

chaoyang ma
Another question regarding fabric and model.
Can one fabric support multiple running model?
At the moment, what I can see is that one fabric can only have one current working model.
Which means if I have five applications using glu to control the start and stop. I need to have five fabric.
Reply | Threaded
Open this post in threaded view
|

Re: console-cli.py

sodul
You only need one fabric.

One fabric can only have one active model, indeed, but each agent can have multiple 'entries', one for each application. I've used Glu to deploy about 20 apps on dozen of servers from a single Fabric/Model.

I do recommend that you use more fabrics to separate your Dev, QA, and Production environments.
Reply | Threaded
Open this post in threaded view
|

Re: console-cli.py

chaoyang ma
yes, i was thinking using entries, adding different mountPoint on each agent.

However my application scenario is that, I have 5 applications, A, B, C, D, E, and they have dependencies. B depends on A, C depends on B, etc, A-> B -> C -> D-> E
Also when deploying, A, B are quite stable, which means do not deploy quite frequently, however, C,D,E are deploying quite frequently and individually.  For example, I may want to deploy C several times, so C is on a higher version.

If I use the same model, how can I change the deployment plan to just deploy C or just deploy C and D?
Reply | Threaded
Open this post in threaded view
|

Re: console-cli.py

frenchyan
Administrator
If the versions for A and B are not changing in the model, then glu will not do anything for them (no delta => nothing to do). This is exactly what glu is good at. :)

Yan


On Mon, Jun 3, 2013 at 7:49 AM, chaoyang ma [via glu] <[hidden email]> wrote:
yes, i was thinking using entries, adding different mountPoint on each agent.

However my application scenario is that, I have 5 applications, A, B, C, D, E, and they have dependencies. B depends on A, C depends on B, etc, A-> B -> C -> D-> E
Also when deploying, A, B are quite stable, which means do not deploy quite frequently, however, C,D,E are deploying quite frequently and individually.  For example, I may want to deploy C several times, so C is on a higher version.

If I use the same model, how can I change the deployment plan to just deploy C or just deploy C and D?


If you reply to this email, your message will be added to the discussion below:
http://glu.977617.n3.nabble.com/console-cli-py-tp4025760p4025765.html
To start a new topic under glu, email [hidden email]
To unsubscribe from glu, click here.
NAML