Пример #1
0
    app_list.append(VMs[vm]['vapp'])

app_list = set(app_list)

cprint('\nThese are the vApps to be updated with new Org VDC Network', 'yellow')
pprint(app_list)



# Add new Org Network to the vApp -------------------------------------------------------
for vapp in app_list:
    # Retrieve current networkConfigSection
    current_config = myvcd.vapp_get_networks(vapps[vapp])
    # Create new body (append new network
    nw_cfg = {'org_nw_name': new_vdcnet, 'org_nw_id': orgnets[new_vdcnet]['uuid']}
    new_config = createbody('templates/nwconfig.j2', nw_cfg)

    # Replace the ending </NetworkConfigSection> tag from current config with new config
    updated_config = current_config.replace("</NetworkConfigSection>", new_config)

    # Add new network to vApp
    print('\nAdding the New Org network {} to the vApp: {}'.format(new_vdcnet, vapp))
    myvcd.vapp_add_network(vapps[vapp], updated_config)


# Switch VM's network card --------------------------------------------------------------
for vm in compl_VMs:
    # Render networkCards section
    """
    # This section would be needed only if the non-primary network card is to be modified
    for adapter in compl_VMs[vm]['adapters']:
Пример #2
0
edge_data['extnetwork'] = extnets[extnw]

# Print configuration summary -----------------------------------------------------------
print('\n')
cprint('\nReview the edge to be created:', 'red')
print('  Organization:       %s' % org)
print('  vDC                 %s' % vdc)
print('  External network:   %s' % extnw)
print('  Name:               %s' % edge_data['name'])
print('  Gateway:            %s' % edge_data['Gateway'])
print('  Netmask:            %s' % edge_data['Netmask'])
print('  Pool End Address:   %s' % edge_data['IpAddress'])
print('\n')

agree = raw_input("Do you want to apply these changes? y/n[N]: " or 'N')

# Configure edge   ----------------------------------------------------------------------

# Proceed with updating configuration
if agree != "Y" and agree != "y":
    print("Script execution canceled")
    sys.exit(1)
else:
    # Define XML Body
    xml_edge = createbody("templates/edge.j2", edge_data)

    # Create edge
    print('Wait for tasks to be completed')
    print('Configuring edge - {0} ---------'.format(edge_data['name']))
    myvcd.create_edge(vdcs[vdc], xml_edge)
Пример #3
0
print('  Netmask:            %s' % vdc_data['Netmask'])
print('  Pool Start Address: %s' % vdc_data['StartAddress'])
print('  Pool End Address:   %s' % vdc_data['EndAddress'])
print('\n')


agree = raw_input("Do you want to apply these changes? y/n[N]: " or 'N')


# Configure edge   ----------------------------------------------------------------------

# Proceed with updating configuration
if agree != "Y" and agree != "y":
    print("Script execution canceled")
    sys.exit(1)
else:
    # Define XML Body
    xml_vdcnet = createbody("templates/vdcnet.j2", vdc_data)

    # Create edge
    print('Wait for tasks to be completed')
    print('Configuring vDC network - {0} ---------'.format(vdc_data['name']))
    myvcd.create_vdcnetwork(vdcs[vdc], xml_vdcnet)







Пример #4
0
        for adapter in compl_VMs[vm]['adapters']:
            if compl_VMs[vm]['adapters'][adapter]['primary_nw'] == 'true':
                primary_adapter = compl_VMs[vm]['adapters'][adapter]

            compl_VMs[vm].update({'prim_nw_conn_index': primary_adapter})

        pprint(compl_VMs[vm])
        """
        cprint(
            '\nUpdating the VM {0} {1}'.format(
                vm, compl_VMs[vm]['adapters']['0']['ip_addr']), 'yellow')
        # Update primary network adapter '0' with new network
        compl_VMs[vm]['adapters']['0']['org_nw'] = new_vdcnet

        # Generate xml body
        xml_body = createbody('templates/nwconnectionsection.j2',
                              compl_VMs[vm])
        print(xml_body)

        bar.update()
        # Update current networkCards section with new Org Network
        task_href = myvcd.vm_update_nwconnectsection(compl_VMs[vm]['uuid'],
                                                     xml_body)

        tasks_list.append(task_href)

        i = 0
        while myvcd.get_task_status(task_href) != 'running':
            time.sleep(0.2)
            i += 1
            print(i)
            if i > 50:
Пример #5
0
extnw_data['VimServerReference'] = vcenter['VimServerReference']

# Print configuration summary ------------------------------------------------
print('\n')
cprint('\nReview the external network to be created:', 'red')
print('  Name:               %s' % extnw_data['name'])
print('  Distributed pgroup: %s' % extnw_data['dvportgroup'])
print('  Gateway:            %s' % extnw_data['Gateway'])
print('  Netmask:            %s' % extnw_data['Netmask'])
print('  Pool Start Address: %s' % extnw_data['StartAddress'])
print('  Pool End Address:   %s' % extnw_data['EndAddress'])
print('\n')

agree = raw_input("Do you want to apply these changes? y/n[N]: " or 'N')

# Configure external network   ------------------------------------------------

# Proceed with updating configuration
if agree != "Y" and agree != "y":
    print("Script execution canceled")
    sys.exit(1)
else:
    # Define XML Body
    xml_extnw = createbody("templates/extnetw.j2", extnw_data)

    # Create edge
    print('Wait for tasks to be completed')
    print('Configuring external network - {0} ---------'.format(
        extnw_data['name']))
    myvcd.create_extnetwork(xml_extnw)