Working cubrid instance PoC.

Warning : cubrid does not bind to a particular interface, so it will listen on every interface. So it is not ready yet for production
parent aa8f3e5a
......@@ -52,13 +52,13 @@ class Recipe(BaseSlapRecipe):
self.requirements, self.ws = self.egg.working_set()
self.cron_d = self.installCrond()
cubrid_conf = self.installCubrid(self.getLocalIPv4Address(), 1523)
cubrid_conf = self.installCubrid(self.getLocalIPv4Address(), 30000)
ca_conf = self.installCertificateAuthority()
key, certificate = self.requestCertificate('Cubrid')
stunnel_conf = self.installStunnel(self.getGlobalIPv6Address(),
cubrid_conf['cubrid_ip'], 12345, cubrid_conf['cubrid_port'],
cubrid_conf['cubrid_ip'], 12345, cubrid_conf['cubrid_broker_port'],
certificate, key, ca_conf['ca_crl'],
ca_conf['certificate_authority_path'])
......@@ -70,11 +70,12 @@ class Recipe(BaseSlapRecipe):
return self.path_list
def installCubrid(self, ip, port, database='db', user='user',
template_filename=None, cubrid_conf=None):
def installCubrid(self, ip, port, database='cubrid_slapos_db'):
#, user='user',
# template_filename=None, cubrid_conf=None):
# XXX-Cedric : use work from Antoine to have backuped + generic cubrid
# XXX-Cedric : Check that running this recipe does not erase database
# XXX-Cedric : add access to cubrid manager and cubrid master
config_dict = {}
config_dict.update(self.options)
config_dict.update(self.parameter_dict)
......@@ -83,13 +84,16 @@ class Recipe(BaseSlapRecipe):
config_dict['cubrid_home'] = cubrid_home_path
config_dict['cubrid_ip'] = ip
config_dict['cubrid_port'] = port
config_dict['cubrid_database'] = os.path.join('cubrid')
config_dict['cubrid_broker_port'] = port
config_dict['cubrid_database'] = database
# Create configuration
cubrid_configuration_template_path = self.getTemplateFilename('cubrid.conf.in')
cubrid_configuration_path = self.createConfigurationFile("cubrid.conf",
self.substituteTemplate(cubrid_configuration_template_path, config_dict))
cubrid_broker_configuration_template_path = self.getTemplateFilename('cubrid_broker.conf.in')
cubrid_broker_configuration_path = self.createConfigurationFile("cubrid_broker.conf",
self.substituteTemplate(cubrid_broker_configuration_template_path, config_dict))
# Create wrapper
cubrid_wrapper_template_location = pkg_resources.resource_filename(
......@@ -103,6 +107,18 @@ class Recipe(BaseSlapRecipe):
self._createDirectory(cubrid_conf_directory)
self._createSimlink(cubrid_configuration_path,
os.path.join(cubrid_conf_directory, 'cubrid.conf'))
self._createSimlink(cubrid_broker_configuration_path,
os.path.join(cubrid_conf_directory, 'cubrid_broker.conf'))
# Files needed to fill database for demo
demodb_schema_template_path = self.getTemplateFilename('demodb_schema')
demodb_schema_path = self._writeFile(os.path.join(cubrid_home_path, 'demodb_schema'),
self.substituteTemplate(demodb_schema_template_path, config_dict))
demodb_objects_template_path = self.getTemplateFilename('demodb_objects')
demodb_objects_path = self._writeFile(os.path.join(cubrid_home_path, 'demodb_objects'),
open(demodb_objects_template_path, 'r').read())
# Create links to cubrid files, otherzise it will whine.
self._createSimlink(os.path.join(self.options['cubrid_location'], 'bin'),
os.path.join(cubrid_home_path, 'bin'))
......
......@@ -5,7 +5,7 @@ data_buffer_size=512M
log_buffer_size=4M
sort_buffer_size=2M
max_clients=100
cubrid_port_id=%(cubrid_port)s
cubrid_port_id=1523
db_volume_size=512M
......
#!/bin/sh
export CUBRID=%(cubrid_home)s
export CUBRID_DATABASES=%(cubrid_home)s
export JAVA_HOME=%(java_home)s
if [ ! -f %(cubrid_database)s ];
then
%(cubrid_binary)s createdb %(cubrid_database)s
$CUBRID/bin/cubrid createdb %(cubrid_database)s
$CUBRID/bin/cubrid loaddb -u dba -s $CUBRID/demodb_schema -d $CUBRID/demodb_objects %(cubrid_database)s
fi
%(cubrid_server_binary)s %(cubrid_database)s
%(cubrid_binary)s service start
%(cubrid_binary)s server start %(cubrid_database)s
[broker]
MASTER_SHM_ID =30001
ADMIN_LOG_FILE =log/broker/cubrid_broker.log
[%%query_editor]
SERVICE =ON
BROKER_PORT =%(cubrid_broker_port)s
MIN_NUM_APPL_SERVER =5
MAX_NUM_APPL_SERVER =40
APPL_SERVER_SHM_ID =30000
LOG_DIR =log/broker/sql_log
ERROR_LOG_DIR =log/broker/error_log
SQL_LOG =ON
TIME_TO_KILL =120
SESSION_TIMEOUT =300
KEEP_CONNECTION =AUTO
[%%BROKER1]
SERVICE =ON
BROKER_PORT =33000
MIN_NUM_APPL_SERVER =5
MAX_NUM_APPL_SERVER =40
APPL_SERVER_SHM_ID =33000
LOG_DIR =log/broker/sql_log
ERROR_LOG_DIR =log/broker/error_log
SQL_LOG =ON
TIME_TO_KILL =120
SESSION_TIMEOUT =300
KEEP_CONNECTION =AUTO
This diff is collapsed.
call find_user('public') on class db_user to g_public;
call find_user('PUBLIC') on class db_user to auser;
create serial event_no
start with 20422
increment by 1
minvalue 20422
maxvalue 10000000000000000000000000000000000000
nocycle;
call change_serial_owner ('event_no', 'PUBLIC') on class db_serial;
call find_user('PUBLIC') on class db_user to auser;
create serial stadium_no
start with 30141
increment by 1
minvalue 30141
maxvalue 10000000000000000000000000000000000000
nocycle;
call change_serial_owner ('stadium_no', 'PUBLIC') on class db_serial;
CREATE CLASS stadium;
call change_owner('stadium', 'PUBLIC') on class db_root;
CREATE CLASS code;
call change_owner('code', 'PUBLIC') on class db_root;
CREATE CLASS nation;
call change_owner('nation', 'PUBLIC') on class db_root;
CREATE CLASS event;
call change_owner('event', 'PUBLIC') on class db_root;
CREATE CLASS athlete;
call change_owner('athlete', 'PUBLIC') on class db_root;
CREATE CLASS participant;
call change_owner('participant', 'PUBLIC') on class db_root;
CREATE CLASS olympic;
call change_owner('olympic', 'PUBLIC') on class db_root;
CREATE CLASS game;
call change_owner('game', 'PUBLIC') on class db_root;
CREATE CLASS record;
call change_owner('record', 'PUBLIC') on class db_root;
CREATE CLASS history;
call change_owner('history', 'PUBLIC') on class db_root;
ALTER CLASS stadium ADD ATTRIBUTE
code integer NOT NULL,
nation_code character(3) NOT NULL,
[name] character varying(50) NOT NULL,
area numeric(10,2),
seats integer,
address character varying(100);
ALTER CLASS stadium ADD ATTRIBUTE
CONSTRAINT [pk_stadium_code] PRIMARY KEY(code);
ALTER CLASS code ADD ATTRIBUTE
s_name character(1),
f_name character varying(6);
ALTER CLASS nation ADD ATTRIBUTE
code character(3) NOT NULL,
[name] character varying(40) NOT NULL,
continent character varying(10),
capital character varying(30);
ALTER CLASS nation ADD ATTRIBUTE
CONSTRAINT [pk_nation_code] PRIMARY KEY(code);
ALTER CLASS event ADD ATTRIBUTE
code integer NOT NULL,
sports character varying(50),
[name] character varying(50),
gender character(1),
players integer;
ALTER CLASS event ADD ATTRIBUTE
CONSTRAINT [pk_event_code] PRIMARY KEY(code);
ALTER CLASS athlete ADD ATTRIBUTE
code integer AUTO_INCREMENT(16693, 1) NOT NULL,
[name] character varying(40) NOT NULL,
gender character(1),
nation_code character(3),
event character varying(30);
ALTER SERIAL athlete_ai_code START WITH 16693;
ALTER CLASS athlete ADD ATTRIBUTE
CONSTRAINT [pk_athlete_code] PRIMARY KEY(code);
ALTER CLASS participant ADD ATTRIBUTE
host_year integer NOT NULL,
nation_code character(3) NOT NULL,
gold integer DEFAULT 0,
silver integer DEFAULT 0,
bronze integer DEFAULT 0;
ALTER CLASS participant ADD ATTRIBUTE
CONSTRAINT [pk_participant_host_year_nation_code] PRIMARY KEY(host_year, nation_code);
ALTER CLASS olympic ADD ATTRIBUTE
host_year integer NOT NULL,
host_nation character varying(40) NOT NULL,
host_city character varying(20) NOT NULL,
opening_date date NOT NULL,
closing_date date NOT NULL,
mascot character varying(20),
slogan character varying(40),
introduction character varying(1500);
ALTER CLASS olympic ADD ATTRIBUTE
CONSTRAINT [pk_olympic_host_year] PRIMARY KEY(host_year);
ALTER CLASS game ADD ATTRIBUTE
host_year integer NOT NULL,
event_code integer NOT NULL,
athlete_code integer NOT NULL,
stadium_code integer NOT NULL,
nation_code character(3),
medal character(1),
game_date date;
ALTER CLASS game ADD ATTRIBUTE
CONSTRAINT [pk_game_host_year_event_code_athlete_code] PRIMARY KEY(host_year, event_code, athlete_code);
ALTER CLASS record ADD ATTRIBUTE
host_year integer NOT NULL,
event_code integer NOT NULL,
athlete_code integer NOT NULL,
medal character(1) NOT NULL,
score character varying(20),
unit character varying(5);
ALTER CLASS record ADD ATTRIBUTE
CONSTRAINT [pk_record_host_year_event_code_athlete_code_medal] PRIMARY KEY(host_year, event_code, athlete_code, medal);
ALTER CLASS history ADD ATTRIBUTE
event_code integer NOT NULL,
athlete character varying(40) NOT NULL,
host_year integer,
score character varying(10),
unit character varying(5);
ALTER CLASS history ADD ATTRIBUTE
CONSTRAINT [pk_history_event_code_athlete] PRIMARY KEY(event_code, athlete);
ALTER CLASS [participant] ADD CONSTRAINT [fk_participant_host_year] FOREIGN KEY(host_year) REFERENCES olympic ON DELETE RESTRICT ON UPDATE RESTRICT ;
ALTER CLASS [participant] ADD CONSTRAINT [fk_participant_nation_code] FOREIGN KEY(nation_code) REFERENCES nation ON DELETE RESTRICT ON UPDATE RESTRICT ;
ALTER CLASS [game] ADD CONSTRAINT [fk_game_event_code] FOREIGN KEY(event_code) REFERENCES event ON DELETE RESTRICT ON UPDATE RESTRICT ;
ALTER CLASS [game] ADD CONSTRAINT [fk_game_athlete_code] FOREIGN KEY(athlete_code) REFERENCES athlete ON DELETE RESTRICT ON UPDATE RESTRICT ;
COMMIT WORK;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment