def test_haproxy_context(self, mock_relation_ids, mock_get_ipv6_addr, mock_local_unit, mock_get_netmask_for_address, mock_get_address_in_network, mock_kv, mock_https, mock_network_manager): mock_network_manager.return_value = 'neutron' mock_https.return_value = False ctxt = context.HAProxyContext()() self.assertEqual(ctxt['service_ports']['nova-api-os-compute'], [8774, 8764])
def test_haproxy_context(self, mock_relation_ids, mock_get_ipv6_addr, mock_local_unit, mock_get_netmask_for_address, mock_get_address_in_network, mock_https, mock_network_manager): mock_network_manager.return_value = 'neutron' mock_https.return_value = False self.is_relation_made.return_value = False ctxt = context.HAProxyContext()() self.assertEqual(ctxt['service_ports']['neutron-server'], [9696, 9686])
def resource_map(actual_services=True): ''' Dynamically generate a map of resources that will be managed for a single hook execution. :param actual_services: Whether to return the actual services that run on a unit (ie. apache2) or the services defined in BASE_SERVICES (ie.nova-placement-api). ''' resource_map = deepcopy(BASE_RESOURCE_MAP) if os.path.exists('/etc/apache2/conf-available'): resource_map.pop(APACHE_CONF) else: resource_map.pop(APACHE_24_CONF) resource_map[NOVA_CONF]['contexts'].append( nova_cc_context.NeutronCCContext()) release = os_release('nova-common') cmp_os_release = CompareOpenStackReleases(release) if cmp_os_release >= 'mitaka': resource_map[NOVA_CONF]['contexts'].append( nova_cc_context.NovaAPISharedDBContext(relation_prefix='novaapi', database='nova_api', ssl_dir=NOVA_CONF_DIR)) if console_attributes('services'): resource_map[NOVA_CONF]['services'] += console_attributes('services') # nova-consoleauth will be managed by pacemaker, if # single-nova-consoleauth is used, then don't monitor for the # nova-consoleauth service to be started (LP: #1660244). if config('single-nova-consoleauth') and relation_ids('ha'): services = resource_map[NOVA_CONF]['services'] if 'nova-consoleauth' in services: services.remove('nova-consoleauth') if (config('enable-serial-console') and cmp_os_release >= 'juno'): resource_map[NOVA_CONF]['services'] += SERIAL_CONSOLE['services'] # also manage any configs that are being updated by subordinates. vmware_ctxt = context.SubordinateConfigContext(interface='nova-vmware', service='nova', config_file=NOVA_CONF) vmware_ctxt = vmware_ctxt() if vmware_ctxt and 'services' in vmware_ctxt: for s in vmware_ctxt['services']: if s not in resource_map[NOVA_CONF]['services']: resource_map[NOVA_CONF]['services'].append(s) if enable_memcache(release=release): resource_map[MEMCACHED_CONF] = { 'contexts': [context.MemcacheContext()], 'services': ['memcached'] } if actual_services and placement_api_enabled(): for cfile in resource_map: svcs = resource_map[cfile]['services'] if 'nova-placement-api' in svcs: svcs.remove('nova-placement-api') if 'apache2' not in svcs: svcs.append('apache2') wsgi_script = "/usr/bin/nova-placement-api" resource_map[WSGI_NOVA_PLACEMENT_API_CONF] = { 'contexts': [ context.WSGIWorkerConfigContext(name="nova", script=wsgi_script), nova_cc_context.HAProxyContext() ], 'services': ['apache2'] } elif not placement_api_enabled(): for cfile in resource_map: svcs = resource_map[cfile]['services'] if 'nova-placement-api' in svcs: svcs.remove('nova-placement-api') return resource_map
resolve_services(), 'contexts': [ context.AMQPContext(ssl_dir=NOVA_CONF_DIR), context.SharedDBContext(relation_prefix='nova', ssl_dir=NOVA_CONF_DIR), context.OSConfigFlagContext(charm_flag='nova-alchemy-flags', template_flag='nova_alchemy_flags'), context.ImageServiceContext(), context.OSConfigFlagContext(), context.SubordinateConfigContext(interface='nova-vmware', service='nova', config_file=NOVA_CONF), nova_cc_context.NovaCellContext(), context.SyslogContext(), context.LogLevelContext(), nova_cc_context.HAProxyContext(), nova_cc_context.IdentityServiceContext(service='nova', service_user='******'), nova_cc_context.VolumeServiceContext(), context.ZeroMQContext(), context.NotificationDriverContext(), nova_cc_context.NovaIPv6Context(), nova_cc_context.NeutronCCContext(), nova_cc_context.NovaConfigContext(), nova_cc_context.InstanceConsoleContext(), nova_cc_context.ConsoleSSLContext(), nova_cc_context.CloudComputeContext(), context.InternalEndpointContext('nova-common'), nova_cc_context.NeutronAPIContext(), nova_cc_context.SerialConsoleContext(), context.MemcacheContext()