Best Python code snippet using tempest_python
clients.py
Source:clients.py
...39 # parameters available, the calls below will trigger a KeyError.40 # We should catch that and raise a better error.41 self._set_compute_clients()42 self._set_identity_clients()43 self._set_volume_clients()44 self._set_object_storage_clients()45 self._set_image_clients()46 self._set_network_clients()47 self.orchestration_client = orchestration.OrchestrationClient(48 self.auth_provider,49 CONF.orchestration.catalog_type,50 CONF.orchestration.region or CONF.identity.region,51 endpoint_type=CONF.orchestration.endpoint_type,52 build_interval=CONF.orchestration.build_interval,53 build_timeout=CONF.orchestration.build_timeout,54 **self.default_params)55 def _prepare_configuration(self):56 """Map values from CONF into Manager parameters57 This uses `config.service_client_config` for all services to collect58 most configuration items needed to init the clients.59 """60 # NOTE(andreaf) Once all service clients in Tempest are migrated61 # to tempest.lib, their configuration will be picked up from the62 # registry, and this method will become redundant.63 configuration = {}64 # Setup the parameters for all Tempest services which are not in lib.65 # NOTE(andreaf) Since client.py is an internal module of Tempest,66 # it doesn't have to consider plugin configuration.67 for service in clients._tempest_internal_modules():68 try:69 # NOTE(andreaf) Use the unversioned service name to fetch70 # the configuration since configuration is not versioned.71 service_for_config = service.split('.')[0]72 if service_for_config not in configuration:73 configuration[service_for_config] = (74 config.service_client_config(service_for_config))75 except lib_exc.UnknownServiceClient:76 LOG.warning(77 'Could not load configuration for service %s', service)78 return configuration79 def _set_network_clients(self):80 self.network_agents_client = self.network.AgentsClient()81 self.network_extensions_client = self.network.ExtensionsClient()82 self.networks_client = self.network.NetworksClient()83 self.subnetpools_client = self.network.SubnetpoolsClient()84 self.subnets_client = self.network.SubnetsClient()85 self.ports_client = self.network.PortsClient()86 self.network_quotas_client = self.network.QuotasClient()87 self.floating_ips_client = self.network.FloatingIPsClient()88 self.metering_labels_client = self.network.MeteringLabelsClient()89 self.metering_label_rules_client = (90 self.network.MeteringLabelRulesClient())91 self.routers_client = self.network.RoutersClient()92 self.security_group_rules_client = (93 self.network.SecurityGroupRulesClient())94 self.security_groups_client = self.network.SecurityGroupsClient()95 self.network_versions_client = self.network.NetworkVersionsClient()96 self.service_providers_client = self.network.ServiceProvidersClient()97 def _set_image_clients(self):98 if CONF.service_available.glance:99 self.image_client = self.image_v1.ImagesClient()100 self.image_member_client = self.image_v1.ImageMembersClient()101 self.image_client_v2 = self.image_v2.ImagesClient()102 self.image_member_client_v2 = self.image_v2.ImageMembersClient()103 self.namespaces_client = self.image_v2.NamespacesClient()104 self.resource_types_client = self.image_v2.ResourceTypesClient()105 self.namespace_objects_client = \106 self.image_v2.NamespaceObjectsClient()107 self.schemas_client = self.image_v2.SchemasClient()108 self.namespace_properties_client = \109 self.image_v2.NamespacePropertiesClient()110 self.namespace_tags_client = \111 self.image_v2.NamespaceTagsClient()112 def _set_compute_clients(self):113 self.agents_client = self.compute.AgentsClient()114 self.compute_networks_client = self.compute.NetworksClient()115 self.migrations_client = self.compute.MigrationsClient()116 self.security_group_default_rules_client = (117 self.compute.SecurityGroupDefaultRulesClient())118 self.certificates_client = self.compute.CertificatesClient()119 eip = CONF.compute_feature_enabled.enable_instance_password120 self.servers_client = self.compute.ServersClient(121 enable_instance_password=eip)122 self.server_groups_client = self.compute.ServerGroupsClient()123 self.limits_client = self.compute.LimitsClient()124 self.compute_images_client = self.compute.ImagesClient()125 self.keypairs_client = self.compute.KeyPairsClient()126 self.quotas_client = self.compute.QuotasClient()127 self.quota_classes_client = self.compute.QuotaClassesClient()128 self.flavors_client = self.compute.FlavorsClient()129 self.extensions_client = self.compute.ExtensionsClient()130 self.floating_ip_pools_client = self.compute.FloatingIPPoolsClient()131 self.floating_ips_bulk_client = self.compute.FloatingIPsBulkClient()132 self.compute_floating_ips_client = self.compute.FloatingIPsClient()133 self.compute_security_group_rules_client = (134 self.compute.SecurityGroupRulesClient())135 self.compute_security_groups_client = (136 self.compute.SecurityGroupsClient())137 self.interfaces_client = self.compute.InterfacesClient()138 self.fixed_ips_client = self.compute.FixedIPsClient()139 self.availability_zone_client = self.compute.AvailabilityZoneClient()140 self.aggregates_client = self.compute.AggregatesClient()141 self.services_client = self.compute.ServicesClient()142 self.tenant_usages_client = self.compute.TenantUsagesClient()143 self.baremetal_nodes_client = self.compute.BaremetalNodesClient()144 self.hosts_client = self.compute.HostsClient()145 self.hypervisor_client = self.compute.HypervisorClient()146 self.instance_usages_audit_log_client = (147 self.compute.InstanceUsagesAuditLogClient())148 self.tenant_networks_client = self.compute.TenantNetworksClient()149 # NOTE: The following client needs special timeout values because150 # the API is a proxy for the other component.151 params_volume = {}152 for _key in ('build_interval', 'build_timeout'):153 _value = self.parameters['volume'].get(_key)154 if _value:155 params_volume[_key] = _value156 self.volumes_extensions_client = self.compute.VolumesClient(157 **params_volume)158 self.compute_versions_client = self.compute.VersionsClient(159 **params_volume)160 self.snapshots_extensions_client = self.compute.SnapshotsClient(161 **params_volume)162 def _set_identity_clients(self):163 # Clients below use the admin endpoint type of Keystone API v2164 params_v2_admin = {165 'endpoint_type': CONF.identity.v2_admin_endpoint_type}166 self.endpoints_client = self.identity_v2.EndpointsClient(167 **params_v2_admin)168 self.identity_client = self.identity_v2.IdentityClient(169 **params_v2_admin)170 self.tenants_client = self.identity_v2.TenantsClient(171 **params_v2_admin)172 self.roles_client = self.identity_v2.RolesClient(**params_v2_admin)173 self.users_client = self.identity_v2.UsersClient(**params_v2_admin)174 self.identity_services_client = self.identity_v2.ServicesClient(175 **params_v2_admin)176 # Clients below use the public endpoint type of Keystone API v2177 params_v2_public = {178 'endpoint_type': CONF.identity.v2_public_endpoint_type}179 self.identity_public_client = self.identity_v2.IdentityClient(180 **params_v2_public)181 self.tenants_public_client = self.identity_v2.TenantsClient(182 **params_v2_public)183 self.users_public_client = self.identity_v2.UsersClient(184 **params_v2_public)185 # Clients below use the endpoint type of Keystone API v3, which is set186 # in endpoint_type187 params_v3 = {'endpoint_type': CONF.identity.v3_endpoint_type}188 self.domains_client = self.identity_v3.DomainsClient(**params_v3)189 self.identity_v3_client = self.identity_v3.IdentityClient(**params_v3)190 self.trusts_client = self.identity_v3.TrustsClient(**params_v3)191 self.users_v3_client = self.identity_v3.UsersClient(**params_v3)192 self.endpoints_v3_client = self.identity_v3.EndPointsClient(193 **params_v3)194 self.roles_v3_client = self.identity_v3.RolesClient(**params_v3)195 self.inherited_roles_client = self.identity_v3.InheritedRolesClient(196 **params_v3)197 self.role_assignments_client = self.identity_v3.RoleAssignmentsClient(198 **params_v3)199 self.identity_services_v3_client = self.identity_v3.ServicesClient(200 **params_v3)201 self.policies_client = self.identity_v3.PoliciesClient(**params_v3)202 self.projects_client = self.identity_v3.ProjectsClient(**params_v3)203 self.regions_client = self.identity_v3.RegionsClient(**params_v3)204 self.credentials_client = self.identity_v3.CredentialsClient(205 **params_v3)206 self.groups_client = self.identity_v3.GroupsClient(**params_v3)207 # Token clients do not use the catalog. They only need default_params.208 # They read auth_url, so they should only be set if the corresponding209 # API version is marked as enabled210 if CONF.identity_feature_enabled.api_v2:211 if CONF.identity.uri:212 self.token_client = self.identity_v2.TokenClient(213 auth_url=CONF.identity.uri)214 else:215 msg = 'Identity v2 API enabled, but no identity.uri set'216 raise lib_exc.InvalidConfiguration(msg)217 if CONF.identity_feature_enabled.api_v3:218 if CONF.identity.uri_v3:219 self.token_v3_client = self.identity_v3.V3TokenClient(220 auth_url=CONF.identity.uri_v3)221 else:222 msg = 'Identity v3 API enabled, but no identity.uri_v3 set'223 raise lib_exc.InvalidConfiguration(msg)224 def _set_volume_clients(self):225 self.volume_qos_client = self.volume_v1.QosSpecsClient()226 self.volume_qos_v2_client = self.volume_v2.QosSpecsClient()227 self.volume_services_client = self.volume_v1.ServicesClient()228 self.volume_services_v2_client = self.volume_v2.ServicesClient()229 self.backups_client = self.volume_v1.BackupsClient()230 self.backups_v2_client = self.volume_v2.BackupsClient()231 self.encryption_types_client = self.volume_v1.EncryptionTypesClient()232 self.encryption_types_v2_client = \233 self.volume_v2.EncryptionTypesClient()234 self.snapshot_manage_v2_client = self.volume_v2.SnapshotManageClient()235 self.snapshots_client = self.volume_v1.SnapshotsClient()236 self.snapshots_v2_client = self.volume_v2.SnapshotsClient()237 self.volumes_client = self.volume_v1.VolumesClient()238 self.volumes_v2_client = self.volume_v2.VolumesClient()...
sf_clients.py
Source:sf_clients.py
...85 'endpoint_type': CONF.sfpool.endpoint_type,86 }87 params.update(self.default_params)88 self.sfpool_client = SfpoolClient(self.auth_provider, **params)89 def _set_volume_clients(self):90 super(SfManager, self)._set_volume_clients()91 params = {92 'service': CONF.volume.catalog_type,93 'region': CONF.volume.region or CONF.identity.region,94 'endpoint_type': CONF.volume.endpoint_type,95 'build_interval': CONF.volume.build_interval,96 'build_timeout': CONF.volume.build_timeout97 }98 self.storage_client = BaseStorageClient(99 self.auth_provider, **params)100 def _set_billcenter_client(self):101 params = {102 'service': CONF.billcenter.catalog_type,103 'region': CONF.billcenter.region,104 'endpoint_type': CONF.billcenter.endpoint_type...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!