-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Suszyński Krzysztof
committed
Aug 8, 2017
1 parent
18a6794
commit 6b55f24
Showing
42 changed files
with
359 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from abc import ABCMeta, abstractmethod | ||
|
||
from six import with_metaclass | ||
from typing import Sequence | ||
|
||
from puppeter.domain.model.configurer import Configurer | ||
from puppeter.domain.model.fqdn import FqdnConfiguration | ||
|
||
|
||
class FqdnSetterGateway(with_metaclass(ABCMeta)): | ||
@abstractmethod | ||
def process_fully_qualified_domain_name(self, fqdn): | ||
# type: (FqdnConfiguration) -> Sequence[Configurer] | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
from typing import Sequence | ||
from typing import Sequence, Optional | ||
|
||
from puppeter.domain.model import Installer | ||
from puppeter.domain.model.configurer import Configurer | ||
|
||
|
||
class InstallerGateway: | ||
def configurers(self, installer: Installer) -> Sequence[Configurer]: ... | ||
def configurers(self, installer: Optional[Installer]) -> Sequence[Configurer]: ... | ||
def _provide_install_configurers(self, installer: Installer) -> Sequence[Configurer]: ... | ||
def _puppet_cert_issue(self, installer: Installer) -> Sequence[Configurer]: ... | ||
def _puppet_services(self, installer: Installer) -> Sequence[Configurer]: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,30 @@ | ||
from typing import Optional | ||
|
||
from puppeter.domain.model.fqdn import FqdnConfiguration | ||
from puppeter.domain.model.installer import Installer | ||
|
||
|
||
class Answers: | ||
def __init__(self, | ||
installer=None, | ||
fqdn_configurator=None, | ||
timesync_configurator=None, | ||
csrattrs_configurator=None): | ||
self.__installer = installer # type: Installer | ||
self.__fqdn_configurator = fqdn_configurator | ||
self.__timesync_configurator = timesync_configurator | ||
self.__csrattrs_configurator = csrattrs_configurator | ||
fqdn_configuration=None, | ||
timesync_configuration=None, | ||
csrattrs_configuration=None): | ||
self.__installer = installer # type: Optional[Installer] | ||
self.__fqdn_configuration = fqdn_configuration # type: Optional[FqdnConfiguration] | ||
self.__timesync_configuration = timesync_configuration | ||
self.__csrattrs_configuration = csrattrs_configuration | ||
|
||
def installer(self): | ||
# type: () -> Installer | ||
# type: () -> Optional[Installer] | ||
return self.__installer | ||
|
||
def fqdn_configurator(self): | ||
return self.__fqdn_configurator | ||
def fqdn_configuration(self): | ||
# type: () -> Optional[FqdnConfiguration] | ||
return self.__fqdn_configuration | ||
|
||
def timesync_configurator(self): | ||
return self.__timesync_configurator | ||
def timesync_configuration(self): | ||
return self.__timesync_configuration | ||
|
||
def csrattrs_configurator(self): | ||
return self.__csrattrs_configurator | ||
def csrattrs_configuration(self): | ||
return self.__csrattrs_configuration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from typing import Union | ||
|
||
from puppeter.domain.model.withoptions import WithOptions | ||
|
||
|
||
class FqdnConfiguration(WithOptions): | ||
def __init__(self, fqdn='localhost.localdomain'): | ||
self.__fqdn = fqdn.strip() | ||
|
||
def raw_options(self): | ||
return self.fqdn() | ||
|
||
def read_raw_options(self, options): | ||
self.__fqdn = str(options).strip() | ||
|
||
def fqdn(self): | ||
# type: () -> str | ||
return self.__fqdn | ||
|
||
def hostname(self): | ||
# type: () -> str | ||
return self.fqdn().split('.')[0] | ||
|
||
def domain(self): | ||
# type: () -> Union[str,None] | ||
domain = '.'.join(self.fqdn().split('.')[1:]) | ||
domain = None if domain == '' else domain | ||
return domain | ||
|
||
def has_domain(self): | ||
# type: () -> bool | ||
return self.domain() is not None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import collections | ||
from abc import ABCMeta, abstractmethod | ||
|
||
from six import with_metaclass, iteritems | ||
from typing import Dict, Any | ||
|
||
|
||
class WithOptions(with_metaclass(ABCMeta, object)): | ||
|
||
@abstractmethod | ||
def raw_options(self): | ||
# type: () -> Dict[str, Any] | ||
pass | ||
|
||
@abstractmethod | ||
def read_raw_options(self, options): | ||
# type: (Dict[str, Any]) -> None | ||
pass | ||
|
||
@staticmethod | ||
def _update(orig_dict, new_dict): | ||
for key, val in iteritems(new_dict): | ||
if isinstance(val, collections.Mapping): | ||
tmp = WithOptions._update(orig_dict=orig_dict.get(key, {}), new_dict=val) | ||
orig_dict[key] = tmp | ||
elif isinstance(val, list): | ||
orig_dict[key] = (orig_dict.get(key, []) + val) | ||
else: | ||
orig_dict[key] = new_dict[key] | ||
return orig_dict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
from puppeter import container | ||
from puppeter.domain.gateway.answers import AnswersGateway | ||
from puppeter.domain.gateway.fqdn import FqdnSetterGateway | ||
from puppeter.persistence.gateway.answers import YamlAnswersGateway | ||
from puppeter.persistence.gateway.fqdn import FqdnSetterGatewayImpl | ||
|
||
|
||
container.bind(AnswersGateway, YamlAnswersGateway) | ||
container.bind(FqdnSetterGateway, FqdnSetterGatewayImpl) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
file { '/etc/hostname': | ||
ensure => 'file', | ||
owner => 'root', | ||
group => 'root', | ||
mode => '0644', | ||
content => '@{hostname}' | ||
} |
Oops, something went wrong.