def write_openrc(): config = hookenv.config() ctx = context.IdentityServiceContext()() if not ctx: return ctx["region"] = config.get("region") templating.render("openrc_v3", "/root/openrc_v3", ctx)
def resource_map(): rm = OrderedDict([ (ASTARA_CONFIG, { 'services': ['astara-orchestrator'], 'contexts': [ astara_context.AstaraOrchestratorContext(), context.AMQPContext(), context.SharedDBContext(), context.IdentityServiceContext( service='astara', service_user='******'), ], }) ]) return rm
def swift_temp_url_key(): """Generate a temp URL key, post it to Swift and return its value. If it is already posted, the current value of the key will be returned. """ import requests keystone_ctxt = context.IdentityServiceContext(service='glance', service_user='******')() if not keystone_ctxt: log('Missing identity-service relation. Skipping generation of ' 'swift temporary url key.') return auth_url = '%s://%s:%s/v2.0/' % (keystone_ctxt['service_protocol'], keystone_ctxt['service_host'], keystone_ctxt['service_port']) from swiftclient import client from swiftclient import exceptions @retry_on_exception(15, base_delay=10, exc_type=(exceptions.ClientException, requests.exceptions.ConnectionError)) def connect_and_post(): log('Connecting swift client...') swift_connection = client.Connection( authurl=auth_url, user='******', key=keystone_ctxt['admin_password'], tenant_name=keystone_ctxt['admin_tenant_name'], auth_version='2.0') account_stats = swift_connection.head_account() if 'x-account-meta-temp-url-key' in account_stats: log("Temp URL key was already posted.") return account_stats['x-account-meta-temp-url-key'] temp_url_key = pwgen(length=64) swift_connection.post_account( headers={'x-account-meta-temp-url-key': temp_url_key}) return temp_url_key return connect_and_post()
def _auth_args(): """Get current service credentials from the identity-service relation""" rel_ctxt = context.IdentityServiceContext() rel_data = rel_ctxt() if not rel_data or not context.context_complete(rel_data): juju_log('identity-service context not complete') return auth_url = '%s://%s:%s/v2.0' % ( rel_data['service_protocol'], rel_data['service_host'], rel_data['service_port']) auth_args = { 'username': rel_data['admin_user'], 'password': rel_data['admin_password'], 'tenant_name': rel_data['admin_tenant_name'], 'auth_url': auth_url, 'auth_strategy': 'keystone', 'region': config('region'), } return auth_args
# list has a complete context. REQUIRED_INTERFACES = { 'database': ['shared-db'], 'identity': ['identity-service'], } def ceph_config_file(): return CHARM_CEPH_CONF.format(service_name()) CONFIG_FILES = OrderedDict([ (GLANCE_REGISTRY_CONF, { 'hook_contexts': [ context.SharedDBContext(ssl_dir=GLANCE_CONF_DIR), context.IdentityServiceContext(service='glance', service_user='******'), context.SyslogContext(), glance_contexts.LoggingConfigContext(), glance_contexts.GlanceIPv6Context(), context.WorkerConfigContext(), context.OSConfigFlagContext(charm_flag='registry-config-flags', template_flag='registry_config_flags'), context.MemcacheContext() ], 'services': ['glance-registry'] }), (GLANCE_API_CONF, { 'hook_contexts': [ context.SharedDBContext(ssl_dir=GLANCE_CONF_DIR), context.AMQPContext(ssl_dir=GLANCE_CONF_DIR), context.IdentityServiceContext(service='glance',
'contexts': [ context.SharedDBContext(ssl_dir=CINDER_CONF_DIR), context.AMQPContext(ssl_dir=CINDER_CONF_DIR), context.ImageServiceContext(), context.OSConfigFlagContext(), context.SyslogContext(), cinder_contexts.CephContext(), cinder_contexts.HAProxyContext(), cinder_contexts.ImageServiceContext(), cinder_contexts.CinderSubordinateConfigContext( interface=['storage-backend', 'backup-backend'], service='cinder', config_file=CINDER_CONF), cinder_contexts.StorageBackendContext(), cinder_contexts.LoggingConfigContext(), context.IdentityServiceContext(service='cinder', service_user='******'), context.BindHostContext(), context.WorkerConfigContext(), cinder_contexts.RegionContext(), context.InternalEndpointContext(), cinder_contexts.VolumeUsageAuditContext(), context.MemcacheContext(), cinder_contexts.SectionalConfigContext(), cinder_contexts.LVMContext() ], 'services': ['cinder-api', 'cinder-volume', 'cinder-scheduler', 'haproxy'] }), (CINDER_API_CONF, { 'contexts': [context.IdentityServiceContext()], 'services': ['cinder-api'],
service_user=SVC), context.AMQPContext(ssl_dir=CEILOMETER_CONF_DIR), LoggingConfigContext(), MongoDBContext(), CeilometerContext(), context.SyslogContext(), context.MemcacheContext(), MetricServiceContext(), context.WorkerConfigContext()], 'services': QUEENS_SERVICES }), ]) CONFIG_FILES = OrderedDict([ (CEILOMETER_CONF, { 'hook_contexts': [context.IdentityServiceContext(service=SVC, service_user=SVC), context.AMQPContext(ssl_dir=CEILOMETER_CONF_DIR), context.InternalEndpointContext('ceilometer-common'), LoggingConfigContext(), MongoDBContext(), CeilometerContext(), context.SyslogContext(), HAProxyContext(), context.MemcacheContext(), MetricServiceContext(), context.WorkerConfigContext()], 'services': CEILOMETER_BASE_SERVICES }), (CEILOMETER_API_SYSTEMD_CONF, { 'hook_contexts': [HAProxyContext()], 'services': ['ceilometer-api'],
CLOUDKITTY_DIR = '/etc/cloudkitty' CLOUDKITTY_CONF = '/etc/cloudkitty/cloudkitty.conf' HAPROXY_CONF = '/etc/haproxy/haproxy.cfg' HTTPS_APACHE_CONF = ('/etc/apache2/sites-available/' 'openstack_https_frontend.conf') CONFIG_FILES = OrderedDict([ (CLOUDKITTY_CONF, { 'services': BASE_SERVICES, 'contexts': [ context.AMQPContext(), context.SharedDBContext(relation_prefix='cloudkitty', ssl_dir=CLOUDKITTY_DIR), context.OSConfigFlagContext(), context.IdentityServiceContext(service=SVC, service_user=SVC), CloudkittyHAProxyContext(), context.SyslogContext() ] }), (HAPROXY_CONF, { 'contexts': [ context.HAProxyContext(singlenode_mode=True), CloudkittyHAProxyContext() ], 'services': ['haproxy'], }), (HTTPS_APACHE_CONF, { 'contexts': [CloudkittyApacheSSLContext()], 'services': ['apache2'], })
REQUIRED_INTERFACES = { 'database': ['shared-db', 'pgsql-db'], 'identity': ['identity-service'], } def ceph_config_file(): return CHARM_CEPH_CONF.format(service_name()) CONFIG_FILES = OrderedDict([ (GLANCE_REGISTRY_CONF, { 'hook_contexts': [ context.SharedDBContext(ssl_dir=GLANCE_CONF_DIR), context.PostgresqlDBContext(), context.IdentityServiceContext(service='glance', service_user='******'), context.SyslogContext(), glance_contexts.LoggingConfigContext(), glance_contexts.GlanceIPv6Context(), context.WorkerConfigContext(), context.OSConfigFlagContext(charm_flag='registry-config-flags', template_flag='registry_config_flags') ], 'services': ['glance-registry'] }), (GLANCE_API_CONF, { 'hook_contexts': [ context.SharedDBContext(ssl_dir=GLANCE_CONF_DIR), context.AMQPContext(ssl_dir=GLANCE_CONF_DIR), context.PostgresqlDBContext(), context.IdentityServiceContext(service='glance',