Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipaplatform: Add Debian platform module. #373

Closed
wants to merge 1 commit into from

Conversation

tjaalton
Copy link
Contributor

@tjaalton tjaalton commented Jan 5, 2017

Hi, this just adds the Debian platform module. There are still other changes needed before vanilla master can be used on Debian or it's derivatives, but they need bigger changes while this is mostly standalone.


# Mappings from service names as FreeIPA code references to these services
# to their actual systemd service names
debian_system_units = redhat_services.redhat_system_units
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please create a copy of the dict with redhat_services.redhat_system_units.copy()

ports = base_services.wellknownports[self.service_name]
if ports:
ipautil.wait_for_open_ports('localhost', ports, self.api.env.startup_timeout)
def stop(self, instance_name='', capture_output=True):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing an empty line before def stop

def tune_nofile_platform(self):
return True

# For services which have no Debian counterpart
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pep8 wants two empty lines between classes.


BaseTask = BaseTaskNamespace()

class DebianTaskNamespace(RedHatTaskNamespace):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two empty lines

Copy link
Contributor

@stlaz stlaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for you contribution! Please find some comments inline, some more may come.

"""

from ipaplatform.paths import paths
from ipaplatform.base.tasks import *
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't use wildcard imports, QuantifiedCode is having a bad day if you do.

return True

def parse_ipa_version(self, version):
return BaseTask.parse_ipa_version(version)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could perhaps make parse_ipa_version a static method so that you don't have to create a BaseTaskNamespace instance just for this one purpose.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so something like:

from pkg_resources import parse_version
...
def parse_ipa_version(self, version):
return parse_version(version)

?

Copy link
Contributor

@stlaz stlaz Jan 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I meant was to add @staticmethod before BaseTaskNamespace parse_version definition so that it goes something like this:

class BaseTaskNamespace(object):
    ...
    @staticmethod
    def parse_ipa_version(version):
        """
        :param version: textual version
        :return: object implementing proper __cmp__ method for version compare
        """
        return parse_version(version)

Note the removal of self which is not needed in the method anyway so it being static is actually the preferred way. Once you do this, you can go:

class DebianTaskNamespace(RedHatTaskNamespace):
    ...
    def parse_ipa_version(self, version):
        return BaseTaskNamespace.parse_ipa_version(version)

Note that your parse_ipa_version can itself be static as it uses none of the instance members stored in self :)

@tjaalton tjaalton force-pushed the deb-platform branch 3 times, most recently from 394f36a to 3bce583 Compare January 10, 2017 14:05
@tiran
Copy link
Member

tiran commented Jan 11, 2017

pylint is failing:

Pylint is running, please wait ...
************* Module ipaplatform.debian.tasks
ipaplatform/debian/tasks.py:10: [E0611(no-name-in-module), ] No name 'BaseTaskNameSpace' in module 'ipaplatform.base.tasks')
ipaplatform/debian/tasks.py:49: [E0602(undefined-variable), DebianTaskNamespace.parse_ipa_version] Undefined variable 'BaseTaskNamespace')
ipaplatform/debian/tasks.py:9: [W0611(unused-import), ] Unused paths imported from ipaplatform.paths)
ipaplatform/debian/tasks.py:10: [W0611(unused-import), ] Unused BaseTaskNameSpace imported from ipaplatform.base.tasks)
************* Module ipaplatform.debian.services
ipaplatform/debian/services.py:64: [R0102(simplifiable-if-statement), DebianSysvService.stop] The if statement can be replaced with 'var = bool(test)')
ipaplatform/debian/services.py:65: [W0612(unused-variable), DebianSysvService.stop] Unused variable 'update_service_list')
ipaplatform/debian/services.py:73: [R0102(simplifiable-if-statement), DebianSysvService.start] The if statement can be replaced with 'var = bool(test)')
ipaplatform/debian/services.py:74: [W0612(unused-variable), DebianSysvService.start] Unused variable 'update_service_list')
ipaplatform/debian/services.py:9: [W0611(unused-import), ] Unused import time)
ipaplatform/debian/services.py:11: [W0611(unused-import), ] Unused tasks imported from ipaplatform.tasks)
ipaplatform/debian/services.py:15: [W0611(unused-import), ] Unused root_logger imported from ipapython.ipa_log_manager)
make: *** [pylint] Error 14

installed = True
try:
ipautil.run([paths.SBIN_SERVICE, self.service_name, "status"])
except ipautil.CalledProcessError, e:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the (not so) new syntax except ipautil.CalledProcessError as e, this breaks Python 3.

@tjaalton tjaalton force-pushed the deb-platform branch 2 times, most recently from 1d9022b to c7b64b7 Compare January 11, 2017 23:27
@stlaz stlaz self-assigned this Jan 17, 2017
SYSTEMD_SYSTEM_HTTPD_D_DIR = "/etc/systemd/system/apache2.service.d/"
SYSTEMD_SYSTEM_HTTPD_IPA_CONF = "/etc/systemd/system/apache2.service.d/ipa.conf"
DNSSEC_TRUSTED_KEY = "/etc/bind/trusted-key.key"
KRA_AGENT_PEM = "/etc/apache2/nssdb/kra-agent.pem"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE to myself: the location of KRA_AGENT_PEM changes in #367 to a distro-common location so we'll be able to remove this once <-- is pulled.

KRB5CC_HTTPD = "/var/run/apache2/ipa/krbcache/krb5ccache"
IPA_CUSTODIA_SOCKET = "/run/apache2/ipa-custodia.sock"
IPA_CUSTODIA_AUDIT_LOG = '/var/log/ipa-custodia.audit.log'
IPA_GETKEYTAB = '/usr/sbin/ipa-getkeytab'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This path is the same as in BasePathNamespace so it may not be needed here.

v2:
- use redhat_services.redhat_system_units.copy
- don't use wildcard imports
- add some empty lines to make pep8 happy

v3:
- make parse_ipa_version static

v4:
- make more methods static

v5:
- fix pylint issues
- use syntax that doesn't break with python3

v6:
- remove IPA_GETKEYTAB from paths, it's the same across distros
@tiran
Copy link
Member

tiran commented Jan 19, 2017

@stlaz the patch looks fine to me now. I can't comment on the path values, though. Do you like to see additional modifications?

@stlaz
Copy link
Contributor

stlaz commented Jan 19, 2017

@tiran I would like to test this in a Vagrant box before pushing it

edit: we're not quite there yet, will give it a final read

@stlaz
Copy link
Contributor

stlaz commented Jan 19, 2017

The patch seems fine, I could have some nitpicks but nothing really imporant. ACK.

@stlaz stlaz added the ack Pull Request approved, can be merged label Jan 19, 2017
@MartinBasti
Copy link
Contributor

@MartinBasti MartinBasti added the pushed Pull Request has already been pushed label Jan 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ack Pull Request approved, can be merged pushed Pull Request has already been pushed
Projects
None yet
4 participants