Changeset 1437
- Timestamp:
- Oct 29, 2008, 9:24:59 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/scripts/xvm-migrate-machine
r1429 r1437 1 # #!/bin/bash1 #!/bin/python 2 2 # Migrates the machine named $1 from the dev cluster. 3 3 # To be run on the prod cluster. … … 5 5 ## The present version is NOT A REAL SCRIPT. 6 6 ## Things may not even be tested. Copy and paste. 7 not_ready_yet_do_not_run_me 7 8 9 10 from invirt import database 11 12 dev_db_uri = 'postgres://sipb-xen@sipb-xen-dev.mit.edu/sipb_xen' 13 14 15 def take_data(machine_name): 8 16 ## dump from dev db; save info well 17 database.connect(dev_db_uri) 18 database.session.begin() 19 machine = database.Machine.query().get_by(name=machine_name) 20 disks = database.Disk.query().filter_by(machine=machine).all() 21 nics = database.NIC.query().filter_by(machine=machine).all() 22 ## remove from dev db; ideally atomic with dump 23 for r in disks + nics + [machine]: 24 database.session.delete(r) 25 database.session.commit() 26 return machine, disks, nics 9 27 10 #echo "\\a \\t \\\\ select * from machines where name = '$MACHINE';" \11 # | psql -h xvm -U sipb-xen sipb_xen -q12 ## 581|fsck|256|price|price|2ab6638f-3f65-2b32-3fd3-c16b74a9b7fe|linux|f|1|price|test|f13 ## watch out for funny characters in description; better (non-)quoting needed14 ## also disks, nics15 16 ## remove from dev db; ideally atomic with dump17 28 18 29 ## shut down if up … … 27 38 28 39 ## add to dev db 40 def restore_data(machine, disks, nics): 41 database.connect() # to prod DB 42 database.session.begin() 43 ## now copy machine, disks, nics to new ORM objects (yuck, oh well) 44 ## and database.session.save(those) 45 database.session.commit() 46 29 47 30 48 ## power on if desired 49 50
Note: See TracChangeset
for help on using the changeset viewer.