Преглед на файлове

write roles to storage if found on classpath

tags/v0.9.11
Jonathan Cobb преди 4 години
родител
ревизия
9616eed903
променени са 5 файла, в които са добавени 18 реда и са изтрити 0 реда
  1. +5
    -0
      bubble-server/src/main/java/bubble/dao/cloud/AnsibleRoleDAO.java
  2. +4
    -0
      bubble-server/src/main/java/bubble/service/cloud/AnsiblePrepService.java
  3. +4
    -0
      bubble-server/src/main/java/bubble/service/cloud/StorageService.java
  4. +4
    -0
      bubble-server/src/main/java/bubble/service_dbfilter/DbFilterStorageService.java
  5. +1
    -0
      bubble-server/src/main/resources/message_templates/en_US/server/post_auth/ResourceMessages.properties

+ 5
- 0
bubble-server/src/main/java/bubble/dao/cloud/AnsibleRoleDAO.java Целия файл

@@ -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));
} }


+ 4
- 0
bubble-server/src/main/java/bubble/service/cloud/AnsiblePrepService.java Целия файл

@@ -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);


+ 4
- 0
bubble-server/src/main/java/bubble/service/cloud/StorageService.java Целия файл

@@ -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;

} }

+ 4
- 0
bubble-server/src/main/java/bubble/service_dbfilter/DbFilterStorageService.java Целия файл

@@ -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"); }


} }

+ 1
- 0
bubble-server/src/main/resources/message_templates/en_US/server/post_auth/ResourceMessages.properties Целия файл

@@ -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


Зареждане…
Отказ
Запис