Beispiel #1
0
    def setup(self, image, key, tm_release, instance_type, app_root, with_api,
              ipa_admin_password, proid, subnet_name):
        ldap_hostname, zk_hostname = self.hostnames_for(roles=[
            constants.ROLES['LDAP'],
            constants.ROLES['ZOOKEEPER'],
        ])

        _ipa = ipa.API()
        _node_hostnames = self._hostname_cluster(count=1)

        for _idx in _node_hostnames.keys():
            _node_h = _node_hostnames[_idx]
            otp = _ipa.add_host(hostname=_node_h)
            self.name = _node_h

            self.configuration = configuration.Node(
                tm_release=tm_release,
                app_root=app_root,
                ldap_hostname=ldap_hostname,
                otp=otp,
                with_api=with_api,
                hostname=_node_h,
                ipa_admin_password=ipa_admin_password,
                proid=proid,
                zk_url=self._zk_url(zk_hostname))
            super().setup(
                image=image,
                count=1,
                key=key,
                instance_type=instance_type,
                subnet_name=subnet_name,
                sg_names=[constants.COMMON_SEC_GRP],
            )
Beispiel #2
0
 def _delete_host_from_ipa(self):
     _api = ipa.API()
     for _i in self.instances:
         if _i.role != constants.ROLES['IPA']:
             try:
                 _api.delete_host(hostname=_i.hostname.lower())
             except AssertionError as e:
                 _LOGGER.warn(
                     'Couldn\'t delete host ' + _i.hostname + ' from ipa. ',
                     e)
Beispiel #3
0
    def setup(
            self,
            image,
            count,
            key,
            cidr_block,
            tm_release,
            instance_type,
            app_root,
            ipa_admin_password,
            proid,
            subnet_name,
    ):
        ipa_server_hostname, = self.hostnames_for(
            roles=[constants.ROLES['IPA']]
        )

        if not ipa_server_hostname:
            raise exceptions.IPAServerNotFound()

        _ldap_hostnames = self._hostname_cluster(count=count)
        _ipa = ipa.API()

        for _idx in _ldap_hostnames.keys():
            _ldap_h = _ldap_hostnames[_idx]
            otp = _ipa.add_host(hostname=_ldap_h)
            _ipa.service_add('ldap', _ldap_h, {
                'domain': connection.Connection.context.domain,
                'hostname': _ldap_h,
            })
            self.name = _ldap_h
            self.configuration = configuration.LDAP(
                tm_release=tm_release,
                app_root=app_root,
                hostname=_ldap_h,
                ipa_admin_password=ipa_admin_password,
                ipa_server_hostname=ipa_server_hostname,
                otp=otp,
                proid=proid
            )
            super().setup(
                image=image,
                count=count,
                cidr_block=cidr_block,
                key=key,
                instance_type=instance_type,
                subnet_name=subnet_name,
                sg_names=[constants.COMMON_SEC_GRP],
            )
Beispiel #4
0
    def setup(
        self,
        image,
        count,
        cidr_block,
        tm_release,
        key,
        instance_type,
        app_root,
        ipa_admin_password,
        proid,
        subnet_name,
    ):
        ldap_hostname, zk_hostname = self.hostnames_for(roles=[
            constants.ROLES['LDAP'],
            constants.ROLES['ZOOKEEPER'],
        ])

        if not ldap_hostname:
            raise exceptions.LDAPNotFound()

        _ipa = ipa.API()
        _master_hostnames = self._hostname_cluster(count)

        for _idx in _master_hostnames.keys():
            _master_h = _master_hostnames[_idx]
            _otp = _ipa.add_host(hostname=_master_h)
            self.name = _master_h

            self.configuration = configuration.Master(
                hostname=_master_h,
                otp=_otp,
                ldap_hostname=ldap_hostname,
                tm_release=tm_release,
                app_root=app_root,
                ipa_admin_password=ipa_admin_password,
                idx=_idx,
                proid=proid,
                zk_url=self._zk_url(zk_hostname))
            super().setup(
                image=image,
                count=1,
                cidr_block=cidr_block,
                key=key,
                instance_type=instance_type,
                subnet_name=subnet_name,
                sg_names=[constants.COMMON_SEC_GRP],
            )
Beispiel #5
0
    def setup(self, image, key, cidr_block, instance_type,
              ipa_admin_password, proid, subnet_name, count=3):
        ldap_hostname, ipa_server_hostname = self.hostnames_for(
            roles=[
                constants.ROLES['IPA'],
                constants.ROLES['LDAP'],
            ]
        )

        if not ipa_server_hostname:
            raise exceptions.IPAServerNotFound()
        if not ldap_hostname:
            raise exceptions.LDAPNotFound()

        _ipa = ipa.API()
        _zk_hostnames = self._hostname_cluster(count=count)
        _cfg_data = self._construct_cfg_data(_zk_hostnames)

        for _idx in _zk_hostnames.keys():
            _zk_h = _zk_hostnames[_idx]
            _otp = _ipa.add_host(hostname=_zk_h)
            _ipa.service_add('zookeeper', _zk_h, {
                'domain': connection.Connection.context.domain,
                'hostname': _zk_h,
            })
            self.name = _zk_h
            self.configuration = configuration.Zookeeper(
                ldap_hostname=ldap_hostname,
                ipa_server_hostname=ipa_server_hostname,
                hostname=_zk_h,
                otp=_otp,
                idx=_idx,
                proid=proid,
                cfg_data=_cfg_data
            )
            super().setup(
                image=image,
                count=1,
                cidr_block=cidr_block,
                key=key,
                instance_type=instance_type,
                subnet_name=subnet_name,
                sg_names=[constants.COMMON_SEC_GRP],
            )
Beispiel #6
0
 def setUp(self):
     self.ipa = ipa.API()