Просмотр исходного кода

write roles to storage if found on classpath

tags/v0.9.11
Jonathan Cobb 4 лет назад
Родитель
Сommit
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 {
@Cleanup final InputStream in = getClass().getClassLoader().getResourceAsStream(roleTgzPath);
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) {
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) {
@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 rolesDir = new File(automation, "roles");
Tarball.unroll(roleTarball, rolesDir);


+ 4
- 0
bubble-server/src/main/java/bubble/service/cloud/StorageService.java Просмотреть файл

@@ -5,10 +5,14 @@
package bubble.service.cloud;

import java.io.IOException;
import java.io.InputStream;

public interface StorageService {

boolean exists(String account, String tgzB64);

boolean write(String account, String uri, InputStream data);

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 org.springframework.stereotype.Service;

import java.io.InputStream;

import static org.cobbzilla.util.daemon.ZillaRuntime.notSupported;

@Service
@@ -14,6 +16,8 @@ public class DbFilterStorageService implements StorageService {

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

}

+ 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.restoreKey.invalid=Restore key is invalid
err.restoreKey.required=Restore key is required
err.role.notFound=Role not found
err.role.exists=Role already exists with this name
err.role.invalid=Role name mismatch
err.roles.required=Roles field is required


Загрузка…
Отмена
Сохранить