org.jclouds.scriptbuilder.domain.Statements.createOrOverwriteFile()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(13.2k)|赞(0)|评价(0)|浏览(92)

本文整理了Java中org.jclouds.scriptbuilder.domain.Statements.createOrOverwriteFile()方法的一些代码示例,展示了Statements.createOrOverwriteFile()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Statements.createOrOverwriteFile()方法的具体详情如下:
包路径:org.jclouds.scriptbuilder.domain.Statements
类名称:Statements
方法名:createOrOverwriteFile

Statements.createOrOverwriteFile介绍

暂无

代码示例

代码示例来源:origin: org.apache.whirr/whirr-hadoop

public static Statement asCreateEnvironmentVariablesFileStatement(String path,
  Configuration config) {
 return createOrOverwriteFile(path, asEnvironmentVariablesLines(config));
}

代码示例来源:origin: jclouds/legacy-jclouds

@VisibleForTesting
void createRolesIfNecessary(ImmutableList.Builder<Statement> statements) {
 // The roles directory must contain one file for each role definition
 if (roles.isPresent() && !roles.get().isEmpty()) {
   statements.add(exec("{md} " + rolePath));
   for (Role role : roles.get()) {
    statements.add(createOrOverwriteFile(rolePath + "/" + role.getName() + ".json",
       ImmutableSet.of(role.toJsonString())));
   }
 }
}

代码示例来源:origin: jclouds/legacy-jclouds

public String render(OsFamily family) {
 checkNotNull(family, "family");
 if (family == OsFamily.WINDOWS)
   throw new UnsupportedOperationException("windows not yet implemented");
 Builder<Statement> statements = ImmutableList.builder();
 statements.add(createOrOverwriteFile(sudoers, ImmutableSet.of("root ALL = (ALL) ALL", "%wheel ALL = (ALL) NOPASSWD:ALL")));
 statements.add(exec("chmod 0440 " + sudoers));
 return new StatementList(statements.build()).render(family);
}

代码示例来源:origin: org.jclouds/jclouds-scriptbuilder

@VisibleForTesting
void createRolesIfNecessary(ImmutableList.Builder<Statement> statements) {
 // The roles directory must contain one file for each role definition
 if (roles.isPresent() && !roles.get().isEmpty()) {
   statements.add(exec("{md} " + rolePath));
   for (Role role : roles.get()) {
    statements.add(createOrOverwriteFile(rolePath + "/" + role.getName() + ".json",
       ImmutableSet.of(role.toJsonString())));
   }
 }
}

代码示例来源:origin: org.apache.jclouds/jclouds-scriptbuilder

@VisibleForTesting
void createRolesIfNecessary(ImmutableList.Builder<Statement> statements) {
 // The roles directory must contain one file for each role definition
 if (roles.isPresent() && !roles.get().isEmpty()) {
   statements.add(exec("{md} " + rolePath));
   for (Role role : roles.get()) {
    statements.add(createOrOverwriteFile(rolePath + "/" + role.getName() + ".json",
       ImmutableSet.of(role.toJsonString())));
   }
 }
}

代码示例来源:origin: io.cloudsoft.jclouds/jclouds-scriptbuilder

@VisibleForTesting
void createRolesIfNecessary(ImmutableList.Builder<Statement> statements) {
 // The roles directory must contain one file for each role definition
 if (roles.isPresent() && !roles.get().isEmpty()) {
   statements.add(exec("{md} " + rolePath));
   for (Role role : roles.get()) {
    statements.add(createOrOverwriteFile(rolePath + "/" + role.getName() + ".json",
       ImmutableSet.of(role.toJsonString())));
   }
 }
}

代码示例来源:origin: org.apache.jclouds/jclouds-scriptbuilder

@VisibleForTesting
void createSoloConfiguration(ImmutableList.Builder<Statement> statements) {
 statements.add(exec("{md} " + fileCachePath));
 for (String path : cookbookPath) {
   statements.add(exec("{md} " + path));
 }
 String cookbookPathJoined = Joiner.on(',').join(transform(cookbookPath, quote()));
 statements.add(createOrOverwriteFile(
    fileCachePath + "/solo.rb",
    ImmutableSet.of("file_cache_path \"" + fileCachePath + "\"", //
       "cookbook_path [" + cookbookPathJoined + "]", "role_path \"" + rolePath + "\"", "data_bag_path \""
          + databagPath + "\"")));
}

代码示例来源:origin: com.amysta.jclouds/jclouds-scriptbuilder

@VisibleForTesting
void createRolesIfNecessary(ImmutableList.Builder<Statement> statements) {
 // The roles directory must contain one file for each role definition
 if (roles.isPresent() && !roles.get().isEmpty()) {
   statements.add(exec("{md} " + rolePath));
   for (Role role : roles.get()) {
    statements.add(createOrOverwriteFile(rolePath + "/" + role.getName() + ".json",
       ImmutableSet.of(role.toJsonString())));
   }
 }
}

代码示例来源:origin: jclouds/legacy-jclouds

@VisibleForTesting
void createSoloConfiguration(ImmutableList.Builder<Statement> statements) {
 statements.add(exec("{md} " + fileCachePath));
 for (String path : cookbookPath) {
   statements.add(exec("{md} " + path));
 }
 String cookbookPathJoined = Joiner.on(',').join(transform(cookbookPath, quote()));
 statements.add(createOrOverwriteFile(
    fileCachePath + "/solo.rb",
    ImmutableSet.of("file_cache_path \"" + fileCachePath + "\"", //
       "cookbook_path [" + cookbookPathJoined + "]", "role_path \"" + rolePath + "\"", "data_bag_path \""
          + databagPath + "\"")));
}

代码示例来源:origin: org.jclouds/jclouds-scriptbuilder

public String render(OsFamily family) {
 checkNotNull(family, "family");
 if (family == OsFamily.WINDOWS)
   throw new UnsupportedOperationException("windows not yet implemented");
 Builder<Statement> statements = ImmutableList.builder();
 statements.add(createOrOverwriteFile(sudoers, ImmutableSet.of("root ALL = (ALL) ALL", "%wheel ALL = (ALL) NOPASSWD:ALL")));
 statements.add(exec("chmod 0440 " + sudoers));
 return new StatementList(statements.build()).render(family);
}

代码示例来源:origin: io.cloudsoft.jclouds/jclouds-scriptbuilder

public String render(OsFamily family) {
 checkNotNull(family, "family");
 if (family == OsFamily.WINDOWS)
   throw new UnsupportedOperationException("windows not yet implemented");
 Builder<Statement> statements = ImmutableList.builder();
 statements.add(createOrOverwriteFile(sudoers, ImmutableSet.of("root ALL = (ALL) ALL", "%wheel ALL = (ALL) NOPASSWD:ALL")));
 statements.add(exec("chmod 0440 " + sudoers));
 return new StatementList(statements.build()).render(family);
}

代码示例来源:origin: jclouds/legacy-jclouds

public void testCreateDefaultNodeConfiguration() {
 ImmutableList.Builder<Statement> statements = ImmutableList.builder();
 ChefSolo solo = ChefSolo.builder().build();
 solo.createNodeConfiguration(statements);
 ImmutableList<Statement> statementList = statements.build();
 Statement expected = createOrOverwriteFile(ChefSolo.DEFAULT_SOLO_PATH + "/node.json",
    ImmutableSet.of("{\"run_list\":[]}"));
 assertEquals(statementList.size(), 1);
 assertEquals(statementList.get(0).render(OsFamily.UNIX), expected.render(OsFamily.UNIX));
}

代码示例来源:origin: jclouds/legacy-jclouds

public void testCreateNodeConfigurationWithJsonAttributes() {
 ImmutableList.Builder<Statement> statements = ImmutableList.builder();
 ChefSolo solo = ChefSolo.builder().jsonAttributes("{\"foo\":\"bar\"}").build();
 solo.createNodeConfiguration(statements);
 ImmutableList<Statement> statementList = statements.build();
 Statement expected = createOrOverwriteFile(ChefSolo.DEFAULT_SOLO_PATH + "/node.json",
    ImmutableSet.of("{\"foo\":\"bar\",\"run_list\":[]}"));
 assertEquals(statementList.size(), 1);
 assertEquals(statementList.get(0).render(OsFamily.UNIX), expected.render(OsFamily.UNIX));
}

代码示例来源:origin: jclouds/legacy-jclouds

public void testCreateNodeConfigurationWithRunList() {
 ImmutableList.Builder<Statement> statements = ImmutableList.builder();
 RunList runlist = RunList.builder().recipe("foo").role("bar").build();
 ChefSolo solo = ChefSolo.builder().runlist(runlist).build();
 solo.createNodeConfiguration(statements);
 ImmutableList<Statement> statementList = statements.build();
 Statement expected = createOrOverwriteFile(ChefSolo.DEFAULT_SOLO_PATH + "/node.json",
    ImmutableSet.of("{\"run_list\":[\"recipe[foo]\",\"role[bar]\"]}"));
 assertEquals(statementList.size(), 1);
 assertEquals(statementList.get(0).render(OsFamily.UNIX), expected.render(OsFamily.UNIX));
}

代码示例来源:origin: jclouds/legacy-jclouds

public void testCreateDatabagsIfNecessaryWithOneDatabagAndCustomPath() {
 ImmutableList.Builder<Statement> statements = ImmutableList.builder();
 DataBag databag = DataBag.builder().name("foo").item("item", "{\"foo\":\"bar\"}").build();
 ChefSolo solo = ChefSolo.builder().dataBagPath("/tmp/databags").defineDataBag(databag).build();
 solo.createDatabagsIfNecessary(statements);
 ImmutableList<Statement> statementList = statements.build();
 Statement expected = createOrOverwriteFile("/tmp/databags/foo/item.json", ImmutableSet.of("{\"foo\":\"bar\"}"));
 assertEquals(statementList.size(), 3);
 assertEquals(statementList.get(0), exec("{md} /tmp/databags"));
 assertEquals(statementList.get(1), exec("{md} /tmp/databags/" + databag.getName()));
 assertEquals(statementList.get(2).render(OsFamily.UNIX), expected.render(OsFamily.UNIX));
}

代码示例来源:origin: jclouds/legacy-jclouds

public void testCreateDatabagsIfNecessaryWithOneDatabag() {
 ImmutableList.Builder<Statement> statements = ImmutableList.builder();
 DataBag databag = DataBag.builder().name("foo").item("item", "{\"foo\":\"bar\"}").build();
 ChefSolo solo = ChefSolo.builder().defineDataBag(databag).build();
 solo.createDatabagsIfNecessary(statements);
 ImmutableList<Statement> statementList = statements.build();
 Statement expected = createOrOverwriteFile(ChefSolo.DEFAULT_SOLO_PATH + "/data_bags/foo/item.json",
    ImmutableSet.of("{\"foo\":\"bar\"}"));
 assertEquals(statementList.size(), 3);
 assertEquals(statementList.get(0), exec("{md} " + ChefSolo.DEFAULT_SOLO_PATH + "/data_bags"));
 assertEquals(statementList.get(1), exec("{md} " + ChefSolo.DEFAULT_SOLO_PATH + "/data_bags/" + databag.getName()));
 assertEquals(statementList.get(2).render(OsFamily.UNIX), expected.render(OsFamily.UNIX));
}

代码示例来源:origin: jclouds/legacy-jclouds

public void testCreateNodeConfigurationWithJsonAttributesAndRunList() {
 ImmutableList.Builder<Statement> statements = ImmutableList.builder();
 RunList runlist = RunList.builder().recipe("foo").role("bar").build();
 ChefSolo solo = ChefSolo.builder().jsonAttributes("{\"foo\":\"bar\"}").runlist(runlist).build();
 solo.createNodeConfiguration(statements);
 ImmutableList<Statement> statementList = statements.build();
 Statement expected = createOrOverwriteFile(ChefSolo.DEFAULT_SOLO_PATH + "/node.json",
    ImmutableSet.of("{\"foo\":\"bar\",\"run_list\":[\"recipe[foo]\",\"role[bar]\"]}"));
 assertEquals(statementList.size(), 1);
 assertEquals(statementList.get(0).render(OsFamily.UNIX), expected.render(OsFamily.UNIX));
}

代码示例来源:origin: apache/jclouds

public void testCreateNodeConfigurationWithJsonAttributesAndRunList() {
 ImmutableList.Builder<Statement> statements = ImmutableList.builder();
 RunList runlist = RunList.builder().recipe("foo").role("bar").build();
 ChefSolo solo = ChefSolo.builder().jsonAttributes("{\"foo\":\"bar\"}").runlist(runlist).build();
 solo.createNodeConfiguration(statements);
 ImmutableList<Statement> statementList = statements.build();
 Statement expected = createOrOverwriteFile(ChefSolo.DEFAULT_SOLO_PATH + "/node.json",
    ImmutableSet.of("{\"foo\":\"bar\",\"run_list\":[\"recipe[foo]\",\"role[bar]\"]}"));
 assertEquals(statementList.size(), 1);
 assertEquals(statementList.get(0).render(OsFamily.UNIX), expected.render(OsFamily.UNIX));
}

代码示例来源:origin: jclouds/legacy-jclouds

public void testCreateRolesIfNecessaryWithOneRole() {
 ImmutableList.Builder<Statement> statements = ImmutableList.builder();
 RunList runlist = RunList.builder().recipe("bar").build();
 Role role = Role.builder().name("foo").runlist(runlist).build();
 ChefSolo solo = ChefSolo.builder().defineRole(role).build();
 solo.createRolesIfNecessary(statements);
 ImmutableList<Statement> statementList = statements.build();
 Statement expected = createOrOverwriteFile(ChefSolo.DEFAULT_SOLO_PATH + "/roles/" + role.getName() + ".json",
    ImmutableSet.of(role.toJsonString()));
 assertEquals(statementList.size(), 2);
 assertEquals(statementList.get(0), exec("{md} " + ChefSolo.DEFAULT_SOLO_PATH + "/roles"));
 assertEquals(statementList.get(1).render(OsFamily.UNIX), expected.render(OsFamily.UNIX));
}

代码示例来源:origin: jclouds/legacy-jclouds

public void testCreateRolesIfNecessaryWithOneRoleAndCustomPath() {
 ImmutableList.Builder<Statement> statements = ImmutableList.builder();
 RunList runlist = RunList.builder().recipe("bar").build();
 Role role = Role.builder().name("foo").runlist(runlist).build();
 ChefSolo solo = ChefSolo.builder().rolePath("/tmp/roles").defineRole(role).build();
 solo.createRolesIfNecessary(statements);
 ImmutableList<Statement> statementList = statements.build();
 Statement expected = createOrOverwriteFile("/tmp/roles/" + role.getName() + ".json",
    ImmutableSet.of(role.toJsonString()));
 assertEquals(statementList.size(), 2);
 assertEquals(statementList.get(0), exec("{md} /tmp/roles"));
 assertEquals(statementList.get(1).render(OsFamily.UNIX), expected.render(OsFamily.UNIX));
}

相关文章