Skip to content

Commit

Permalink
hack: update scripts so the gofed can be run from repository
Browse files Browse the repository at this point in the history
  • Loading branch information
ingvagabund committed May 2, 2016
1 parent 3823f72 commit ddbf7d9
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 20 deletions.
16 changes: 14 additions & 2 deletions hack/clean-repo.sh
Expand Up @@ -2,8 +2,20 @@

CUR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# remove rendered templates
echo "removing rendered services"
rm -f ${CUR_DIR}/daemons/*.service

# remove infra->gofed_infra symlink
echo "removing infra->gofed_infra symlink"
rm -f ${CUR_DIR}/../third_party/infra

echo "removing directories under working_directory"
pushd ${CUR_DIR}/../working_directory/ >/dev/null
rm -rf resource_client simplefilestorage resource_provider storage
popd >/dev/null

echo "git checkout replaced infra.conf and resources.conf files"
pushd ${CUR_DIR}/../third_party/gofed_infra >/dev/null
git checkout system/config/infra.conf
cd ../gofed_resources
git checkout proposal/config/resources.conf
popd >/dev/null
6 changes: 6 additions & 0 deletions hack/prep.sh
Expand Up @@ -18,4 +18,10 @@ if [ ! -e infra ]; then
fi
popd >/dev/null

# create directory for resources and storages
pushd ${CUR_DIR}/../working_directory >/dev/null
echo "Making 'resource_client, simplefilestorage, resource_provider, storage' directories under working_directory"
mkdir -p resource_client simplefilestorage resource_provider storage
popd >/dev/null

popd >/dev/null
49 changes: 31 additions & 18 deletions hack/render-templates.py
Expand Up @@ -4,34 +4,47 @@

script_dir = getScriptDir(__file__)

def renderTemplate(template_file, template_vars):
def renderTemplate(template_file, template_vars, file):

templateLoader = jinja2.FileSystemLoader( searchpath=script_dir )
templateEnv = jinja2.Environment( loader=templateLoader )
template = templateEnv.get_template( template_file )
return template.render( template_vars )
content = template.render( template_vars )

rootdir = os.path.dirname(script_dir)
with open(file, "w") as f:
f.write(content)

# render gofed-resources-client.service
rootdir = os.path.dirname(script_dir)

content = renderTemplate(
print "rendering gofed-resources-client.service"
renderTemplate(
"templates/gofed-resources-client.jinja", {
"envs": "GOFED_DEVEL=1 PYTHONPATH=%s/third_party" % rootdir,
"resourceclientdaemon": "%s/third_party/gofed_infra/system/daemons/resourceclientdaemon.py" % rootdir
})

with open("%s/daemons/gofed-resources-client.service" % script_dir, "w") as f:
f.write(content)
"resourceclientdaemon": "%s/third_party/gofed_infra/system/daemons/resourceclientdaemon.py" % rootdir},
"%s/daemons/gofed-resources-client.service" % script_dir
)

# render gofed-resources-provider.service

content = renderTemplate(
print "rendering gofed-resources-provider.service"
renderTemplate(
"templates/gofed-resources-provider.jinja", {
"envs": "GOFED_DEVEL=1 PYTHONPATH=%s/third_party" % rootdir,
"resourceproviderdaemon": "%s/third_party/gofed_infra/system/daemons/resourceproviderdaemon.py" % rootdir
})

with open("%s/daemons/gofed-resources-provider.service" % script_dir, "w") as f:
f.write(content)
"resourceproviderdaemon": "%s/third_party/gofed_infra/system/daemons/resourceproviderdaemon.py" % rootdir},
"%s/daemons/gofed-resources-provider.service" % script_dir
)

print "rendering third_party/gofed_infra/system/config/infra.conf"
renderTemplate(
"templates/infra.jinja", {
"resource_client_dir": "%s/working_directory/resource_client" % rootdir,
"simplefilestorage": "%s/working_directory/simplefilestorage" % rootdir},
"%s/third_party/gofed_infra/system/config/infra.conf" % rootdir
)

print "third_party/gofed_resources/proposal/config/resources.conf"
renderTemplate(
"templates/resources.jinja", {
"resource_provider_dir": "%s/working_directory/resource_provider" % rootdir,
"storage_dir": "%s/working_directory/storage" % rootdir},
"%s/third_party/gofed_resources/proposal/config/resources.conf" % rootdir
)

11 changes: 11 additions & 0 deletions hack/templates/infra.jinja
@@ -0,0 +1,11 @@
[storage]
readplugin: filestoragereader
writeplugin: filestoragewriter
write: true
read: true

[resources]
client_dir: {{ resource_client_dir }}

[simplefilestorage]
working_directory: {{ simplefilestorage }}
4 changes: 4 additions & 0 deletions hack/templates/resources.jinja
@@ -0,0 +1,4 @@
[resources]
storage_dir: {{ storage_dir }}
provider_dir: {{ resource_provider_dir }}
cache_resources: false
4 changes: 4 additions & 0 deletions working_directory/README.md
@@ -0,0 +1,4 @@
# Working directory

Main purpose of this directory is to support ``quick start`` with the **gofed** tool.
It is not meant as a permament directory for all extracted data and resources.

0 comments on commit ddbf7d9

Please sign in to comment.