Lines Matching refs:self

28     def __init__(self, **kwargs):
30 self.instance_name = kwargs.get('name')
31 self.dsinstance_host = kwargs.get('host')
32 self.dsinstance_suffix = kwargs.get('suffix')
33 self.multihost = kwargs.get('multihost')
34 self.dsrootdn_pwd = kwargs.get('root_dn_password')
35 self.dsldap_port = kwargs.get('ldap_port', None)
36 self.dstls_port = kwargs.get('ldap_tls_port', None)
37 self.dsrootdn = DS_ROOTDN
38 self.ds_inst_name = 'slapd-%s' % self.instance_name
39 self.dsrootdir = '/etc/dirsrv'
40 self.dsinst_path = os.path.join(self.dsrootdir, self.ds_inst_name)
42 def __str__(self):
43 return "%s.%s('%r')" % (self.__module__, self.__class__.__name__,
44 self.__dict__)
46 def __repr__(self):
47 return '%s(%s, %r)' % (self.__module__, self.__class__.__name__,
48 self.__dict__)
50 def create_config(self):
65 config.set('General', 'FullMachineName', self.dsinstance_host)
70 config.set('slapd', 'ServerIdentifier', self.instance_name)
71 config.set('slapd', 'ServerPort', self.dsldap_port)
72 config.set('slapd', 'Suffix', self.dsinstance_suffix)
73 config.set('slapd', 'RootDN', self.dsrootdn)
74 config.set('slapd', 'RootDNPwd', self.dsrootdn_pwd)
82 def setup_ds(self, ds_cfg_file):
94 self.multihost.transport.put_file(ds_cfg_file, '/tmp/test.cfg')
98 self.multihost.run_command(setup_args)
105 def remove_ds(self, inst_name=None):
118 inst_name = self.ds_inst_name
121 self.multihost.run_command(remove_args)
125 def setup_certs(self, ssl_dir):
141 stop_ds = ['systemctl', 'stop', 'dirsrv@%s' % (self.instance_name)]
143 self.multihost.run_command(stop_ds)
147 self.multihost.log.info('DS instance stopped successfully')
149 dirsrv_cert_path = '/etc/dirsrv/' + self.ds_inst_name + '/cacert.pem'
153 destination = os.path.join(self.dsinst_path, db_file)
154 self.multihost.transport.put_file(source, destination)
155 target_pin_file = os.path.join(self.dsinst_path, 'pin.txt')
161 self.multihost.run_command(create_cert_dir)
162 self.multihost.transport.put_file(os.path.join(
165 self.multihost.run_command(change_ownership)
170 self.multihost.run_command(change_group)
175 self.multihost.run_command(chmod_file)
178 start_ds = ['systemctl', 'start', 'dirsrv@%s' % (self.instance_name)]
180 self.multihost.run_command(start_ds)
184 self.multihost.log.info('DS instance started successfully')
185 ca = self.multihost.get_file_contents(cacert_file_path)
186 self.multihost.transport.put_file_contents(dirsrv_cert_path, ca)
188 def enable_ssl(self, binduri, tls_port):
201 ldap_obj = LdapOperations(uri=binduri, binddn=self.dsrootdn,
202 bindpw=self.dsrootdn_pwd)
216 'nsSSLPersonalitySSL': 'Server-Cert-%s' % (self.dsinstance_host),
256 def __init__(self, multihost_obj, ssl=None, ssldb=None):
266 self.ds_used_ports = {}
267 self.dirsrv_info = {}
268 self.dirsrv_obj = None
269 self.ds_instance_name = None
270 self.multihost = multihost_obj
271 self.ds_instance_host = self.multihost.sys_hostname
272 self.ds_instance_suffix = None
273 self.ds_rootdn_pwd = None
274 self.ds_ldap_port = None
275 self.ds_tls_port = None
276 self.ssl = ssl
277 if self.ssl:
278 self.ssl_dir = ssldb
280 def __iter__(self):
282 return self.dirsrv_info.itervalues()
284 def __getitem__(self, key):
286 return self.dirsrv_info[key]
288 def _set_options(self,
310 self.ds_instance_name = instance_name
312 self.ds_instance_suffix = instance_suffix
314 self.ds_instance_suffix = 'dc=example,dc=org'
317 self.ds_rootdn_pwd = root_dn_pwd
319 self.ds_rootdn_pwd = 'Secret123'
322 self.ds_ldap_port, self.ds_tls_port = self._set_ports(
327 self.ds_used_ports[self.ds_instance_name] = [
328 self.ds_ldap_port, self.ds_tls_port]
332 self._validate_options()
338 def _set_ports(self, u_port, e_port):
346 1.1.2 Use the ports and add it to the self.UsedPorts list
351 2.1.2 Use the ports and add it to self.ds_used_ports list
367 if (self._check_remote_port(ldap_port) or
368 self._check_remote_port(ldaps_port)):
374 for ports in self.ds_used_ports.values():
388 def _check_remote_port(self, port):
400 sock_obj.connect((self.ds_instance_host, port))
409 def _validate_options(self):
422 self.ds_instance_name]
423 output = self.multihost.run_command(check_instance, raiseonerr=False)
426 self.ds_instance_name)
428 def create_ds_instance(self,
450 result, return_code = self._set_options(inst_name,
456 self.dirsrv_obj = DirSrv(name=self.ds_instance_name,
457 host=self.ds_instance_host,
458 suffix=self.ds_instance_suffix,
459 multihost=self.multihost,
460 root_dn_password=self.ds_rootdn_pwd,
461 ldap_port=self.ds_ldap_port,
462 tls_port=self.ds_tls_port)
463 cfg_file = self.dirsrv_obj.create_config()
465 self.dirsrv_obj.setup_ds(cfg_file)
468 self.dirsrv_info[self.ds_instance_name] = self.dirsrv_obj.__dict__
469 if self.ssl:
471 self.dirsrv_obj.setup_certs(self.ssl_dir)
475 (result, return_code) = self.enablessl()
480 def enablessl(self):
498 'ldap_port_t', '-p', 'tcp', str(self.ds_tls_port)]
501 self.ds_instance_name]
502 if self.ds_tls_port != 636:
504 self.multihost.run_command(add_tls_port)
508 self.multihost.log.info('Added %s port to ldap_port_t' %
509 self.ds_tls_port)
511 self.dirsrv_obj.enable_ssl('ldap://%s:%r' % (self.ds_instance_host,
512 self.ds_ldap_port),
513 self.ds_tls_port)
518 self.multihost.run_command(restart_ds)
522 self.multihost.log.info('DS instance restarted successfully')
526 '/var/log/dirsrv/slapd-%s/errors' % self.
528 output = self.multihost.run_command(tail_cmd, raiseonerr=False)
534 def remove_ds_instance(self, instance_name):
546 ret = self.dirsrv_info[instance_name]
550 self.dirsrv_obj.remove_ds(ds_inst_name)
555 del self.ds_used_ports[instance_name]