~ubuntu-branches/ubuntu/maverick/eucalyptus/maverick

« back to all changes in this revision

Viewing changes to clc/modules/core/conf/scripts/Import_161.groovy

  • Committer: Bazaar Package Importer
  • Author(s): Dave Walker (Daviey)
  • Date: 2010-07-21 17:27:10 UTC
  • mfrom: (1.1.38 upstream)
  • Revision ID: james.westby@ubuntu.com-20100721172710-7xv07dmdqgivc3t9
Tags: 2.0~bzr1211-0ubuntu1
* New major upstream version merge, 2.0 (r1211).
* debian/patches/:
  - 01-wsdl-stubs.patch, debian/wsdl.md5sums: wsdl stubs updated.
  - 02-Makefile.patch: Updated to reflect new code layout.
  - 07-local_support_euca_conf-in.patch: Updated to reflect new code layout.
  - 08-ubuntu-default-networking.patch: Refreshed.
  - 09-small-128-192MB.patch: Updated to point to new location.
  - 10-disable-iscsi.patch: Refreshed.
  - 11-state-cleanup-memleakfix.patch: Removed, fixed upstream.
  - 15-fix-default-ramdisk.patch: Updated to point to new location.
  - 16-kvm_libvirt_xml_default_use_kvm.patch: Updated to reflect changes.
  - 17-fix_walrus_OOM_errors.patch: Removed, fixed upstream.
  - 18-priv_security.patch: Updated to reflect upstream changes.
  - 20-brute-force-webui.patch: Updated to reflect upstream changes. 
  - 21-eucalyptus-1.7-with-gwt-1.6.4.patch: New patch, allows 
    eucalyptus-1.7 to be built against gwt 1.6.4. Based on patch courtesy 
    of Dmitrii Zagorodnov, upstream. (LP: #597330)
* debian/eucalyptus-java-common.links: 
  - Changed symlink for groovy, point to groovy.all.jar, making compatiable 
    with groovy versions >1.7. (LP: #595421)
  - Added ant.jar & jetty-rewrite-handler.jar as they are now required.
* debian/control
  - & debian/build-jars: Added libjavassist-java and libjetty-extra-java as 
    build dependencies.
  - Added libjetty-extra-java as a dependency of eucalyptus-java-common
* The binary resulting jar's have been renamed from eucalyptus-*-1.6.2.jar
  to eucalyptus-*-main.jar:    
  - debian/eucalyptus-cc.upstart
  - debian/eucalyptus-cloud.install
  - debian/eucalyptus-common.eucalyptus.upstart
  - debian/eucalyptus-java-common.install
  - debian/eucalyptus-network.upstart
  - debian/eucalyptus-sc.install
  - debian/eucalyptus-walrus.install
* debian/eucalyptus-java-common.install: New upstream jars that have been
  installed:
  - eucalyptus-db-hsqldb-ext-main.jar
  - eucalyptus-component-main.jar
* debian/control:
  - Updated Standards Version to 3.8.4 (no change)
  - Updated the upstream Homepage to: http://open.eucalyptus.com/
  - Changed Vcs-Bzr to reflect new location of Ubuntu hosted development branch.
  - Made the Build Dependency of groovy and the binary eucalyptus-java-common
    package depend on version >=1.7.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import com.eucalyptus.util.EntityWrapper;
2
 
import com.eucalyptus.util.StorageProperties;
3
 
import com.eucalyptus.util.WalrusProperties;
4
 
import com.eucalyptus.util.EntityWrapper;
5
 
import com.eucalyptus.bootstrap.Component;
6
 
import groovy.sql.Sql;
7
 
import edu.ucsb.eucalyptus.cloud.entities.BucketInfo;
8
 
import edu.ucsb.eucalyptus.cloud.entities.AOEVolumeInfo;
9
 
import edu.ucsb.eucalyptus.cloud.entities.AOEMetaInfo;
10
 
import com.eucalyptus.util.DatabaseUtil;
11
 
import edu.ucsb.eucalyptus.cloud.entities.SnapshotInfo;
12
 
import edu.ucsb.eucalyptus.cloud.entities.VolumeInfo;
13
 
 
14
 
 
15
 
/* euca.*.dir are set by euca_upgrade when calling this script */
16
 
baseDir = new File("${System.getProperty('euca.old')}/var/lib/eucalyptus/db").absolutePath;
17
 
targetDir = new File("${System.getProperty('euca.new')}/var/lib/eucalyptus/db").absolutePath;
18
 
targetDbPrefix= "eucalyptus"
19
 
Component c = Component.db
20
 
c.setUri( "jdbc:hsqldb:file:${targetDir}/${targetDbPrefix}" );
21
 
System.setProperty("euca.db.host", "jdbc:hsqldb:file:${targetDir}/${targetDbPrefix}")
22
 
System.setProperty("euca.db.password", "${System.getenv('EUCALYPTUS_DB')}");
23
 
db_pass = System.getenv('EUCALYPTUS_DB');
24
 
System.setProperty("euca.log.level", 'INFO');
25
 
 
26
 
def getSqlStorage() {
27
 
        source = new org.hsqldb.jdbc.jdbcDataSource();
28
 
        source.database = "jdbc:hsqldb:file:${baseDir}/eucalyptus_storage";
29
 
        source.user = 'sa';
30
 
        source.password = db_pass;
31
 
        return new Sql(source);
32
 
}
33
 
 
34
 
def getSqlWalrus() {
35
 
        source = new org.hsqldb.jdbc.jdbcDataSource();
36
 
        source.database = "jdbc:hsqldb:file:${baseDir}/eucalyptus_walrus";
37
 
        source.user = 'sa';
38
 
        source.password = db_pass;
39
 
        return new Sql(source);
40
 
}
41
 
 
42
 
def getSqlVols() {
43
 
        source = new org.hsqldb.jdbc.jdbcDataSource();
44
 
        source.database = "jdbc:hsqldb:file:${baseDir}/eucalyptus_images";
45
 
        source.user = 'sa';
46
 
        source.password = db_pass;
47
 
        return new Sql(source);
48
 
}
49
 
 
50
 
 
51
 
oldDbStorage = getSqlStorage();
52
 
oldDbWalrus = getSqlWalrus();
53
 
oldDbVols = getSqlVols();
54
 
 
55
 
println "BASE DIR:   ${baseDir}"
56
 
println "TARGET DIR: ${targetDir}"
57
 
try {
58
 
  if( !targetDir.equals(baseDir) ) {
59
 
    new File("${baseDir}").eachFileMatch(~/.*\.(script)|.*\.(log)|.*\.(properties)/) { baseDb ->
60
 
      targetDb = new File(baseDb.path.replaceAll(baseDir,targetDir));
61
 
      println "-> Copying ${baseDb.absolutePath} to ${targetDb.absolutePath}..."
62
 
      if(targetDb.exists()) {
63
 
        println "Bailing out of upgrade: ${targetDb.absolutePath} already exists!"
64
 
        println "It looks like a previous upgrade may have failed!"
65
 
        println "You will need to manually cleanup ${targetDir} before proceeding." 
66
 
        System.exit(1)
67
 
      } else {
68
 
        targetDb.withWriter(){ w -> w.write(baseDb.text); w.flush(); w.close(); }
69
 
      }
70
 
    }
71
 
  }
72
 
  new after_database().run();
73
 
} catch( Throwable t ) {
74
 
  t.printStackTrace();
75
 
  t?.getCause().printStackTrace();
76
 
  System.exit(1);
77
 
}
78
 
 
79
 
def updateBuckets() {
80
 
        EntityWrapper<BucketInfo> dbBucket = new EntityWrapper<BucketInfo>( WalrusProperties.DB_NAME );
81
 
        BucketInfo bucketInfo = new BucketInfo();
82
 
        List<BucketInfo> buckets = dbBucket.query(bucketInfo);
83
 
        for(BucketInfo bucket : buckets) {
84
 
                bucket.setLoggingEnabled(false);                
85
 
    println "-> Updating BucketInfo: ${bucket.dump()}"
86
 
  }
87
 
        dbBucket.commit();
88
 
}
89
 
 
90
 
updateBuckets();
91
 
 
92
 
volMap = [:]
93
 
oldDbVols.rows('SELECT * FROM VOLUME').each {
94
 
  volMap[it.DISPLAYNAME]=it.CLUSTER
95
 
96
 
 
97
 
oldDbStorage.rows('SELECT * FROM LVMMETADATA').each {
98
 
        EntityWrapper<AOEMetaInfo> dbStorage = new EntityWrapper<AOEMetaInfo>( StorageProperties.DB_NAME );
99
 
        try {
100
 
                AOEMetaInfo metaInfo = new AOEMetaInfo(it.HOSTNAME);
101
 
                metaInfo.setMajorNumber(it.MAJOR_NUMBER);
102
 
                metaInfo.setMinorNumber(it.MINOR_NUMBER);
103
 
    println "-> Import AOEMetaInfo: ${metaInfo.dump()}"
104
 
                dbStorage.add(metaInfo);
105
 
                dbStorage.commit();
106
 
        } catch(Throwable t) {
107
 
                t.printStackTrace();
108
 
                dbStorage.rollback();
109
 
        }       
110
 
}
111
 
 
112
 
oldDbVols.rows('SELECT * FROM VOLUME').each {
113
 
        EntityWrapper<VolumeInfo> dbStorage = new EntityWrapper<VolumeInfo>( StorageProperties.DB_NAME );
114
 
        try {
115
 
                VolumeInfo volInfo = new VolumeInfo(it.DISPLAYNAME);
116
 
                volInfo.setScName(null);
117
 
                VolumeInfo foundVolInfo = dbStorage.getUnique(volInfo);
118
 
                foundVolInfo.setScName(it.CLUSTER);
119
 
                dbStorage.commit();
120
 
        } catch (Throwable t) {
121
 
                t.printStackTrace();
122
 
                dbStorage.rollback();
123
 
        }
124
 
 
125
 
126
 
 
127
 
oldDbVols.rows('SELECT * FROM SNAPSHOT').each {
128
 
        EntityWrapper<SnapshotInfo> dbStorage = new EntityWrapper<SnapshotInfo>( StorageProperties.DB_NAME );
129
 
        try {
130
 
                SnapshotInfo snapInfo = new SnapshotInfo(it.DISPLAYNAME);
131
 
                snapInfo.setScName(null);
132
 
                SnapshotInfo foundSnapInfo = dbStorage.getUnique(snapInfo);
133
 
                foundSnapInfo.setScName(it.CLUSTER);
134
 
                dbStorage.commit();
135
 
        } catch (Throwable t) {
136
 
                t.printStackTrace();
137
 
                dbStorage.rollback();
138
 
        }
139
 
 
140
 
}
141
 
 
142
 
oldDbStorage.rows('SELECT * FROM LVMVOLUMES').each {
143
 
        EntityWrapper<AOEVolumeInfo> dbStorage = new EntityWrapper<AOEVolumeInfo>( StorageProperties.DB_NAME );
144
 
        try {
145
 
                AOEVolumeInfo volumeInfo = new AOEVolumeInfo(it.VOLUME_NAME);
146
 
                volumeInfo.setMajorNumber(it.MAJOR_NUMBER);
147
 
                volumeInfo.setMinorNumber(it.MINOR_NUMBER);
148
 
                volumeInfo.setLoDevName(it.LODEV_NAME);
149
 
                volumeInfo.setLoFileName(it.LOFILE_NAME);
150
 
                volumeInfo.setVbladePid(it.VBLADE_PID);
151
 
                volumeInfo.setScName("StorageController-local".equals(it.SC_NAME)?volMap[it.VOLUME_NAME]:it.SC_NAME);
152
 
                volumeInfo.setPvName(it.PV_NAME);
153
 
                volumeInfo.setLvName(it.LV_NAME);
154
 
                volumeInfo.setVgName(it.VG_NAME);
155
 
                volumeInfo.setSize(it.SIZE);
156
 
                volumeInfo.setStatus(it.STATUS);
157
 
                volumeInfo.setSnapshotOf(it.SNAPSHOT_OF);
158
 
    println "-> Import AOEVolumeInfo: ${volumeInfo.dump()}"
159
 
                dbStorage.add(volumeInfo);
160
 
                dbStorage.commit();
161
 
        } catch(Throwable t) {
162
 
                t.printStackTrace();
163
 
                dbStorage.rollback();
164
 
        }       
165
 
}
166
 
 
167
 
//flush
168
 
DatabaseUtil.closeAllEMFs();
169
 
oldDbStorage.close();
170
 
oldDbWalrus.close();
171
 
oldDbVols.close();
172
 
//the db will not sync to disk even after a close in some cases. Wait a bit.
173
 
Thread.sleep(5000);
174
 
System.exit(0);