def main(): args = collect_args() common.load_config(CONF, args.config) noop = True if args.for_realsies: noop = False else: print "Running migration in noop mode, use -f to actually migrate things" direction = args.direction conn = MySQLdb.connect(host=CONF.get('db', 'host'), user=CONF.get('db', 'user'), passwd=CONF.get('db', 'password'), db=CONF.get('db', 'name')) cursor = MySQLdb.cursors.DictCursor(conn) url = CONF.get('creds', 'auth_url') username = CONF.get('creds', 'username') password = CONF.get('creds', 'password') tenant = CONF.get('creds', 'tenant_name') host = socket.gethostname() novac = common.get_nova_client(username=username, password=password, tenant=tenant, url=url) neutronc = common.get_neutron_client(username=username, password=password, tenant=tenant, url=url) networks = [] for section in CONF.sections(): if section.startswith('network_'): network_id = CONF.get(section, 'neutron_net_id') network = get_network(neutronc, network_id) for option in ('device', 'bridge', 'nova_name'): network[option] = CONF.get(section, option) networks.append(network) instances = common.all_servers(novac, host=host) if direction == 'neutron': manager = NeutronMigration elif direction == 'nova': manager = NovaMigration else: print "unknown direction" print "Running checks" errors = migrate_interfaces(True, manager, neutronc, cursor, networks, instances) if not noop and not errors: print "running for real" migrate_interfaces(False, manager, neutronc, cursor, networks, instances) if errors: print "ERROR: Cannot run due to errors" cursor.close() conn.close() print "SUCCESS!"
def main(): args = collect_args() common.load_config(CONF, args.config) conn = MySQLdb.connect( host=CONF.get('nova_db', 'host'), user=CONF.get('nova_db', 'user'), passwd=CONF.get('nova_db', 'password'), db=CONF.get('nova_db', 'name')) cursor = MySQLdb.cursors.DictCursor(conn) fixed_ips = get_hyperisor_fixed_ips(cursor) url = CONF.get('creds', 'auth_url') username = CONF.get('creds', 'username') password = CONF.get('creds', 'password') tenant = CONF.get('creds', 'tenant_name') neutronc = common.get_neutron_client(username=username, password=password, tenant=tenant, url=url) add_ports(cursor, neutronc, fixed_ips) cursor.close() conn.close()
def main(): args = collect_args() common.load_config(CONF, args.config) target_zone = args.zone conn = MySQLdb.connect(host=CONF.get('db', 'host'), user=CONF.get('db', 'user'), passwd=CONF.get('db', 'password'), db=CONF.get('db', 'name')) cursor = MySQLdb.cursors.DictCursor(conn) novac = common.get_nova_client() check_hypervisors(novac) neutronc = common.get_neutron_client() print "creating networks" mappings = create_networks(neutronc, cursor) print "getting instances" instances = common.all_servers(novac) print "adding ports" for i in instances: add_ports(neutronc, cursor, mappings, i, target_zone) cursor.close() conn.close()
def main(): args = collect_args() common.load_config(CONF, args.config) target_zone = args.zone conn = MySQLdb.connect( host=CONF.get('db', 'host'), user=CONF.get('db', 'user'), passwd=CONF.get('db', 'password'), db=CONF.get('db', 'name')) cursor = MySQLdb.cursors.DictCursor(conn) novac = common.get_nova_client() check_hypervisors(novac) neutronc = common.get_neutron_client() print "creating networks" mappings = create_networks(neutronc) print "getting instances" instances = common.all_servers(novac) print "adding ports" for i in instances: add_ports(neutronc, cursor, mappings, i, target_zone) cursor.close() conn.close()
def main(): args = collect_args() common.load_config(CONF, args.config) conn = MySQLdb.connect(host=CONF.get('nova_db', 'host'), user=CONF.get('nova_db', 'user'), passwd=CONF.get('nova_db', 'password'), db=CONF.get('nova_db', 'name')) cursor = MySQLdb.cursors.DictCursor(conn) fixed_ips = get_hyperisor_fixed_ips(cursor) url = CONF.get('creds', 'auth_url') username = CONF.get('creds', 'username') password = CONF.get('creds', 'password') tenant = CONF.get('creds', 'tenant_name') neutronc = common.get_neutron_client(username=username, password=password, tenant=tenant, url=url) add_ports(cursor, neutronc, fixed_ips) cursor.close() conn.close()
def main(): args = collect_args() common.load_config(CONF, args.config) noop = True if args.for_realsies: noop = False else: print "Running migration in noop mode, use -f to actually migrate things" direction = args.direction conn = MySQLdb.connect( host=CONF.get('db', 'host'), user=CONF.get('db', 'user'), passwd=CONF.get('db', 'password'), db=CONF.get('db', 'name')) cursor = MySQLdb.cursors.DictCursor(conn) url = CONF.get('creds', 'auth_url') username = CONF.get('creds', 'username') password = CONF.get('creds', 'password') tenant = CONF.get('creds', 'tenant_name') host = socket.gethostname() novac = common.get_nova_client(username=username, password=password, tenant=tenant, url=url) neutronc = common.get_neutron_client(username=username, password=password, tenant=tenant, url=url) networks = [] for section in CONF.sections(): if section.startswith('network_'): network_id = CONF.get(section, 'neutron_net_id') network = get_network(neutronc, network_id) for option in ('device', 'bridge', 'nova_name'): network[option] = CONF.get(section, option) networks.append(network) instances = common.all_servers(novac, host=host) if direction == 'neutron': manager = NeutronMigration elif direction == 'nova': manager = NovaMigration else: print "unknown direction" print "Running checks" errors = migrate_interfaces(True, manager, neutronc, cursor, networks, instances) if not noop and not errors: print "running for real" migrate_interfaces(False, manager, neutronc, cursor, networks, instances) if errors: print "ERROR: Cannot run due to errors" cursor.close() conn.close() print "SUCCESS!"
def main(): args = collect_args() common.load_config(CONF, args.config) noop = True if args.for_realsies: noop = False else: print "Running migration in noop mode, use -f to actually migrate things" direction = args.direction conn = MySQLdb.connect( host=CONF.get('db', 'host'), user=CONF.get('db', 'user'), passwd=CONF.get('db', 'password'), db=CONF.get('db', 'name')) cursor = MySQLdb.cursors.DictCursor(conn) url = CONF.get('creds', 'auth_url') username = CONF.get('creds', 'username') password = CONF.get('creds', 'password') tenant = CONF.get('creds', 'tenant_name') region = CONF.get('creds', 'region') host = socket.gethostname() novac = common.get_nova_client(username=username, password=password, tenant=tenant, region=region, url=url) neutronc = common.get_neutron_client(username=username, password=password, tenant=tenant, region=region, url=url) networks = [] device = 'bond0' # Gather neutron network id, nova network name, device/physnet, and nova bridge # Could generate a list? Or do we need to generate this data in generate-network-data.py? # Example in prod: # device = bond0 # bridge = brXXX for section in CONF.sections(): if section.startswith('network_default'): device = CONF.get(section, 'device') # O hai - why aren't you defined? cursor.execute("SELECT * from networks WHERE project_id is not null order by id") nova_networks = cursor.fetchall() for novanet in nova_networks: network = get_network(neutronc, novanet['label']) print network network['device'] = device network['bridge'] = novanet['bridge'] network['nova_name'] = novanet['label'] network['neutron_net_id'] = network['id'] networks.append(network) #for section in CONF.sections(): # if section.startswith('network_'): # network_id = CONF.get(section, 'neutron_net_id') # network = get_network(neutronc, network_id) # for option in ('device', 'bridge', 'nova_name'): # network[option] = CONF.get(section, option) # networks.append(network) instances = common.all_servers(novac, host=host) if direction == 'neutron': manager = NeutronMigration elif direction == 'nova': manager = NovaMigration else: print "unknown direction" print "Running checks" errors = migrate_interfaces(True, manager, neutronc, cursor, networks, instances) if not noop and not errors: print "running for real" migrate_interfaces(False, manager, neutronc, cursor, networks, instances) if errors: print "ERROR: Cannot run due to errors" cursor.close() conn.close() print "SUCCESS!"