summaryrefslogtreecommitdiffstats
path: root/sshkeyshare
diff options
context:
space:
mode:
Diffstat (limited to 'sshkeyshare')
-rw-r--r--sshkeyshare/LICENSE.txt17
-rw-r--r--sshkeyshare/README.md56
-rw-r--r--sshkeyshare/pom.xml327
-rw-r--r--sshkeyshare/requirements.txt1
-rw-r--r--sshkeyshare/setup.py37
-rw-r--r--sshkeyshare/sshkey_types.yaml17
-rw-r--r--sshkeyshare/sshkeyshare/__init__.py28
-rw-r--r--sshkeyshare/sshkeyshare/keyshare_plugin.py39
-rw-r--r--sshkeyshare/tests/test_plugin.py14
-rw-r--r--sshkeyshare/tox.ini35
10 files changed, 571 insertions, 0 deletions
diff --git a/sshkeyshare/LICENSE.txt b/sshkeyshare/LICENSE.txt
new file mode 100644
index 0000000..86c0033
--- /dev/null
+++ b/sshkeyshare/LICENSE.txt
@@ -0,0 +1,17 @@
+============LICENSE_START=======================================================
+org.onap.dcaegen2
+================================================================================
+Copyright (c) 2017-2020 AT&T Intellectual Property. All rights reserved.
+================================================================================
+Licensed 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.
+============LICENSE_END=========================================================
diff --git a/sshkeyshare/README.md b/sshkeyshare/README.md
new file mode 100644
index 0000000..ac0b1fe
--- /dev/null
+++ b/sshkeyshare/README.md
@@ -0,0 +1,56 @@
+<!--
+============LICENSE_START=======================================================
+org.onap.dcaegen2
+================================================================================
+Copyright (c) 2017-2020 AT&T Intellectual Property. All rights reserved.
+================================================================================
+Licensed 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.
+============LICENSE_END=========================================================
+-->
+
+# sshkeyshare plugin
+Cloudify plugin for creating ssh key pairs on the fly
+# Description
+The sshkeyshare Cloudify plugin creates an ssh key pair that can be used,
+by VMs or other containers spun up by a Cloudify blueprint, for establishing
+connections, among them. The blue print can, for example, provide the
+private key to one VM and the public one to another, as part of their
+initial configuration, to allow the one with the private key to
+automatically connect to the other one, to run commands.
+# Plugin Requirements
+* Python versions
+ * 2.7.x
+
+Note: These requirements apply to the VM where Cloudify Manager itself runs.
+
+Note: Cloudify Manager, itself, requires Pythong 2.7.x (and CentOS 7).
+
+# Types
+## dcaegen2.nodes.ssh.keypair
+**Derived From:** cloudify.nodes.Root
+
+**Properties:**
+This type has no properties
+
+**Mapped Operations:**
+* `cloudify.interfaces.lifecycle.create` Creates a new ssh keypair
+using ssh-keygen
+
+**Attributes:**
+* `public` A string containing the public key of the newly created
+keypair.
+* `base64private` A single line base-64 encoded representation of
+the content of the private key file for the newly created keypair.
+
+# Relationships
+This plugin does not define or use any relationships
diff --git a/sshkeyshare/pom.xml b/sshkeyshare/pom.xml
new file mode 100644
index 0000000..c2062f4
--- /dev/null
+++ b/sshkeyshare/pom.xml
@@ -0,0 +1,327 @@
+<?xml version="1.0"?>
+<!--
+============LICENSE_START=======================================================
+org.onap.dcaegen2
+================================================================================
+Copyright (c) 2017,2020 AT&T Intellectual Property. All rights reserved.
+================================================================================
+Licensed 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.
+============LICENSE_END=========================================================
+-->
+<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>
+ <parent>
+ <groupId>org.onap.dcaegen2.platform</groupId>
+ <artifactId>plugins</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <!--- CHANGE THE FOLLOWING 3 OBJECTS for your own repo -->
+ <groupId>org.onap.dcaegen2.platform.plugins</groupId>
+ <artifactId>sshkeyshare</artifactId>
+ <name>sshkeyshare</name>
+
+ <version>1.2.0-SNAPSHOT</version>
+ <url>http://maven.apache.org</url>
+ <properties>
+ <!-- name from the setup.py file -->
+ <plugin.name>sshkeyshare</plugin.name>
+ <!-- path to directory containing the setup.py relative to this file -->
+ <plugin.subdir>.</plugin.subdir>
+ <!-- path of types file itself relative to this file -->
+ <typefile.source>sshkey_types.yaml</typefile.source>
+ <!-- path, in repo, to store type file -->
+ <typefile.dest>type_files/sshkeyshare/sshkey_types.yaml</typefile.dest>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <sonar.sources>.</sonar.sources>
+ <sonar.junit.reportsPath>xunit-results.xml</sonar.junit.reportsPath>
+ <sonar.python.coverage.reportPaths>coverage.xml</sonar.python.coverage.reportPaths>
+ <sonar.language>py</sonar.language>
+ <sonar.pluginName>Python</sonar.pluginName>
+ <sonar.inclusions>**/*.py</sonar.inclusions>
+ <sonar.exclusions>tests/*,setup.py</sonar.exclusions>
+ </properties>
+
+ <build>
+ <finalName>${project.artifactId}-${project.version}</finalName>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>sonar-maven-plugin</artifactId>
+ <version>2.7.1</version>
+ </plugin>
+
+ <!-- nexus-staging-maven-plugin is called during deploy phase by default behavior.
+ we do not need it -->
+ <plugin>
+ <groupId>org.sonatype.plugins</groupId>
+ <artifactId>nexus-staging-maven-plugin</artifactId>
+ <version>1.6.7</version>
+ <configuration>
+ <skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo>
+ </configuration>
+ </plugin>
+
+ <!-- maven-deploy-plugin is called during deploy but we do not need it -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <version>2.8</version>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+
+ <plugins>
+
+ <!-- first disable the default Java plugins at various stages -->
+ <!-- maven-resources-plugin is called during "*resource" phases by default behavior. it prepares the resources
+ dir. we do not need it -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.6</version>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+
+ <!-- maven-compiler-plugin is called during "compile" phases by default behavior. we do not need it -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+
+ <!-- maven-jar-plugin is called during "compile" phase by default behavior. we do not need it -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.4</version>
+ <executions>
+ <execution>
+ <id>default-jar</id>
+ <phase/>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- maven-install-plugin is called during "install" phase by default behavior. it tries to copy stuff under
+ target dir to ~/.m2. we do not need it -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-install-plugin</artifactId>
+ <version>2.4</version>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+
+ <!-- maven-surefire-plugin is called during "test" phase by default behavior. it triggers junit test.
+ we do not need it -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.12.4</version>
+ <configuration>
+ <skipTests>true</skipTests>
+ </configuration>
+ </plugin>
+
+ <!-- now we configure custom action (calling a script) at various lifecycle phases -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>clean phase script</id>
+ <phase>clean</phase>
+ <goals><goal>exec</goal></goals>
+ <configuration>
+ <executable>${session.executionRootDirectory}/mvn-phase-script.sh</executable>
+ <arguments>
+ <argument>${project.artifactId}</argument>
+ <argument>clean</argument>
+ </arguments>
+ <environmentVariables>
+ <!-- make mvn properties as env for our script -->
+ <MVN_PROJECT_GROUPID>${project.groupId}</MVN_PROJECT_GROUPID>
+ <MVN_PROJECT_ARTIFACTID>${project.artifactId}</MVN_PROJECT_ARTIFACTID>
+ <MVN_PROJECT_VERSION>${project.version}</MVN_PROJECT_VERSION>
+ <MVN_NEXUSPROXY>${onap.nexus.url}</MVN_NEXUSPROXY>
+ <MVN_RAWREPO_BASEURL_UPLOAD>${onap.nexus.rawrepo.baseurl.upload}</MVN_RAWREPO_BASEURL_UPLOAD>
+ <MVN_RAWREPO_BASEURL_DOWNLOAD>${onap.nexus.rawrepo.baseurl.download}</MVN_RAWREPO_BASEURL_DOWNLOAD>
+ <MVN_RAWREPO_SERVERID>${onap.nexus.rawrepo.serverid}</MVN_RAWREPO_SERVERID>
+ <PLUGIN_NAME>${plugin.name}</PLUGIN_NAME>
+ <PLUGIN_SUBDIR>${plugin.subdir}</PLUGIN_SUBDIR>
+ </environmentVariables>
+ </configuration>
+ </execution>
+
+ <execution>
+ <id>generate-sources script</id>
+ <phase>generate-sources</phase>
+ <goals><goal>exec</goal></goals>
+ <configuration>
+ <executable>mvn-phase-script.sh</executable>
+ <arguments>
+ <argument>${project.artifactId}</argument>
+ <argument>generate-sources</argument>
+ </arguments>
+ <environmentVariables>
+ <!-- make mvn properties as env for our script -->
+ <MVN_PROJECT_GROUPID>${project.groupId}</MVN_PROJECT_GROUPID>
+ <MVN_PROJECT_ARTIFACTID>${project.artifactId}</MVN_PROJECT_ARTIFACTID>
+ <MVN_PROJECT_VERSION>${project.version}</MVN_PROJECT_VERSION>
+ <MVN_NEXUSPROXY>${onap.nexus.url}</MVN_NEXUSPROXY>
+ <MVN_RAWREPO_BASEURL_UPLOAD>${onap.nexus.rawrepo.baseurl.upload}</MVN_RAWREPO_BASEURL_UPLOAD>
+ <MVN_RAWREPO_BASEURL_DOWNLOAD>${onap.nexus.rawrepo.baseurl.download}</MVN_RAWREPO_BASEURL_DOWNLOAD>
+ <MVN_RAWREPO_SERVERID>${onap.nexus.rawrepo.serverid}</MVN_RAWREPO_SERVERID>
+ </environmentVariables>
+ </configuration>
+ </execution>
+
+ <execution>
+ <id>compile script</id>
+ <phase>compile</phase>
+ <goals><goal>exec</goal></goals>
+ <configuration>
+ <executable>mvn-phase-script.sh</executable>
+ <arguments>
+ <argument>${project.artifactId}</argument>
+ <argument>compile</argument>
+ </arguments>
+ <environmentVariables>
+ <!-- make mvn properties as env for our script -->
+ <MVN_PROJECT_GROUPID>${project.groupId}</MVN_PROJECT_GROUPID>
+ <MVN_PROJECT_ARTIFACTID>${project.artifactId}</MVN_PROJECT_ARTIFACTID>
+ <MVN_PROJECT_VERSION>${project.version}</MVN_PROJECT_VERSION>
+ <MVN_NEXUSPROXY>${onap.nexus.url}</MVN_NEXUSPROXY>
+ <MVN_RAWREPO_BASEURL_UPLOAD>${onap.nexus.rawrepo.baseurl.upload}</MVN_RAWREPO_BASEURL_UPLOAD>
+ <MVN_RAWREPO_BASEURL_DOWNLOAD>${onap.nexus.rawrepo.baseurl.download}</MVN_RAWREPO_BASEURL_DOWNLOAD>
+ <MVN_RAWREPO_SERVERID>${onap.nexus.rawrepo.serverid}</MVN_RAWREPO_SERVERID>
+ </environmentVariables>
+ </configuration>
+ </execution>
+
+ <execution>
+ <id>package script</id>
+ <phase>package</phase>
+ <goals><goal>exec</goal></goals>
+ <configuration>
+ <executable>mvn-phase-script.sh</executable>
+ <arguments>
+ <argument>${project.artifactId}</argument>
+ <argument>package</argument>
+ </arguments>
+ <environmentVariables>
+ <!-- make mvn properties as env for our script -->
+ <MVN_PROJECT_GROUPID>${project.groupId}</MVN_PROJECT_GROUPID>
+ <MVN_PROJECT_ARTIFACTID>${project.artifactId}</MVN_PROJECT_ARTIFACTID>
+ <MVN_PROJECT_VERSION>${project.version}</MVN_PROJECT_VERSION>
+ <MVN_NEXUSPROXY>${onap.nexus.url}</MVN_NEXUSPROXY>
+ <MVN_RAWREPO_BASEURL_UPLOAD>${onap.nexus.rawrepo.baseurl.upload}</MVN_RAWREPO_BASEURL_UPLOAD>
+ <MVN_RAWREPO_BASEURL_DOWNLOAD>${onap.nexus.rawrepo.baseurl.download}</MVN_RAWREPO_BASEURL_DOWNLOAD>
+ <MVN_RAWREPO_SERVERID>${onap.nexus.rawrepo.serverid}</MVN_RAWREPO_SERVERID>
+ <PLUGIN_NAME>${plugin.name}</PLUGIN_NAME>
+ <PLUGIN_SUBDIR>${plugin.subdir}</PLUGIN_SUBDIR>
+ </environmentVariables>
+ </configuration>
+ </execution>
+
+ <execution>
+ <id>test script</id>
+ <phase>test</phase>
+ <goals><goal>exec</goal></goals>
+ <configuration>
+ <executable>mvn-phase-script.sh</executable>
+ <arguments>
+ <argument>${project.artifactId}</argument>
+ <argument>test</argument>
+ </arguments>
+ <environmentVariables>
+ <!-- make mvn properties as env for our script -->
+ <MVN_PROJECT_GROUPID>${project.groupId}</MVN_PROJECT_GROUPID>
+ <MVN_PROJECT_ARTIFACTID>${project.artifactId}</MVN_PROJECT_ARTIFACTID>
+ <MVN_PROJECT_VERSION>${project.version}</MVN_PROJECT_VERSION>
+ <MVN_NEXUSPROXY>${onap.nexus.url}</MVN_NEXUSPROXY>
+ <MVN_RAWREPO_BASEURL_UPLOAD>${onap.nexus.rawrepo.baseurl.upload}</MVN_RAWREPO_BASEURL_UPLOAD>
+ <MVN_RAWREPO_BASEURL_DOWNLOAD>${onap.nexus.rawrepo.baseurl.download}</MVN_RAWREPO_BASEURL_DOWNLOAD>
+ <MVN_RAWREPO_SERVERID>${onap.nexus.rawrepo.serverid}</MVN_RAWREPO_SERVERID>
+ <PLUGIN_NAME>${plugin.name}</PLUGIN_NAME>
+ <PLUGIN_SUBDIR>${plugin.subdir}</PLUGIN_SUBDIR>
+ </environmentVariables>
+ </configuration>
+ </execution>
+
+ <execution>
+ <id>install script</id>
+ <phase>install</phase>
+ <goals><goal>exec</goal></goals>
+ <configuration>
+ <executable>mvn-phase-script.sh</executable>
+ <arguments>
+ <argument>${project.artifactId}</argument>
+ <argument>install</argument>
+ </arguments>
+ <environmentVariables>
+ <!-- make mvn properties as env for our script -->
+ <MVN_PROJECT_GROUPID>${project.groupId}</MVN_PROJECT_GROUPID>
+ <MVN_PROJECT_ARTIFACTID>${project.artifactId}</MVN_PROJECT_ARTIFACTID>
+ <MVN_PROJECT_VERSION>${project.version}</MVN_PROJECT_VERSION>
+ <MVN_NEXUSPROXY>${onap.nexus.url}</MVN_NEXUSPROXY>
+ <MVN_RAWREPO_BASEURL_UPLOAD>${onap.nexus.rawrepo.baseurl.upload}</MVN_RAWREPO_BASEURL_UPLOAD>
+ <MVN_RAWREPO_BASEURL_DOWNLOAD>${onap.nexus.rawrepo.baseurl.download}</MVN_RAWREPO_BASEURL_DOWNLOAD>
+ <MVN_RAWREPO_SERVERID>${onap.nexus.rawrepo.serverid}</MVN_RAWREPO_SERVERID>
+ </environmentVariables>
+ </configuration>
+ </execution>
+
+ <execution>
+ <id>deploy script</id>
+ <phase>deploy</phase>
+ <goals><goal>exec</goal></goals>
+ <configuration>
+ <executable>${session.executionRootDirectory}/mvn-phase-script.sh</executable>
+ <arguments>
+ <argument>${project.artifactId}</argument>
+ <argument>deploy</argument>
+ </arguments>
+ <environmentVariables>
+ <!-- make mvn properties as env for our script -->
+ <MVN_PROJECT_GROUPID>${project.groupId}</MVN_PROJECT_GROUPID>
+ <MVN_PROJECT_ARTIFACTID>${project.artifactId}</MVN_PROJECT_ARTIFACTID>
+ <MVN_PROJECT_VERSION>${project.version}</MVN_PROJECT_VERSION>
+ <MVN_NEXUSPROXY>${onap.nexus.url}</MVN_NEXUSPROXY>
+ <MVN_RAWREPO_BASEURL_UPLOAD>${onap.nexus.rawrepo.baseurl.upload}</MVN_RAWREPO_BASEURL_UPLOAD>
+ <MVN_RAWREPO_BASEURL_DOWNLOAD>${onap.nexus.rawrepo.baseurl.download}</MVN_RAWREPO_BASEURL_DOWNLOAD>
+ <MVN_RAWREPO_SERVERID>${onap.nexus.rawrepo.serverid}</MVN_RAWREPO_SERVERID>
+ <MVN_SERVER_ID>${project.distributionManagement.snapshotRepository.id}</MVN_SERVER_ID>
+ <TYPE_FILE_SOURCE>${typefile.source}</TYPE_FILE_SOURCE>
+ <TYPE_FILE_DEST>${typefile.dest}</TYPE_FILE_DEST>
+ <PLUGIN_NAME>${plugin.name}</PLUGIN_NAME>
+ <PLUGIN_SUBDIR>${plugin.subdir}</PLUGIN_SUBDIR>
+ </environmentVariables>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sshkeyshare/requirements.txt b/sshkeyshare/requirements.txt
new file mode 100644
index 0000000..833d57a
--- /dev/null
+++ b/sshkeyshare/requirements.txt
@@ -0,0 +1 @@
+cloudify-common>=5.0.5
diff --git a/sshkeyshare/setup.py b/sshkeyshare/setup.py
new file mode 100644
index 0000000..3b66c88
--- /dev/null
+++ b/sshkeyshare/setup.py
@@ -0,0 +1,37 @@
+# ============LICENSE_START====================================================
+# org.onap.dcaegen2
+# =============================================================================
+# Copyright (c) 2017-2020 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2020 Pantheon.tech. All rights reserved.
+# =============================================================================
+# Licensed 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.
+# ============LICENSE_END======================================================
+
+import os
+from setuptools import setup, find_packages
+
+setup(
+ name='sshkeyshare',
+ version='1.2.0',
+ packages=find_packages(),
+ author='AT&T',
+ description=('Cloudify plugin for creating ssh keypairs on the fly.'),
+ license='Apache 2.0',
+ keywords='',
+ url='https://wiki.onap.org',
+ zip_safe=False,
+ package_data={'':['LICENSE.txt']},
+ install_requires=[
+ 'cloudify-common>=5.0.5',
+ ],
+)
diff --git a/sshkeyshare/sshkey_types.yaml b/sshkeyshare/sshkey_types.yaml
new file mode 100644
index 0000000..565ab1e
--- /dev/null
+++ b/sshkeyshare/sshkey_types.yaml
@@ -0,0 +1,17 @@
+tosca_definitions_version: cloudify_dsl_1_3
+
+imports:
+ - http://www.getcloudify.org/spec/cloudify/3.4/types.yaml
+plugins:
+ ssh_keyshare:
+ executor: central_deployment_agent
+ package_name: sshkeyshare
+ package_version: 1.1.0
+node_types:
+ dcaegen2.nodes.ssh.keypair:
+ derived_from: cloudify.nodes.Root
+ properties:
+ interfaces:
+ cloudify.interfaces.lifecycle:
+ create:
+ implementation: ssh_keyshare.sshkeyshare.keyshare_plugin.generate
diff --git a/sshkeyshare/sshkeyshare/__init__.py b/sshkeyshare/sshkeyshare/__init__.py
new file mode 100644
index 0000000..0d79837
--- /dev/null
+++ b/sshkeyshare/sshkeyshare/__init__.py
@@ -0,0 +1,28 @@
+# ============LICENSE_START====================================================
+# org.onap.dcaegen2
+# =============================================================================
+# Copyright (c) 2017-2020 AT&T Intellectual Property. All rights reserved.
+# =============================================================================
+# Licensed 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.
+# ============LICENSE_END======================================================
+
+import logging
+
+def get_module_logger(mod_name):
+ logger = logging.getLogger(mod_name)
+ handler=logging.StreamHandler()
+ formatter=logging.Formatter('%(asctime)s [%(name)-12s] %(levelname)-8s %(message)s')
+ handler.setFormatter(formatter)
+ logger.addHandler(handler)
+ logger.setLevel(logging.DEBUG)
+ return logger
diff --git a/sshkeyshare/sshkeyshare/keyshare_plugin.py b/sshkeyshare/sshkeyshare/keyshare_plugin.py
new file mode 100644
index 0000000..41e56e0
--- /dev/null
+++ b/sshkeyshare/sshkeyshare/keyshare_plugin.py
@@ -0,0 +1,39 @@
+# ============LICENSE_START====================================================
+# org.onap.dcaegen2
+# =============================================================================
+# Copyright (c) 2017,2020 AT&T Intellectual Property. All rights reserved.
+# =============================================================================
+# Licensed 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.
+# ============LICENSE_END======================================================
+
+import uuid
+import os
+from cloudify import ctx
+from cloudify.decorators import operation
+
+@operation(resumable=True)
+def generate(**kwargs):
+ """
+ Create SSH key pair
+ """
+ tmpdir = '/tmp/{0}'.format(uuid.uuid4().hex)
+ os.mkdir(tmpdir, 0o700)
+ os.system('ssh-keygen -t rsa -b 2048 -C "hadoop@cdapcluster" -N "" -f {0}/id_rsa'.format(tmpdir))
+ os.system('base64 -w 0 <{0}/id_rsa >{0}/id64'.format(tmpdir))
+ with open('{0}/id64'.format(tmpdir), 'r') as f:
+ k64 = f.read()
+ with open('{0}/id_rsa.pub'.format(tmpdir), 'r') as f:
+ pub = f.read()
+ os.system('rm -rf {0}'.format(tmpdir))
+ ctx.instance.runtime_properties['public'] = pub.strip()
+ ctx.instance.runtime_properties['base64private'] = k64.strip()
diff --git a/sshkeyshare/tests/test_plugin.py b/sshkeyshare/tests/test_plugin.py
new file mode 100644
index 0000000..6c5fe93
--- /dev/null
+++ b/sshkeyshare/tests/test_plugin.py
@@ -0,0 +1,14 @@
+import sshkeyshare.keyshare_plugin
+from cloudify.mocks import MockCloudifyContext
+from cloudify.state import current_ctx
+from cloudify import ctx
+
+def test_generate():
+ mock_ctx = MockCloudifyContext(node_id='test_node_id', node_name='test_node_name', properties={})
+ try:
+ current_ctx.set(mock_ctx)
+ sshkeyshare.keyshare_plugin.generate()
+ pub = ctx.instance.runtime_properties['public']
+ pvt64 = ctx.instance.runtime_properties['base64private']
+ finally:
+ current_ctx.clear()
diff --git a/sshkeyshare/tox.ini b/sshkeyshare/tox.ini
new file mode 100644
index 0000000..af05cdc
--- /dev/null
+++ b/sshkeyshare/tox.ini
@@ -0,0 +1,35 @@
+# ============LICENSE_START====================================================
+# =============================================================================
+# Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2020 Pantheon.tech. All rights reserved.
+# =============================================================================
+# Licensed 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.
+# ============LICENSE_END======================================================
+
+[tox]
+envlist = py27,py36,py37,py38
+skip_missing_interpreters = true
+
+[testenv]
+deps=
+ pytest
+ coverage
+ pytest-cov
+ -rrequirements.txt
+setenv=
+ PYTHONPATH={toxinidir}
+commands=
+ pytest --junitxml xunit-results.xml --cov sshkeyshare --cov-report xml
+ coverage xml
+ coverage report
+ coverage html