train-mcp 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +24 -0
- data/README.md +28 -0
- data/lib/train-mcp.rb +21 -0
- data/lib/train-mcp/connection.rb +43 -0
- data/lib/train-mcp/platform.rb +13 -0
- data/lib/train-mcp/transport.rb +31 -0
- data/lib/train-mcp/version.rb +10 -0
- data/train-mcp.gemspec +47 -0
- metadata +66 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a08c9d219a7e937c92cbbc3c3ae38f868c9ac3adb90be0ecf782b415eaeed112
|
4
|
+
data.tar.gz: 51224500bc66531999c9054cfc4942ef0f98de8e0660d11ce7f1a96865ad6031
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: add388bc2c9f1233df822d5f6a5d4f905f3a920bbfa1c64364358f352ed2f1ee499b66f7d8ffedaf638457cf45661d8dbd3335d157db9b299207c781bb05fee6
|
7
|
+
data.tar.gz: 92eaf18316dbfc37af3578f36fd8e60c1e865678218404f6feb07e192c2d3f0100c0b4f5e4ee692fb516c547275c93fb520d8e3b4cf15d27c6a6c29bb38a6495
|
data/Gemfile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
# This is Gemfile, which is used by bundler
|
6
|
+
# to ensure a coherent set of gems is installed.
|
7
|
+
# This file lists dependencies needed when outside
|
8
|
+
# of a gem (the gemspec lists deps for gem deployment)
|
9
|
+
|
10
|
+
# Bundler should refer to the gemspec for any dependencies.
|
11
|
+
gemspec
|
12
|
+
|
13
|
+
gem "train-core", [">= 1.7.5", "< 4.0"]
|
14
|
+
group :development do
|
15
|
+
gem "pry"
|
16
|
+
gem "bundler"
|
17
|
+
gem "byebug"
|
18
|
+
gem "minitest"
|
19
|
+
gem "mocha"
|
20
|
+
gem "m"
|
21
|
+
gem "rake"
|
22
|
+
gem "chefstyle"
|
23
|
+
gem "rubocop"
|
24
|
+
end
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
## Inspec Train Plugin for NTT Managed Cloud Platform
|
2
|
+
|
3
|
+
This plugin allows Chef Inspec to connect to the NTT MAnaged CLoud Platform API for validation of cloud resources.
|
4
|
+
|
5
|
+
### Usage
|
6
|
+
|
7
|
+
For local testing, just run `gem build train-mcp.gemspec` , then install the plugin using the command `inspec plugin install <path to gem file created above>`.
|
8
|
+
You need 4 Environment variables set at present:
|
9
|
+
|
10
|
+
* MCP_USER (username for Managed Cloud Platform)
|
11
|
+
* MCP_PASSWORD (password for the above account)
|
12
|
+
* MCP_ORG (Organization ID for MCP)
|
13
|
+
* MCP_ENDPOINT (APi endpoint based on your region. See below for an example)
|
14
|
+
|
15
|
+
Example MCP Endpoint : https://api-au.dimensiondata.com/oec/0.9
|
16
|
+
For different regions, change the api-au in the address above to your desired region (api-na, api-eu etc).
|
17
|
+
In the future, the region will be able to be passed to Train by using mcp://<region> when you are executing controls. This is coming soon...
|
18
|
+
|
19
|
+
To validate you have a connection, run `inspec detect -t mcp://` and you should receive the following output:
|
20
|
+
|
21
|
+
```
|
22
|
+
Platform Details ──────────────────────────────
|
23
|
+
|
24
|
+
Name: mcp
|
25
|
+
Families: cloud, api
|
26
|
+
Release: 0.1.2
|
27
|
+
```
|
28
|
+
|
data/lib/train-mcp.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# This file is known as the "entry point."
|
2
|
+
# This is the file Train will try to load if it
|
3
|
+
# thinks your plugin is needed.
|
4
|
+
|
5
|
+
# The *only* thing this file should do is setup the
|
6
|
+
# load path, then load plugin files.
|
7
|
+
|
8
|
+
# Next two lines simply add the path of the gem to the load path.
|
9
|
+
# This is not needed when being loaded as a gem; but when doing
|
10
|
+
# plugin development, you may need it. Either way, it's harmless.
|
11
|
+
libdir = File.dirname(__FILE__)
|
12
|
+
$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
|
13
|
+
|
14
|
+
# It's traditional to keep your gem version in a separate file, so CI can find it easier.
|
15
|
+
require "train-mcp/version"
|
16
|
+
|
17
|
+
# A train plugin has three components: Transport, Connection, and Platform.
|
18
|
+
# Transport acts as the glue.
|
19
|
+
require "train-mcp/transport"
|
20
|
+
require "train-mcp/platform"
|
21
|
+
require "train-mcp/connection"
|
@@ -0,0 +1,43 @@
|
|
1
|
+
|
2
|
+
require 'train'
|
3
|
+
require 'cloudcontrol'
|
4
|
+
|
5
|
+
# Push platform detection out to a mixin, as it tends
|
6
|
+
# to develop at a different cadence than the rest
|
7
|
+
require 'train-mcp/platform'
|
8
|
+
|
9
|
+
require 'mixlib/shellout'
|
10
|
+
require 'ostruct'
|
11
|
+
|
12
|
+
module TrainPlugins
|
13
|
+
module Mcp
|
14
|
+
class Connection < Train::Plugins::Transport::BaseConnection
|
15
|
+
include TrainPlugins::Mcp::Platform
|
16
|
+
def initialize(options)
|
17
|
+
super(options)
|
18
|
+
@uuid = mcp_client.account.myaccount
|
19
|
+
end
|
20
|
+
|
21
|
+
def mcp_client
|
22
|
+
klass = ::CloudControl::Client
|
23
|
+
return klass.new(@options[:url],
|
24
|
+
@options[:org_id],
|
25
|
+
@options[:user],
|
26
|
+
@options[:pass])
|
27
|
+
# @cache[:api_call][klass.to_s.to_sym] ||= klass.new(url: @options[:url], user: @options[:user], pass: @options[:pass], org_id: @options[:org_id])
|
28
|
+
end
|
29
|
+
|
30
|
+
def mcp_resource(klass, args)
|
31
|
+
klass.new(args)
|
32
|
+
end
|
33
|
+
|
34
|
+
def unique_identifier
|
35
|
+
@uuid = mcp_client.account.myaccount.org_id.to_json
|
36
|
+
end
|
37
|
+
# TODO: determine exactly what this is used for
|
38
|
+
def uri
|
39
|
+
"mcp://#{@options[:url]}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Platform definition file. This is a good place to separate out any
|
2
|
+
# logic regarding the identification of the OS or API at the far end
|
3
|
+
# of the connection.
|
4
|
+
|
5
|
+
module TrainPlugins::Mcp
|
6
|
+
module Platform
|
7
|
+
def platform
|
8
|
+
Train::Platforms.name("mcp").in_family("cloud")
|
9
|
+
plugin_version = "train-mcp: v#{TrainPlugins::Mcp::VERSION}"
|
10
|
+
force_platform!("mcp", release: TrainPlugins::Mcp::VERSION)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# Train Plugins v1 are usually declared under the TrainPlugins namespace.
|
2
|
+
# Each plugin has three components: Transport, Connection, and Platform.
|
3
|
+
# We'll only define the Transport here, but we'll refer to the others.
|
4
|
+
require "train-mcp/connection"
|
5
|
+
require "train"
|
6
|
+
require "train/plugins"
|
7
|
+
|
8
|
+
module TrainPlugins
|
9
|
+
module Mcp
|
10
|
+
class Transport < Train.plugin(1)
|
11
|
+
name "mcp"
|
12
|
+
|
13
|
+
# The only thing you MUST do in a transport is a define a
|
14
|
+
# connection() method that returns a instance that is a
|
15
|
+
# subclass of BaseConnection.
|
16
|
+
option :user, required: true, default: ENV["MCP_USER"]
|
17
|
+
option :pass, required: true, default: ENV["MCP_PASSWORD"]
|
18
|
+
option :org_id, required: true, default: ENV["MCP_ORG"]
|
19
|
+
option :url, required: true, default: ENV["MCP_ENDPOINT"]
|
20
|
+
# The options passed to this are undocumented and rarely used.
|
21
|
+
def connection(_instance_opts = nil)
|
22
|
+
# Typical practice is to cache the connection as an instance variable.
|
23
|
+
# Do what makes sense for your platform.
|
24
|
+
# @options here is the parsed options that the calling
|
25
|
+
# app handed to us at process invocation. See the Connection class
|
26
|
+
# for more details.
|
27
|
+
@connection ||= TrainPlugins::Mcp::Connection.new(@options)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# This file exists simply to record the version number of the plugin.
|
2
|
+
# It is kept in a separate file, so that your gemspec can load it and
|
3
|
+
# learn the current version without loading the whole plugin. Also,
|
4
|
+
# many CI servers can update this file when "version bumping".
|
5
|
+
|
6
|
+
module TrainPlugins
|
7
|
+
module Mcp
|
8
|
+
VERSION = '0.2.0'.freeze
|
9
|
+
end
|
10
|
+
end
|
data/train-mcp.gemspec
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# As plugins are usually packaged and distributed as a RubyGem,
|
2
|
+
# we have to provide a .gemspec file, which controls the gembuild
|
3
|
+
# and publish process. This is a fairly generic gemspec.
|
4
|
+
|
5
|
+
# It is traditional in a gemspec to dynamically load the current version
|
6
|
+
# from a file in the source tree. The next three lines make that happen.
|
7
|
+
lib = File.expand_path("../lib", __FILE__)
|
8
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
9
|
+
require "train-mcp/version"
|
10
|
+
|
11
|
+
Gem::Specification.new do |spec|
|
12
|
+
# Importantly, all Train plugins must be prefixed with `train-`
|
13
|
+
spec.name = "train-mcp"
|
14
|
+
|
15
|
+
# It is polite to namespace your plugin under TrainPlugins::YourPluginInCamelCase
|
16
|
+
spec.version = TrainPlugins::Mcp::VERSION
|
17
|
+
spec.authors = ["Nigel Wright"]
|
18
|
+
spec.email = ["nigel.wright@global.ntt"]
|
19
|
+
spec.summary = "Train Plugin for the NTT Managed Cloud Platform (cloud control)"
|
20
|
+
spec.description = "Example for implementing a Train plugin. This simply performs the ROT13 substitution cipher on file content and command output."
|
21
|
+
spec.homepage = "https://github.com/inspec/train/tree/master/examples/plugin"
|
22
|
+
spec.license = "Apache-2.0"
|
23
|
+
|
24
|
+
# Though complicated-looking, this is pretty standard for a gemspec.
|
25
|
+
# It just filters what will actually be packaged in the gem (leaving
|
26
|
+
# out tests, etc)
|
27
|
+
spec.files = %w{
|
28
|
+
README.md train-mcp.gemspec Gemfile
|
29
|
+
} + Dir.glob(
|
30
|
+
"lib/**/*", File::FNM_DOTMATCH
|
31
|
+
).reject { |f| File.directory?(f) }
|
32
|
+
spec.require_paths = ["lib"]
|
33
|
+
|
34
|
+
# If you rely on any other gems, list them here with any constraints.
|
35
|
+
# This is how `inspec plugin install` is able to manage your dependencies.
|
36
|
+
# For example, perhaps you are writing a thing that talks to AWS, and you
|
37
|
+
# want to ensure you have `aws-sdk` in a certain version.
|
38
|
+
|
39
|
+
# If you only need certain gems during development or testing, list
|
40
|
+
# them in Gemfile, not here.
|
41
|
+
# Do not list inspec as a dependency of the train plugin.
|
42
|
+
|
43
|
+
# All plugins should mention train, > 1.4
|
44
|
+
# spec.add_dependency "train", "~> 3.0"
|
45
|
+
spec.add_dependency 'cloudcontrol_sdk', "0.4.1"
|
46
|
+
|
47
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: train-mcp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nigel Wright
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-12-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: cloudcontrol_sdk
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.4.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.4.1
|
27
|
+
description: Example for implementing a Train plugin. This simply performs the ROT13
|
28
|
+
substitution cipher on file content and command output.
|
29
|
+
email:
|
30
|
+
- nigel.wright@global.ntt
|
31
|
+
executables: []
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- Gemfile
|
36
|
+
- README.md
|
37
|
+
- lib/train-mcp.rb
|
38
|
+
- lib/train-mcp/connection.rb
|
39
|
+
- lib/train-mcp/platform.rb
|
40
|
+
- lib/train-mcp/transport.rb
|
41
|
+
- lib/train-mcp/version.rb
|
42
|
+
- train-mcp.gemspec
|
43
|
+
homepage: https://github.com/inspec/train/tree/master/examples/plugin
|
44
|
+
licenses:
|
45
|
+
- Apache-2.0
|
46
|
+
metadata: {}
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubygems_version: 3.0.6
|
63
|
+
signing_key:
|
64
|
+
specification_version: 4
|
65
|
+
summary: Train Plugin for the NTT Managed Cloud Platform (cloud control)
|
66
|
+
test_files: []
|