コード例 #1
0
    def _validate_fields(self, change_fields):
        msg = u._("Must supply non-Blank {0} argument for SecretStores entry.")

        if not change_fields.get('name'):
            raise exception.MissingArgumentError(msg.format("name"))
        if not change_fields.get('store_plugin'):
            raise exception.MissingArgumentError(msg.format("store_plugin"))
コード例 #2
0
ファイル: models.py プロジェクト: ktroach/barbican
    def __init__(self, parsed_ca_in):
        """Creates certificate authority entity."""
        super(CertificateAuthority, self).__init__()

        msg = u._("Must supply Non-None {0} argument "
                  "for CertificateAuthority entry.")

        parsed_ca = dict(parsed_ca_in)

        plugin_name = parsed_ca.pop('plugin_name', None)
        if plugin_name is None:
            raise exception.MissingArgumentError(msg.format("plugin_name"))
        self.plugin_name = plugin_name

        plugin_ca_id = parsed_ca.pop('plugin_ca_id', None)
        if plugin_ca_id is None:
            raise exception.MissingArgumentError(msg.format("plugin_ca_id"))
        self.plugin_ca_id = plugin_ca_id

        expiration = parsed_ca.pop('expiration', None)
        self.expiration = self._iso_to_datetime(expiration)

        creator_id = parsed_ca.pop('creator_id', None)
        if creator_id is not None:
            self.creator_id = creator_id

        project_id = parsed_ca.pop('project_id', None)
        if project_id is not None:
            self.project_id = project_id

        for key in parsed_ca:
            meta = CertificateAuthorityMetadatum(key, parsed_ca[key])
            self.ca_meta[key] = meta

        self.status = States.ACTIVE
コード例 #3
0
ファイル: models.py プロジェクト: ktroach/barbican
    def __init__(self,
                 container_id,
                 operation,
                 project_access=None,
                 user_ids=None):
        """Creates container ACL entity."""
        super(ContainerACL, self).__init__()

        msg = u._("Must supply non-None {0} argument for ContainerACL entry.")

        if container_id is None:
            raise exception.MissingArgumentError(msg.format("container_id"))
        self.container_id = container_id

        if operation is None:
            raise exception.MissingArgumentError(msg.format("operation"))
        self.operation = operation

        if project_access is not None:
            self.project_access = project_access
        self.status = States.ACTIVE

        if user_ids is not None and isinstance(user_ids, list):
            userids = set(user_ids)  # remove duplicate if any
            for user_id in userids:
                acl_user = ContainerACLUser(self.id, user_id)
                self.acl_users.append(acl_user)
コード例 #4
0
ファイル: secret_acl.py プロジェクト: zzh8002/barbican
    def _validate_fields(self, change_fields):
        msg = u._("Must supply non-None {0} argument for SecretACL entry.")

        if change_fields.get('secret_id') is None:
            raise exception.MissingArgumentError(msg.format("secret_id"))

        if change_fields.get('operation') is None:
            raise exception.MissingArgumentError(msg.format("operation"))
コード例 #5
0
ファイル: transport_key.py プロジェクト: zzh8002/barbican
    def _validate_fields(self, change_fields):
        msg = u._("Must supply non-None {0} argument for TransportKey entry.")

        if change_fields.get('plugin_name') is None:
            raise exception.MissingArgumentError(msg.format("plugin_name"))

        if change_fields.get('transport_key') is None:
            raise exception.MissingArgumentError(msg.format("transport_key"))
コード例 #6
0
    def _validate_fields(self, change_fields):

        msg = u._("Must supply non-None {0} argument for ProjectSecretStore "
                  " entry.")

        if not change_fields.get('project_id'):
            raise exception.MissingArgumentError(msg.format("project_id"))
        if not change_fields.get('secret_store_id'):
            raise exception.MissingArgumentError(msg.format("secret_store_id"))
コード例 #7
0
    def _validate_fields(self, change_fields):

        msg = u._("Must supply non-None {0} argument "
                  "for SecretStoreMetadatum entry.")

        if change_fields.get('key') is None:
            raise exception.MissingArgumentError(msg.format('key'))
        if change_fields.get('value') is None:
            raise exception.MissingArgumentError(msg.format('value'))
コード例 #8
0
ファイル: models.py プロジェクト: ktroach/barbican
    def __init__(self, key, value):
        super(CertificateAuthorityMetadatum, self).__init__()

        msg = u._("Must supply non-None {0} argument "
                  "for CertificateAuthorityMetadatum entry.")

        if key is None:
            raise exception.MissingArgumentError(msg.format("key"))
        self.key = key

        if value is None:
            raise exception.MissingArgumentError(msg.format("value"))
        self.value = value
コード例 #9
0
ファイル: models.py プロジェクト: ktroach/barbican
    def __init__(self, plugin_name, transport_key):
        """Creates transport key entity."""
        super(TransportKey, self).__init__()

        msg = u._("Must supply non-None {0} argument for TransportKey entry.")

        if plugin_name is None:
            raise exception.MissingArgumentError(msg.format("plugin_name"))

        self.plugin_name = plugin_name

        if transport_key is None:
            raise exception.MissingArgumentError(msg.format("transport_key"))

        self.transport_key = transport_key
        self.status = States.ACTIVE
コード例 #10
0
ファイル: models.py プロジェクト: ktroach/barbican
    def __init__(self, project_id=None, parsed_project_quotas=None):
        """Creates Project Quotas entity from a project and a dict.

        :param project_id: the internal id of the project with quotas
        :param parsed_project_quotas: a dict with the keys matching the
        resources for which quotas are to be set, and the values containing
        the quota value to be set for this project and that resource.
        :return: None
        """
        super(ProjectQuotas, self).__init__()

        msg = u._("Must supply non-None {0} argument for ProjectQuotas entry.")

        if project_id is None:
            raise exception.MissingArgumentError(msg.format("project_id"))
        self.project_id = project_id

        if parsed_project_quotas is None:
            self.secrets = None
            self.orders = None
            self.containers = None
            self.consumers = None
            self.cas = None
        else:
            self.secrets = parsed_project_quotas.get('secrets')
            self.orders = parsed_project_quotas.get('orders')
            self.containers = parsed_project_quotas.get('containers')
            self.consumers = parsed_project_quotas.get('consumers')
            self.cas = parsed_project_quotas.get('cas')
コード例 #11
0
ファイル: models.py プロジェクト: ktroach/barbican
    def __init__(self, project_id, ca_id):
        """Registers a Consumer to a Container."""
        super(PreferredCertificateAuthority, self).__init__()

        msg = u._("Must supply non-None {0} argument "
                  "for PreferredCertificateAuthority entry.")

        if project_id is None:
            raise exception.MissingArgumentError(msg.format("project_id"))
        self.project_id = project_id

        if ca_id is None:
            raise exception.MissingArgumentError(msg.format("ca_id"))
        self.ca_id = ca_id

        self.status = States.ACTIVE
コード例 #12
0
ファイル: models.py プロジェクト: stanzikratel/barbican-2
    def __init__(self, secret, key, value):
        super(SecretStoreMetadatum, self).__init__()

        msg = ("Must supply non-None {0} argument "
               "for SecretStoreMetadatum entry.")

        if secret is None:
            raise exception.MissingArgumentError(msg.format("secret"))
        self.secret_id = secret.id

        if key is None:
            raise exception.MissingArgumentError(msg.format("key"))
        self.key = key

        if value is None:
            raise exception.MissingArgumentError(msg.format("value"))
        self.value = value
コード例 #13
0
ファイル: models.py プロジェクト: ktroach/barbican
    def __init__(self, acl_id, user_id):
        """Creates secret ACL user entity."""
        super(SecretACLUser, self).__init__()

        msg = u._("Must supply non-None {0} argument for SecretACLUser entry.")

        self.acl_id = acl_id
        if user_id is None:
            raise exception.MissingArgumentError(msg.format("user_id"))
        self.user_id = user_id
        self.status = States.ACTIVE
コード例 #14
0
    def _validate_fields(self, change_fields):

        if change_fields.get('user_id') is None:
            msg = u._("Must supply non-None {0} argument for ContainerACLUser "
                      "entry.")
            raise exception.MissingArgumentError(msg.format("user_id"))
コード例 #15
0
    def _validate_fields(self, change_fields):
        msg = u._("Must supply non-None {0} argument for ProjectQuotas entry.")

        if change_fields.get('project_id') is None:
            raise exception.MissingArgumentError(msg.format("project_id"))