Skip to content

Commit c22d202

Browse files
committed
added admin version of service and tested
1 parent 4b683fe commit c22d202

25 files changed

Lines changed: 1858 additions & 0 deletions
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
env/
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
27+
# PyInstaller
28+
# Usually these files are written by a python script from a template
29+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
30+
*.manifest
31+
*.spec
32+
33+
# Installer logs
34+
pip-log.txt
35+
pip-delete-this-directory.txt
36+
37+
# Unit test / coverage reports
38+
htmlcov/
39+
.tox/
40+
.coverage
41+
.coverage.*
42+
.cache
43+
nosetests.xml
44+
coverage.xml
45+
*,cover
46+
.hypothesis/
47+
48+
# Translations
49+
*.mo
50+
*.pot
51+
52+
# Django stuff:
53+
*.log
54+
55+
# Sphinx documentation
56+
docs/_build/
57+
58+
# PyBuilder
59+
target/
60+
cloudshell_config.yml
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
TOSCA-Meta-File-Version: 1.0
2+
CSAR-Version: 0.1.0
3+
Created-By: Anonymous
4+
Entry-Definitions: shell-definition.yaml
461 Bytes
Loading
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<properties>
3+
4+
<!-- The address of the Quali server on which to deploy, mandatory -->
5+
<serverRootAddress>localhost</serverRootAddress>
6+
7+
<!-- The port of the Quali server on which to deploy, defaults to "8029" -->
8+
<port>8029</port>
9+
10+
<!-- The server admin username, password and domain to use when deploying -->
11+
<username>YOUR_USERNAME</username>
12+
<password>YOUR_PASSWORD</password>
13+
<domain>Global</domain>
14+
15+
<!-- Simple patterns to filter when sending the driver to the server separated by semicolons (e.g. "file.xml;logs/", also supports regular expressions),
16+
on top of the patterns specified here the plugin will automatically filter the "deployment/" and ".idea/" folders and the "deployment.xml" file -->
17+
<fileFilters>dont_upload_me.xml</fileFilters>
18+
19+
<!-- The drivers to update, holds one or more drivers -->
20+
<drivers>
21+
<!-- runFromLocalProject - Decides whether to run the driver from the current project directory for debugging purposes, defaults to "false" -->
22+
<!-- waitForDebugger - When `runFromLocalProject` is enabled, decides whether to wait for a debugger to attach before running any Python driver code, defaults to "false" -->
23+
<!-- sourceRootFolder - The folder to refer to as the project source root (if specified, the folder will be zipped and deployed instead of the whole project), defaults to the root project folder -->
24+
<driver runFromLocalProject="true" waitForDebugger="true" sourceRootFolder="admin-ansible-config-2g">
25+
<!-- A list of paths to the driver's files or folders relative to the project's root.
26+
may be a path to a directory, in which case all the files and folders under the directory are added into the driver's zip file.
27+
if the <sources> element is not specified, all the files under the project are added to the driver's zip file -->
28+
<sources>
29+
<source>src</source>
30+
</sources>
31+
<!-- the driver name of the driver to update -->
32+
<targetName>AdminAnsibleConfig2GDriver</targetName>
33+
</driver>
34+
</drivers>
35+
36+
<!-- The scripts to update, holds one or more scripts -->
37+
<!-- A list of paths to the script's files or folders relative to the project's root.
38+
if the <sources> element is not specified, all the files under the project are added to the script's zip file.
39+
if only one file is specified, the file will not be compressed into a zip file.
40+
-->
41+
<!--
42+
<scripts>
43+
44+
<script>
45+
46+
<sources>
47+
<source>script1.py</source>
48+
</sources>
49+
<targetName>scriptToUpdate</targetName>
50+
</script>
51+
</scripts>
52+
-->
53+
</properties>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.. _readme:
2+
3+
.. include:: ../README.rst
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
tosca_definitions_version: tosca_simple_yaml_1_0
2+
3+
metadata:
4+
template_name: Admin Ansible Config 2G
5+
template_author: Quali
6+
template_version: 1.0.1
7+
template_icon: shell-icon.png
8+
9+
description: >
10+
TOSCA based service shell
11+
12+
imports:
13+
- cloudshell_standard: cloudshell_admin_only_custom_service_standard_1_0_0.yaml
14+
15+
node_types:
16+
17+
vendor.resource.Admin Ansible Config 2G:
18+
derived_from: cloudshell.nodes.AdminOnlyCustomService
19+
properties:
20+
Address:
21+
description: (Optional) Address of Script Repo Server.
22+
type: string
23+
tags: [ user_input ]
24+
Repo User:
25+
description: (Optional) Source Control user for private repo authentication. Required for Github Private Repo. For Gitlab user not required, only access token in password field.
26+
type: string
27+
tags: [ user_input ]
28+
Repo Password:
29+
description: (Optional) Source Control password for private repo authentication. For GitLab, add private access token here.
30+
type: cloudshell.datatypes.Password
31+
tags: [ user_input ]
32+
Playbook Base Path:
33+
description: Base URL to script. This path will join with script path passed to execute playbook command. (Github - https://raw.githubusercontent.com/QualiSystemsLab/App-Configuration-Demo-Scripts/master/, Gitlab - http://<SERVER_IP>/api/v4/projects/<PROJECT_ID>/repository/files)
34+
type: string
35+
tags: [ user_input ]
36+
Playbook Script Path:
37+
description: Path to script from root of repo. This will join with base path to create full URL.
38+
type: string
39+
tags: [ user_input ]
40+
Playbook URL Full:
41+
description: Full path URL of script. For Github can be "raw" url. For gitlab, pass Rest API formatted url (Github - https://raw.githubusercontent.com/QualiSystemsLab/App-Configuration-Demo-Scripts/master/<FILE_PATH>, Gitlab - http://<SERVER_IP>/api/v4/projects/<PROJECT_ID>/repository/files/<FILE_PATH>/raw?ref=<BRANCH>)
42+
type: string
43+
tags: [ user_input ]
44+
Connection Method:
45+
description: Specifies the "ansible_connection" host variable
46+
type: string
47+
tags: [ user_input ]
48+
default: ssh
49+
constraints:
50+
- valid_values: [ ssh, winrm, network_cli ]
51+
Script Parameters:
52+
description: (Optional) key pair values passed to HOST_VARS. Can pass simple arguments in this format (ansible_var1,val1;ansible_var2,val2) or JSON format for nested data structures (a dictionary or list of dictionaries accepted).
53+
type: string
54+
tags: [ user_input ]
55+
Inventory Groups:
56+
description: (Optional) Designating groups in playbook to be executed.
57+
type: string
58+
tags: [ user_input ]
59+
Ansible CMD Args:
60+
description: (Optional) Additional arguments passed to ansible-playbook command line execution.
61+
type: string
62+
tags: [ user_input ]
63+
Timeout Minutes:
64+
description: (Optional) Minutes to wait while polling target hosts.
65+
type: integer
66+
default: 10
67+
tags: [ user_input ]
68+
Gitlab Branch:
69+
description: (Optional) Defaults to master branch. This attribute relevant for downloading from non-master branches in Gitlab repos.
70+
type: string
71+
tags: [ user_input ]
72+
Ansible Config Selector:
73+
description: (Optional) An alternative to connectors. Create and match this attribute value on target resources. Both matching selector and connected resources will run together.
74+
type: string
75+
tags: [ user_input ]
76+
Service Categories:
77+
type: list
78+
default: [ Configuration Management ]
79+
artifacts:
80+
icon:
81+
file: shell-icon.png
82+
type: tosca.artifacts.File
83+
driver:
84+
file: AnsibleConfig2GDriver.zip
85+
type: tosca.artifacts.File
8.98 KB
Loading
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import json
2+
3+
4+
class AnsibleConfiguration(object):
5+
def __init__(self, playbook_repo=None, hosts_conf=None, additional_cmd_args=None, timeout_minutes = None):
6+
"""
7+
:type playbook_repo: PlaybookRepository
8+
:type hosts_conf: list[HostConfiguration]
9+
:type additional_cmd_args: str
10+
:type timeout_minutes: float
11+
"""
12+
self.timeoutMinutes = timeout_minutes or 0.0
13+
self.repositoryDetails = playbook_repo or PlaybookRepository()
14+
self.hostsDetails = hosts_conf or []
15+
self.additionalArgs = additional_cmd_args
16+
self.isSecondGenService = True
17+
self.printOutput = True
18+
19+
def get_pretty_json(self):
20+
return json.dumps(self, default=lambda o: getattr(o, '__dict__', str(o)), indent=4)
21+
22+
23+
class PlaybookRepository(object):
24+
def __init__(self):
25+
self.url = None
26+
self.username = None
27+
self.password = None
28+
29+
30+
class HostConfiguration(object):
31+
def __init__(self):
32+
self.ip = None
33+
self.connectionMethod = None
34+
self.connectionSecured = None
35+
self.username = None
36+
self.password = None
37+
self.accessKey = None
38+
self.groups = None
39+
self.parameters = None
40+

0 commit comments

Comments
 (0)