def add_service(self, service): """Add a service to the Connection. Attaches an instance of the :class:`~openstack.proxy.Proxy` class contained in :class:`~openstack.service_description.ServiceDescription`. The :class:`~openstack.proxy.Proxy` will be attached to the `Connection` by its ``service_type`` and by any ``aliases`` that may be specified. :param openstack.service_description.ServiceDescription service: Object describing the service to be attached. As a convenience, if ``service`` is a string it will be treated as a ``service_type`` and a basic :class:`~openstack.service_description.ServiceDescription` will be created. """ # If we don't have a proxy, just instantiate Proxy so that # we get an adapter. if isinstance(service, six.string_types): service = service_description.ServiceDescription(service) # Directly invoke descriptor of the ServiceDescription def getter(self): return service.__get__(self, service) # Register the ServiceDescription class (as property) # with every known alias for a "runtime descriptor" for attr_name in service.all_types: setattr(self.__class__, attr_name.replace('-', '_'), property(fget=getter)) self.config.enable_service(attr_name)
def add_service(self, service): """Add a service to the Connection. Attaches an instance of the :class:`~openstack.proxy.Proxy` class contained in :class:`~openstack.service_description.ServiceDescription`. The :class:`~openstack.proxy.Proxy` will be attached to the `Connection` by its ``service_type`` and by any ``aliases`` that may be specified. :param openstack.service_description.ServiceDescription service: Object describing the service to be attached. As a convenience, if ``service`` is a string it will be treated as a ``service_type`` and a basic :class:`~openstack.service_description.ServiceDescription` will be created. """ # If we don't have a proxy, just instantiate Proxy so that # we get an adapter. if isinstance(service, six.string_types): service = service_description.ServiceDescription(service) # Register the proxy class with every known alias for attr_name in service.all_types: setattr(self, attr_name.replace('-', '_'), service)
def _make_client_new(self): auth = ks_password.Password( auth_url=CONF.api.auth_url, username=CONF.api.username, password=CONF.api.password, user_domain_id=CONF.api.user_domain_id, project_name=CONF.api.project_name, project_domain_id=CONF.api.project_domain_id) session = ks_session.Session(auth=auth) desc = service_description.ServiceDescription(service_type='ha', proxy_class=_proxy.Proxy) conn = connection.Connection(session=session, extra_services=[desc]) conn.add_service(desc) if version.__version__.find('0.11.0') == 0: client = conn.ha else: client = conn.ha.proxy_class(session=session, service_type='ha') return client
def add_service(self, service): """Add a service to the Connection. Attaches an instance of the :class:`~openstack.proxy.BaseProxy` class contained in :class:`~openstack.service_description.ServiceDescription`. The :class:`~openstack.proxy.BaseProxy` will be attached to the `Connection` by its ``service_type`` and by any ``aliases`` that may be specified. :param openstack.service_description.ServiceDescription service: Object describing the service to be attached. As a convenience, if ``service`` is a string it will be treated as a ``service_type`` and a basic :class:`~openstack.service_description.ServiceDescription` will be created. """ # If we don't have a proxy, just instantiate BaseProxy so that # we get an adapter. if isinstance(service, six.string_types): service_type = service service = service_description.ServiceDescription(service_type) else: service_type = service.service_type proxy_object = service.proxy_class( session=self.config.get_session(), task_manager=self.task_manager, allow_version_hack=True, service_type=self.config.get_service_type(service_type), service_name=self.config.get_service_name(service_type), interface=self.config.get_interface(service_type), region_name=self.config.region_name, version=self.config.get_api_version(service_type) ) # Register the proxy class with every known alias for attr_name in service.all_types: setattr(self, attr_name.replace('-', '_'), proxy_object)
class ServicesMixin(object): identity = identity_service.IdentityService(service_type='identity') compute = compute_service.ComputeService(service_type='compute') image = image_service.ImageService(service_type='image') load_balancer = load_balancer_service.LoadBalancerService( service_type='load-balancer') object_store = object_store_service.ObjectStoreService( service_type='object-store') clustering = clustering_service.ClusteringService( service_type='clustering') resource_cluster = clustering cluster = clustering data_processing = service_description.ServiceDescription( service_type='data-processing') baremetal = baremetal_service.BaremetalService(service_type='baremetal') bare_metal = baremetal baremetal_introspection = baremetal_introspection_service.BaremetalIntrospectionService( service_type='baremetal-introspection') key_manager = key_manager_service.KeyManagerService( service_type='key-manager') resource_optimization = service_description.ServiceDescription( service_type='resource-optimization') infra_optim = resource_optimization message = message_service.MessageService(service_type='message') messaging = message application_catalog = service_description.ServiceDescription( service_type='application-catalog') container_infrastructure_management = service_description.ServiceDescription( service_type='container-infrastructure-management') container_infrastructure = container_infrastructure_management container_infra = container_infrastructure_management search = service_description.ServiceDescription(service_type='search') dns = dns_service.DnsService(service_type='dns') workflow = workflow_service.WorkflowService(service_type='workflow') rating = service_description.ServiceDescription(service_type='rating') operator_policy = service_description.ServiceDescription( service_type='operator-policy') policy = operator_policy shared_file_system = service_description.ServiceDescription( service_type='shared-file-system') share = shared_file_system data_protection_orchestration = service_description.ServiceDescription( service_type='data-protection-orchestration') orchestration = orchestration_service.OrchestrationService( service_type='orchestration') block_storage = block_storage_service.BlockStorageService( service_type='block-storage') block_store = block_storage volume = block_storage alarm = service_description.ServiceDescription(service_type='alarm') alarming = alarm meter = service_description.ServiceDescription(service_type='meter') metering = meter telemetry = meter event = service_description.ServiceDescription(service_type='event') events = event application_deployment = service_description.ServiceDescription( service_type='application-deployment') application_deployment = application_deployment multi_region_network_automation = service_description.ServiceDescription( service_type='multi-region-network-automation') tricircle = multi_region_network_automation database = database_service.DatabaseService(service_type='database') application_container = service_description.ServiceDescription( service_type='application-container') container = application_container root_cause_analysis = service_description.ServiceDescription( service_type='root-cause-analysis') rca = root_cause_analysis nfv_orchestration = service_description.ServiceDescription( service_type='nfv-orchestration') network = network_service.NetworkService(service_type='network') backup = service_description.ServiceDescription(service_type='backup') monitoring_logging = service_description.ServiceDescription( service_type='monitoring-logging') monitoring_log_api = monitoring_logging monitoring = service_description.ServiceDescription( service_type='monitoring') monitoring_events = service_description.ServiceDescription( service_type='monitoring-events') placement = service_description.ServiceDescription( service_type='placement') instance_ha = instance_ha_service.InstanceHaService( service_type='instance-ha') ha = instance_ha reservation = service_description.ServiceDescription( service_type='reservation') function_engine = service_description.ServiceDescription( service_type='function-engine') accelerator = accelerator_service.AcceleratorService( service_type='accelerator') admin_logic = service_description.ServiceDescription( service_type='admin-logic') registration = admin_logic