Skip to content

Commit 179f40a

Browse files
author
Spencer Rak
committed
fixup! Add LibvirtServerCustomization
1 parent c8c49a1 commit 179f40a

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

carthage_base/customizations.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import sh
22

33
from carthage.machine import MachineCustomization
4+
from carthage.setup_tasks import setup_task
45

56
class LibvirtServerCustomization(MachineCustomization):
67
@setup_task("Install Libvirt")

carthage_base/pki.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from carthage.ansible import ansible_role_task
1818
import carthage.setup_tasks
1919
from carthage.pki import *
20-
20+
from carthage_base import proxy
2121

2222
__all__ = []
2323

@@ -77,17 +77,18 @@ async def _resolve_args(self, instance):
7777
ainjector = instance.ainjector
7878
results = await resolve_deferred(
7979
ainjector,
80-
item=[self.dns_name, self.cert, self.key, self.ca],
81-
args={})
80+
item=[self.dns_name, self.cert, self.key, self.ca],
81+
args={})
8282
results = (results[0],)+tuple((relative_path(x) if x is not None else None) for x in results[1:])
8383
return results
8484

8585
async def func(self, instance, pki):
8686
path = self._path(instance)
8787
dns_name, cert, key, ca = await self._resolve_args(instance)
88-
dns_name = dns_name or instance.name
89-
carthage.utils.validate_shell_safe(dns_name)
90-
key_pem, cert_pem = await pki.issue_credentials(dns_name, f'Credentials for {cert}')
88+
public_name = await instance.ainjector.get_instance_async(InjectionKey(proxy.public_name_key, _optional=True))
89+
issue_name = dns_name or public_name or instance.name
90+
carthage.utils.validate_shell_safe(issue_name)
91+
key_pem, cert_pem = await pki.issue_credentials(issue_name, f'Credentials for {cert}')
9192
trust_store = await pki.trust_store()
9293
ca_file = await trust_store.ca_file()
9394
ca_pem = ca_file.read_text()
@@ -109,7 +110,7 @@ async def func(self, instance, pki):
109110
async def check_completed_func(self, instance):
110111
try:
111112
path = self._path(instance)
112-
dns_name, cert, *rest = await self._resolve_args(instance)
113+
_, cert, *rest = await self._resolve_args(instance)
113114
cert_path = (path/cert)
114115
stat = cert_path.stat()
115116
if certificate_is_expired(cert_path.read_text(), days_left=14, fraction_left=0.33):

0 commit comments

Comments
 (0)