@@ -108,6 +108,11 @@ public class AnsibleRoleDAO extends AccountOwnedTemplateDAO<AnsibleRole> { | |||||
try { | try { | ||||
@Cleanup final InputStream in = getClass().getClassLoader().getResourceAsStream(roleTgzPath); | @Cleanup final InputStream in = getClass().getClassLoader().getResourceAsStream(roleTgzPath); | ||||
existsOnClasspath = in != null; | existsOnClasspath = in != null; | ||||
if (existsOnClasspath) { | |||||
if (!storageService.write(role.getAccount(), role.getTgzB64(), in)) { | |||||
log.warn("preCreate: error writing role archive from classpath:"+roleTgzPath+" -> storage:"+role.getTgzB64()); | |||||
} | |||||
} | |||||
} catch (Exception ioe) { | } catch (Exception ioe) { | ||||
log.warn("preCreate: role archive not found in storage ("+role.getTgzB64()+") and exception searching classpath ("+roleTgzPath+"): "+shortError(ioe)); | log.warn("preCreate: role archive not found in storage ("+role.getTgzB64()+") and exception searching classpath ("+roleTgzPath+"): "+shortError(ioe)); | ||||
} | } | ||||
@@ -123,6 +123,10 @@ public class AnsiblePrepService { | |||||
for (AnsibleRole role : roles) { | for (AnsibleRole role : roles) { | ||||
@Cleanup final InputStream roleStream = getTgzInputStream(node.getAccount(), role); | @Cleanup final InputStream roleStream = getTgzInputStream(node.getAccount(), role); | ||||
if (roleStream == null) { | |||||
errors.addViolation("err.role.notFound", "roleStream was null for: "+role.getTgzB64()); | |||||
continue; | |||||
} | |||||
final File roleTarball = toFile(new File(tarballDir, role.getName() + ".tgz"), roleStream); | final File roleTarball = toFile(new File(tarballDir, role.getName() + ".tgz"), roleStream); | ||||
final File rolesDir = new File(automation, "roles"); | final File rolesDir = new File(automation, "roles"); | ||||
Tarball.unroll(roleTarball, rolesDir); | Tarball.unroll(roleTarball, rolesDir); | ||||
@@ -5,10 +5,14 @@ | |||||
package bubble.service.cloud; | package bubble.service.cloud; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.io.InputStream; | |||||
public interface StorageService { | public interface StorageService { | ||||
boolean exists(String account, String tgzB64); | boolean exists(String account, String tgzB64); | ||||
boolean write(String account, String uri, InputStream data); | |||||
void delete(String account, String path) throws IOException; | void delete(String account, String path) throws IOException; | ||||
} | } |
@@ -7,6 +7,8 @@ package bubble.service_dbfilter; | |||||
import bubble.service.cloud.StorageService; | import bubble.service.cloud.StorageService; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import java.io.InputStream; | |||||
import static org.cobbzilla.util.daemon.ZillaRuntime.notSupported; | import static org.cobbzilla.util.daemon.ZillaRuntime.notSupported; | ||||
@Service | @Service | ||||
@@ -14,6 +16,8 @@ public class DbFilterStorageService implements StorageService { | |||||
@Override public boolean exists(String account, String tgzB64) { return notSupported("exists"); } | @Override public boolean exists(String account, String tgzB64) { return notSupported("exists"); } | ||||
@Override public boolean write(String account, String uri, InputStream data) { return notSupported("write"); } | |||||
@Override public void delete(String account, String path) { notSupported("delete"); } | @Override public void delete(String account, String path) { notSupported("delete"); } | ||||
} | } |
@@ -696,6 +696,7 @@ err.removeRule.multipleCustomLists=More than one built-in filter list was found | |||||
err.request.invalid=Request is invalid | err.request.invalid=Request is invalid | ||||
err.restoreKey.invalid=Restore key is invalid | err.restoreKey.invalid=Restore key is invalid | ||||
err.restoreKey.required=Restore key is required | err.restoreKey.required=Restore key is required | ||||
err.role.notFound=Role not found | |||||
err.role.exists=Role already exists with this name | err.role.exists=Role already exists with this name | ||||
err.role.invalid=Role name mismatch | err.role.invalid=Role name mismatch | ||||
err.roles.required=Roles field is required | err.roles.required=Roles field is required | ||||