# db
if ! psql -U $SFA_DB_USER -c "" $SFA_DB_NAME >/dev/null 2>&1 ; then
createdb -U postgres --template=template0 --encoding=UNICODE --owner=$SFA_DB_USER $SFA_DB_NAME
+ check
# xxx in case we'd like to ship the db schema separately
- #psql -U $SFA_DB_USER -f /etc/sfa/or/someplace/else/sfa.sql $SFA_DB_NAME
+ psql -U $SFA_DB_USER -f /usr/share/sfa/sfa.sql $SFA_DB_NAME
+ check
fi
check
# install peer certs
action $"SFA installing peer certs" daemon /usr/bin/sfa-start.py -t -d $OPTIONS
- if [ "$SFA_REGISTRY_ENABLED" -eq 1 ]; then
- action $"SFA Registry" daemon /usr/bin/sfa-start.py -r -d $OPTIONS
- fi
-
- if [ "$SFA_AGGREGATE_ENABLED" -eq 1 ]; then
- action $"SFA Aggregate" daemon /usr/bin/sfa-start.py -a -d $OPTIONS
- fi
+ [ "$SFA_REGISTRY_ENABLED" == 1 ] && action $"SFA Registry" daemon /usr/bin/sfa-start.py -r -d $OPTIONS
+
+ [ "$SFA_AGGREGATE_ENABLED" == 1 ] && action $"SFA Aggregate" daemon /usr/bin/sfa-start.py -a -d $OPTIONS
- if [ "$SFA_SM_ENABLED" -eq 1 ]; then
- action "SFA SliceMgr" daemon /usr/bin/sfa-start.py -s -d $OPTIONS
- fi
+ [ "$SFA_SM_ENABLED" == 1 ] && action "SFA SliceMgr" daemon /usr/bin/sfa-start.py -s -d $OPTIONS
- if [ "$SFA_FLASHPOLICY_ENABLED" -eq 1 ]; then
+ [ "$SFA_FLASHPOLICY_ENABLED" == 1 ] && \
action "Flash Policy Server" daemon /usr/bin/sfa_flashpolicy.py --file="$SFA_FLASHPOLICY_CONFIG_FILE" --port=$SFA_FLASHPOLICY_PORT -d
- fi
touch /var/lock/subsys/sfa-start.py
]),
('/etc/sfatables/matches/', glob('sfatables/matches/*.xml')),
('/etc/sfatables/targets/', glob('sfatables/targets/*.xml')),
- ('/etc/init.d/', [ "init.d/%s"%x for x in initscripts ])]
+ ('/etc/init.d/', [ "init.d/%s"%x for x in initscripts ]),
+ ('/usr/share/sfa/', [ 'sfa/storage/sfa.sql' ] ),
+ ]
# add sfatables processors as data_files
processor_files = [f for f in glob('sfatables/processors/*') if os.path.isfile(f)]
rm -rf $RPM_BUILD_ROOT
make VERSIONTAG="%{version}-%{taglevel}" SCMURL="%{SCMURL}" install DESTDIR="$RPM_BUILD_ROOT"
rm -rf $RPM_BUILD_ROOT/%{python_sitelib}/*egg-info
+# this gets duplicated
+rm -rf $RPM_BUILD_ROOT/usr/share/sfa/sfa.sql
%clean
rm -rf $RPM_BUILD_ROOT
%config /etc/sfa/default_config.xml
%config (noreplace) /etc/sfa/aggregates.xml
%config (noreplace) /etc/sfa/registries.xml
+/usr/share/sfa/sfa.sql
/var/www/html/wsdl/*.wsdl
%files plc
--- /dev/null
+--
+-- SFA database schema
+--
+
+SET client_encoding = 'UNICODE';
+
+--------------------------------------------------------------------------------
+-- Version
+--------------------------------------------------------------------------------
+
+-- Database version
+CREATE TABLE sfa_db_version (
+ version integer NOT NULL,
+ subversion integer NOT NULL DEFAULT 0
+) WITH OIDS;
+
+-- the migration scripts do not use the major 'version' number
+-- so 5.0 sets subversion at 100
+-- in case your database misses the site and persons tags feature,
+-- you might wish to first upgrade to 4.3-rc16 before moving to some 5.0
+-- or run the up script here
+-- http://svn.planet-lab.org/svn/PLCAPI/branches/4.3/migrations/
+
+INSERT INTO sfa_db_version (version, subversion) VALUES (1, 1);
+
+--------------------------------------------------------------------------------
+-- Aggregates and store procedures
+--------------------------------------------------------------------------------
+
+-- Like MySQL GROUP_CONCAT(), this function aggregates values into a
+-- PostgreSQL array.
+CREATE AGGREGATE array_accum (
+ sfunc = array_append,
+ basetype = anyelement,
+ stype = anyarray,
+ initcond = '{}'
+);
+
+-- main table
+CREATE TABLE sfa (
+ record_id serial PRIMARY KEY ,
+ hrn text NOT NULL,
+ authority text NOT NULL,
+ peer_authority text,
+ gid text,
+ type text NOT NULL,
+ pointer integer,
+ date_created timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ last_updated timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+CREATE INDEX sfa_hrn_ids on sfa (hrn);
+CREATE INDEX sfa_type_ids on sfa (type);
+CREATE INDEX sfa_authority_ids on sfa (authority);
+CREATE INDEX sfa_peer_authority_ids on sfa (peer_authority);
+CREATE INDEX sfa_pointer_ids on sfa (pointer);
def create(self):
-
- querystr = "CREATE TABLE " + self.tablename + " ( \
- record_id serial PRIMARY KEY , \
- hrn text NOT NULL, \
- authority text NOT NULL, \
- peer_authority text, \
- gid text, \
- type text NOT NULL, \
- pointer integer, \
- date_created timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, \
- last_updated timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP);"
- template = "CREATE INDEX %s_%s_idx ON %s (%s);"
- indexes = [template % ( self.tablename, field, self.tablename, field) \
- for field in ['hrn', 'type', 'authority', 'peer_authority', 'pointer']]
- # IF EXISTS doenst exist in postgres < 8.2
- try:
- self.db.do('DROP TABLE IF EXISTS ' + self.tablename)
- except:
- try:
- self.db.do('DROP TABLE' + self.tablename)
- except:
- pass
-
- self.db.do(querystr)
- for index in indexes:
- self.db.do(index)
-
- self.db.commit()
+ pass
+# querystr = "CREATE TABLE " + self.tablename + " ( \
+# record_id serial PRIMARY KEY , \
+# hrn text NOT NULL, \
+# authority text NOT NULL, \
+# peer_authority text, \
+# gid text, \
+# type text NOT NULL, \
+# pointer integer, \
+# date_created timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, \
+# last_updated timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP);"
+# template = "CREATE INDEX %s_%s_idx ON %s (%s);"
+# indexes = [template % ( self.tablename, field, self.tablename, field) \
+# for field in ['hrn', 'type', 'authority', 'peer_authority', 'pointer']]
+# # IF EXISTS doenst exist in postgres < 8.2
+# try:
+# self.db.do('DROP TABLE IF EXISTS ' + self.tablename)
+# except:
+# try:
+# self.db.do('DROP TABLE' + self.tablename)
+# except:
+# pass
+#
+# self.db.do(querystr)
+# for index in indexes:
+# self.db.do(index)
+#
+# self.db.commit()
def remove(self, record):
params = {'record_id': record['record_id']}