Beispiel #1
0
 def discover_all(self):
     identity_client = clients.identity_client(self.cloud)
     raw_tenants = self.retry(identity_client.tenants.list,
                              returns_iterable=True)
     with model.Session() as session:
         for raw_tenant in raw_tenants:
             session.store(self.load_from_cloud(raw_tenant))
Beispiel #2
0
 def discover_all(self):
     identity_client = clients.identity_client(self.cloud)
     raw_tenants = self.retry(identity_client.tenants.list,
                              returns_iterable=True)
     with model.Session() as session:
         for raw_tenant in raw_tenants:
             session.store(self.load_from_cloud(raw_tenant))
Beispiel #3
0
 def discover_one(self, uuid):
     identity_client = clients.identity_client(self.cloud)
     try:
         raw_tenant = self.retry(identity_client.tenants.get, uuid,
                                 expected_exceptions=[exceptions.NotFound])
         tenant = self.load_from_cloud(raw_tenant)
         with model.Session() as session:
             session.store(tenant)
             return tenant
     except exceptions.NotFound:
         raise discover.NotFound()
Beispiel #4
0
 def run(self, cfg, migration):
     cloud = cfg.clouds[getattr(migration, self.location)]
     identity_client = clients.identity_client(cloud)
     try:
         clients.retry(identity_client.roles.remove_user_role,
                       user=self.user_id,
                       role=self.role_id,
                       tenant=self.tenant_id,
                       expected_exceptions=[keystone_exceptions.NotFound])
     except keystone_exceptions.NotFound:
         pass
Beispiel #5
0
 def discover_one(self, uuid):
     identity_client = clients.identity_client(self.cloud)
     try:
         raw_tenant = self.retry(identity_client.tenants.get,
                                 uuid,
                                 expected_exceptions=[exceptions.NotFound])
         tenant = self.load_from_cloud(raw_tenant)
         with model.Session() as session:
             session.store(tenant)
             return tenant
     except exceptions.NotFound:
         raise discover.NotFound()
Beispiel #6
0
 def migrate(self, source_obj, *args, **kwargs):
     cloud = self.cloud
     identity_client = clients.identity_client(cloud)
     destructor_var = self.destructor_var
     try:
         self.user_id = self._user_id(cloud.credential.username)
         self.role_id = self._role_id(cloud.admin_role)
         self.tenant_id = _get_object_tenant_id(self.cloud, source_obj)
         clients.retry(identity_client.roles.add_user_role,
                       user=self.user_id,
                       role=self.role_id,
                       tenant=self.tenant_id,
                       expected_exceptions=[keystone_exceptions.Conflict])
         self.destructor = EnsureAdminRoleDestructor(
             self.location, self.user_id, self.role_id, self.tenant_id)
     except keystone_exceptions.Conflict:
         pass
     return {destructor_var: self.destructor}
Beispiel #7
0
 def migrate(self, source_obj, *args, **kwargs):
     identity_client = clients.identity_client(self.dst_cloud)
     try:
         destination_obj = clients.retry(
             identity_client.tenants.create,
             source_obj.name,
             description=source_obj.description,
             enabled=source_obj.enabled,
             expected_exceptions=[exceptions.Conflict])
         self.created_object = destination_obj
     except exceptions.Conflict:
         for tenant_obj in clients.retry(identity_client.tenants.list):
             if tenant_obj.name.lower() == source_obj.name.lower():
                 destination_obj = tenant_obj
                 break
         else:
             raise base.AbortMigration('Invalid state')
     destination = self.load_from_cloud(identity.Tenant, self.dst_cloud,
                                        destination_obj)
     return dict(dst_object=destination)
Beispiel #8
0
 def dst_identity(self):
     cloud = self.config.clouds[self.migration.destination]
     return clients.identity_client(cloud)
Beispiel #9
0
 def dst_identity(self):
     cloud = self.config.clouds[self.migration.destination]
     return clients.identity_client(cloud)
Beispiel #10
0
 def revert(self, *args, **kwargs):
     if self.created_object is not None:
         identity_client = clients.identity_client(self.dst_cloud)
         clients.retry(identity_client.tenants.delete, self.created_object)
     super(CreateTenant, self).revert(*args, **kwargs)
Beispiel #11
0
 def _get_tenants(self):
     identity_client = clients.identity_client(self.cloud)
     return identity_client.tenants.list()
Beispiel #12
0
 def _manager(self):
     identity_client = clients.identity_client(self.cloud)
     return identity_client.roles
Beispiel #13
0
 def identity_client(self, scope=None):
     # pylint: disable=no-member
     return clients.identity_client(self.credential, scope or self.scope)
Beispiel #14
0
 def _get_tenants(self):
     identity_client = clients.identity_client(self.cloud)
     return identity_client.tenants.list()