You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ah...@apache.org on 2012/10/26 02:35:08 UTC
git commit: Added a database creator class. not working yet. Edison
will look at it
Updated Branches:
refs/heads/javelin c272cf6b6 -> a388a748d
Added a database creator class. not working yet. Edison will look at it
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/a388a748
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/a388a748
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/a388a748
Branch: refs/heads/javelin
Commit: a388a748d055b837f9479fd797aef512f53a2a51
Parents: c272cf6
Author: Alex Huang <al...@citrix.com>
Authored: Thu Oct 25 17:34:37 2012 -0700
Committer: Alex Huang <al...@citrix.com>
Committed: Thu Oct 25 17:34:54 2012 -0700
----------------------------------------------------------------------
developer/pom.xml | 67 ++++++++++++
server/src/com/cloud/upgrade/DatabaseCreator.java | 87 ++++++++++++++++
2 files changed, 154 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a388a748/developer/pom.xml
----------------------------------------------------------------------
diff --git a/developer/pom.xml b/developer/pom.xml
index d2352c2..fa69093 100644
--- a/developer/pom.xml
+++ b/developer/pom.xml
@@ -33,6 +33,73 @@
<profiles>
<profile>
+ <id>deploydb2</id>
+ <activation>
+ <property>
+ <name>deploydb2</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.2.1</version>
+ <dependencies>
+ <!-- specify the dependent jdbc driver here -->
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>${cs.mysql.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
+ <version>${cs.dbcp.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-pool</groupId>
+ <artifactId>commons-pool</artifactId>
+ <version>${cs.pool.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jasypt</groupId>
+ <artifactId>jasypt</artifactId>
+ <version>${cs.jasypt.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloud-server</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloud-utils</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <id>create-database-2</id>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <executable>java</executable>
+ <arguments>
+ <argument>-classpath</argument>
+ <classpath><dependency>org.apache.cloudstack:cloud-server</dependency></classpath>
+ <argument>com.cloud.upgrade.DatabaseCreator</argument>
+ </arguments>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
<id>deploydb</id>
<activation>
<property>
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a388a748/server/src/com/cloud/upgrade/DatabaseCreator.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/upgrade/DatabaseCreator.java b/server/src/com/cloud/upgrade/DatabaseCreator.java
new file mode 100755
index 0000000..89e4b6b
--- /dev/null
+++ b/server/src/com/cloud/upgrade/DatabaseCreator.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.cloud.upgrade;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import com.cloud.utils.PropertiesUtil;
+import com.cloud.utils.db.ScriptRunner;
+import com.cloud.utils.db.Transaction;
+
+/**
+ * Creates the CloudStack Database
+ */
+public class DatabaseCreator {
+ protected static void printHelp(String cmd) {
+ System.out.println(
+ "DatabaseCreator creates the database schema by removing the \n" +
+ "previous schema, creating the schema, and running \n" +
+ "through the database updaters.");
+ System.out.println("Usage: " + cmd + " [initial schema file] [database upgrade class]");
+ }
+
+ public static void main(String[] args) {
+ System.out.println("Hello world!");
+ }
+ public static void main2(String[] args) {
+ if (args.length < 2) {
+ printHelp("DatabaseCreator");
+ System.exit(1);
+ }
+
+ File cleanScript = PropertiesUtil.findConfigFile(args[0]);
+ if (cleanScript == null) {
+ System.err.println("Unable to find " + args[0]);
+ printHelp("DatabaseCreator");
+ System.exit(1);
+ }
+
+ Connection conn = Transaction.getStandaloneConnection();
+
+ ScriptRunner runner = new ScriptRunner(conn, true, true);
+ FileReader reader = null;
+ try {
+ reader = new FileReader(cleanScript);
+ } catch (FileNotFoundException e) {
+ System.err.println("Unable to read " + args[0] + ": " + e.getMessage());
+ System.exit(1);
+ }
+ try {
+ runner.runScript(reader);
+ } catch (IOException e) {
+ System.err.println("Unable to read " + args[0] + ": " + e.getMessage());
+ System.exit(1);
+ } catch (SQLException e) {
+ System.err.println("Unable to execute " + args[0] + ": " + e.getMessage());
+ System.exit(1);
+ }
+
+ try {
+ conn.close();
+ } catch (SQLException e) {
+ System.err.println("Unable to close DB connection: " + e.getMessage());
+ }
+ }
+
+}