Skip to content

Commit 772f660

Browse files
author
Alex Huang
committed
Changed the create database steps to be create from a single create-schema.sql and then apply database modifications
1 parent 3423c5d commit 772f660

5 files changed

Lines changed: 205 additions & 103 deletions

File tree

developer/pom.xml

Lines changed: 140 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
2-
license agreements. See the NOTICE file distributed with this work for additional
3-
information regarding copyright ownership. The ASF licenses this file to
4-
you under the Apache License, Version 2.0 (the "License"); you may not use
5-
this file except in compliance with the License. You may obtain a copy of
6-
the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
7-
by applicable law or agreed to in writing, software distributed under the
8-
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9-
OF ANY KIND, either express or implied. See the License for the specific
10-
language governing permissions and limitations under the License. -->
1+
<?xml version="1.0" encoding="UTF-8"?><!-- Licensed to the Apache Software
2+
Foundation (ASF) under one or more contributor license agreements. See the
3+
NOTICE file distributed with this work for additional information regarding
4+
copyright ownership. The ASF licenses this file to you under the Apache License,
5+
Version 2.0 (the "License"); you may not use this file except in compliance
6+
with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software distributed
8+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
9+
OR CONDITIONS OF ANY KIND, either express or implied. See the License for
10+
the specific language governing permissions and limitations under the License. -->
1111
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1212
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1313
<modelVersion>4.0.0</modelVersion>
@@ -34,14 +34,61 @@
3434

3535
<profiles>
3636
<profile>
37-
<id>deploydb2</id>
37+
<id>deploydb</id>
3838
<activation>
3939
<property>
40-
<name>deploydb2</name>
40+
<name>deploydb</name>
4141
</property>
4242
</activation>
4343
<build>
4444
<plugins>
45+
<plugin>
46+
<groupId>org.codehaus.mojo</groupId>
47+
<artifactId>properties-maven-plugin</artifactId>
48+
<version>1.0-alpha-2</version>
49+
<executions>
50+
<execution>
51+
<phase>initialize</phase>
52+
<goals>
53+
<goal>read-project-properties</goal>
54+
</goals>
55+
<configuration>
56+
<files>
57+
<file>${project.parent.basedir}/utils/conf/db.properties</file>
58+
<file>${project.parent.basedir}/utils/conf/db.properties.override</file>
59+
</files>
60+
<quiet>true</quiet>
61+
</configuration>
62+
</execution>
63+
</executions>
64+
</plugin>
65+
<plugin>
66+
<artifactId>maven-antrun-plugin</artifactId>
67+
<version>1.7</version>
68+
<executions>
69+
<execution>
70+
<phase>generate-resources</phase>
71+
<goals>
72+
<goal>run</goal>
73+
</goals>
74+
<configuration>
75+
<target>
76+
<filter token="VERSION" value="${project.version}" />
77+
<copy todir="${basedir}/target/db" filtering="true">
78+
<fileset dir="${project.basedir}/../setup/db/" />
79+
80+
</copy>
81+
<copy todir="${basedir}/target/db" filtering="true">
82+
<fileset
83+
dir="${project.basedir}/../awsapi-setup/db/mysql/">
84+
<include name="**/*.sql" />
85+
</fileset>
86+
</copy>
87+
</target>
88+
</configuration>
89+
</execution>
90+
</executions>
91+
</plugin>
4592
<plugin>
4693
<groupId>org.codehaus.mojo</groupId>
4794
<artifactId>exec-maven-plugin</artifactId>
@@ -81,8 +128,8 @@
81128
</dependencies>
82129
<executions>
83130
<execution>
84-
<phase>package</phase>
85-
<id>create-database-2</id>
131+
<phase>process-test-resources</phase>
132+
<id>create-schema</id>
86133
<goals>
87134
<goal>java</goal>
88135
</goals>
@@ -96,16 +143,91 @@
96143
<artifactId>cloud-server</artifactId>
97144
</executableDependency>
98145
<mainClass>com.cloud.upgrade.DatabaseCreator</mainClass>
146+
<arguments>
147+
<argument>${basedir}/target/db/create-schema.sql</argument>
148+
<argument>${basedir}/target/db/create-schema-premium.sql</argument>
149+
<argument>com.cloud.upgrade.DatabaseUpgradeChecker</argument>
150+
</arguments>
99151
</configuration>
100152
</plugin>
153+
<plugin>
154+
<groupId>org.codehaus.mojo</groupId>
155+
<artifactId>sql-maven-plugin</artifactId>
156+
<version>1.5</version>
157+
<dependencies>
158+
<!-- specify the dependent jdbc driver here -->
159+
<dependency>
160+
<groupId>mysql</groupId>
161+
<artifactId>mysql-connector-java</artifactId>
162+
<version>${cs.mysql.version}</version>
163+
</dependency>
164+
</dependencies>
165+
<configuration>
166+
<driver>org.gjt.mm.mysql.Driver</driver>
167+
<url>jdbc:mysql://${db.cloud.host}:${db.cloud.port}/cloud</url>
168+
<username>${db.cloud.username}</username>
169+
<password>${db.cloud.password}</password>
170+
<!--all executions are ignored if -Dmaven.test.skip=true -->
171+
<skip>${maven.test.skip}</skip>
172+
<forceMojoExecution>true</forceMojoExecution>
173+
</configuration>
174+
<executions>
175+
<execution>
176+
<id>create-other-schema</id>
177+
<phase>process-test-resources</phase>
178+
<goals>
179+
<goal>execute</goal>
180+
</goals>
181+
<configuration>
182+
<srcFiles>
183+
<srcFile>${basedir}/target/db/templates.sql</srcFile>
184+
<srcFile>${basedir}/target/db/create-index-fk.sql</srcFile>
185+
<srcFile>${basedir}/target/db/cloudbridge_schema.sql</srcFile>
186+
<srcFile>${basedir}/target/db/cloudbridge_multipart.sql</srcFile>
187+
<srcFile>${basedir}/target/db/cloudbridge_index.sql</srcFile>
188+
<srcFile>${basedir}/target/db/cloudbridge_multipart_alter.sql</srcFile>
189+
<srcFile>${basedir}/target/db/cloudbridge_bucketpolicy.sql</srcFile>
190+
<srcFile>${basedir}/target/db/cloudbridge_policy_alter.sql</srcFile>
191+
<srcFile>${basedir}/target/db/cloudbridge_offering.sql</srcFile>
192+
<srcFile>${basedir}/target/db/cloudbridge_offering_alter.sql</srcFile>
193+
</srcFiles>
194+
</configuration>
195+
</execution>
196+
<execution>
197+
<id>prefill-schema</id>
198+
<phase>process-test-resources</phase>
199+
<goals>
200+
<goal>execute</goal>
201+
</goals>
202+
<configuration>
203+
<sqlCommand>INSERT INTO `cloud`.`domain` (id, name,
204+
parent, path, owner) VALUES (1, 'ROOT', NULL, '/',
205+
2)</sqlCommand>
206+
</configuration>
207+
</execution>
208+
<execution>
209+
<id>prefill-configuration</id>
210+
<phase>process-test-resources</phase>
211+
<goals>
212+
<goal>execute</goal>
213+
</goals>
214+
<configuration>
215+
<sqlCommand>INSERT INTO `cloud`.`configuration`
216+
(category, instance, component, name, value) VALUES
217+
('Hidden', 'DEFAULT', 'management-server', 'init',
218+
'false')</sqlCommand>
219+
</configuration>
220+
</execution>
221+
</executions>
222+
</plugin>
101223
</plugins>
102224
</build>
103225
</profile>
104226
<profile>
105-
<id>deploydb</id>
227+
<id>cleandb</id>
106228
<activation>
107229
<property>
108-
<name>deploydb</name>
230+
<name>cleandb</name>
109231
</property>
110232
</activation>
111233
<build>
@@ -143,8 +265,8 @@
143265
<target>
144266
<filter token="VERSION" value="${project.version}" />
145267
<copy todir="${basedir}/target/db" filtering="true">
146-
<fileset dir="${project.basedir}/../setup/db/">
147-
</fileset>
268+
<fileset dir="${project.basedir}/../setup/db/" />
269+
148270
</copy>
149271
<copy todir="${basedir}/target/db" filtering="true">
150272
<fileset
@@ -348,54 +470,6 @@
348470
'${db.cloud.password}';</sqlCommand>
349471
</configuration>
350472
</execution>
351-
<execution>
352-
<id>create-schema</id>
353-
<phase>process-test-resources</phase>
354-
<goals>
355-
<goal>execute</goal>
356-
</goals>
357-
<configuration>
358-
<srcFiles>
359-
<srcFile>${basedir}/target/db/create-schema.sql</srcFile>
360-
<srcFile>${basedir}/target/db/create-schema-premium.sql</srcFile>
361-
<srcFile>${basedir}/target/db/templates.sql</srcFile>
362-
<srcFile>${basedir}/target/db/create-index-fk.sql</srcFile>
363-
<srcFile>${basedir}/target/db/cloudbridge_schema.sql</srcFile>
364-
<srcFile>${basedir}/target/db/cloudbridge_multipart.sql</srcFile>
365-
<srcFile>${basedir}/target/db/cloudbridge_index.sql</srcFile>
366-
<srcFile>${basedir}/target/db/cloudbridge_multipart_alter.sql</srcFile>
367-
<srcFile>${basedir}/target/db/cloudbridge_bucketpolicy.sql</srcFile>
368-
<srcFile>${basedir}/target/db/cloudbridge_policy_alter.sql</srcFile>
369-
<srcFile>${basedir}/target/db/cloudbridge_offering.sql</srcFile>
370-
<srcFile>${basedir}/target/db/cloudbridge_offering_alter.sql</srcFile>
371-
</srcFiles>
372-
</configuration>
373-
</execution>
374-
<execution>
375-
<id>prefill-schema</id>
376-
<phase>process-test-resources</phase>
377-
<goals>
378-
<goal>execute</goal>
379-
</goals>
380-
<configuration>
381-
<sqlCommand>INSERT INTO `cloud`.`domain` (id, name,
382-
parent, path, owner) VALUES (1, 'ROOT', NULL, '/',
383-
2)</sqlCommand>
384-
</configuration>
385-
</execution>
386-
<execution>
387-
<id>prefill-configuration</id>
388-
<phase>process-test-resources</phase>
389-
<goals>
390-
<goal>execute</goal>
391-
</goals>
392-
<configuration>
393-
<sqlCommand>INSERT INTO `cloud`.`configuration`
394-
(category, instance, component, name, value) VALUES
395-
('Hidden', 'DEFAULT', 'management-server', 'init',
396-
'false')</sqlCommand>
397-
</configuration>
398-
</execution>
399473
</executions>
400474
</plugin>
401475
</plugins>

platform/api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@
3737
<build>
3838
<defaultGoal>install</defaultGoal>
3939
<sourceDirectory>src</sourceDirectory>
40-
<!-- <testSourceDirectory>test</testSourceDirectory> -->
40+
<testSourceDirectory>test</testSourceDirectory>
4141
</build>
4242
</project>

platform/api/src/org/apache/cloudstack/platform/cloud/entity/api/NetworkEntity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@
2323
import com.cloud.network.Network;
2424

2525
public interface NetworkEntity extends CloudEntity, Network {
26+
void connectTo(NetworkEntity network);
2627
}

platform/api/src/org/apache/cloudstack/platform/cloud/entity/api/VirtualMachineEntity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ public interface VirtualMachineEntity extends VirtualMachine, CloudEntity {
110110
* @param network network to attach
111111
* @param deviceId device id to use when a nic is created
112112
*/
113-
void connectTo(NetworkEntity network, short deviceId);
113+
void connectTo(NetworkEntity network, short nicId);
114114

115115
/**
116116
* Disconnect the VM from this network
117117
* @param netowrk network to disconnect from
118118
*/
119-
void disconnectFrom(NetworkEntity netowrk);
119+
void disconnectFrom(NetworkEntity netowrk, short nicId);
120120
}

0 commit comments

Comments
 (0)