Пример #1
0
 def __init__(self, name, reference, binary_path, scratch_path):
     if not isinstance(name, basestring):
         raise IncorrectTypeError(
             RemoteHost,
             'name',
             type(name),
             basestring)
     self.__name = name
     if not isinstance(reference, basestring):
         raise IncorrectTypeError(
             RemoteHost,
             'reference',
             type(reference),
             basestring)
     self.__reference = reference
     if not isinstance(binary_path, basestring):
         raise IncorrectTypeError(
             RemoteHost,
             'binary_path',
             type(binary_path),
             basestring)
     self.__binary_path = binary_path
     if not isinstance(scratch_path, basestring):
         raise IncorrectTypeError(
             RemoteHost,
             'scratch_path',
             type(scratch_path),
             basestring)
     self.__scratch_path = scratch_path
 def __init__(self, name, reference):
     if not isinstance(name, basestring):
         raise IncorrectTypeError(RemoteUser, 'name', type(name),
                                  basestring)
     self.__name = name
     if not isinstance(reference, basestring):
         raise IncorrectTypeError(RemoteUser, 'reference', type(reference),
                                  basestring)
     self.__reference = reference
 def __init__(self, uid, gid):
     if not isinstance(uid, int):
         raise IncorrectTypeError(OwnershipSpecification, 'uid', type(uid),
                                  int)
     self._uid = uid
     if not isinstance(gid, int):
         raise IncorrectTypeError(OwnershipSpecification, 'gid', type(gid),
                                  int)
     self._gid = gid
 def __init__(self, username, private_key, public_key):
     super(KeyPairCredentials, self).__init__(username)
     if not isinstance(private_key, basestring):
         raise IncorrectTypeError(KeyPairCredentials, 'private_key',
                                  type(private_key), basestring)
     self.__private_key = private_key
     if not isinstance(public_key, basestring):
         raise IncorrectTypeError(KeyPairCredentials, 'public_key',
                                  type(public_key), basestring)
     self.__public_key = public_key
    def __init__(self, remote_environment, mount_path, shared_path=None):
        """A Mount object asks for multiple Python objects (RemoteEnvironment,
        RemoteHost), which have parameters (such as name, binary_path and
        scratch_path) that require the plugin writer to provide values for.
        Plugin writers will not know the values for these, nor are these values
        ever used by engine code, except for RemoteHost's reference parameter.
        This check allows plugin writers to provide either a RemoteEnvironment
        object with fully populated parameters, or a reference string, leaving
        the other parameters to be populated with dummy values. This saves the
        plugin writer from attempting to provide parameter values that they
        won't have access to."""
        def __is_correct_reference_format(reference):
            unix_format = re.compile("^UNIX_HOST_ENVIRONMENT-\d+$")
            win_format = re.compile("^WINDOWS_HOST_ENVIRONMENT-\d+$")
            return bool(unix_format.match(reference)) or \
                   bool(win_format.match(reference))

        def __make_remote_environment_from_reference(reference):
            dummy_host = RemoteHost("dummy host", "dummy reference",
                                    "dummy binary path", "dummy scratch path")
            if not isinstance(remote_environment, RemoteEnvironment) and not \
                __is_correct_reference_format(remote_environment):
                raise RuntimeError(
                    "Reference '{}' is not a valid host environment reference."
                    .format(reference))
            return RemoteEnvironment("dummy name", reference, dummy_host)

        # if reference is not a RemoteEnvironment nor a string
        if not isinstance(remote_environment, RemoteEnvironment) and not \
            isinstance(remote_environment, six.string_types):
            raise IncorrectTypeError(Mount, 'remote_environment',
                                     type(remote_environment),
                                     [RemoteEnvironment, six.string_types[0]])
        # if reference is a string, but incorrectly formatted
        if isinstance(
                remote_environment, six.string_types
        ) and not __is_correct_reference_format(remote_environment):
            raise IncorrectReferenceFormatError(remote_environment)

        # If the plugin has provided us with just a valid reference string,
        # convert to a real Python object
        if isinstance(remote_environment, six.string_types):
            self._remote_environment = __make_remote_environment_from_reference(
                remote_environment)
        else:
            self._remote_environment = remote_environment
        if not isinstance(mount_path, six.string_types):
            raise IncorrectTypeError(Mount, 'mount_path', type(mount_path),
                                     six.string_types[0])
        self._mount_path = mount_path

        if shared_path and not isinstance(shared_path, six.string_types[0]):
            raise IncorrectTypeError(Mount, 'shared_path', type(shared_path),
                                     six.string_types[0], False)
        self._shared_path = shared_path
    def __init__(self, environment, user):
        if isinstance(environment, RemoteEnvironment):
            self.__environment = environment
        else:
            raise IncorrectTypeError(RemoteConnection, 'environment',
                                     type(environment), RemoteEnvironment)

        if isinstance(user, RemoteUser):
            self.__user = user
        else:
            raise IncorrectTypeError(RemoteConnection, 'user', type(user),
                                     RemoteUser)
    def __init__(self, guid, source_connection, parameters, mount,
                 staged_connection):

        self._guid = guid
        if not isinstance(source_connection, RemoteConnection):
            raise IncorrectTypeError(RemoteConnection, 'source_connection',
                                     type(source_connection), RemoteConnection)
        self._source_connection = source_connection
        self._parameters = parameters
        self._mount = mount
        if not isinstance(staged_connection, RemoteConnection):
            raise IncorrectTypeError(RemoteConnection, 'staged_connection',
                                     type(staged_connection), RemoteConnection)
        self._staged_connection = staged_connection
    def __init__(self, name, reference, host):
        if not isinstance(name, basestring):
            raise IncorrectTypeError(RemoteEnvironment, 'name', type(name),
                                     basestring)
        self.__name = name
        if not isinstance(reference, basestring):
            raise IncorrectTypeError(RemoteEnvironment, 'reference',
                                     type(reference), basestring)
        self.__reference = reference

        if isinstance(host, RemoteHost):
            self.host = host
        else:
            raise IncorrectTypeError(RemoteEnvironment, 'host', type(host),
                                     RemoteHost)
 def __init__(self, guid, connection, parameters):
     self._guid = guid
     if not isinstance(connection, RemoteConnection):
         raise IncorrectTypeError(RemoteConnection, 'connection',
                                  type(connection), RemoteConnection)
     self._connection = connection
     self._parameters = parameters
Пример #10
0
 def from_proto(user):
     """Converts protobuf class common_pb2.RemoteUser to plugin class RemoteUser
     """
     if not isinstance(user, common_pb2.RemoteUser):
         raise IncorrectTypeError(RemoteUser, 'user', type(user),
                                  common_pb2.RemoteUser)
     remote_user = RemoteUser(name=user.name, reference=user.reference)
     return remote_user
    def __init__(self, mounts, ownership_specification=None):
        if not isinstance(mounts, list):
            raise IncorrectTypeError(MountSpecification, 'mounts',
                                     type(mounts), [Mount])
        if not all(isinstance(mount, Mount) for mount in mounts):
            raise IncorrectTypeError(MountSpecification, 'mounts',
                                     [type(mount) for mount in mounts],
                                     [Mount])
        self._mounts = mounts

        if (ownership_specification and not isinstance(
                ownership_specification, OwnershipSpecification)):
            raise IncorrectTypeError(MountSpecification,
                                     'ownership_specification',
                                     type(ownership_specification),
                                     OwnershipSpecification, False)

        self._ownership_specification = ownership_specification
Пример #12
0
    def __init__(self, remote_environment, mount_path, shared_path=None):
        if not isinstance(remote_environment, RemoteEnvironment):
            raise IncorrectTypeError(
                Mount,
                'remote_environment',
                type(remote_environment),
                RemoteEnvironment)
        self._remote_environment = remote_environment

        if not isinstance(mount_path, basestring):
            raise IncorrectTypeError(
                Mount, 'mount_path', type(mount_path), basestring)
        self._mount_path = mount_path

        if shared_path and not isinstance(shared_path, basestring):
            raise IncorrectTypeError(
                Mount, 'shared_path', type(shared_path), basestring, False)
        self._shared_path = shared_path
Пример #13
0
 def from_proto(credentials_result):
     """Converts protobuf class libs_pb2.CredentialsResult to plugin class PasswordCredentials
     """
     if not isinstance(credentials_result, libs_pb2.CredentialsResult):
         raise IncorrectTypeError(PasswordCredentials, 'credentials_result',
                                  type(credentials_result),
                                  libs_pb2.CredentialsResult)
     return PasswordCredentials(username=credentials_result.username,
                                password=credentials_result.pasword)
Пример #14
0
 def from_proto(connection):
     """Converts protobuf class common_pb2.RemoteConnection to plugin class RemoteConnection
     """
     if not isinstance(connection, common_pb2.RemoteConnection):
         raise IncorrectTypeError(RemoteConnection, 'connection',
                                  type(connection),
                                  common_pb2.RemoteConnection)
     environment = RemoteEnvironment.from_proto(connection.environment)
     user = RemoteUser.from_proto(connection.user)
     return RemoteConnection(environment=environment, user=user)
Пример #15
0
 def from_proto(environment):
     """Converts protobuf class common_pb2.RemoteEnvironment to plugin class RemoteEnvironment
     """
     if not isinstance(environment, common_pb2.RemoteEnvironment):
         raise IncorrectTypeError(RemoteEnvironment, 'environment',
                                  type(environment),
                                  common_pb2.RemoteEnvironment)
     return RemoteEnvironment(name=environment.name,
                              reference=environment.reference,
                              host=RemoteHost.from_proto(environment.host))
Пример #16
0
 def from_proto(host):
     """Converts protobuf class common_pb2.RemoteHost to plugin class RemoteHost
     """
     if not isinstance(host, common_pb2.RemoteHost):
         raise IncorrectTypeError(RemoteHost, 'host', type(host),
                                  common_pb2.RemoteHost)
     return RemoteHost(name=host.name,
                       reference=host.reference,
                       binary_path=host.binary_path,
                       scratch_path=host.scratch_path)
Пример #17
0
 def from_proto(credentials_result):
     """Converts protobuf class libs_pb2.CredentialsResult to plugin class KeyPairCredentials
     """
     if not isinstance(credentials_result, libs_pb2.CredentialsResult):
         raise IncorrectTypeError(KeyPairCredentials, 'credentials_result',
                                  type(credentials_result),
                                  libs_pb2.CredentialsResult)
     return KeyPairCredentials(
         username=credentials_result.username,
         private_key=credentials_result.key_pair.private_key,
         public_key=credentials_result.key_pair.public_key)
Пример #18
0
 def __init__(self, username, password):
     super(PasswordCredentials, self).__init__(username)
     if not isinstance(password, basestring):
         raise IncorrectTypeError(PasswordCredentials, 'password',
                                  type(password), basestring)
     self.__password = password
Пример #19
0
 def __init__(self, username):
     if not isinstance(username, basestring):
         raise IncorrectTypeError(Credentials, 'username', type(username),
                                  basestring)
     self.__username = username