You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/02/01 18:47:55 UTC
[19/51] [abbrv] [partial] brooklyn-library git commit: move subdir
from incubator up a level as it is promoted to its own repo (first
non-incubator commit!)
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/messaging/src/test/resources/qpid-test-config.xml
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/messaging/src/test/resources/qpid-test-config.xml b/brooklyn-library/software/messaging/src/test/resources/qpid-test-config.xml
deleted file mode 100644
index 5fcb028..0000000
--- a/brooklyn-library/software/messaging/src/test/resources/qpid-test-config.xml
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<broker>
- <plugin-directory>${QPID_HOME}/lib/plugins</plugin-directory>
- <cache-directory>${QPID_HOME}/cache</cache-directory>
- <connector>
- <ssl>
- <enabled>false</enabled>
- </ssl>
- </connector>
- <management>
- <enabled>true</enabled>
- <ssl>
- <enabled>false</enabled>
- </ssl>
- </management>
- <security>
- <pd-auth-manager>
- <principal-database>
- <class>org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase
- </class>
- <attributes>
- <attribute>
- <name>passwordFile</name>
- <value>${QPID_HOME}/etc/passwd</value>
- </attribute>
- </attributes>
- </principal-database>
- </pd-auth-manager>
- <allow-all />
- <msg-auth>false</msg-auth>
- </security>
- <virtualhosts>
- <default>localhost</default>
- <virtualhost>
- <name>localhost</name>
- <localhost>
- <custom-exchanges>
- <class-name>monterey.qpid.plugin.exchanges.switcher.SwitcherExchangeType</class-name>
- </custom-exchanges>
- <store>
- <class>org.apache.qpid.server.store.MemoryMessageStore</class>
- </store>
- </localhost>
- </virtualhost>
- </virtualhosts>
- <queue>
- <auto_register>true</auto_register>
- </queue>
- <status-updates>ON</status-updates>
-</broker>
-
-
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/monitoring/pom.xml
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/monitoring/pom.xml b/brooklyn-library/software/monitoring/pom.xml
deleted file mode 100644
index 299d788..0000000
--- a/brooklyn-library/software/monitoring/pom.xml
+++ /dev/null
@@ -1,112 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <packaging>jar</packaging>
-
- <artifactId>brooklyn-software-monitoring</artifactId>
-
- <name>Brooklyn Monitoring Software Entities</name>
- <description>
- Brooklyn entities for monitoring processes
- </description>
- <parent>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-library</artifactId>
- <version>0.9.0-SNAPSHOT</version> <!-- BROOKLYN_VERSION -->
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-software-base</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-core</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-utils-common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-utils-groovy</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-test-support</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-core</artifactId>
- <version>${project.version}</version>
- <classifier>tests</classifier>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-software-base</artifactId>
- <version>${project.version}</version>
- <classifier>tests</classifier>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-software-database</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <!-- bring in jclouds for testing -->
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-locations-jclouds</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/monitoring/src/main/java/org/apache/brooklyn/entity/monitoring/monit/MonitDriver.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/monitoring/src/main/java/org/apache/brooklyn/entity/monitoring/monit/MonitDriver.java b/brooklyn-library/software/monitoring/src/main/java/org/apache/brooklyn/entity/monitoring/monit/MonitDriver.java
deleted file mode 100644
index d088928..0000000
--- a/brooklyn-library/software/monitoring/src/main/java/org/apache/brooklyn/entity/monitoring/monit/MonitDriver.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.entity.monitoring.monit;
-
-import org.apache.brooklyn.entity.software.base.SoftwareProcessDriver;
-
-public interface MonitDriver extends SoftwareProcessDriver {
-
- String getStatusCmd();
-
- String getExpandedInstallDir();
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/monitoring/src/main/java/org/apache/brooklyn/entity/monitoring/monit/MonitNode.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/monitoring/src/main/java/org/apache/brooklyn/entity/monitoring/monit/MonitNode.java b/brooklyn-library/software/monitoring/src/main/java/org/apache/brooklyn/entity/monitoring/monit/MonitNode.java
deleted file mode 100644
index 2e3798c..0000000
--- a/brooklyn-library/software/monitoring/src/main/java/org/apache/brooklyn/entity/monitoring/monit/MonitNode.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.entity.monitoring.monit;
-
-import java.util.Map;
-
-import org.apache.brooklyn.api.catalog.Catalog;
-import org.apache.brooklyn.api.entity.ImplementedBy;
-import org.apache.brooklyn.api.objs.HasShortName;
-import org.apache.brooklyn.api.sensor.AttributeSensor;
-import org.apache.brooklyn.config.ConfigKey;
-import org.apache.brooklyn.core.config.ConfigKeys;
-import org.apache.brooklyn.core.entity.Attributes;
-import org.apache.brooklyn.core.sensor.BasicAttributeSensorAndConfigKey;
-import org.apache.brooklyn.core.sensor.Sensors;
-import org.apache.brooklyn.core.sensor.BasicAttributeSensorAndConfigKey.StringAttributeSensorAndConfigKey;
-import org.apache.brooklyn.entity.software.base.SoftwareProcess;
-import org.apache.brooklyn.util.core.flags.SetFromFlag;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.reflect.TypeToken;
-
-@Catalog(name="Monit Node", description="Monit is a free open source utility for managing and monitoring, processes, programs, files, directories and filesystems on a UNIX system")
-@ImplementedBy(MonitNodeImpl.class)
-public interface MonitNode extends SoftwareProcess, HasShortName {
- // e.g. https://mmonit.com/monit/dist/binary/5.6/monit-5.6-linux-x64.tar.gz
- @SetFromFlag("downloadUrl")
- public static final BasicAttributeSensorAndConfigKey<String> DOWNLOAD_URL = new StringAttributeSensorAndConfigKey(
- Attributes.DOWNLOAD_URL, "https://mmonit.com/monit/dist/binary/${version}/monit-${version}-${driver.osTag}.tar.gz");
-
- @SetFromFlag("version")
- public static final ConfigKey<String> SUGGESTED_VERSION = ConfigKeys.newConfigKeyWithDefault(SoftwareProcess.SUGGESTED_VERSION, "5.9");
-
- @SetFromFlag("controlFileUrl")
- public static final ConfigKey<String> CONTROL_FILE_URL = ConfigKeys.newStringConfigKey("monit.control.url", "URL where monit control (.monitrc) file can be found", "");
-
- @SuppressWarnings("serial")
- public static final ConfigKey<Map<String, Object>> CONTROL_FILE_SUBSTITUTIONS = ConfigKeys.newConfigKey(new TypeToken<Map<String, Object>>(){}, "monit.control.substitutions",
- "Additional substitutions to be used in the control file template", ImmutableMap.<String, Object>of());
-
- public static final AttributeSensor<String> MONIT_TARGET_PROCESS_NAME = Sensors.newStringSensor("monit.target.process.name");
-
- public static final AttributeSensor<String> MONIT_TARGET_PROCESS_STATUS = Sensors.newStringSensor("monit.target.process.status");
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/monitoring/src/main/java/org/apache/brooklyn/entity/monitoring/monit/MonitNodeImpl.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/monitoring/src/main/java/org/apache/brooklyn/entity/monitoring/monit/MonitNodeImpl.java b/brooklyn-library/software/monitoring/src/main/java/org/apache/brooklyn/entity/monitoring/monit/MonitNodeImpl.java
deleted file mode 100644
index 2702994..0000000
--- a/brooklyn-library/software/monitoring/src/main/java/org/apache/brooklyn/entity/monitoring/monit/MonitNodeImpl.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.entity.monitoring.monit;
-
-import java.util.Map;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.entity.software.base.SoftwareProcessImpl;
-import org.apache.brooklyn.feed.ssh.SshFeed;
-import org.apache.brooklyn.feed.ssh.SshPollConfig;
-import org.apache.brooklyn.feed.ssh.SshPollValue;
-import org.apache.brooklyn.location.ssh.SshMachineLocation;
-import org.apache.brooklyn.util.text.Strings;
-import org.apache.brooklyn.util.time.Duration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Function;
-import com.google.common.collect.Iterables;
-
-public class MonitNodeImpl extends SoftwareProcessImpl implements MonitNode {
-
- private static final Logger LOG = LoggerFactory.getLogger(MonitNodeImpl.class);
-
- private SshFeed feed;
-
- public MonitNodeImpl() {
- }
-
- public MonitNodeImpl(Map<?,?> flags) {
- super(flags, null);
- }
-
- public MonitNodeImpl(Map<?,?> flags, Entity parent) {
- super(flags, parent);
- }
-
- @Override
- public Class<? extends MonitDriver> getDriverInterface() {
- return MonitDriver.class;
- }
-
- @Override
- public MonitDriver getDriver() {
- return (MonitDriver) super.getDriver();
- }
-
- @Override
- protected void connectSensors() {
- super.connectSensors();
- Location machine = Iterables.get(getLocations(), 0, null);
-
- if (machine instanceof SshMachineLocation) {
- String cmd = getDriver().getStatusCmd();
- feed = SshFeed.builder()
- .entity(this)
- .period(Duration.FIVE_SECONDS)
- .machine((SshMachineLocation) machine)
- .poll(new SshPollConfig<Boolean>(SERVICE_UP)
- .command(cmd)
- .setOnSuccess(true)
- .setOnFailureOrException(false))
- .poll(new SshPollConfig<String>(MONIT_TARGET_PROCESS_NAME)
- .command(cmd)
- .onSuccess(new Function<SshPollValue, String>() {
- @Override
- public String apply(SshPollValue input) {
- String process = Strings.getFirstWordAfter(input.getStdout(), "Process");
- return process;
- }
- })
- .setOnFailureOrException(null))
- .poll(new SshPollConfig<String>(MONIT_TARGET_PROCESS_STATUS)
- .command(cmd)
- .onSuccess(new Function<SshPollValue, String>() {
- @Override
- public String apply(SshPollValue input) {
- return Strings.trim(Strings.getRemainderOfLineAfter(input.getStdout(), "status"));
- }
- })
- .setOnFailureOrException(null))
- .build();
- } else {
- LOG.warn("Location(s) {} not an ssh-machine location, so not polling for status; setting serviceUp immediately", getLocations());
- sensors().set(SERVICE_UP, true);
- }
- }
-
- @Override
- protected void disconnectSensors() {
- if (feed != null) feed.stop();
- }
-
- @Override
- public String getShortName() {
- return "Monit";
- }
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/monitoring/src/main/java/org/apache/brooklyn/entity/monitoring/monit/MonitSshDriver.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/monitoring/src/main/java/org/apache/brooklyn/entity/monitoring/monit/MonitSshDriver.java b/brooklyn-library/software/monitoring/src/main/java/org/apache/brooklyn/entity/monitoring/monit/MonitSshDriver.java
deleted file mode 100644
index e89ce90..0000000
--- a/brooklyn-library/software/monitoring/src/main/java/org/apache/brooklyn/entity/monitoring/monit/MonitSshDriver.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.entity.monitoring.monit;
-
-import static java.lang.String.format;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.brooklyn.api.location.OsDetails;
-import org.apache.brooklyn.core.entity.Entities;
-import org.apache.brooklyn.entity.software.base.AbstractSoftwareProcessSshDriver;
-import org.apache.brooklyn.entity.software.base.lifecycle.ScriptHelper;
-import org.apache.brooklyn.location.ssh.SshMachineLocation;
-import org.apache.brooklyn.util.collections.MutableMap;
-import org.apache.brooklyn.util.os.Os;
-import org.apache.brooklyn.util.ssh.BashCommands;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-
-public class MonitSshDriver extends AbstractSoftwareProcessSshDriver implements MonitDriver {
-
- private String remoteControlFilePath;
-
- public MonitSshDriver(MonitNodeImpl entity, SshMachineLocation machine) {
- super(entity, machine);
- }
-
- @Override
- public void preInstall() {
- resolver = Entities.newDownloader(this);
- setExpandedInstallDir(Os.mergePaths(getInstallDir(), resolver.getUnpackedDirectoryName(format("monit-%s", getVersion()))));
- }
-
- @Override
- public void install() {
- List<String> urls = resolver.getTargets();
- String saveAs = resolver.getFilename();
-
- List<String> commands = ImmutableList.<String>builder()
- .add(BashCommands.INSTALL_TAR)
- .add(BashCommands.INSTALL_CURL)
- .add(BashCommands.commandToDownloadUrlsAs(urls, saveAs))
- .add(format("tar xfvz %s", saveAs))
- .build();
-
- newScript(INSTALLING)
- .failOnNonZeroResultCode()
- .body
- .append(commands)
- .execute();
- }
-
- @Override
- public void customize() {
- newScript(CUSTOMIZING)
- .body.append("echo copying control file")
- .execute(); //create the directory
- String controlFileUrl = getEntity().getConfig(MonitNode.CONTROL_FILE_URL);
- remoteControlFilePath = getRunDir() + "/monit.monitrc";
- copyTemplate(controlFileUrl, remoteControlFilePath, false, getEntity().getConfig(MonitNode.CONTROL_FILE_SUBSTITUTIONS));
- // Monit demands the control file has permissions <= 0700
- newScript(CUSTOMIZING)
- .body.append("chmod 600 " + remoteControlFilePath)
- .execute();
- }
-
- @Override
- public void launch() {
- // NOTE: executing monit in daemon mode will spawn a separate process for the monit daemon so the value of $! cannot be used
- // instead we use the -p argument
- String command = format("touch %s && nohup %s/bin/monit -c %s -p %s > out.log 2> err.log < /dev/null &", getMonitPidFile(),
- getExpandedInstallDir(), remoteControlFilePath, getMonitPidFile());
- newScript(MutableMap.of("usePidFile", false), LAUNCHING)
- .updateTaskAndFailOnNonZeroResultCode()
- .body.append(command)
- .execute();
- }
-
- @Override
- public boolean isRunning() {
- Map<String,?> flags = ImmutableMap.of("usePidFile", getMonitPidFile());
- return newScript(flags, CHECK_RUNNING).execute() == 0;
- }
-
- @Override
- public void stop() {
- new ScriptHelper(this, "Send SIGTERM to Monit process")
- .body.append("kill -s SIGTERM `cat " + getMonitPidFile() + "`")
- .execute();
- }
-
- protected String getMonitPidFile() {
- // Monit seems to dislike starting with a relative path to a pid file.
- return getRunDir() + "/" + AbstractSoftwareProcessSshDriver.PID_FILENAME;
- }
-
- public String getMonitLogFile() {
- return getRunDir() + "/monit.log";
- }
-
- public String getOsTag() {
- OsDetails os = getLocation().getOsDetails();
- if (os == null) {
- // Default to 64 bit linux
- return "linux-x64";
- } else if (os.isMac()) {
- return "macosx-universal";
- } else {
- String arch = os.is64bit() ? "x64" : "x86";
- return "linux-" + arch;
- }
- }
-
- @Override
- public String getStatusCmd() {
- return format("%s/bin/monit -c %s status", getExpandedInstallDir(), remoteControlFilePath);
- }
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/monitoring/src/test/java/org/apache/brooklyn/entity/monitoring/monit/MonitIntegrationTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/monitoring/src/test/java/org/apache/brooklyn/entity/monitoring/monit/MonitIntegrationTest.java b/brooklyn-library/software/monitoring/src/test/java/org/apache/brooklyn/entity/monitoring/monit/MonitIntegrationTest.java
deleted file mode 100644
index f19e6b9..0000000
--- a/brooklyn-library/software/monitoring/src/test/java/org/apache/brooklyn/entity/monitoring/monit/MonitIntegrationTest.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.entity.monitoring.monit;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotEquals;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.util.Map;
-import java.util.concurrent.Callable;
-
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.location.MachineDetails;
-import org.apache.brooklyn.core.entity.Entities;
-import org.apache.brooklyn.core.sensor.DependentConfiguration;
-import org.apache.brooklyn.core.test.BrooklynAppLiveTestSupport;
-import org.apache.brooklyn.entity.database.mysql.MySqlNode;
-import org.apache.brooklyn.entity.software.base.SameServerEntity;
-import org.apache.brooklyn.entity.software.base.SoftwareProcess;
-import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
-import org.apache.brooklyn.test.Asserts;
-import org.apache.brooklyn.test.EntityTestUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Function;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.io.Files;
-
-public class MonitIntegrationTest extends BrooklynAppLiveTestSupport {
-
- private static final Logger LOG = LoggerFactory.getLogger(MonitIntegrationTest.class);
-
- LocalhostMachineProvisioningLocation loc;
- Process testProcess;
-
- @BeforeMethod(alwaysRun=true)
- public void setUp() throws Exception {
- super.setUp();
- loc = app.newLocalhostProvisioningLocation();
- testProcess = (new ProcessBuilder()).command("vi", "monittest").start();
- }
-
- @AfterMethod(alwaysRun = true)
- @Override
- public void tearDown() throws Exception {
- try {
- super.tearDown();
- } finally {
- if (testProcess != null) {
- testProcess.destroy();
- }
- }
- }
-
- @Test(groups = "Integration")
- public void test_localhost() throws Exception {
- final MonitNode monitNode = app.createAndManageChild(EntitySpec.create(MonitNode.class)
- .configure(MonitNode.CONTROL_FILE_URL, "classpath:///org/apache/brooklyn/entity/monitoring/monit/monit.monitrc"));
- app.start(ImmutableSet.of(loc));
- LOG.info("Monit started");
- EntityTestUtils.assertAttributeEqualsEventually(monitNode, MonitNode.MONIT_TARGET_PROCESS_STATUS, "Running");
- }
-
- @Test(groups = "Integration")
- public void test_monitorMySql() throws Exception {
- SameServerEntity sameServerEntity = app.createAndManageChild(EntitySpec.create(SameServerEntity.class));
- MySqlNode mySqlNode = sameServerEntity.addChild(EntitySpec.create(MySqlNode.class));
-
- Function<String, Map<String, Object>> controlFileSubstitutionsFunction = new Function<String, Map<String, Object>>() {
- public Map<String, Object> apply(String input) {
- return ImmutableMap.<String, Object>of("targetPidFile", input);
- }
- };
- EntitySpec<MonitNode> monitSpec = EntitySpec.create(MonitNode.class)
- .configure(MonitNode.CONTROL_FILE_URL, "classpath:///org/apache/brooklyn/entity/monitoring/monit/monitmysql.monitrc")
- .configure(MonitNode.CONTROL_FILE_SUBSTITUTIONS, DependentConfiguration.valueWhenAttributeReady(mySqlNode,
- SoftwareProcess.PID_FILE, controlFileSubstitutionsFunction));
- final MonitNode monitNode = sameServerEntity.addChild(monitSpec);
-
- app.start(ImmutableSet.of(loc));
- LOG.info("Monit and MySQL started");
- EntityTestUtils.assertAttributeEqualsEventually(monitNode, MonitNode.MONIT_TARGET_PROCESS_STATUS, "Running");
- mySqlNode.stop();
- Asserts.succeedsEventually(new Runnable() {
- @Override
- public void run() {
- String targetStatus = monitNode.getAttribute(MonitNode.MONIT_TARGET_PROCESS_STATUS);
- LOG.debug("MonitNode target status: {}", targetStatus);
- assertNotEquals(targetStatus, "Running");
- }
- });
- mySqlNode.restart();
- EntityTestUtils.assertAttributeEqualsEventually(monitNode, MonitNode.MONIT_TARGET_PROCESS_STATUS, "Running");
- }
-
- @Test(groups = "Integration")
- public void test_monitorMySqlAutoRestart() throws Exception {
- // This runs on localhost; free to obtain another machine with impunity.
- final String osFlavor;
- MachineDetails machineDetails = app.getExecutionContext().submit(new Callable<MachineDetails>() {
- public MachineDetails call() throws Exception {
- return loc.obtain().getMachineDetails();
- }}).get();
- if (machineDetails.getOsDetails().isMac()) {
- osFlavor = "osx10.6-x86_64";
- } else if (machineDetails.getOsDetails().isWindows()) {
- throw new UnsupportedOperationException("Windows not supported for test_monitorMySqlAutoRestart");
- } else {
- osFlavor = "linux2.6-x86_64"; // assume 64 bit linux
- }
-
- // The monit node needs to know the installation and run directory of the mysql dir, so we need to specify it explicitly
- File tempDir = Files.createTempDir();
- tempDir.deleteOnExit();
- final String mySqlInstallDir = tempDir.getAbsolutePath() + "/install";
- final String mySqlRunDir = tempDir.getAbsolutePath() + "/run";
- final String mySqlDataDir = tempDir.getAbsolutePath() + "/data";
- final String mySqlVersion = MySqlNode.SUGGESTED_VERSION.getDefaultValue();
-
- SameServerEntity sameServerEntity = app.createAndManageChild(EntitySpec.create(SameServerEntity.class));
- final MySqlNode mySqlNode = sameServerEntity.addChild(EntitySpec.create(MySqlNode.class)
- .configure(MySqlNode.INSTALL_DIR, mySqlInstallDir)
- .configure(MySqlNode.RUN_DIR, mySqlRunDir)
- .configure(MySqlNode.DATA_DIR, mySqlDataDir));
-
- Function<String, Map<String, Object>> controlFileSubstitutionsFunction = new Function<String, Map<String, Object>>() {
- public Map<String, Object> apply(String input) {
- return ImmutableMap.<String, Object>of(
- "targetPidFile", input,
- "mySqlInstallDir", mySqlInstallDir,
- "mySqlRunDir", mySqlRunDir,
- "mySqlVersion", mySqlVersion,
- "mySqlOsFlavor", osFlavor
- );
- }
- };
-
- final MonitNode monitNode = sameServerEntity.addChild(EntitySpec.create(MonitNode.class)
- .configure(MonitNode.CONTROL_FILE_URL, "classpath:///org/apache/brooklyn/entity/monitoring/monit/monitmysqlwithrestart.monitrc")
- .configure(MonitNode.CONTROL_FILE_SUBSTITUTIONS, DependentConfiguration.valueWhenAttributeReady(mySqlNode,
- SoftwareProcess.PID_FILE, controlFileSubstitutionsFunction)));
-
- app.start(ImmutableSet.of(loc));
- LOG.info("Monit and MySQL started");
- final String[] initialPid = {""};
- Asserts.succeedsEventually(new Runnable() {
- @Override
- public void run() {
- String targetStatus = monitNode.getAttribute(MonitNode.MONIT_TARGET_PROCESS_STATUS);
- LOG.debug("MonitNode target status: {}", targetStatus);
- assertEquals(targetStatus, "Running");
- try {
- initialPid[0] = Files.readFirstLine(new File(mySqlNode.getAttribute(SoftwareProcess.PID_FILE)), Charset.defaultCharset());
- LOG.debug("Initial PID: {}", initialPid[0]);
- } catch (IOException e) {
- Asserts.fail("Could not read PID file: " + e);
- }
- }
- });
- mySqlNode.stop();
- EntityTestUtils.assertAttributeEqualsEventually(monitNode, MonitNode.MONIT_TARGET_PROCESS_STATUS, "Running");
-
- // NOTE: Do not manually restart the mySqlNode, it should be restarted by monit
- Asserts.succeedsEventually(new Runnable() {
- @Override
- public void run() {
- try {
- String pidFileLocation = mySqlNode.getAttribute(SoftwareProcess.PID_FILE);
- String newPid = Files.readFirstLine(new File(pidFileLocation), Charset.defaultCharset());
- LOG.debug("Old PID: {}, New PID: {} read from PID file: {}", new String[] {initialPid[0], newPid, pidFileLocation});
- assertNotEquals(initialPid[0], newPid, "Process PID has not changed");
- } catch (IOException e) {
- Asserts.fail("Could not read PID file: " + e);
- }
- String targetStatus = monitNode.getAttribute(MonitNode.MONIT_TARGET_PROCESS_STATUS);
- LOG.debug("MonitNode target status: {}", targetStatus);
- assertEquals(targetStatus, "Running");
- }
- });
- }
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/monitoring/src/test/resources/org/apache/brooklyn/entity/monitoring/monit/monit.monitrc
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/monitoring/src/test/resources/org/apache/brooklyn/entity/monitoring/monit/monit.monitrc b/brooklyn-library/software/monitoring/src/test/resources/org/apache/brooklyn/entity/monitoring/monit/monit.monitrc
deleted file mode 100644
index 4a8bbe2..0000000
--- a/brooklyn-library/software/monitoring/src/test/resources/org/apache/brooklyn/entity/monitoring/monit/monit.monitrc
+++ /dev/null
@@ -1,30 +0,0 @@
-[#ftl]
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-set httpd port 2812 and use address localhost
-allow localhost
-set daemon 5
-set pidfile ${driver.runDir}/pid.txt
-set logfile ${driver.runDir}/monit.log
-
-check process vi
- matching "vi monittest"
- group test
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/monitoring/src/test/resources/org/apache/brooklyn/entity/monitoring/monit/monitmysql.monitrc
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/monitoring/src/test/resources/org/apache/brooklyn/entity/monitoring/monit/monitmysql.monitrc b/brooklyn-library/software/monitoring/src/test/resources/org/apache/brooklyn/entity/monitoring/monit/monitmysql.monitrc
deleted file mode 100644
index b5bc4a6..0000000
--- a/brooklyn-library/software/monitoring/src/test/resources/org/apache/brooklyn/entity/monitoring/monit/monitmysql.monitrc
+++ /dev/null
@@ -1,29 +0,0 @@
-[#ftl]
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-set httpd port 2812 and use address localhost
-allow localhost
-set daemon 5
-set pidfile ${driver.runDir}/pid.txt
-set logfile ${driver.runDir}/monit.log
-
-check process mysqld with pidfile ${targetPidFile}
- group database
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/monitoring/src/test/resources/org/apache/brooklyn/entity/monitoring/monit/monitmysqlwithrestart.monitrc
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/monitoring/src/test/resources/org/apache/brooklyn/entity/monitoring/monit/monitmysqlwithrestart.monitrc b/brooklyn-library/software/monitoring/src/test/resources/org/apache/brooklyn/entity/monitoring/monit/monitmysqlwithrestart.monitrc
deleted file mode 100644
index ccd76dc..0000000
--- a/brooklyn-library/software/monitoring/src/test/resources/org/apache/brooklyn/entity/monitoring/monit/monitmysqlwithrestart.monitrc
+++ /dev/null
@@ -1,31 +0,0 @@
-[#ftl]
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-set httpd port 2812 and use address localhost
-allow localhost
-set daemon 5
-set pidfile ${driver.runDir}/pid.txt
-set logfile ${driver.runDir}/monit.log
-
-check process mysqld with pidfile ${targetPidFile}
- group database
- mode active
- start program = "/bin/bash -c 'rm ${mySqlRunDir}/pid.txt ; ${mySqlInstallDir}/mysql-${mySqlVersion}-${mySqlOsFlavor}/bin/mysqld --defaults-file=${mySqlRunDir}/mymysql.cnf --user=root >> ${mySqlRunDir}/out.log 2>> ${mySqlRunDir}/err.log < /dev/null & echo $! > ${mySqlRunDir}/pid.txt'"
- stop program = "/bin/bash -c 'kill -s SIGTERM $(cat ${mySqlRunDir}/pid.txt) ; kill -s KILL $(cat ${mySqlRunDir}/pid.txt) ; rm ${mySqlRunDir}/pid.txt'"
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/network/pom.xml
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/network/pom.xml b/brooklyn-library/software/network/pom.xml
deleted file mode 100644
index 3c785e6..0000000
--- a/brooklyn-library/software/network/pom.xml
+++ /dev/null
@@ -1,97 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <packaging>jar</packaging>
- <artifactId>brooklyn-software-network</artifactId>
- <name>Brooklyn Network Software Entities</name>
- <description>
- Brooklyn entities for network service software processes
- </description>
- <parent>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-library</artifactId>
- <version>0.9.0-SNAPSHOT</version> <!-- BROOKLYN_VERSION -->
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-software-base</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-core</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-utils-common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-test-support</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-core</artifactId>
- <version>${project.version}</version>
- <classifier>tests</classifier>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-software-base</artifactId>
- <version>${project.version}</version>
- <classifier>tests</classifier>
- <scope>test</scope>
- </dependency>
- <!-- bring in jclouds for testing -->
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-locations-jclouds</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/network/src/main/java/org/apache/brooklyn/entity/network/bind/BindDnsServer.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/network/src/main/java/org/apache/brooklyn/entity/network/bind/BindDnsServer.java b/brooklyn-library/software/network/src/main/java/org/apache/brooklyn/entity/network/bind/BindDnsServer.java
deleted file mode 100644
index f5b5e21..0000000
--- a/brooklyn-library/software/network/src/main/java/org/apache/brooklyn/entity/network/bind/BindDnsServer.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.entity.network.bind;
-
-import java.util.Map;
-
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.collect.Multimap;
-import com.google.common.reflect.TypeToken;
-
-import org.apache.brooklyn.api.catalog.Catalog;
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.ImplementedBy;
-import org.apache.brooklyn.api.sensor.AttributeSensor;
-import org.apache.brooklyn.config.ConfigKey;
-import org.apache.brooklyn.core.annotation.Effector;
-import org.apache.brooklyn.core.config.ConfigKeys;
-import org.apache.brooklyn.core.location.PortRanges;
-import org.apache.brooklyn.core.sensor.PortAttributeSensorAndConfigKey;
-import org.apache.brooklyn.core.sensor.Sensors;
-import org.apache.brooklyn.entity.group.DynamicGroup;
-import org.apache.brooklyn.entity.software.base.SoftwareProcess;
-import org.apache.brooklyn.util.core.flags.SetFromFlag;
-import org.apache.brooklyn.util.net.Cidr;
-
-/**
- * This sets up a BIND DNS server.
- */
-@Catalog(name="BIND", description="BIND is an Internet Domain Name Server.", iconUrl="classpath:///isc-logo.png")
-@ImplementedBy(BindDnsServerImpl.class)
-public interface BindDnsServer extends SoftwareProcess {
-
- @SetFromFlag("filter")
- ConfigKey<Predicate<? super Entity>> ENTITY_FILTER = ConfigKeys.newConfigKey(new TypeToken<Predicate<? super Entity>>() {},
- "bind.entity.filter", "Filter for entities which will use the BIND DNS service for name resolution." +
- "Default is all instances of SoftwareProcess in the application.",
- Predicates.instanceOf(SoftwareProcess.class));
-
- @SetFromFlag("domainName")
- ConfigKey<String> DOMAIN_NAME = ConfigKeys.newStringConfigKey(
- "bind.domain.name", "The DNS domain name to serve", "brooklyn.local");
-
- @SetFromFlag("reverseLookupNetwork")
- ConfigKey<String> REVERSE_LOOKUP_NETWORK = ConfigKeys.newStringConfigKey(
- "bind.reverse-lookup.address", "Network address for reverse lookup zone");
-
- @SetFromFlag("subnet")
- ConfigKey<String> MANAGEMENT_CIDR = ConfigKeys.newStringConfigKey(
- "bind.access.cidr", "Subnet CIDR or ACL allowed to access DNS", "0.0.0.0/0");
-
- @SetFromFlag("hostnameSensor")
- ConfigKey<AttributeSensor<String>> HOSTNAME_SENSOR = ConfigKeys.newConfigKey(new TypeToken<AttributeSensor<String>>() {},
- "bind.sensor.hostname", "Sensor on managed entities that reports the hostname");
-
- PortAttributeSensorAndConfigKey DNS_PORT =
- new PortAttributeSensorAndConfigKey("bind.port", "BIND DNS port for TCP and UDP", PortRanges.fromString("53"));
-
- @SetFromFlag("zoneFileTemplate")
- ConfigKey<String> DOMAIN_ZONE_FILE_TEMPLATE = ConfigKeys.newStringConfigKey(
- "bind.template.domain-zone", "The BIND domain zone file to serve (as FreeMarker template)",
- "classpath://org/apache/brooklyn/entity/network/bind/domain.zone");
-
- @SetFromFlag("reverseZoneFileTemplate")
- ConfigKey<String> REVERSE_ZONE_FILE_TEMPLATE = ConfigKeys.newStringConfigKey(
- "bind.template.reverse-zone", "The BIND reverse lookup zone file to serve (as FreeMarker template)",
- "classpath://org/apache/brooklyn/entity/network/bind/reverse.zone");
-
- @SetFromFlag("namedConfTemplate")
- ConfigKey<String> NAMED_CONF_TEMPLATE = ConfigKeys.newStringConfigKey(
- "bind.template.named-conf", "The BIND named configuration file (as FreeMarker template)",
- "classpath://org/apache/brooklyn/entity/network/bind/named.conf");
-
- @SetFromFlag("updateRootZonesFile")
- ConfigKey<Boolean> UPDATE_ROOT_ZONES_FILE = ConfigKeys.newBooleanConfigKey(
- "bind.updateRootZones", "Instructs the entity to fetch the latest root zones file from ftp.rs.internic.net.",
- Boolean.FALSE);
-
-
- /* Reverse lookup attributes. */
-
- AttributeSensor<Cidr> REVERSE_LOOKUP_CIDR = Sensors.newSensor(Cidr.class,
- "bind.reverse-lookup.cidr", "The network CIDR that hosts must have for reverse lookup entries " +
- "to be added (default uses server address /24)");
-
- AttributeSensor<String> REVERSE_LOOKUP_DOMAIN = Sensors.newStringSensor(
- "bind.reverse-lookup.domain", "The in-addr.arpa reverse lookup domain name");
-
-
- /* Configuration applicable to clients of the BIND DNS service. */
-
- @SetFromFlag("replaceResolvConf")
- ConfigKey<Boolean> REPLACE_RESOLV_CONF = ConfigKeys.newBooleanConfigKey(
- "bind.resolv-conf.replce", "Set to replace resolv.conf with the template (default is to use eth0 script)", Boolean.FALSE);
-
- @SetFromFlag("interfaceConfigTemplate")
- ConfigKey<String> INTERFACE_CONFIG_TEMPLATE = ConfigKeys.newStringConfigKey(
- "bind.template.interface-cfg", "The network interface configuration file for clients (as FreeMarker template)",
- "classpath://org/apache/brooklyn/entity/network/bind/ifcfg");
-
- @SetFromFlag("interfaceConfigTemplate")
- ConfigKey<String> RESOLV_CONF_TEMPLATE = ConfigKeys.newStringConfigKey(
- "bind.template.resolv-conf", "The resolver configuration file for clients (as FreeMarker template)",
- "classpath://org/apache/brooklyn/entity/network/bind/resolv.conf");
-
- AttributeSensor<DynamicGroup> ENTITIES = Sensors.newSensor(DynamicGroup.class,
- "bind.entities", "The entities being managed by this server");
-
- AttributeSensor<Multimap<String, String>> ADDRESS_MAPPINGS = Sensors.newSensor(new TypeToken<Multimap<String, String>>() {},
- "bind.mappings", "All address mappings maintained by the server, in form address -> [names]");
-
- AttributeSensor<Map<String, String>> A_RECORDS = Sensors.newSensor(new TypeToken<Map<String, String>>() {},
- "bind.records.a", "All A records for the server, in form name -> address");
-
- AttributeSensor<Multimap<String, String>> CNAME_RECORDS = Sensors.newSensor(new TypeToken<Multimap<String, String>>() {},
- "bind.records.cname", "All CNAME records for the server, in form name -> [names]");
-
- AttributeSensor<Map<String, String>> PTR_RECORDS = Sensors.newSensor(new TypeToken<Map<String, String>>() {},
- "bind.records.ptr", "All PTR records for the server, in form address -> name. Entries will be in REVERSE_LOOKUP_CIDR. " +
- "Entries are guaranteed to have an inverse mapping in A_RECORDS.");
-
- AttributeSensor<Long> SERIAL = Sensors.newLongSensor(
- "bind.serial", "A serial number guaranteed to be valid for use in a modified domain.zone or reverse.zone file");
-
- public Multimap<String, String> getAddressMappings();
-
- /**
- * @return the IP to hostname mappings stored in this DNS server's conf file
- * @deprecated since 0.7.0 use {@link #PTR_RECORDS} instead.
- */
- @Deprecated
- @Effector(description="Gets the IP to hostname mappings stored in this DNS server's conf file")
- public Map<String, String> getReverseMappings();
-
- /**
- * @return the predicate used to filter entities for the Bind server to manage.
- */
- Predicate<? super Entity> getEntityFilter();
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/network/src/main/java/org/apache/brooklyn/entity/network/bind/BindDnsServerDriver.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/network/src/main/java/org/apache/brooklyn/entity/network/bind/BindDnsServerDriver.java b/brooklyn-library/software/network/src/main/java/org/apache/brooklyn/entity/network/bind/BindDnsServerDriver.java
deleted file mode 100644
index 8eb7d57..0000000
--- a/brooklyn-library/software/network/src/main/java/org/apache/brooklyn/entity/network/bind/BindDnsServerDriver.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.entity.network.bind;
-
-import org.apache.brooklyn.entity.software.base.SoftwareProcessDriver;
-
-import com.google.common.annotations.VisibleForTesting;
-
-public interface BindDnsServerDriver extends SoftwareProcessDriver {
-
- /**
- * Uploads configuration files and restarts the service.
- */
- void updateBindConfiguration();
-
- /**
- * @return a support class appropriate for the machine the server is running on.
- */
- @VisibleForTesting
- BindOsSupport getOsSupport();
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/network/src/main/java/org/apache/brooklyn/entity/network/bind/BindDnsServerImpl.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/network/src/main/java/org/apache/brooklyn/entity/network/bind/BindDnsServerImpl.java b/brooklyn-library/software/network/src/main/java/org/apache/brooklyn/entity/network/bind/BindDnsServerImpl.java
deleted file mode 100644
index 2ee89e2..0000000
--- a/brooklyn-library/software/network/src/main/java/org/apache/brooklyn/entity/network/bind/BindDnsServerImpl.java
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.entity.network.bind;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.io.ByteArrayInputStream;
-import java.io.StringReader;
-import java.util.Collection;
-import java.util.Map;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.policy.PolicySpec;
-import org.apache.brooklyn.api.sensor.Sensor;
-import org.apache.brooklyn.core.entity.Attributes;
-import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
-import org.apache.brooklyn.core.location.Machines;
-import org.apache.brooklyn.entity.group.AbstractMembershipTrackingPolicy;
-import org.apache.brooklyn.entity.group.DynamicGroup;
-import org.apache.brooklyn.entity.software.base.SoftwareProcessImpl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.CharMatcher;
-import com.google.common.base.Function;
-import com.google.common.base.Joiner;
-import com.google.common.base.Predicate;
-import com.google.common.base.Splitter;
-import com.google.common.collect.BiMap;
-import com.google.common.collect.FluentIterable;
-import com.google.common.collect.HashBiMap;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableListMultimap;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableMultimap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Multimap;
-import com.google.common.collect.MultimapBuilder;
-import com.google.common.collect.Multimaps;
-
-import org.apache.brooklyn.location.ssh.SshMachineLocation;
-import org.apache.brooklyn.util.guava.Maybe;
-import org.apache.brooklyn.util.net.Cidr;
-import org.apache.brooklyn.util.ssh.BashCommands;
-import org.apache.brooklyn.util.text.Strings;
-
-/**
- * This sets up a BIND DNS server.
- * <p>
- * <b>NOTE</b> This entity has only been certified on <i>CentOS</i>, <i>RHEL</i>,
- * <i>Ubuntu</i> and <i>Debian</i> operating systems.
- */
-public class BindDnsServerImpl extends SoftwareProcessImpl implements BindDnsServer {
-
- private static final Logger LOG = LoggerFactory.getLogger(BindDnsServerImpl.class);
- private final Object serialMutex = new Object();
-
- // As per RFC 952 and RFC 1123.
- private static final CharMatcher DOMAIN_NAME_FIRST_CHAR_MATCHER = CharMatcher.inRange('a', 'z')
- .or(CharMatcher.inRange('A', 'Z'))
- .or(CharMatcher.inRange('0', '9'));
- private static final CharMatcher DOMAIN_NAME_MATCHER = DOMAIN_NAME_FIRST_CHAR_MATCHER
- .or(CharMatcher.is('-'));
-
-
- private class HostnameTransformer implements Function<Entity, String> {
- @Override
- public String apply(Entity input) {
- String hostname = input.getAttribute(getConfig(HOSTNAME_SENSOR));
- hostname = DOMAIN_NAME_FIRST_CHAR_MATCHER.negate().trimFrom(hostname);
- hostname = DOMAIN_NAME_MATCHER.negate().trimAndCollapseFrom(hostname, '-');
- if (hostname.length() > 63) {
- hostname = hostname.substring(0, 63);
- }
- return hostname;
- }
- }
-
- public BindDnsServerImpl() {
- super();
- }
-
- @Override
- public void init() {
- super.init();
- checkNotNull(getConfig(HOSTNAME_SENSOR), "%s requires value for %s", getClass().getName(), HOSTNAME_SENSOR);
- DynamicGroup entities = addChild(EntitySpec.create(DynamicGroup.class)
- .configure(DynamicGroup.ENTITY_FILTER, getEntityFilter()));
- sensors().set(ENTITIES, entities);
- sensors().set(A_RECORDS, ImmutableMap.<String, String>of());
- sensors().set(CNAME_RECORDS, ImmutableMultimap.<String, String>of());
- sensors().set(PTR_RECORDS, ImmutableMap.<String, String>of());
- sensors().set(ADDRESS_MAPPINGS, ImmutableMultimap.<String, String>of());
- synchronized (serialMutex) {
- sensors().set(SERIAL, System.currentTimeMillis());
- }
- }
-
- @Override
- public void postRebind() {
- update();
- }
-
- @Override
- public Class<?> getDriverInterface() {
- return BindDnsServerDriver.class;
- }
-
- @Override
- public Multimap<String, String> getAddressMappings() {
- return getAttribute(ADDRESS_MAPPINGS);
- }
-
- @Override
- public Map<String, String> getReverseMappings() {
- return getAttribute(PTR_RECORDS);
- }
-
- @Override
- public BindDnsServerDriver getDriver() {
- return (BindDnsServerDriver) super.getDriver();
- }
-
- @Override
- public void connectSensors() {
- connectServiceUpIsRunning();
- }
-
- @Override
- public void disconnectSensors() {
- super.disconnectSensors();
- disconnectServiceUpIsRunning();
- }
-
- @Override
- protected void preStart() {
- String reverse = getConfig(REVERSE_LOOKUP_NETWORK);
- if (Strings.isBlank(reverse)) reverse = getAttribute(ADDRESS);
- sensors().set(REVERSE_LOOKUP_CIDR, new Cidr(reverse + "/24"));
- String reverseLookupDomain = Joiner.on('.').join(Iterables.skip(Lists.reverse(Lists.newArrayList(
- Splitter.on('.').split(reverse))), 1)) + ".in-addr.arpa";
- sensors().set(REVERSE_LOOKUP_DOMAIN, reverseLookupDomain);
-
- policies().add(PolicySpec.create(MemberTrackingPolicy.class)
- .displayName("Address tracker")
- .configure(AbstractMembershipTrackingPolicy.SENSORS_TO_TRACK, ImmutableSet.<Sensor<?>>of(getConfig(HOSTNAME_SENSOR)))
- .configure(AbstractMembershipTrackingPolicy.GROUP, getEntities()));
- }
-
- @Override
- public void postStart() {
- update();
- }
-
- public static class MemberTrackingPolicy extends AbstractMembershipTrackingPolicy {
- @Override
- protected void onEntityChange(Entity member) {
- if (LOG.isTraceEnabled()) {
- LOG.trace("State of {} on change: {}", member, member.getAttribute(Attributes.SERVICE_STATE_ACTUAL).name());
- }
- ((BindDnsServerImpl) entity).update();
- }
- @Override
- protected void onEntityAdded(Entity member) {
- if (LOG.isTraceEnabled()) {
- LOG.trace("State of {} on added: {}", member, member.getAttribute(Attributes.SERVICE_STATE_ACTUAL).name());
- }
- ((BindDnsServerImpl) entity).configureResolver(member);
- }
- }
-
- private class HasHostnameAndValidLifecycle implements Predicate<Entity> {
- @Override
- public boolean apply(Entity input) {
- switch (input.getAttribute(Attributes.SERVICE_STATE_ACTUAL)) {
- case STOPPED:
- case STOPPING:
- case DESTROYED:
- return false;
- }
- return input.getAttribute(getConfig(HOSTNAME_SENSOR)) != null;
- }
- }
-
- public void update() {
- Lifecycle serverState = getAttribute(Attributes.SERVICE_STATE_ACTUAL);
- if (Lifecycle.STOPPED.equals(serverState) || Lifecycle.STOPPING.equals(serverState)
- || Lifecycle.DESTROYED.equals(serverState) || !getAttribute(Attributes.SERVICE_UP)) {
- LOG.debug("Skipped update of {} when service state is {} and running is {}",
- new Object[]{this, getAttribute(Attributes.SERVICE_STATE_ACTUAL), getAttribute(SERVICE_UP)});
- return;
- }
- synchronized (this) {
- Iterable<Entity> availableEntities = FluentIterable.from(getEntities().getMembers())
- .filter(new HasHostnameAndValidLifecycle());
- LOG.debug("{} updating with entities: {}", this, Iterables.toString(availableEntities));
- ImmutableListMultimap<String, Entity> hostnameToEntity = Multimaps.index(availableEntities,
- new HostnameTransformer());
-
- Map<String, String> octetToName = Maps.newHashMap();
- BiMap<String, String> ipToARecord = HashBiMap.create();
- Multimap<String, String> aRecordToCnames = MultimapBuilder.hashKeys().hashSetValues().build();
- Multimap<String, String> ipToAllNames = MultimapBuilder.hashKeys().hashSetValues().build();
-
- for (Map.Entry<String, Entity> e : hostnameToEntity.entries()) {
- String domainName = e.getKey();
- Maybe<SshMachineLocation> location = Machines.findUniqueMachineLocation(e.getValue().getLocations(), SshMachineLocation.class);
- if (!location.isPresent()) {
- LOG.debug("Member {} of {} does not have an SSH location so will not be configured", e.getValue(), this);
- continue;
- } else if (ipToARecord.inverse().containsKey(domainName)) {
- continue;
- }
-
- String address = location.get().getAddress().getHostAddress();
- ipToAllNames.put(address, domainName);
- if (!ipToARecord.containsKey(address)) {
- ipToARecord.put(address, domainName);
- if (getReverseLookupNetwork().contains(new Cidr(address + "/32"))) {
- String octet = Iterables.get(Splitter.on('.').split(address), 3);
- if (!octetToName.containsKey(octet)) octetToName.put(octet, domainName);
- }
- } else {
- aRecordToCnames.put(ipToARecord.get(address), domainName);
- }
- }
- sensors().set(A_RECORDS, ImmutableMap.copyOf(ipToARecord.inverse()));
- sensors().set(PTR_RECORDS, ImmutableMap.copyOf(octetToName));
- sensors().set(CNAME_RECORDS, Multimaps.unmodifiableMultimap(aRecordToCnames));
- sensors().set(ADDRESS_MAPPINGS, Multimaps.unmodifiableMultimap(ipToAllNames));
-
- // Update Bind configuration files and restart the service
- getDriver().updateBindConfiguration();
- }
- }
-
- protected void configureResolver(Entity entity) {
- Maybe<SshMachineLocation> machine = Machines.findUniqueMachineLocation(entity.getLocations(), SshMachineLocation.class);
- if (machine.isPresent()) {
- if (getConfig(REPLACE_RESOLV_CONF)) {
- machine.get().copyTo(new StringReader(getConfig(RESOLV_CONF_TEMPLATE)), "/etc/resolv.conf");
- } else {
- appendTemplate(getConfig(INTERFACE_CONFIG_TEMPLATE), "/etc/sysconfig/network-scripts/ifcfg-eth0", machine.get());
- machine.get().execScript("reload network", ImmutableList.of(BashCommands.sudo("service network reload")));
- }
- LOG.info("configured resolver on {}", machine);
- } else {
- LOG.debug("{} can't configure resolver at {}: no SshMachineLocation", this, entity);
- }
- }
-
- protected void appendTemplate(String template, String destination, SshMachineLocation machine) {
- String content = ((BindDnsServerSshDriver) getDriver()).processTemplate(template);
- String temp = "/tmp/template-" + Strings.makeRandomId(6);
- machine.copyTo(new ByteArrayInputStream(content.getBytes()), temp);
- machine.execScript("updating file", ImmutableList.of(
- BashCommands.sudo(String.format("tee -a %s < %s", destination, temp)),
- String.format("rm -f %s", temp)));
- }
-
-
- @Override
- public Predicate<? super Entity> getEntityFilter() {
- return getConfig(ENTITY_FILTER);
- }
-
- // Mostly used in templates
- public String getManagementCidr() {
- return getConfig(MANAGEMENT_CIDR);
- }
-
- public Integer getDnsPort() {
- return getAttribute(DNS_PORT);
- }
-
- public String getDomainName() {
- return getConfig(DOMAIN_NAME);
- }
-
- /**
- * @return A serial number guaranteed to be valid for use in a modified domain.zone or reverse.zone file.
- */
- public long getSerial() {
- synchronized (serialMutex) {
- long next = getAttribute(SERIAL) + 1;
- sensors().set(SERIAL, next);
- return next;
- }
- }
-
- public Cidr getReverseLookupNetwork() {
- return getAttribute(REVERSE_LOOKUP_CIDR);
- }
-
- public String getReverseLookupDomain() {
- return getAttribute(REVERSE_LOOKUP_DOMAIN);
- }
-
- public DynamicGroup getEntities() {
- return getAttribute(ENTITIES);
- }
-
- public Map<String, String> getAddressRecords() {
- return getAttribute(A_RECORDS);
- }
-
- public Multimap<String, String> getCanonicalNameRecords() {
- return getAttribute(CNAME_RECORDS);
- }
-
- public Map<String, Collection<String>> getCnamesForTemplates() {
- return getAttribute(CNAME_RECORDS).asMap();
- }
-
- public Map<String, String> getPointerRecords() {
- return getAttribute(PTR_RECORDS);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/network/src/main/java/org/apache/brooklyn/entity/network/bind/BindDnsServerSshDriver.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/network/src/main/java/org/apache/brooklyn/entity/network/bind/BindDnsServerSshDriver.java b/brooklyn-library/software/network/src/main/java/org/apache/brooklyn/entity/network/bind/BindDnsServerSshDriver.java
deleted file mode 100644
index b9991c8..0000000
--- a/brooklyn-library/software/network/src/main/java/org/apache/brooklyn/entity/network/bind/BindDnsServerSshDriver.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.entity.network.bind;
-
-import java.io.ByteArrayInputStream;
-import java.util.List;
-import java.util.Map;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-
-import org.apache.brooklyn.entity.software.base.AbstractSoftwareProcessSshDriver;
-import org.apache.brooklyn.location.ssh.SshMachineLocation;
-import org.apache.brooklyn.util.collections.MutableMap;
-import org.apache.brooklyn.util.net.Networking;
-import org.apache.brooklyn.util.net.Protocol;
-import org.apache.brooklyn.util.os.Os;
-import org.apache.brooklyn.util.ssh.BashCommands;
-import org.apache.brooklyn.util.ssh.IptablesCommands;
-import org.apache.brooklyn.util.ssh.IptablesCommands.Chain;
-import org.apache.brooklyn.util.ssh.IptablesCommands.Policy;
-import org.apache.brooklyn.util.text.Strings;
-
-public class BindDnsServerSshDriver extends AbstractSoftwareProcessSshDriver implements BindDnsServerDriver {
-
- private static final Logger LOG = LoggerFactory.getLogger(BindDnsServerSshDriver.class);
- private volatile BindOsSupport osSupport;
- private final Object osSupportMutex = new Object();
-
- public BindDnsServerSshDriver(BindDnsServerImpl entity, SshMachineLocation machine) {
- super(entity, machine);
- }
-
- @Override
- public BindDnsServerImpl getEntity() {
- return (BindDnsServerImpl) super.getEntity();
- }
-
- @Override
- public void install() {
- List<String> commands = ImmutableList.<String>builder()
- .add(BashCommands.installPackage(MutableMap.of(
- "yum", "bind", "apt", "bind9"), "bind"))
- .add(BashCommands.ok("which setenforce && " + BashCommands.sudo("setenforce 0")))
- .build();
- newScript(INSTALLING)
- .failOnNonZeroResultCode()
- .body.append(commands)
- .execute();
- }
-
- @Override
- public void customize() {
- Integer dnsPort = getEntity().getDnsPort();
- Map<String, Object> ports = MutableMap.<String, Object>of("dnsPort", dnsPort);
- Networking.checkPortsValid(ports);
-
- List<String> commands = Lists.newArrayList(
- BashCommands.sudo("mkdir -p " + getDataDirectory() + " " + getDynamicDirectory() + " " + getOsSupport().getConfigDirectory()),
- BashCommands.sudo("chown -R bind:bind " + getDataDirectory() + " " + getDynamicDirectory()),
- // TODO determine name of ethernet interface if not eth0?
- IptablesCommands.insertIptablesRule(Chain.INPUT, "eth0", Protocol.UDP, dnsPort, Policy.ACCEPT),
- IptablesCommands.insertIptablesRule(Chain.INPUT, "eth0", Protocol.TCP, dnsPort, Policy.ACCEPT),
- // TODO Iptables is not a service on Ubuntu
- BashCommands.sudo("service iptables save"),
- BashCommands.sudo("service iptables restart"));
- if (getEntity().getConfig(BindDnsServer.UPDATE_ROOT_ZONES_FILE)) {
- commands.add("wget --user=ftp --password=ftp ftp://ftp.rs.internic.net/domain/db.cache " +
- "-O " + getOsSupport().getRootZonesFile());
- }
- newScript(CUSTOMIZING)
- .body.append(commands)
- // fails if iptables is not a service, e.g. on ubuntu
- //.failOnNonZeroResultCode()
- .execute();
-
- copyAsRoot("classpath://org/apache/brooklyn/entity/network/bind/rfc1912.zone", getRfc1912ZonesFile());
- copyAsRoot("classpath://org/apache/brooklyn/entity/network/bind/named.localhost", Os.mergePathsUnix(getOsSupport().getConfigDirectory(), "named.localhost"));
- copyAsRoot("classpath://org/apache/brooklyn/entity/network/bind/named.loopback", Os.mergePathsUnix(getOsSupport().getConfigDirectory(), "named.loopback"));
- copyAsRoot("classpath://org/apache/brooklyn/entity/network/bind/named.empty", Os.mergePathsUnix(getOsSupport().getConfigDirectory(), "named.empty"));
-
- newScript("Checking BIND configuration")
- .body.append(BashCommands.sudo("named-checkconf"))
- .failOnNonZeroResultCode()
- .execute();
- }
-
- @Override
- public void launch() {
- newScript(MutableMap.of("usePidFile", false), LAUNCHING)
- .body.append(BashCommands.sudo("service " + getOsSupport().getServiceName() + " start"))
- .execute();
- }
-
- @Override
- public boolean isRunning() {
- return newScript(MutableMap.of("usePidFile", false), CHECK_RUNNING)
- .body.append(BashCommands.sudo("service " + getOsSupport().getServiceName() + " status"))
- .execute() == 0;
- }
-
- @Override
- public void stop() {
- newScript(MutableMap.of("usePidFile", false), STOPPING)
- .body.append(BashCommands.sudo("service " + getOsSupport().getServiceName() + " stop"))
- .execute();
- }
-
- @Override
- public void updateBindConfiguration() {
- LOG.debug("Updating bind configuration at " + getMachine());
- copyAsRoot(entity.getConfig(BindDnsServer.NAMED_CONF_TEMPLATE), getOsSupport().getRootConfigFile());
- copyAsRoot(entity.getConfig(BindDnsServer.DOMAIN_ZONE_FILE_TEMPLATE), getDomainZoneFile());
- copyAsRoot(entity.getConfig(BindDnsServer.REVERSE_ZONE_FILE_TEMPLATE), getReverseZoneFile());
- int result = getMachine().execScript("restart bind",
- ImmutableList.of(BashCommands.sudo("service " + getOsSupport().getServiceName() + " restart")));
- LOG.info("Updated named configuration and zone file for '{}' on {} (exit code {}).",
- new Object[]{entity.getConfig(BindDnsServer.DOMAIN_NAME), entity, result});
- }
-
- private void copyAsRoot(String template, String destination) {
- String content = processTemplate(template);
- String temp = "/tmp/template-" + Strings.makeRandomId(6);
- getMachine().copyTo(new ByteArrayInputStream(content.getBytes()), temp);
- getMachine().execScript("copying file", ImmutableList.of(BashCommands.sudo(String.format("mv %s %s", temp, destination))));
- }
-
- /** @return The location on the server of the domain zone file */
- public String getDomainZoneFile() {
- return Os.mergePaths(getOsSupport().getConfigDirectory(), "domain.zone");
- }
-
- /** @return The location on the server of the reverse zone file */
- public String getReverseZoneFile() {
- return Os.mergePaths(getOsSupport().getConfigDirectory(), "reverse.zone");
- }
-
- public String getDataDirectory() {
- return Os.mergePaths(getOsSupport().getWorkingDirectory(), "data");
- }
-
- public String getDynamicDirectory() {
- return Os.mergePaths(getOsSupport().getWorkingDirectory(), "dynamic");
- }
-
- public String getRfc1912ZonesFile() {
- return Os.mergePaths(getOsSupport().getConfigDirectory(), "rfc1912.zone");
- }
-
- public BindOsSupport getOsSupport() {
- BindOsSupport result = osSupport;
- if (result == null) {
- synchronized (osSupportMutex) {
- result = osSupport;
- if (result == null) {
- boolean yumExists = newScript("testing for yum")
- .body.append(BashCommands.requireExecutable("yum"))
- .execute() == 0;
- osSupport = result = yumExists ? BindOsSupport.forRhel() : BindOsSupport.forDebian();
- }
- }
- }
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/network/src/main/java/org/apache/brooklyn/entity/network/bind/BindOsSupport.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/network/src/main/java/org/apache/brooklyn/entity/network/bind/BindOsSupport.java b/brooklyn-library/software/network/src/main/java/org/apache/brooklyn/entity/network/bind/BindOsSupport.java
deleted file mode 100644
index c48f8a3..0000000
--- a/brooklyn-library/software/network/src/main/java/org/apache/brooklyn/entity/network/bind/BindOsSupport.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.entity.network.bind;
-
-import javax.annotation.concurrent.Immutable;
-
-/**
- * Provides operating system-specific information for working with the Bind service.
- */
-// Class would be package-private if Freemarker didn't complain vociferously.
-@Immutable
-public class BindOsSupport {
-
- // Likewise would make these package-private and have no getters if Freemarker was ok with it.
- private final String packageName;
- private final String serviceName;
- private final String rootConfigFile;
- private final String configDirectory;
- private final String workingDirectory;
- private final String rootZonesFile;
- private final String keysFile;
-
- private BindOsSupport(
- String packageName,
- String serviceName,
- String rootConfigFile,
- String configDirectory,
- String workingDirectory,
- String rootZonesFile,
- String keysFile) {
- this.packageName = packageName;
- this.serviceName = serviceName;
- this.rootConfigFile = rootConfigFile;
- this.configDirectory = configDirectory;
- this.workingDirectory = workingDirectory;
- this.rootZonesFile = rootZonesFile;
- this.keysFile = keysFile;
- }
-
- /**
- * @return support for RHEL-based operating systems.
- */
- public static BindOsSupport forRhel() {
- return new BindOsSupport(
- "bind",
- "named",
- "/etc/named.conf",
- "/var/named",
- "/var/named/data",
- "/var/named/named.ca",
- "/etc/named.iscdlv.key");
- }
-
- /**
- * @return support for Debian-based operating systems.
- */
- public static BindOsSupport forDebian() {
- return new BindOsSupport(
- "bind9",
- "bind9",
- "/etc/bind/named.conf",
- "/etc/bind",
- "/var/cache/bind",
- "/etc/bind/db.root",
- "/etc/bind/bind.keys"
- );
- }
-
- public String getPackageName() {
- return packageName;
- }
-
- public String getServiceName() {
- return serviceName;
- }
-
- public String getRootConfigFile() {
- return rootConfigFile;
- }
-
- public String getConfigDirectory() {
- return configDirectory;
- }
-
- public String getWorkingDirectory() {
- return workingDirectory;
- }
-
- public String getRootZonesFile() {
- return rootZonesFile;
- }
-
- public String getKeysFile() {
- return keysFile;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/network/src/main/resources/isc-logo.png
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/network/src/main/resources/isc-logo.png b/brooklyn-library/software/network/src/main/resources/isc-logo.png
deleted file mode 100644
index 44cdec6..0000000
Binary files a/brooklyn-library/software/network/src/main/resources/isc-logo.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/network/src/main/resources/org/apache/brooklyn/entity/network/bind/domain.zone
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/network/src/main/resources/org/apache/brooklyn/entity/network/bind/domain.zone b/brooklyn-library/software/network/src/main/resources/org/apache/brooklyn/entity/network/bind/domain.zone
deleted file mode 100644
index 671d234..0000000
--- a/brooklyn-library/software/network/src/main/resources/org/apache/brooklyn/entity/network/bind/domain.zone
+++ /dev/null
@@ -1,46 +0,0 @@
-[#ftl]
-;;
-;; Licensed to the Apache Software Foundation (ASF) under one
-;; or more contributor license agreements. See the NOTICE file
-;; distributed with this work for additional information
-;; regarding copyright ownership. The ASF licenses this file
-;; to you under the Apache License, Version 2.0 (the
-;; "License"); you may not use this file except in compliance
-;; with the License. You may obtain a copy of the License at
-;;
-;; http://www.apache.org/licenses/LICENSE-2.0
-;;
-;; Unless required by applicable law or agreed to in writing,
-;; software distributed under the License is distributed on an
-;; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-;; KIND, either express or implied. See the License for the
-;; specific language governing permissions and limitations
-;; under the License.
-;;
-;; Generated by Brooklyn on ${.now?string.short}
-;;
-;;
-[#noparse]$TTL[/#noparse] 86400
-@ IN SOA ns1.${entity.domainName}. root.${entity.domainName}. (
- ${entity.serial?c} ; serial
- 3600 ; refresh
- 1800 ; retry
- 604800 ; expire
- 86400 ; ttl
-)
-@ IN NS ns1.${entity.domainName}.
-@ IN NS ns2.${entity.domainName}.
-ns1 IN A ${driver.address}
-ns2 IN A ${driver.address}
-
-;; Addresses
-[#list entity.addressRecords?keys as address]
-${address} IN A ${entity.addressRecords[address]}
-[/#list]
-
-;; Canonical names
-[#list entity.cnamesForTemplates?keys as aRecord]
-[#list entity.cnamesForTemplates[aRecord] as cname]
-${cname} IN CNAME ${aRecord}
-[/#list]
-[/#list]
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/network/src/main/resources/org/apache/brooklyn/entity/network/bind/ifcfg
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/network/src/main/resources/org/apache/brooklyn/entity/network/bind/ifcfg b/brooklyn-library/software/network/src/main/resources/org/apache/brooklyn/entity/network/bind/ifcfg
deleted file mode 100644
index b8b310d..0000000
--- a/brooklyn-library/software/network/src/main/resources/org/apache/brooklyn/entity/network/bind/ifcfg
+++ /dev/null
@@ -1,24 +0,0 @@
-[#ftl]
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-# Generated by Brooklyn on ${.now?string.short}
-#
-DOMAIN=${entity.domainName}
-DNS1=${driver.address}
-DNS2=8.8.8.8
\ No newline at end of file