summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@redhat.com>2014-05-07 14:23:54 +0200
committerTomas Bzatek <tbzatek@redhat.com>2014-05-07 14:23:54 +0200
commitf5f826cc0f634b15f0573bfa5654ca9e7221e7a5 (patch)
treed58c9f65d27d5d706b0673ed3ae1a475b45b2663 /tools
parent691e41026477298b00d3a9cbd41ae9620601e888 (diff)
downloadopenlmi-providers-f5f826cc0f634b15f0573bfa5654ca9e7221e7a5.tar.gz
openlmi-providers-f5f826cc0f634b15f0573bfa5654ca9e7221e7a5.tar.xz
openlmi-providers-f5f826cc0f634b15f0573bfa5654ca9e7221e7a5.zip
devassistant: Add support for creating new scripts
This snippet first clones the upstream openlmi-scripts repo and uses the make_new.py script to create new command. The generated structure is independent from the openlmi-scripts repo and only depends on openlmi-tools.
Diffstat (limited to 'tools')
-rw-r--r--tools/devassistant/assistants/crt/python/openlmi-scripts.yaml108
-rw-r--r--tools/devassistant/assistants/prep/openlmi-scripts.yaml35
2 files changed, 143 insertions, 0 deletions
diff --git a/tools/devassistant/assistants/crt/python/openlmi-scripts.yaml b/tools/devassistant/assistants/crt/python/openlmi-scripts.yaml
new file mode 100644
index 0000000..9594474
--- /dev/null
+++ b/tools/devassistant/assistants/crt/python/openlmi-scripts.yaml
@@ -0,0 +1,108 @@
+openlmi:
+ fullname: LMI script assistant
+ description: 'LMI script assistant will help you create an OpenLMI script and install necessary dependencies.'
+
+ dependencies:
+ - use: super.dependencies
+ - rpm: ['openlmi-python-base', 'openlmi-tools', 'python-docopt']
+
+ dependencies_eclipse:
+ - use: eclipse.dependencies_python
+
+ dependencies_vim:
+ - use: vim.dependencies
+
+ args:
+ name:
+ use: common_args
+
+ url:
+ flags:
+ - -u
+ - --url
+ help:
+ If used, will check out LMI scripts from given URL (useful when working with fork).
+ required: False
+ default: https://github.com/openlmi/openlmi-scripts.git
+
+ author:
+ flags:
+ - -a
+ - --author
+ help:
+ Specify author
+ required: False
+ default: "John Doe"
+
+ email:
+ flags:
+ - -m
+ - --email
+ help:
+ Specify author's e-mail
+ required: False
+ default: "john@example.com"
+
+ eclipse:
+ use: eclipse
+
+ github:
+ use: common_args
+
+ vim:
+ use: vim
+
+ files:
+ gitignore: &gitignore
+ source: ../.gitignore
+ sources: &sources
+ source: .
+
+ run:
+ - $dirname: $(dirname "$name")
+ - $basename: $(basename "$name")
+ - $lbasename: $(basename "$name" | tr '[A-Z]' '[a-z]')
+ - log_i: 'Creating LMI script $basename in $dirname ...'
+ - if $(test -e "$name"):
+ - log_e: '$name already exists, cannot proceed.'
+ - else:
+ - cl: mkdir -p "$name"
+ - cl: cd "$name"
+ - log_i: Getting LMI scripts sources ...
+ - $git_output: $(git clone --depth 1 "$url" .openlmi-scripts)
+ - if $(echo "$git_output" | grep "fatal"):
+ - log_e: Could not checkout sources - $git_output
+
+ - cl: cd .openlmi-scripts/commands
+ - cl_i: ./make_new.py -p "$basename" -d "$basename" -a "$author" -e "$email" "$lbasename"
+ - cl: cd "$lbasename"
+ - cl: cp -r * ../../..
+ - cl: cd ../../..
+ - cl_i: cp .openlmi-scripts/Makefile.inc Makefile
+ - cl_i: cp .openlmi-scripts/VERSION .
+ - cl: rm -rf .openlmi-scripts
+
+ - log_i: 'Building sources ...'
+ - cl_i: make setup
+ - cl_i: python setup.py build
+ - cl: cd ..
+
+ - cl: cd "$name"
+ - if defined $vim:
+ - use: vim.run
+ - if $eclipse:
+ - use: eclipse.run_python
+ - cl: cp *gitignore .
+ - use: git_init_add_commit
+ - if defined $github:
+ - github: create_and_push
+ - log_i: 'New LMI script $basename in $dirname has been created.'
+ - log_i: 'Remember it''s just a skeleton that should be filled in in order to make the script'
+ - log_i: 'usable.'
+ - log_i: ''
+ - log_i: 'Please read http://pythonhosted.org/openlmi-tools/scripts/script-tutorial.html for'
+ - log_i: 'a basic tutorial on how to write LMI scripts. Especially the "Setting up environment"'
+ - log_i: 'section is important for testing and debugging. Note that this assistant already did'
+ - log_i: 'the work noted in "Making our command structure" section for you.'
+ - log_i: ''
+ - log_i: 'Related information are kept on the project website: http://www.openlmi.org/devassistant'
diff --git a/tools/devassistant/assistants/prep/openlmi-scripts.yaml b/tools/devassistant/assistants/prep/openlmi-scripts.yaml
new file mode 100644
index 0000000..5a25eca
--- /dev/null
+++ b/tools/devassistant/assistants/prep/openlmi-scripts.yaml
@@ -0,0 +1,35 @@
+devassistant:
+ fullname: LMI scripts prepare assistant
+ description: Set up environment for LMI scripts development and checkout sources.
+
+ dependencies:
+ - rpm: ['openlmi-python-base', 'openlmi-tools', 'python-docopt']
+
+ args:
+ url:
+ flags:
+ - -u
+ - --url
+ help:
+ If used, will check out LMI scripts from given URL (useful when working with fork).
+ required: False
+ default: https://github.com/openlmi/openlmi-scripts.git
+ path:
+ use: common_args
+ help:
+ Path where to checkout the repo (will be created if it does not exist).
+
+ run:
+ - if not $(test -e "$path"):
+ - cl: mkdir -p "$path"
+ - cl: cd "$path"
+ - if $(test -e openlmi-scripts):
+ - log_e: 'openlmi-scripts directory/file already exists in directory "$path", exiting'
+ - log_i: Getting LMI scripts sources ...
+ - $git_output: $(git clone "$url")
+ - if $(echo "$git_output" | grep "fatal"):
+ - log_e: Could not checkout sources - $git_output
+ - cl: cd openlmi-scripts
+ - cl: git submodule init
+ - cl: git submodule update
+ - log_i: LMI scripts are prepared in $path/openlmi-scripts.