def write_chars(file_pointer, char_dict, locked_chars, lost_worlds, outfile):
    char_keys = [
        "start", "start2", "cathedral", "castle", "proto", "burrow", "dactyl"
    ]
    loadchars = [0x57, 0x5C, 0x62, 0x6A, 0x68, 0x6C, 0x6D]
    charnames = [
        0x39D7E, 0x39D80, 0x377090, 0x5F6E5, 0x372AB7, 0x38932D, 0x3BB90E
    ]
    chars = [0x39D82, 0x39D84, 0x376FEB, 0x5F5EE, 0x372A6F, 0x389275, 0x3BB8FA]
    chars2 = [0, 0, 0x377088, 0x5F6DD, 0x372AAD, 0x389323, 0x3BB904]
    chars3 = [0, 0, 0x377099, 0x5F6E8, 0x372AC1, 0x389336, 0x3BB916]
    chars4 = [0, 0, 0x3770D1, 0x5F6E8, 0x372ADB, 0x389352, 0x3BB927]
    charloads = [0, 0, 0x3770D2, 0x5F6E8, 0x372ADC, 0x389353, 0x3BB928]
    if lost_worlds == "Y":
        charnames[0] = 0x39CCF
        charnames[1] = 0x39CD1
        chars[0] = 0x39CD3
        chars[1] = 0x39CD5
    if locked_chars == "Y":
        charnames[4] = 0x372AB9
        chars2[4] = 0x372AAF
        chars3[4] = 0x372AC3
        chars4[4] = 0x372ADD
        charloads[4] = 0x372ADE
        patch.patch_file("patches/locked_chars.txt", outfile)
    i = 0
    while i < 7:
        char = char_dict[char_keys[i]][0]
        file_pointer.seek(charnames[i])
        file_pointer.write(st.pack("B", char | 0xC0))
        file_pointer.seek(chars[i])
        file_pointer.write(st.pack("B", char))
        if i < 2:
            i += 1
            continue
        file_pointer.seek(chars2[i])
        file_pointer.write(st.pack("B", char))
        file_pointer.seek(chars3[i])
        file_pointer.write(st.pack("B", char))
        file_pointer.seek(chars4[i])
        file_pointer.write(st.pack("B", char))
        if chars4[i] != charloads[i]:
            file_pointer.seek(charloads[i])
            file_pointer.write(st.pack("B", loadchars[char]))
        i += 1
Example #2
0
 f = open(outfile, 'r+b')
 while position < 351306:
     p.seek(position)
     pointer1 = p.read(1)
     pointer1 = tenthousands_digit(pointer1)
     position += 1
     pointer2 = p.read(2)
     pointer = make_number(pointer1, pointer2)
     position += 2
     length = p.read(2)
     length = get_length(length)
     position += 2
     position = write_data(length, pointer, position)
 p.close
 f.close
 patches.patch_file("patches/patch_codebase.txt", outfile)
 if glitch_fixes == "Y":
     patches.patch_file("patches/save_anywhere_patch.txt", outfile)
     patches.patch_file("patches/unequip_patch.txt", outfile)
     patches.patch_file("patches/fadeout_patch.txt", outfile)
     patches.patch_file("patches/hp_overflow_patch.txt", outfile)
 if fast_move == "Y":
     patches.patch_file("patches/fast_overworld_walk_patch.txt", outfile)
     patches.patch_file("patches/faster_epoch_patch.txt", outfile)
 if sense_dpad == "Y":
     patches.patch_file("patches/faster_menu_dpad.txt", outfile)
 print "Randomizing treasures..."
 treasures.randomize_treasures(outfile)
 hardcoded_items.randomize_hardcoded_items(outfile)
 print "Randomizing shops..."
 shops.randomize_shops(outfile)
Example #3
0
def generate_rom():
     global flags
     global sourcefile
     global difficulty
     global glitch_fixes
     global fast_move
     global sense_dpad
     global lost_worlds
     global boss_scaler
     global zeal_end
     global quick_pendant
     global locked_chars
     global tech_list
     global seed
     outfile = sourcefile.split(".")
     outfile = str(outfile[0])
     if flags == "":
       outfile = "%s.%s.sfc"%(outfile,seed)
     else:
       outfile = "%s.%s.%s.sfc"%(outfile,flags,seed)
     size = stat(sourcefile).st_size
     if size % 0x400 == 0:
        copyfile(sourcefile, outfile)
     elif size % 0x200 == 0:
        print("SNES header detected. Removing header from output file.")
        f = open(sourcefile, 'r+b')
        data = f.read()
        f.close()
        data = data[0x200:]
        open(outfile, 'w+').close()
        f = open(outfile, 'r+b')
        f.write(data)
        f.close()
     print("Applying patch. This might take a while.")
     bigpatches.write_patch("patch.ips",outfile)
     patches.patch_file("patches/patch_codebase.txt",outfile)
     if glitch_fixes == "Y":
        patches.patch_file("patches/save_anywhere_patch.txt",outfile)
        patches.patch_file("patches/unequip_patch.txt",outfile)
        patches.patch_file("patches/fadeout_patch.txt",outfile)
        patches.patch_file("patches/hp_overflow_patch.txt",outfile)
     if fast_move == "Y":
        patches.patch_file("patches/fast_overworld_walk_patch.txt",outfile)
        patches.patch_file("patches/faster_epoch_patch.txt",outfile)
     if sense_dpad == "Y":
        patches.patch_file("patches/faster_menu_dpad.txt",outfile)
     if zeal_end == "Y":
        patches.patch_file("patches/zeal_end_boss.txt",outfile)
     if lost_worlds == "Y":
        bigpatches.write_patch("patches/lost.ips",outfile)
     if lost_worlds == "Y":
         pass
     elif quick_pendant == "Y":
             patches.patch_file("patches/fast_charge_pendant.txt",outfile)
     print("Randomizing treasures...")
     treasures.randomize_treasures(outfile,difficulty)
     hardcoded_items.randomize_hardcoded_items(outfile)
     print("Randomizing enemy loot...")
     enemystuff.randomize_enemy_stuff(outfile,difficulty)
     print("Randomizing shops...")
     shops.randomize_shops(outfile)
     print("Randomizing character locations...")
     char_locs = char_slots.randomize_char_positions(outfile,locked_chars,lost_worlds)
     print("Now placing key items...")
     if lost_worlds == "Y":
         keyitemlist = keyitems.randomize_lost_worlds_keys(char_locs,outfile)
     else:
         keyitemlist = keyitems.randomize_keys(char_locs,outfile,locked_chars)
     if difficulty == "hard":
         bigpatches.write_patch("patches/hard.ips",outfile)
     if boss_scaler == "Y":
         print("Rescaling bosses based on key items..")
         boss_scale.scale_bosses(char_locs,keyitemlist,locked_chars,outfile)
     if tech_list == "Y":
        tech_order.take_pointer(outfile)
     # Tyrano Castle chest hack
     f = open(outfile,"r+b")
     f.seek(0x35F6D5)
     f.write(st.pack("B",1))
     f.close()
     #Mystic Mtn event fix in Lost Worlds
     if lost_worlds == "Y":         
       f = open(outfile,"r+b")
       bigpatches.write_patch("patches/mysticmtnfix.ips",outfile)
     #Bangor Dome event fix if character locks are on
       if locked_chars == "Y":
         bigpatches.write_patch("patches/bangorfix.ips",outfile)
       f.close()
     print("Randomization completed successfully.")
Example #4
0
def generate_rom():
    global flags
    global sourcefile
    global outputfolder
    global difficulty
    global glitch_fixes
    global fast_move
    global sense_dpad
    global lost_worlds
    global boss_rando
    global boss_scaler
    global zeal_end
    global quick_pendant
    global locked_chars
    global tech_list
    global seed
    global unlocked_magic
    global quiet_mode
    global chronosanity
    global tab_treasures
    global shop_prices

    # isolate the ROM file name
    inputPath = pathlib.Path(sourcefile)
    outfile = inputPath.name

    # Create the output file name
    outfile = outfile.split(".")
    outfile = str(outfile[0])
    if flags == "":
        outfile = "%s.%s.sfc" % (outfile, seed)
    else:
        outfile = "%s.%s.%s.sfc" % (outfile, flags, seed)

    # Append the output file name to the selected directory
    # If there is no selected directory, use the input path
    if outputfolder == None or outputfolder == "":
        outfile = str(inputPath.parent.joinpath(outfile))
    else:
        outfile = str(pathlib.Path(outputfolder).joinpath(outfile))

    size = stat(sourcefile).st_size
    if size % 0x400 == 0:
        copyfile(sourcefile, outfile)
    elif size % 0x200 == 0:
        print("SNES header detected. Removing header from output file.")
        f = open(sourcefile, 'r+b')
        data = f.read()
        f.close()
        data = data[0x200:]
        open(outfile, 'w+').close()
        f = open(outfile, 'r+b')
        f.write(data)
        f.close()
    print("Applying patch. This might take a while.")
    bigpatches.write_patch_alt("patch.ips", outfile)
    patches.patch_file("patches/patch_codebase.txt", outfile)
    if glitch_fixes == "Y":
        patches.patch_file("patches/save_anywhere_patch.txt", outfile)
        patches.patch_file("patches/unequip_patch.txt", outfile)
        patches.patch_file("patches/fadeout_patch.txt", outfile)
        patches.patch_file("patches/hp_overflow_patch.txt", outfile)
    if fast_move == "Y":
        patches.patch_file("patches/fast_overworld_walk_patch.txt", outfile)
        patches.patch_file("patches/faster_epoch_patch.txt", outfile)
    if sense_dpad == "Y":
        patches.patch_file("patches/faster_menu_dpad.txt", outfile)
    if zeal_end == "Y":
        patches.patch_file("patches/zeal_end_boss.txt", outfile)
    if lost_worlds == "Y":
        bigpatches.write_patch_alt("patches/lost.ips", outfile)
    if lost_worlds == "Y":
        pass
    elif quick_pendant == "Y":
        patches.patch_file("patches/fast_charge_pendant.txt", outfile)
    if unlocked_magic == "Y":
        fastmagic.set_fast_magic_file(outfile)
        # bigpatches.write_patch_alt("patches/fastmagic.ips",outfile)
    if difficulty == "hard":
        bigpatches.write_patch_alt("patches/hard.ips", outfile)
    tabwriter.rewrite_tabs(
        outfile
    )  #Psuedoarc's code to rewrite Power and Magic tabs and make them more impactful
    print("Randomizing treasures...")
    treasures.randomize_treasures(outfile, difficulty, tab_treasures)
    hardcoded_items.randomize_hardcoded_items(outfile, tab_treasures)
    print("Randomizing enemy loot...")
    enemystuff.randomize_enemy_stuff(outfile, difficulty)
    print("Randomizing shops...")
    shops.randomize_shops(outfile)
    shops.modify_shop_prices(outfile, shop_prices)
    print("Randomizing character locations...")
    char_locs = char_slots.randomize_char_positions(outfile, locked_chars,
                                                    lost_worlds)
    print("Now placing key items...")
    if chronosanity == "Y":
        chronosanity_logic.writeKeyItems(outfile, char_locs,
                                         (locked_chars == "Y"),
                                         (quick_pendant == "Y"),
                                         lost_worlds == "Y")
    elif lost_worlds == "Y":
        keyitemlist = keyitems.randomize_lost_worlds_keys(char_locs, outfile)
    else:
        keyitemlist = keyitems.randomize_keys(char_locs, outfile, locked_chars)
    if boss_scaler == "Y" and chronosanity != "Y":
        print("Rescaling bosses based on key items..")
        boss_scale.scale_bosses(char_locs, keyitemlist, locked_chars, outfile)
    #print("Boss rando: " + boss_rando)
    if boss_rando == "Y":
        boss_shuffler.randomize_bosses(outfile, difficulty)
    if tech_list == "Fully Random":
        tech_order.take_pointer(outfile)
    elif tech_list == "Balanced Random":
        tech_order.take_pointer_balanced(outfile)
    if quiet_mode == "Y":
        bigpatches.write_patch_alt("patches/nomusic.ips", outfile)
    # Tyrano Castle chest hack
    f = open(outfile, "r+b")
    f.seek(0x35F6D5)
    f.write(st.pack("B", 1))
    f.close()
    #Mystic Mtn event fix in Lost Worlds
    if lost_worlds == "Y":
        f = open(outfile, "r+b")
        bigpatches.write_patch_alt("patches/mysticmtnfix.ips", outfile)
        bigpatches.write_patch_alt("patches/losteot.ips", outfile)
        #Bangor Dome event fix if character locks are on
        if locked_chars == "Y":
            bigpatches.write_patch_alt("patches/bangorfix.ips", outfile)
        f.close()
    print("Randomization completed successfully.")
Example #5
0
osutils.run_std("mysql -u root -p%s -e \"GRANT ALL ON quantum.* TO 'quantum'@'%s' IDENTIFIED BY '%s';\"" % (openstack_pass.root_db_pass, openstack_pass.controller_host, openstack_pass.quantum_db_pass) )

# Restart Quantum
osutils.run_std('cd /etc/init.d/; for i in $( ls quantum-* ); do sudo service $i status; done')


# Edit /etc/quantum/api-paste.ini
props = {}
props['[filter:authtoken]paste.filter_factory'] = (None, 'keystoneclient.middleware.auth_token:filter_factory')
props['[filter:authtoken]auth_host'] = (None, openstack_pass.controller_host)
props['[filter:authtoken]auth_port'] = (None, 35357)
props['[filter:authtoken]auth_protocol'] = (None, 'http')
props['[filter:authtoken]admin_tenant_name'] = (None, 'admin')
props['[filter:authtoken]admin_user'] = (None, 'admin')
props['[filter:authtoken]admin_password'] = (None, openstack_pass.openstack_pass)
p = patcher.patch_file('/etc/quantum/api-paste.ini', props, True)
print('info: /etc/quantum/api-paste.ini patched ' + str(p))

# SQL connection string
sql = "mysql://*****:*****@%s:3306/quantum" % (openstack_pass.quantum_db_pass, openstack_pass.controller_host)

# Edit the OVS plugin configuration file
props = {}
props['[DATABASE]sql_connection'] = (None, sql)
props['[OVS]tenant_network_type'] = (None, 'gre')
props['[OVS]tunnel_id_ranges'] = (None, '1:1000')
props['[OVS]integration_bridge'] = (None, 'br-int')
props['[OVS]tunnel_bridge'] = (None, 'br-tun')
props['[OVS]local_ip'] = (None, openstack_conf.controller_ip)
props['[OVS]enable_tunneling'] = (None, True)
props['[SECURITYGROUP]firewall_driver'] = (None, 'quantum.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver')
Example #6
0
def randomize_midbosses(outfile, f):
    magus_hp = rand.randrange(10000, 16000, 1000)
    tyrano_hp = rand.randrange(8000, 14000, 1000)
    magus_select = rand.randrange(0, 7)
    tyrano_element = rand.randrange(0, 5)
    f.seek(0xC57E4)
    f.write(st.pack("H", tyrano_hp))
    f.seek(0xC5D5F)
    f.write(st.pack("H", magus_hp))
    if magus_select == 0:
        bossmutator.patch_file("patches/magus_c.txt", outfile)
    elif magus_select == 1:
        bossmutator.patch_file("patches/magus_m.txt", outfile)
    elif magus_select == 2:
        bossmutator.patch_file("patches/magus_l.txt", outfile)
    elif magus_select == 3:
        bossmutator.patch_file("patches/magus_r.txt", outfile)
    elif magus_select == 4:
        bossmutator.patch_file("patches/magus_f.txt", outfile)
    elif magus_select == 5:
        bossmutator.patch_file("patches/magus_a.txt", outfile)
    if tyrano_element == 0:
        bossmutator.patch_file("patches/tyrano_i.txt", outfile)
    elif tyrano_element == 1:
        bossmutator.patch_file("patches/tyrano_l.txt", outfile)
    elif tyrano_element == 2:
        bossmutator.patch_file("patches/tyrano_s.txt", outfile)
    elif tyrano_element == 3:
        bossmutator.patch_file("patches/tyrano_n.txt", outfile)
Example #7
0
    openstack_pass.keystone_db_pass, openstack_pass.controller_host)

props['[sql]connection'] = ('sqlite:////var/lib/keystone/keystone.db', sql)
props['[sql]idle_timeout'] = (None, 200)

if openstack_conf.version in ["folsom", "grizzly"]:
    #props['[identity]driver'] = (None, 'keystone.identity.backends.sql.Identity')
    pass
else:
    props['[catalog]driver'] = (
        'keystone.catalog.backends.sql.Catalog',
        'keystone.catalog.backends.templated.TemplatedCatalog')
    props['[catalog]template_file'] = (
        None, '/etc/keystone/default_catalog.templates')

p = patcher.patch_file('/etc/keystone/keystone.conf', props, True)
print("info: /etc/keystone/keystone.conf patched " + str(p))

# Restart keystone
osutils.run_std('service keystone restart')

# Sync keystone with MySQL
osutils.run_std('keystone-manage db_sync')

# Tenants
adminTenantId = keystone_utils.tenant_create('admin')
serviceTenantId = keystone_utils.tenant_create('service')
projectTenantId = keystone_utils.tenant_create(openstack_conf.myproject)

print("adminTenantId = " + adminTenantId)
print("serviceTenantId = " + serviceTenantId)
Example #8
0
  osutils.run_std('apt-get install -y cinder-api cinder-scheduler cinder-volume iscsitarget iscsitarget-dkms')

  # Create database for Cinder
  osutils.run_std("mysql -u root -p%s -e 'CREATE DATABASE cinder;'" % (openstack_pass.root_db_pass) )
  osutils.run_std("mysql -u root -p%s -e \"GRANT ALL ON cinder.* TO 'cinder'@'%s' IDENTIFIED BY '%s';\"" % (openstack_pass.root_db_pass, '%', openstack_pass.cinder_db_pass) )
  osutils.run_std("mysql -u root -p%s -e \"GRANT ALL ON cinder.* TO 'cinder'@'%s' IDENTIFIED BY '%s';\"" % (openstack_pass.root_db_pass, 'localhost', openstack_pass.cinder_db_pass) )
  osutils.run_std("mysql -u root -p%s -e \"GRANT ALL ON cinder.* TO 'cinder'@'%s' IDENTIFIED BY '%s';\"" % (openstack_pass.root_db_pass, openstack_pass.controller_host, openstack_pass.cinder_db_pass) )

  # Patch confs
  props = {}
  props['service_host'] = ('127.0.0.1', openstack_pass.controller_host)
  props['auth_host'] = ('127.0.0.1', openstack_pass.controller_host)
  props['admin_tenant_name'] = ('%SERVICE_TENANT_NAME%', 'admin')
  props['admin_user'] = ('%SERVICE_USER%', 'admin')
  props['admin_password'] = ('%SERVICE_PASSWORD%', openstack_pass.openstack_pass)
  p = patcher.patch_file('/etc/cinder/api-paste.ini', props, True)
  print('info: /etc/cinder/api-paste.ini patched ' + str(p))

  sql = "mysql://*****:*****@%s:3306/cinder" % (openstack_pass.cinder_db_pass, openstack_pass.controller_host)

  props = {}
  props['sql_connection'] = (None, sql)
  props['auth_strategy'] = (None, 'keystone')
  props['verbose'] = (None, openstack_conf.verbose)
  props['debug'] = (None, openstack_conf.debug)
  props['iscsi_helper'] = (None, 'tgtadm')
  props['state_path'] = (None, '/var/lib/cinder')
  props['volumes_dir'] = (None, '/var/lib/cinder/volumes')

  props['rabbit_host'] = (None, openstack_pass.controller_host)
  props['rabbit_port'] = (None, 5672)
Example #9
0
#!/usr/bin/python

import patcher
import osutils

osutils.beroot()

osutils.run_std('apt-get install -y bridge-utils vlan')

props={}
props["net.ipv4.ip_forward"] = ("0", "1")
props["net.ipv4.conf.all.rp_filter"] = (None, "0")
props["net.ipv4.conf.default.rp_filter"] = (None, "0")

p = patcher.patch_file("/etc/sysctl.conf", props)
print("info: /etc/sysctl.conf patched " + str(p))

osutils.run_std('sysctl net.ipv4.ip_forward=1')

# Append eth1 to /etc/network/interface
#
# auto eth1
# iface eth1 inet manual
#        up ifconfig $IFACE 0.0.0.0 up
#        up ifconfig $IFACE promisc
#
# Restart network
# osutils.run_std('service networking restart')


Example #10
0
osutils.run_std('apt-get install -y novnc nova-novncproxy')

# Install LibVirt
osutils.run_std('apt-get install -y libvirt-bin pm-utils')

# Install iSCSI
osutils.run_std('apt-get install -y tgt open-iscsi open-iscsi-utils')

# Patch confs

props = {}
props['auth_host'] = ('127.0.0.1', openstack_pass.controller_host)
props['admin_tenant_name'] = ('%SERVICE_TENANT_NAME%', 'admin')
props['admin_user'] = ('%SERVICE_USER%', 'admin')
props['admin_password'] = ('%SERVICE_PASSWORD%', openstack_pass.openstack_pass)
p = patcher.patch_file('/etc/nova/api-paste.ini', props, True)
print('info: /etc/nova/api-paste.ini patched ' + str(p))

# Templates confs

if not os.path.exists('/etc/nova/nova.conf.bak'):
    shutil.copy2('/etc/nova/nova.conf', '/etc/nova/nova.conf.bak')

patcher.template_file('nova.conf.' + openstack_conf.version,
                      '/etc/nova/nova.conf')
print('info: /etc/nova/nova.conf saved')

if not os.path.exists('/etc/nova/nova-compute.conf.bak'):
    shutil.copy2('/etc/nova/nova-compute.conf',
                 '/etc/nova/nova-compute.conf.bak')
Example #11
0
        % (openstack_pass.root_db_pass, 'localhost',
           openstack_pass.cinder_db_pass))
    osutils.run_std(
        "mysql -u root -p%s -e \"GRANT ALL ON cinder.* TO 'cinder'@'%s' IDENTIFIED BY '%s';\""
        % (openstack_pass.root_db_pass, openstack_pass.controller_host,
           openstack_pass.cinder_db_pass))

    # Patch confs
    props = {}
    props['service_host'] = ('127.0.0.1', openstack_pass.controller_host)
    props['auth_host'] = ('127.0.0.1', openstack_pass.controller_host)
    props['admin_tenant_name'] = ('%SERVICE_TENANT_NAME%', 'admin')
    props['admin_user'] = ('%SERVICE_USER%', 'admin')
    props['admin_password'] = ('%SERVICE_PASSWORD%',
                               openstack_pass.openstack_pass)
    p = patcher.patch_file('/etc/cinder/api-paste.ini', props, True)
    print('info: /etc/cinder/api-paste.ini patched ' + str(p))

    sql = "mysql://*****:*****@%s:3306/cinder" % (openstack_pass.cinder_db_pass,
                                                openstack_pass.controller_host)

    props = {}
    props['sql_connection'] = (None, sql)
    props['auth_strategy'] = (None, 'keystone')
    props['verbose'] = (None, openstack_conf.verbose)
    props['debug'] = (None, openstack_conf.debug)
    props['iscsi_helper'] = (None, 'tgtadm')
    props['state_path'] = (None, '/var/lib/cinder')
    props['volumes_dir'] = (None, '/var/lib/cinder/volumes')

    props['rabbit_host'] = (None, openstack_pass.controller_host)
Example #12
0
props['[DEFAULT]admin_port'] = (None, 35357)
props['[DEFAULT]compute_port'] = (None, 8774)

sql = "mysql://*****:*****@%s:3306/keystone" % (openstack_pass.keystone_db_pass, openstack_pass.controller_host)

props['[sql]connection'] = ('sqlite:////var/lib/keystone/keystone.db', sql)
props['[sql]idle_timeout'] = (None, 200)

if openstack_conf.version in ["folsom", "grizzly"]:
  #props['[identity]driver'] = (None, 'keystone.identity.backends.sql.Identity')
  pass
else:
  props['[catalog]driver'] = ('keystone.catalog.backends.sql.Catalog', 'keystone.catalog.backends.templated.TemplatedCatalog')
  props['[catalog]template_file'] = (None, '/etc/keystone/default_catalog.templates')

p = patcher.patch_file('/etc/keystone/keystone.conf', props, True)
print("info: /etc/keystone/keystone.conf patched " + str(p))


# Restart keystone
osutils.run_std('service keystone restart')

# Sync keystone with MySQL
osutils.run_std('keystone-manage db_sync')

# Tenants
adminTenantId   = keystone_utils.tenant_create('admin')
serviceTenantId = keystone_utils.tenant_create('service')
projectTenantId = keystone_utils.tenant_create(openstack_conf.myproject)

print("adminTenantId = " + adminTenantId)
Example #13
0
#!/usr/bin/python

import patcher
import osutils

osutils.beroot()

osutils.run_std('apt-get install -y bridge-utils vlan')

props = {}
props["net.ipv4.ip_forward"] = ("0", "1")
props["net.ipv4.conf.all.rp_filter"] = (None, "0")
props["net.ipv4.conf.default.rp_filter"] = (None, "0")

p = patcher.patch_file("/etc/sysctl.conf", props)
print("info: /etc/sysctl.conf patched " + str(p))

osutils.run_std('sysctl net.ipv4.ip_forward=1')

# Append eth1 to /etc/network/interface
#
# auto eth1
# iface eth1 inet manual
#        up ifconfig $IFACE 0.0.0.0 up
#        up ifconfig $IFACE promisc
#
# Restart network
# osutils.run_std('service networking restart')
Example #14
0
        'export DEBIAN_FRONTEND=noninteractive && apt-get install -q -y mysql-server'
    )


def setup_root_pass():
    if os.system('mysqladmin -u root status') == 0:
        osutils.run_std('mysqladmin -u root password ' +
                        openstack_pass.root_db_pass)


def install_python_mysql():
    osutils.run_std('apt-get install -y python-mysqldb')


install_mysql()

while not os.path.exists('/etc/mysql/my.cnf'):
    print('warn: file /etc/mysql/my.cnf not found, reinstalling mysql')
    install_mysql()

setup_root_pass()
install_python_mysql()

props = {}
props['bind-address'] = ('127.0.0.1', '0.0.0.0')
p = patcher.patch_file("/etc/mysql/my.cnf", props, True)
print("info: my.cnf patched " + str(p))

#Restart MySQL
osutils.run_std('service mysql restart')
Example #15
0
    "mysql -u root -p%s -e \"GRANT ALL ON glance.* TO 'glance'@'%s' IDENTIFIED BY '%s';\""
    % (openstack_pass.root_db_pass, openstack_pass.controller_host,
       openstack_pass.glance_db_pass))

sql = "mysql://*****:*****@%s:3306/glance" % (openstack_pass.glance_db_pass,
                                            openstack_pass.controller_host)

if openstack_conf.version == 'essex':
    osutils.run_std(
        'apt-get install -y glance glance-api glance-client glance-common glance-registry python-glance'
    )

    props = {}
    props['rabbit_password'] = ('guest', openstack_pass.rabbit_pass)
    props['[paste_deploy]flavor'] = (None, 'keystone')
    p = patcher.patch_file('/etc/glance/glance-api.conf', props, True)
    print('info: /etc/glance/glance-api.conf patched ' + str(p))

    props = {}
    props['sql_connection'] = ('sqlite:////var/lib/glance/glance.sqlite', sql)
    props['[paste_deploy]flavor'] = (None, 'keystone')
    p = patcher.patch_file('/etc/glance/glance-registry.conf', props, True)
    print('info: /etc/glance/glance-registry.conf patched ' + str(p))

    props = {}
    props['admin_tenant_name'] = ('%SERVICE_TENANT_NAME%', 'admin')
    props['admin_user'] = ('%SERVICE_USER%', 'admin')
    props['admin_password'] = ('%SERVICE_PASSWORD%',
                               openstack_pass.openstack_pass)
    p = patcher.patch_file('/etc/glance/glance-registry-paste.ini', props,
                           True)
Example #16
0
# Install LibVirt
osutils.run_std('apt-get install -y libvirt-bin pm-utils')

# Install iSCSI
osutils.run_std('apt-get install -y tgt open-iscsi open-iscsi-utils')


# Patch confs

props = {}
props['auth_host'] = ('127.0.0.1', openstack_pass.controller_host)
props['admin_tenant_name'] = ('%SERVICE_TENANT_NAME%', 'admin')
props['admin_user'] = ('%SERVICE_USER%', 'admin')
props['admin_password'] = ('%SERVICE_PASSWORD%', openstack_pass.openstack_pass)
p = patcher.patch_file('/etc/nova/api-paste.ini', props, True)
print('info: /etc/nova/api-paste.ini patched ' + str(p))

# Templates confs

if not os.path.exists('/etc/nova/nova.conf.bak'):
  shutil.copy2('/etc/nova/nova.conf', '/etc/nova/nova.conf.bak')

patcher.template_file('nova.conf.' + openstack_conf.version, '/etc/nova/nova.conf')
print('info: /etc/nova/nova.conf saved')

if not os.path.exists('/etc/nova/nova-compute.conf.bak'):
  shutil.copy2('/etc/nova/nova-compute.conf', '/etc/nova/nova-compute.conf.bak')

patcher.template_file('nova-compute.conf.' + openstack_conf.version, '/etc/nova/nova-compute.conf')
print('info: /etc/nova/nova-compute.conf saved')