Пример #1
0
class Securitytoken(resource2.Resource):
    resource_key = 'credential'
    resources_key = 'credentials'
    base_path = '/OS-CREDENTIAL/securitytokens'
    service = iam_service.IamService()

    # Properties
    #: The accesskey of the securitytoken.
    access = resource2.Body('access')
    #: The secretkey of the securitytoken.
    secret = resource2.Body('secret')
    #: The expire time of the securitytoken.
    expires_at = resource2.Body('expires_at')
    #: The securitytoken of the securitytoken.
    securitytoken = resource2.Body('securitytoken')

    def create(self, session, **attrs):
        endpoint_override = self.service.get_endpoint_override()
        uri = self.base_path
        response = session.post(uri,
                                endpoint_filter=self.service,
                                endpoint_override=endpoint_override,
                                json=attrs)
        self._translate_response(response)
        return self
Пример #2
0
 def test_service(self):
     sot = iam_service.IamService()
     self.assertEqual('iam', sot.service_type)
     self.assertEqual('public', sot.interface)
     self.assertIsNone(sot.region)
     self.assertIsNone(sot.service_name)
     self.assertEqual(1, len(sot.valid_versions))
     self.assertEqual('v3', sot.valid_versions[0].module)
     self.assertEqual('v3', sot.valid_versions[0].path)
Пример #3
0
class Credential(resource2.Resource):
    resource_key = 'credential'
    resources_key = 'credentials'
    base_path = '/OS-CREDENTIAL/credentials'
    service = iam_service.IamService()

    # capabilities
    allow_create = True
    allow_get = True
    allow_update = True
    allow_delete = True
    allow_list = True

    _query_mapping = resource2.QueryParameters('user_id')

    # Properties
    #: The last_use_time of the credential.
    last_use_time = resource2.Body('last_use_time')
    #: The accesskey of the credential.
    access = resource2.Body('access')
    #: The create_time of the credential.
    create_time = resource2.Body('create_time')
    #: The user_id of the credential.
    user_id = resource2.Body('user_id')
    #: The description key of the credential.
    description = resource2.Body('description')
    #: The status key of the credential.
    status = resource2.Body('status')
    #: The secret key of the credential.
    secret = resource2.Body('secret')

    def get_credential(self, session, access_key):
        endpoint_override = self.service.get_endpoint_override()
        url = utils.urljoin(self.base_path, access_key)
        response = session.get(url, endpoint_filter=self.service,
                               endpoint_override=endpoint_override)
        self._translate_response(response)
        return self

    def update_credential(self, session, access_key, **attrs):
        endpoint_override = self.service.get_endpoint_override()
        url = utils.urljoin(self.base_path, access_key)
        response = session.put(url, endpoint_filter=self.service,
                               endpoint_override=endpoint_override,
                               json=attrs)
        self._translate_response(response)
        return self
Пример #4
0
class Customrole(resource2.Resource):
    resource_key = 'role'
    resources_key = 'roles'
    base_path = '/OS-ROLE/roles'
    service = iam_service.IamService()

    # capabilities
    allow_create = True
    allow_get = True
    allow_update = True
    allow_delete = True
    allow_list = True
    patch_update = True

    # Properties
    #: Unique role name, within the owning domain. *Type: string*
    name = resource2.Body('name')
    #: The links for the service resource.
    links = resource2.Body('links', type=dict)
    #: The id of the domain that the role belongs to. *Type: string*
    domain_id = resource2.Body('domain_id')
    #: The display type of the role. *Type: string*
    type = resource2.Body('type')
    #: The display name of the role. *Type: string*
    display_name = resource2.Body('display_name')
    #: The catalog of the role. *Type: string*
    catalog = resource2.Body('catalog')
    #: The policy of the role.
    policy = resource2.Body('policy', type=dict)
    #: The description of the role. *Type: string*
    description = resource2.Body('description')
    #: The flag of the role. *Type: string*
    flag = resource2.Body('flag')
    #: The description_cn of the role. *Type: string*
    description_cn = resource2.Body('description_cn')
    #: The id of the role. *Type: string*
    id = resource2.Body('id')
    #: The updated_time of the role. *Type: string*
    updated_time = resource2.Body('updated_time')
    #: The created_time of the role. *Type: string*
    created_time = resource2.Body('created_time')
    #: The references of the role. *Type: int*
    references = resource2.Body('references', type=int)
Пример #5
0
    def __init__(self, plugins=None):
        """User preference for each service.

        :param plugins: List of entry point namespaces to load.

        Create a new :class:`~openstack.profile.Profile`
        object with no preferences defined, but knowledge of the services.
        Services are identified by their service type, e.g.: 'identity',
        'compute', etc.
        """
        self._services = {}

        self._add_service(anti_ddos_service.AntiDDosService(version="v1"))
        self._add_service(block_store_service.BlockStoreService(version="v2"))
        self._add_service(compute_service.ComputeService(version="v2"))
        self._add_service(cts_service.CTSService(version="v1"))
        self._add_service(dms_service.DMSService(version="v1"))
        self._add_service(identity_service.IdentityService(version="v3"))
        self._add_service(image_service.ImageService(version="v2"))
        self._add_service(kms_service.KMSService(version="v1"))
        self._add_service(maas_service.MaaSService(version="v1"))
        self._add_service(network_service.NetworkService(version="v2.0"))
        self._add_service(orchestration_service.OrchestrationService(version="v1"))
        self._add_service(smn_service.SMNService(version="v2"))
        # QianBiao.NG HuaWei Services
        self._add_service(dns_service.DNSService(version="v2"))
        self._add_service(cloud_eye_service.CloudEyeService(version="v1"))
        ass = auto_scaling_service.AutoScalingService(version="v1")
        self._add_service(ass)
        vbs_v2 = volume_backup_service.VolumeBackupService(version="v2")
        self._add_service(vbs_v2)
        self._add_service(map_reduce_service.MapReduceService(version="v1"))
        self._add_service(evs_service.EvsServiceV2_1(version='v2.1'))
        self._add_service(evs_service.EvsService(version='v2'))
        self._add_service(ecs_service.EcsService(version='v1'))
        self._add_service(ecs_service.EcsServiceV1_1(version='v1.1'))
        self._add_service(vpc_service.VpcService(version='v2.0'))
        self._add_service(vpc_service.VpcServiceV1(version='v1'))
        self._add_service(bms_service.BmsService(version='v1'))
        self._add_service(deh_service.DehService(version='v1.0'))
        self._add_service(csbs_service.CsbsService(version='v1'))
        self._add_service(ims_service.ImsService(version='v2'))
        self._add_service(nat_service.NatService(version='v2.0'))
        self._add_service(lb_service.LoadBalancerService(version='v1'))
        # not support below service
        # self._add_service(message_service.MessageService(version="v1"))
        # self._add_service(cluster_service.ClusterService(version="v1"))
        # self._add_service(database_service.DatabaseService(version="v1"))
        # self._add_service(alarm_service.AlarmService(version="v2"))
        # self._add_service(bare_metal_service.BareMetalService(version="v1"))
        # self._add_service(key_manager_service.KeyManagerService(version="v1"))
        # self._add_service(
            # object_store_service.ObjectStoreService(version="v1"))

        self._add_service(rds_service.RDSService(version="v1"))
        self._add_service(cdn_service.CDNService(version='v1'))
        self._add_service(iam_service.IamService(version='v3.0'))

        # self._add_service(rds_os_service.RDSService(version="v1"))
        # self._add_service(telemetry_service.TelemetryService(version="v2"))
        # self._add_service(workflow_service.WorkflowService(version="v2"))
        self._add_service(fgs_service.FGSService(version='v2'))

        if plugins:
            for plugin in plugins:
                self._load_plugin(plugin)
        self.service_keys = sorted(self._services.keys())
Пример #6
0
class User(resource2.Resource):
    resource_key = 'user'
    resources_key = 'users'
    base_path = '/OS-USER/users'
    service = iam_service.IamService()

    # capabilities
    allow_create = True
    allow_get = True
    allow_update = True
    allow_delete = True
    allow_list = True
    patch_update = True

    # Properties
    #: The areacode of mobile. *Type: string*
    areacode = resource2.Body('areacode')
    #: The create_time of user. *Type: string*
    create_time = resource2.Body('create_time')
    #: The default_project_id of user. *Type: string*
    default_project_id = resource2.Body('default_project_id')
    #: The description of user. *Type: string*
    description = resource2.Body('description')
    #: The domain_id of user. *Type: string*
    domain_id = resource2.Body('domain_id')
    #: The update_time of user. *Type: string*
    update_time = resource2.Body('update_time')
    #: The email of user. *Type: string*
    email = resource2.Body('email')
    #: The mobile of user. *Type: string*
    mobile = resource2.Body('mobile')
    #: The enabled of user. *Type: bool*
    is_enabled = resource2.Body('enabled', type=bool)
    #: The id of user. *Type: string*
    id = resource2.Body('id')
    #: The is_domain_owner of user. *Type: bool*
    is_domain_owner = resource2.Body('is_domain_owner', type=bool)
    #: The name of user. *Type: string*
    name = resource2.Body('name')
    #: The password_expires_at of user. *Type: string*
    password_expires_at = resource2.Body('password_expires_at')
    #: The phone of user. *Type: string*
    phone = resource2.Body('phone')
    #: The phone of user. *Type: dict*
    links = resource2.Body('links', type=dict)
    #: The pwd_status of user. *Type: bool*
    pwd_status = resource2.Body('pwd_status', type=bool)
    #: The status of user. *Type: int*
    status = resource2.Body('status', type=int)
    #: The xdomain_id of user. *Type: string*
    xdomain_id = resource2.Body('xdomain_id')
    #: The xdomain_type of user. *Type: string*
    xdomain_type = resource2.Body('xdomain_type')
    #: The xuser_id of user. *Type: string*
    xuser_id = resource2.Body('xuser_id')
    #: The xuser_type of user. *Type: string*
    xuser_type = resource2.Body('xuser_type')

    def query_user_details(self, session, user_id):
        endpoint_override = self.service.get_endpoint_override()
        uri = utils.urljoin(self.base_path, user_id)
        response = session.get(uri,
                               endpoint_filter=self.service,
                               endpoint_override=endpoint_override)
        self._translate_response(response)
        return self

    def create_user(self, session, **user):
        endpoint_override = self.service.get_endpoint_override()
        uri = self.base_path
        response = session.post(uri,
                                endpoint_filter=self.service,
                                endpoint_override=endpoint_override,
                                json=user)
        self._translate_response(response)
        return self

    def update_user_information(self, session, user_id, **user):
        endpoint_override = self.service.get_endpoint_override()
        uri = utils.urljoin(self.base_path, user_id, 'info')
        response = session.put(uri,
                               endpoint_filter=self.service,
                               endpoint_override=endpoint_override,
                               json=user)
        return response.status_code == 204

    def update_user_information_by_admin(self, session, user_id, **user):
        endpoint_override = self.service.get_endpoint_override()
        uri = utils.urljoin(self.base_path, user_id)
        response = session.put(uri,
                               endpoint_filter=self.service,
                               endpoint_override=endpoint_override,
                               json=user)
        self._translate_response(response)
        return self
Пример #7
0
class Agency(resource2.Resource):
    resource_key = 'agency'
    resources_key = 'agencies'
    base_path = '/OS-AGENCY/agencies'
    service = iam_service.IamService()

    # capabilities
    allow_create = True
    allow_get = True
    allow_update = True
    allow_delete = True
    allow_list = True

    _query_mapping = resource2.QueryParameters('name', 'domain_id',
                                               "trust_domain_id")

    # Properties
    #: The create_time of the agency. *Type: string*
    create_time = resource2.Body('create_time')
    #: The description of the agency. *Type: string*
    description = resource2.Body('description')
    #: The domain_id of the agency. *Type: string*
    domain_id = resource2.Body('domain_id')
    #: The duration of the agency. *Type: string*
    duration = resource2.Body('duration')
    #: The expire_time of the agency. *Type: string*
    expire_time = resource2.Body('expire_time')
    #: The id of the agency. *Type: string*
    id = resource2.Body('id')
    #: The name of the agency. *Type: string*
    name = resource2.Body('name')
    #: The trust_domain_id of the agency. *Type: string*
    trust_domain_id = resource2.Body('trust_domain_id')
    #: The trust_domain_name of the agency. *Type: string*
    trust_domain_name = resource2.Body('trust_domain_name')

    def update_agency(self, session, agency_id, **attrs):
        endpoint_override = self.service.get_endpoint_override()
        url = utils.urljoin(self.base_path, agency_id)
        response = session.put(url,
                               endpoint_filter=self.service,
                               endpoint_override=endpoint_override,
                               json=attrs)
        self._translate_response(response)
        return self

    def grant_domain_agency_role(self, session, domain_id, agency_id, role_id):
        endpoint_override = self.service.get_endpoint_override()
        uri = utils.urljoin("OS-AGENCY", 'domains', domain_id, 'agencies',
                            agency_id, 'roles', role_id)
        response = session.put(uri,
                               endpoint_filter=self.service,
                               endpoint_override=endpoint_override,
                               raise_exc=False)
        return response.status_code == 204

    def grant_project_agency_role(self, session, project_id, agency_id,
                                  role_id):
        endpoint_override = self.service.get_endpoint_override()
        uri = utils.urljoin("OS-AGENCY", 'projects', project_id, 'agencies',
                            agency_id, 'roles', role_id)
        response = session.put(uri,
                               endpoint_filter=self.service,
                               endpoint_override=endpoint_override,
                               raise_exc=False)
        return response.status_code == 204

    def check_domain_agency_role(self, session, domain_id, agency_id, role_id):
        endpoint_override = self.service.get_endpoint_override()
        uri = utils.urljoin("OS-AGENCY", 'domains', domain_id, 'agencies',
                            agency_id, 'roles', role_id)
        response = session.head(uri,
                                endpoint_filter=self.service,
                                endpoint_override=endpoint_override,
                                raise_exc=False)
        return response.status_code == 204

    def check_project_agency_role(self, session, project_id, agency_id,
                                  role_id):
        endpoint_override = self.service.get_endpoint_override()
        uri = utils.urljoin("OS-AGENCY", 'projects', project_id, 'agencies',
                            agency_id, 'roles', role_id)
        response = session.head(uri,
                                endpoint_filter=self.service,
                                endpoint_override=endpoint_override,
                                raise_exc=False)
        return response.status_code == 204

    def delete_domain_agency_role(self, session, domain_id, agency_id,
                                  role_id):
        endpoint_override = self.service.get_endpoint_override()
        uri = utils.urljoin("OS-AGENCY", 'domains', domain_id, 'agencies',
                            agency_id, 'roles', role_id)
        response = session.delete(uri,
                                  endpoint_filter=self.service,
                                  endpoint_override=endpoint_override,
                                  raise_exc=False)
        return response.status_code == 204

    def delete_project_agency_role(self, session, project_id, agency_id,
                                   role_id):
        endpoint_override = self.service.get_endpoint_override()
        uri = utils.urljoin("OS-AGENCY", 'projects', project_id, 'agencies',
                            agency_id, 'roles', role_id)
        response = session.delete(uri,
                                  endpoint_filter=self.service,
                                  endpoint_override=endpoint_override,
                                  raise_exc=False)
        return response.status_code == 204
Пример #8
0
class ProjectAgencyRole(role.Role):
    base_path = "/OS-AGENCY/projects/%(project_id)s/agencies/%(agency_id)s/roles"
    service = iam_service.IamService()
Пример #9
0
class DomainAgencyRole(role.Role):
    base_path = "/OS-AGENCY/domains/%(domain_id)s/agencies/%(agency_id)s/roles"
    service = iam_service.IamService()
Пример #10
0
class Project(resource2.Resource):
    resource_key = 'project'
    resources_key = 'projects'
    base_path = '/v3-ext/projects'
    service = iam_service.IamService()

    # capabilities
    allow_get = True
    allow_update = True

    _query_mapping = resource2.QueryParameters('domain_id', 'enabled',
                                               'is_domain', 'name', 'page',
                                               'parent_id', 'per_page')
    # Properties
    #: The description of the project. *Type: string*
    description = resource2.Body('description')
    #: References the domain ID which owns the project; if a domain ID is not
    #: specified by the client, the Identity service implementation will
    #: default it to the domain ID to which the client's token is scoped.
    #: *Type: string*
    domain_id = resource2.Body('domain_id', type=bool)
    #: Indicates whether the project also acts as a domain. If set to True,
    #: the project acts as both a project and a domain. Default is False.
    #: New in version 3.6
    is_domain = resource2.Body('is_domain', type=bool)
    #: Setting this attribute to ``False`` prevents users from authorizing
    #: against this project. Additionally, all pre-existing tokens authorized
    #: for the project are immediately invalidated. Re-enabling a project
    #: does not re-enable pre-existing tokens. *Type: bool*
    is_enabled = resource2.Body('enabled', type=bool)
    #: Unique project name, within the owning domain. *Type: string*
    name = resource2.Body('name')
    #: The ID of the parent of the project.
    #: New in version 3.4
    parent_id = resource2.Body('parent_id')
    #: The links of the parent of the project.
    links = resource2.Body('links', type=dict)
    #: The ID of the of the project.
    id = resource2.Body('id')
    #: The status of the of the project.
    status = resource2.Body('status')

    def update_project_status(self, session, project_id, project):
        endpoint = session.get_endpoint(
            service_type=self.service.service_type).rstrip("v3.0")
        url = utils.urljoin(endpoint, self.base_path, project_id)
        endpoint_override = self.service.get_endpoint_override()
        resp = session.put(url,
                           endpoint_filter=self.service,
                           endpoint_override=endpoint_override,
                           json=project)
        if resp.status_code == 204:
            return True
        return False

    def get_project_details_and_status(self, session, project_id):
        endpoint = session.get_endpoint(
            service_type=self.service.service_type).rstrip("v3.0")
        url = utils.urljoin(endpoint, self.base_path, project_id)
        endpoint_override = self.service.get_endpoint_override()
        resp = session.get(url,
                           endpoint_filter=self.service,
                           endpoint_override=endpoint_override)
        self._translate_response(resp)
        return self