コード例 #1
0
def create_flavors(nova_client=None):
    """Create basic flavors.

    :param nova_client: Authenticated nova client
    :type nova_client: novaclient.v2.client.Client
    """
    if not nova_client:
        keystone_session = openstack_utils.get_overcloud_keystone_session()
        nova_client = openstack_utils.get_nova_session_client(keystone_session)
    cli_utils.setup_logging()

    for attempt in Retrying(stop=stop_after_attempt(3),
                            wait=wait_exponential(multiplier=1, min=2,
                                                  max=10)):
        with attempt:
            existing_flavors = nova_client.flavors.list()

    names = [flavor.name for flavor in existing_flavors]
    for flavor in nova_utils.FLAVORS.keys():
        if flavor not in names:
            nova_flavor = nova_client.flavors.create(
                name=flavor,
                ram=nova_utils.FLAVORS[flavor]['ram'],
                vcpus=nova_utils.FLAVORS[flavor]['vcpus'],
                disk=nova_utils.FLAVORS[flavor]['disk'],
                flavorid=nova_utils.FLAVORS[flavor]['flavorid'])
            if 'extra-specs' in nova_utils.FLAVORS[flavor]:
                nova_flavor.set_keys(nova_utils.FLAVORS[flavor]['extra-specs'])
コード例 #2
0
 def setUpClass(cls):
     """Run class setup for running tests."""
     super(ManilaGaneshaTests, cls).setUpClass()
     cls.nova_client = (
         openstack_utils.get_nova_session_client(cls.keystone_session))
     cls.manila_client = manilaclient.Client(
         session=cls.keystone_session, client_version='2')
コード例 #3
0
 def setUpClass(cls):
     """Run class setup for running percona-cluster cold start tests."""
     super(PerconaClusterColdStartTest, cls).setUpClass()
     cls.overcloud_keystone_session = (
         openstack_utils.get_undercloud_keystone_session())
     cls.nova_client = openstack_utils.get_nova_session_client(
         cls.overcloud_keystone_session)
コード例 #4
0
    def test_vm_creation(self):
        """Tests to launch a cirros image."""
        cli_utils.setup_logging()
        keystone_session = openstack_utils.get_overcloud_keystone_session()
        # Retrieve necessary clients
        nova_client = openstack_utils.get_nova_session_client(keystone_session)
        neutron_client = openstack_utils.get_neutron_session_client(
            keystone_session)

        image = nova_client.glance.find_image("cirros")
        flavor = nova_client.flavors.find(name="m1.small")
        networks = neutron_client.list_networks(name=net_name)
        if len(networks['networks']) == 0:
            raise Exception('Network {} has not been created'.format(net_name))
        nics = [{'net-id': networks['networks'][0]['id']}]
        # Launch instance.
        logging.info('Launching instance {}'.format(vm_name))
        instance = nova_client.servers.create(name=vm_name,
                                              image=image,
                                              flavor=flavor,
                                              nics=nics)

        # Test Instance is ready.
        logging.info('Checking instance is active')
        openstack_utils.resource_reaches_status(nova_client.servers,
                                                instance.id,
                                                expected_status='ACTIVE')
コード例 #5
0
def main(argv):
    cli_utils.setup_logging()
    parser = argparse.ArgumentParser()
    parser.add_argument('-d',
                        '--domain_name',
                        help='DNS Domain Name. '
                        'Must end in a .',
                        default='mojo.serverstack.')
    options = parser.parse_args()
    domain_name = cli_utils.parse_arg(options, 'domain_name')

    os_version = openstack_utils.get_current_os_versions(
        'keystone')['keystone']
    if os_version >= 'mitaka':
        designate_api = '2'
    else:
        designate_api = '1'
    keystone_session = openstack_utils.get_overcloud_keystone_session()

    nova_client = openstack_utils.get_nova_session_client(keystone_session)
    des_client = mojo_os_utils.get_designate_session_client(
        keystone_session, all_tenants=True, client_version=designate_api)
    for server in nova_client.servers.list():
        for addr_info in server.addresses['private']:
            if addr_info['OS-EXT-IPS:type'] == 'floating':
                mojo_os_utils.check_dns_entry(
                    des_client, addr_info['addr'], domain_name,
                    '{}.{}'.format(server.name, domain_name))
コード例 #6
0
 def setUpClass(cls):
     """Run class setup for running tests."""
     super(CinderTests, cls).setUpClass()
     cls.cinder_client = openstack_utils.get_cinder_session_client(
         cls.keystone_session)
     cls.nova_client = openstack_utils.get_nova_session_client(
         cls.keystone_session)
コード例 #7
0
 def setUpClass(cls):
     """Run class setup for running tests."""
     super(MasakariTest, cls).setUpClass()
     cls.keystone_session = openstack_utils.get_overcloud_keystone_session()
     cls.model_name = zaza.model.get_juju_model()
     cls.nova_client = openstack_utils.get_nova_session_client(
         cls.keystone_session)
コード例 #8
0
ファイル: setup.py プロジェクト: r-f-g/zaza-openstack-tests
def create_bm_flavors(nova_client=None):
    """Create baremetal flavors.

    :param nova_client: Authenticated nova client
    :type nova_client: novaclient.v2.client.Client
    """
    if not nova_client:
        keystone_session = openstack_utils.get_overcloud_keystone_session()
        nova_client = openstack_utils.get_nova_session_client(keystone_session)
    cli_utils.setup_logging()
    names = [flavor.name for flavor in nova_client.flavors.list()]
    # Disable scheduling based on standard flavor properties
    default_properties = {
        "resources:VCPU": 0,
        "resources:MEMORY_MB": 0,
        "resources:DISK_GB": 0,
    }
    for flavor in FLAVORS.keys():
        if flavor not in names:
            properties = copy.deepcopy(default_properties)
            properties.update(FLAVORS[flavor]["properties"])
            bm_flavor = nova_client.flavors.create(
                name=flavor,
                ram=FLAVORS[flavor]['ram'],
                vcpus=FLAVORS[flavor]['vcpus'],
                disk=FLAVORS[flavor]['disk'],
                flavorid=FLAVORS[flavor]['flavorid'])
            bm_flavor.set_keys(properties)
コード例 #9
0
 def setUpClass(cls):
     """Run class setup for running percona-cluster cold start tests."""
     super().setUpClass()
     cls.application = "mysql-innodb-cluster"
     cls.overcloud_keystone_session = (
         openstack_utils.get_undercloud_keystone_session())
     cls.nova_client = openstack_utils.get_nova_session_client(
         cls.overcloud_keystone_session)
コード例 #10
0
ファイル: tests.py プロジェクト: wolsen/zaza-openstack-tests
 def setUpClass(cls):
     """Run class setup for running tests."""
     super(AodhServerAlarmTest, cls).setUpClass(application_name='aodh')
     cls.aodh_client = openstack_utils.get_aodh_session_client(
         cls.keystone_session)
     cls.nova_client = openstack_utils.get_nova_session_client(
         cls.keystone_session)
     cls.run_resource_cleanup = True
コード例 #11
0
 def setUpClass(cls, application_name=None, model_alias=None):
     """Run setup for test class to create common resources."""
     super(OpenStackBaseTest, cls).setUpClass(application_name, model_alias)
     cls.keystone_session = openstack_utils.get_overcloud_keystone_session(
         model_name=cls.model_name)
     cls.cacert = openstack_utils.get_cacert()
     cls.nova_client = (
         openstack_utils.get_nova_session_client(cls.keystone_session))
コード例 #12
0
def setup_gateway_ext_port(network_config,
                           keystone_session=None,
                           limit_gws=None,
                           use_juju_wait=True):
    """Perform setup external port on Neutron Gateway.

    For OpenStack on OpenStack scenarios.

    :param network_config: Network configuration dictionary
    :type network_config: dict
    :param keystone_session: Keystone session object for undercloud
    :type keystone_session: keystoneauth1.session.Session object
    :param limit_gws: Limit the number of gateways that get a port attached
    :type limit_gws: Optional[int]
    :param use_juju_wait: Use juju wait (default True) for model to settle
    :type use_juju_wait: boolean
    :returns: None
    :rtype: None
    """
    # If a session has not been provided, acquire one
    if not keystone_session:
        keystone_session = openstack_utils.get_undercloud_keystone_session()

    # Get authenticated clients
    nova_client = openstack_utils.get_nova_session_client(keystone_session)
    neutron_client = openstack_utils.get_neutron_session_client(
        keystone_session)

    # Add an interface to the neutron-gateway units and tell juju to use it
    # as the external port.
    if "net_id" in network_config.keys():
        net_id = network_config["net_id"]
    else:
        net_id = None

    try:
        # If we're using netplan, we need to add the new interface to the guest
        current_release = openstack_utils.get_os_release()
        bionic_queens = openstack_utils.get_os_release('bionic_queens')
        if current_release >= bionic_queens:
            logging.warn("Adding second interface for dataport to guest "
                         "netplan for bionic-queens and later")
            add_dataport_to_netplan = True
        else:
            add_dataport_to_netplan = False
    except zaza.openstack.utilities.exceptions.ApplicationNotFound:
        # The setup_gateway_ext_port helper may be used with non-OpenStack
        # workloads.
        add_dataport_to_netplan = False

    logging.info("Configuring network for OpenStack undercloud/provider")
    openstack_utils.configure_gateway_ext_port(
        nova_client,
        neutron_client,
        net_id=net_id,
        add_dataport_to_netplan=add_dataport_to_netplan,
        limit_gws=limit_gws,
        use_juju_wait=use_juju_wait)
コード例 #13
0
 def setUpClass(cls):
     """Run class setup for running tests."""
     super().setUpClass(application_name=cls.application_name)
     cls.cinder_client = openstack_utils.get_cinder_session_client(
         cls.keystone_session)
     cls.nova_client = openstack_utils.get_nova_session_client(
         cls.keystone_session)
     cls.keystone_client = openstack_utils.get_keystone_session_client(
         cls.keystone_session)
コード例 #14
0
 def _cleanup_vgpu_flavor(self):
     logging.info('Cleaning up created flavor...')
     nova_client = openstack_utils.get_nova_session_client(
         self.keystone_session)
     try:
         flavor = nova_client.flavors.get(self.flavor_id)
     except novaclient.exceptions.NotFound:
         return
     nova_client.flavors.delete(flavor)
コード例 #15
0
 def setUpClass(cls):
     """Run class setup for running tests."""
     super(CinderTests, cls).setUpClass(application_name='cinder')
     cls.application_name = 'cinder'
     cls.lead_unit = zaza.model.get_lead_unit_name(
         "cinder", model_name=cls.model_name)
     cls.cinder_client = openstack_utils.get_cinder_session_client(
         cls.keystone_session)
     cls.nova_client = openstack_utils.get_nova_session_client(
         cls.keystone_session)
コード例 #16
0
def main(argv):
    cli_utils.setup_logging()
    try:
        cacert = os.path.join(os.environ.get('MOJO_LOCAL_DIR'), 'cacert.pem')
        os.stat(cacert)
    except FileNotFoundError:
        cacert = None
    keystone_session = openstack_utils.get_overcloud_keystone_session(
        verify=cacert)
    aodhc = mojo_os_utils.get_aodh_session_client(keystone_session)
    nova_client = openstack_utils.get_nova_session_client(keystone_session)

    servers = nova_client.servers.list()
    assert servers, "No servers available for AODH testing"
    if servers:
        alarm_name = 'mojo_instance_off'
        server = servers[0]
        assert server.status == 'ACTIVE', "Server {} not active".format(
            server.name)
        logging.info('Using server {} for aodh test'.format(server.name))
        server = nova_client.servers.find(name=server.name)
        logging.info('Deleting alarm {} if it exists'.format(alarm_name))
        mojo_os_utils.delete_alarm(aodhc, alarm_name, cache_wait=True)
        logging.info('Creating alarm {}'.format(alarm_name))
        alarm_def = {
            'type': 'event',
            'name': alarm_name,
            'description': 'Instance powered OFF',
            'alarm_actions': ['log://'],
            'ok_actions': ['log://'],
            'insufficient_data_actions': ['log://'],
            'event_rule': {
                'event_type':
                'compute.instance.power_off.*',
                'query': [{
                    'field': 'traits.instance_id',
                    'op': 'eq',
                    'type': 'string',
                    'value': server.id
                }]
            }
        }
        alarm_info = aodhc.alarm.create(alarm_def)
        logging.info('Stopping server {}'.format(server.name))
        server.stop()
        for i in range(10):
            alarm_state = mojo_os_utils.get_alarm_state(
                aodhc, alarm_info['alarm_id'])
            if alarm_state == 'alarm':
                logging.info('Alarm triggered')
                break
            else:
                time.sleep(15)
        else:
            raise Exception("Alarm failed to trigger")
コード例 #17
0
 def setUpClass(cls):
     """Run class setup for running Heat tests."""
     super(HeatBasicDeployment, cls).setUpClass()
     cls.application = 'heat'
     cls.keystone_session = openstack_utils.get_overcloud_keystone_session()
     cls.heat_client = openstack_utils.get_heat_session_client(
         cls.keystone_session)
     cls.glance_client = openstack_utils.get_glance_session_client(
         cls.keystone_session)
     cls.nova_client = openstack_utils.get_nova_session_client(
         cls.keystone_session)
コード例 #18
0
 def remove_vm_on_failure(retry_state):
     logging.info(
         'Detected failure launching or connecting to VM {}'.format(
             vm_name))
     keystone_session = openstack_utils.get_overcloud_keystone_session()
     nova_client = openstack_utils.get_nova_session_client(keystone_session)
     vm = nova_client.servers.find(name=vm_name)
     openstack_utils.resource_removed(
         nova_client.servers,
         vm.id,
         msg="Waiting for the Nova VM {} to be deleted".format(vm.name))
コード例 #19
0
 def setUpClass(cls):
     """Run class setup for running Neutron API Networking tests."""
     cls.keystone_session = (
         openstack_utils.get_overcloud_keystone_session())
     cls.nova_client = (openstack_utils.get_nova_session_client(
         cls.keystone_session))
     # NOTE(fnordahl): in the event of a test failure we do not want to run
     # tear down code as it will make debugging a problem virtually
     # impossible.  To alleviate each test method will set the
     # `run_tearDown` instance variable at the end which will let us run
     # tear down only when there were no failure.
     cls.run_tearDown = False
コード例 #20
0
ファイル: tests.py プロジェクト: wolsen/zaza-openstack-tests
 def setUpClass(cls):
     """Run class setup for running tests."""
     super(ManilaBaseTest, cls).setUpClass()
     cls.nova_client = openstack_utils.get_nova_session_client(
         session=cls.keystone_session)
     cls.manila_client = manilaclient.Client(session=cls.keystone_session,
                                             client_version='2')
     cls.share_name = 'test-manila-share'
     cls.share_type_name = 'default_share_type'
     cls.share_protocol = 'nfs'
     cls.mount_dir = '/mnt/manila_share'
     cls.share_network = None
コード例 #21
0
def add_nova_config(ctxt, keystone_session):
    """Add nova config to context.

    :param ctxt: Context dictionary
    :type ctxt: dict
    :param keystone_session: keystoneauth1.session.Session object
    :type: keystoneauth1.session.Session
    :returns: None
    :rtype: None
    """
    nova_client = openstack_utils.get_nova_session_client(keystone_session)
    for flavor in nova_client.flavors.list():
        if flavor.name == TEMPEST_FLAVOR_NAME:
            ctxt['flavor_ref'] = flavor.id
        if flavor.name == TEMPEST_ALT_FLAVOR_NAME:
            ctxt['flavor_ref_alt'] = flavor.id
コード例 #22
0
    def test_sync_compute_az_action(self):
        """Test sync-compute-availability-zones action."""
        juju_units_az_map = {}
        compute_config = zaza.model.get_application_config('nova-compute')
        default_az = compute_config['default-availability-zone']['value']
        use_juju_az = compute_config['customize-failure-domain']['value']

        for unit in zaza.model.get_units('nova-compute',
                                         model_name=self.model_name):
            zone = default_az
            if use_juju_az:
                result = zaza.model.run_on_unit(unit.name,
                                                'echo $JUJU_AVAILABILITY_ZONE',
                                                model_name=self.model_name,
                                                timeout=60)
                self.assertEqual(int(result['Code']), 0)
                juju_az = result['Stdout'].strip()
                if juju_az:
                    zone = juju_az

            juju_units_az_map[zaza.model.get_unit_public_address(unit)] = zone
            continue

        session = openstack_utils.get_overcloud_keystone_session()
        nova = openstack_utils.get_nova_session_client(session)

        result = zaza.model.run_action_on_leader(
            'nova-cloud-controller',
            'sync-compute-availability-zones',
            model_name=self.model_name)

        # For validating the action results, we simply want to validate that
        # the action was completed and we have something in the output. The
        # functional validation really occurs below, in that the hosts are
        # checked to be in the appropriate host aggregates.
        self.assertEqual(result.status, 'completed')
        self.assertNotEqual('', result.results['output'])

        unique_az_list = list(set(juju_units_az_map.values()))
        aggregates = nova.aggregates.list()
        self.assertEqual(len(aggregates), len(unique_az_list))
        for unit_address in juju_units_az_map:
            az = juju_units_az_map[unit_address]
            aggregate = nova.aggregates.find(name='{}_az'.format(az),
                                             availability_zone=az)
            hypervisor = nova.hypervisors.find(host_ip=unit_address)
            self.assertIn(hypervisor.hypervisor_hostname, aggregate.hosts)
コード例 #23
0
def manage_ssh_key(nova_client=None):
    """Create basic flavors.

    :param nova_client: Authenticated nova client
    :type nova_client: novaclient.v2.client.Client
    """
    if not nova_client:
        keystone_session = openstack_utils.get_overcloud_keystone_session()
        nova_client = openstack_utils.get_nova_session_client(keystone_session)
    cli_utils.setup_logging()
    if not openstack_utils.valid_key_exists(nova_client,
                                            nova_utils.KEYPAIR_NAME):
        key = openstack_utils.create_ssh_key(nova_client,
                                             nova_utils.KEYPAIR_NAME,
                                             replace=True)
        openstack_utils.write_private_key(nova_utils.KEYPAIR_NAME,
                                          key.private_key)
コード例 #24
0
def setup_gateway_ext_port(network_config, keystone_session=None):
    """Perform setup external port on Neutron Gateway.

    For OpenStack on OpenStack scenarios.

    :param network_config: Network configuration dictionary
    :type network_config: dict
    :param keystone_session: Keystone session object for undercloud
    :type keystone_session: keystoneauth1.session.Session object
    :returns: None
    :rtype: None
    """
    # If a session has not been provided, acquire one
    if not keystone_session:
        keystone_session = openstack_utils.get_undercloud_keystone_session()

    # Get authenticated clients
    nova_client = openstack_utils.get_nova_session_client(keystone_session)
    neutron_client = openstack_utils.get_neutron_session_client(
        keystone_session)

    # Add an interface to the neutron-gateway units and tell juju to use it
    # as the external port.
    if "net_id" in network_config.keys():
        net_id = network_config["net_id"]
    else:
        net_id = None

    # If we're using netplan, we need to add the new interface to the guest
    current_release = openstack_utils.get_os_release()
    bionic_queens = openstack_utils.get_os_release('bionic_queens')
    if current_release >= bionic_queens:
        logging.warn("Adding second interface for dataport to guest netplan "
                     "for bionic-queens and later")
        add_dataport_to_netplan = True
    else:
        add_dataport_to_netplan = False

    logging.info("Configuring network for OpenStack undercloud/provider")
    openstack_utils.configure_gateway_ext_port(
        nova_client,
        neutron_client,
        dvr_mode=network_config.get("dvr_enabled", False),
        net_id=net_id,
        add_dataport_to_netplan=add_dataport_to_netplan)
コード例 #25
0
def create_flavors(nova_client=None):
    """Create basic flavors.

    :param nova_client: Authenticated nova client
    :type nova_client: novaclient.v2.client.Client
    """
    if not nova_client:
        keystone_session = openstack_utils.get_overcloud_keystone_session()
        nova_client = openstack_utils.get_nova_session_client(keystone_session)
    cli_utils.setup_logging()
    names = [flavor.name for flavor in nova_client.flavors.list()]
    for flavor in nova_utils.FLAVORS.keys():
        if flavor not in names:
            nova_client.flavors.create(
                name=flavor,
                ram=nova_utils.FLAVORS[flavor]['ram'],
                vcpus=nova_utils.FLAVORS[flavor]['vcpus'],
                disk=nova_utils.FLAVORS[flavor]['disk'],
                flavorid=nova_utils.FLAVORS[flavor]['flavorid'])
コード例 #26
0
    def test_104_compute_api_functionality(self):
        """Verify basic compute API functionality."""
        logging.info('Instantiating nova client...')
        keystone_session = openstack_utils.get_overcloud_keystone_session()
        nova = openstack_utils.get_nova_session_client(keystone_session)

        logging.info('Checking api functionality...')

        actual_service_names = [service.to_dict()['binary'] for service in
                                nova.services.list()]
        for expected_service_name in ('nova-scheduler', 'nova-conductor',
                                      'nova-compute'):
            assert(expected_service_name in actual_service_names)

        # Thanks to setup.create_flavors we should have a few flavors already:
        assert(len(nova.flavors.list()) > 0)

        # Just checking it's not raising and returning an iterable:
        assert(len(nova.servers.list()) >= 0)
コード例 #27
0
    def test_gateway_failure(self):
        """Validate networking in the case of a gateway failure."""
        instance_1, instance_2 = self.retrieve_guests()
        if not all([instance_1, instance_2]):
            self.launch_guests()
            instance_1, instance_2 = self.retrieve_guests()
        self.check_connectivity(instance_1, instance_2)

        routers = self.neutron_client.list_routers(
            name='provider-router')['routers']
        assert len(routers) == 1, "Unexpected router count {}".format(
            len(routers))
        provider_router = routers[0]
        l3_agents = self.neutron_client.list_l3_agent_hosting_routers(
            router=provider_router['id'])['agents']
        logging.info(
            'Checking there are multiple L3 agents running tenant router')
        assert len(l3_agents) == 2, "Unexpected l3 agent count {}".format(
            len(l3_agents))
        uc_ks_session = openstack_utils.get_undercloud_keystone_session()
        uc_nova_client = openstack_utils.get_nova_session_client(uc_ks_session)
        uc_neutron_client = openstack_utils.get_neutron_session_client(
            uc_ks_session)
        for agent in l3_agents:
            gateway_hostname = agent['host']
            gateway_server = uc_nova_client.servers.find(name=gateway_hostname)
            logging.info("Shutting down {}".format(gateway_hostname))
            gateway_server.stop()
            self.check_server_state(
                uc_nova_client,
                'SHUTOFF',
                server_name=gateway_hostname)
            self.check_connectivity(instance_1, instance_2)
            gateway_server.start()
            self.check_server_state(
                uc_nova_client,
                'ACTIVE',
                server_name=gateway_hostname)
            self.check_neutron_agent_up(
                uc_neutron_client,
                gateway_hostname)
            self.check_connectivity(instance_1, instance_2)
コード例 #28
0
def create_segments(segment_number=1, host_assignment_method=None):
    """Create a masakari segment and populate it with hypervisors.

    :param segment_number: Number of segments to create
    :type segment_number: int
    :param host_assignment_method: Method to use to assign hypervisors to
                                   segments
    :type host_assignment_method: f()
    """
    host_assignment_method = host_assignment_method or ROUND_ROBIN
    keystone_session = openstack_utils.get_overcloud_keystone_session()
    nova_client = openstack_utils.get_nova_session_client(keystone_session)
    masakari_client = openstack_utils.get_masakari_session_client(
        keystone_session)
    for segment_number in range(0, segment_number):
        segment_name = 'seg{}'.format(segment_number)
        logging.info('Creating segment {}'.format(segment_name))
        masakari_client.create_segment(name=segment_name,
                                       recovery_method='auto',
                                       service_type='COMPUTE')
    HOST_ASSIGNMENT_METHODS[host_assignment_method](nova_client,
                                                    masakari_client)
コード例 #29
0
def main():
    args = parse_args(sys.argv[1:])
    cli_utils.setup_logging(log_level=args.loglevel.upper())
    session = zaza_os.get_undercloud_keystone_session()
    neutron_client = zaza_os.get_neutron_session_client(session)
    nova_client = zaza_os.get_nova_session_client(session)
    if args.vnic_binding_type == 'dummy':
        logging.warning('Running in dummy mode')
        binding_type = None
    else:
        binding_type = args.vnic_binding_type
    if args.action == 'cleanup':
        logging.info('Running cleanup')
        cleanup(nova_client, neutron_client, args.network_name,
                args.application_name)
    elif args.action == 'add-ports':
        logging.info('Adding ports')
        create_ports(nova_client,
                     neutron_client,
                     args.network_name,
                     args.application_name,
                     binding_type,
                     shutdown_move=True)
        logging.info('Adding to netplan')
        add_port_to_netplan(neutron_client, args.network_name,
                            args.application_name)
    elif args.action == 'add-servers':
        add_servers(nova_client,
                    neutron_client,
                    args.network_name,
                    args.number_of_units,
                    args.flavor,
                    args.image_name,
                    vnic_type=binding_type,
                    port_security_enabled=args.enable_port_security)
    elif args.action == 'add-manual-cloud':
        add_cloud(nova_client)
    elif args.action == 'add-machines':
        add_machines(nova_client)
コード例 #30
0
    def test_create_loadbalancer(self):
        """Create load balancer."""
        nova_client = openstack_utils.get_nova_session_client(
            self.keystone_session)

        # Get IP of the prepared payload instances
        payload_ips = []
        for server in nova_client.servers.list():
            payload_ips.append(server.networks['private'][0])
        self.assertTrue(len(payload_ips) > 0)

        resp = self.neutron_client.list_networks(name='private')
        subnet_id = resp['networks'][0]['subnets'][0]
        if openstack_utils.dvr_enabled():
            resp = self.neutron_client.list_networks(
                name='private_lb_fip_network')
            vip_subnet_id = resp['networks'][0]['subnets'][0]
        else:
            vip_subnet_id = subnet_id
        for provider in self.get_lb_providers(self.octavia_client).keys():
            logging.info(
                'Creating loadbalancer with provider {}'.format(provider))
            lb = self._create_lb_resources(self.octavia_client, provider,
                                           vip_subnet_id, subnet_id,
                                           payload_ips)
            self.loadbalancers.append(lb)

            lb_fp = openstack_utils.create_floating_ip(
                self.neutron_client, 'ext_net', port={'id': lb['vip_port_id']})

            snippet = 'This is the default welcome page'
            assert snippet in self._get_payload(lb_fp['floating_ip_address'])
            logging.info('Found "{}" in page retrieved through load balancer '
                         ' (provider="{}") at "http://{}/"'.format(
                             snippet, provider, lb_fp['floating_ip_address']))

        # If we get here, it means the tests passed
        self.run_tearDown = True