Skip to content
This repository has been archived by the owner on Sep 23, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:nimbusproject/epumgmt
Browse files Browse the repository at this point in the history
  • Loading branch information
BuzzTroll committed Oct 21, 2010
2 parents df357fe + 84b9dbd commit a026adc
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 35 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -4,3 +4,5 @@ var/epumgmt/runlogs/*
var/epumgmt/confs_used/*
var/epumgmt/persistence/*lock
var/epumgmt/persistence/*list
var/epumgmt/persistence/epumgmt.db

13 changes: 11 additions & 2 deletions etc/epumgmt/internal.conf
Expand Up @@ -7,12 +7,21 @@
[persistence]
# Persistence allows the program to store information about current tasks.

# The program uses a directory to store the information. If this setting is a
# The program uses a directory to store information. If this setting is a
# relative path, it will be resolved from the epumgmt specific var directory
# (see "dirs.conf").

persistencedir: persistence
persistencedb: sqlite:////home/bresnaha/Dev/Nimbus/OOI/epumgmt.db

# The program must configure a database. If this setting is a local path,
# it is assumed that it is a SQLite database. If the path is relative, it's
# resolved from the persistencedir setting. If it is not a path at all, it's
# assumed that this is a connection string to pass on verbatim to cloudminer
# (SQLAlchemy).

persistencedb: epumgmt.db

#persistencedb: sqlite:////var/somewhere/epumgmt.db


[emimpls]
Expand Down
15 changes: 15 additions & 0 deletions etc/epumgmt/services/rabbitmq.chefroles.json
@@ -0,0 +1,15 @@
{
"capabilitycontainer":{
"broker":"${broker_ip_address}",
"bootscript":"res/scripts/newcc.py",
"sysname":"${exchange_scope}",
"broker_heartbeat":"5",
"lcaarch_branch":"cei",
"lcaarch_commit_hash":"${lcaarch_commit_hash}",
"log_level":"WARNING"
},
"username":"cc",
"services":{
},
"recipes":["rabbitmq"]
}
6 changes: 3 additions & 3 deletions libexec/epumgmt/fab-bootstrap/chefconf.rb
@@ -1,5 +1,5 @@
cookbook_path "/opt/chef/cookbooks"
cookbook_path "/opt/dt-data/cookbooks"
log_level :info
file_store_path "/opt/chef/tmp"
file_cache_path "/opt/chef/tmp"
file_store_path "/opt/dt-data/tmp"
file_cache_path "/opt/dt-data/tmp"
Chef::Log::Formatter.show_time = false
36 changes: 12 additions & 24 deletions libexec/epumgmt/fab-bootstrap/fabfile.py
Expand Up @@ -5,7 +5,7 @@
from fabric.decorators import runs_once

def bootstrap(rolesfile=None):
update()
update_dt_data()
put_chef_data(rolesfile=rolesfile)
run_chef_solo()

Expand Down Expand Up @@ -38,32 +38,20 @@ def update():
with hide('stdout'):
run("sudo apt-get -q update")

def install_chef():
run("sudo apt-get install -y ruby-dev libopenssl-ruby rubygems")
run("sudo gem install chef ohai --no-ri --no-rdoc --source http://gems.opscode.com --source http://gems.rubyforge.org")
run("sudo ln -s /var/lib/gems/1.8/bin/chef-solo /usr/local/bin/")
run("sudo ln -s /var/lib/gems/1.8/bin/ohai /usr/local/bin/")

@runs_once
def ensure_opt():
run("if [ ! -d /opt ]; then sudo mkdir /opt; fi")
def update_dt_data():
# checkout the latest cookbooks:
with cd("/opt/dt-data"):
run("sudo git fetch")
run("sudo git reset --hard origin/HEAD")

def put_chef_data(rolesfile=None):
ensure_opt()
run("if [ -d /opt/chef ]; then sudo rm -rf /opt/chef; fi")
run("sudo mkdir /opt/chef && sudo chown ubuntu:ubuntu /opt/chef")
# checkout the latest cookbooks:
run("sudo apt-get install -y git-core")
run("git clone http://github.com/clemesha-ooi/ooi-cookbooks.git /opt/chef/cookbooks")
# put the role and config files:
put("chefconf.rb", "/opt/chef/")
if rolesfile:
put(rolesfile, "/opt/chef/chefroles.json")
else:
put("chefroles.json", "/opt/chef/")
put("chefconf.rb", "/tmp/")
put(rolesfile or "chefroles.json", "/tmp/chefroles.json")
run("sudo mkdir -p /opt/dt-data/run")
run("sudo mv /tmp/chefconf.rb /tmp/chefroles.json /opt/dt-data/run/")


def run_chef_solo():
run("sudo chef-solo -l debug -c /opt/chef/chefconf.rb -j /opt/chef/chefroles.json")
run("sudo chef-solo -l debug -c /opt/dt-data/run/chefconf.rb -j /opt/dt-data/run/chefroles.json")



44 changes: 38 additions & 6 deletions src/python/epumgmt/main/em_core_persistence.py
Expand Up @@ -3,6 +3,7 @@
import pickle
import stat
import sys
import urlparse
from epumgmt.defaults import RunVM
from epumgmt.api.exceptions import *
import epumgmt.main.em_args as em_args
Expand All @@ -15,15 +16,46 @@ class Persistence:
def __init__(self, params, common):
self.p = params
self.c = common
self.pdb = None
self.lockfilepath = None

def validate(self):
pdb = self.p.get_conf_or_none("persistence", "persistencedb")
if not pdb:
def _find_db_conf(self):
dbconf = self.p.get_conf_or_none("persistence", "persistencedb")
if not dbconf:
raise InvalidConfig("There is no persistence->persistencedb configuration")
self.pdb = pdb
self.cdb = CloudMiner(self.pdb)
url = urlparse.urlparse(dbconf)

# If it's some kind of URL, return verbatim
if url.scheme:
self.c.log.info("Database configuration (verbatim): %s" % dbconf)
return dbconf

# If it's an absolute path, assuming SQLite.
# Relative paths are taken from the persistencedir setting.

if not os.path.isabs(dbconf):
pdir = self.p.get_conf_or_none("persistence", "persistencedir")
if not pdir:
raise InvalidConfig("There is no persistence->persistencedir configuration")

if not os.path.isabs(pdir):
pdir = self.c.resolve_var_dir(pdir)

if not os.path.isdir(pdir):
raise InvalidConfig("Not a directory: %s" % pdir)

dbconf = os.path.join(pdir, dbconf)

sqlitedbconf = "sqlite:///" + dbconf
self.c.log.info("Database configuration (deduced): %s" % sqlitedbconf)

if not os.path.exists(dbconf):
raise InvalidConfig("File does not exist: %s" % dbconf)

return sqlitedbconf


def validate(self):
self.cdb = CloudMiner(self._find_db_conf())

def new_vm(self, run_name, vm):
"""Adds VM to a run_vms list if it exists for "run_name". If list
Expand Down
Empty file.

0 comments on commit a026adc

Please sign in to comment.