Permalink
Browse files

Merge pull request #16 from vmware/development

Update master branch
  • Loading branch information...
2 parents 3c0bc17 + 9077c2a commit 5f7b615f0e40baecb5b03d6c287ddfb7b040b3e8 @nanliu nanliu committed Nov 15, 2013
@@ -1,29 +1,16 @@
# Copyright (C) 2013 VMware, Inc.
begin
require 'puppet_x/puppetlabs/transport'
-rescue LoadError => detail
- require 'pathname' # WORK_AROUND #14073 and #7788
- vmware_module = Puppet::Module.find('vmware_lib', Puppet[:environment].to_s)
- require File.join vmware_module.path, 'lib/puppet_x/puppetlabs/transport'
-end
-
-begin
require 'puppet_x/puppetlabs/transport/ssh'
rescue LoadError => detail
require 'pathname' # WORK_AROUND #14073 and #7788
- module_lib = Pathname.new(__FILE__).parent.parent.parent
- require File.join module_lib, 'puppet_x/puppetlabs/transport/ssh'
+ mod = Puppet::Module.find('vmware_lib', Puppet[:environment].to_s)
+ require File.join mod.path, 'lib/puppet_x/puppetlabs/transport'
+ require File.join mod.path, 'lib/puppet_x/puppetlabs/transport/ssh'
end
-
class Puppet::Provider::Vcsa < Puppet::Provider
confine :feature => :ssh
- def self.transport(resource)
- @transport ||= PuppetX::Puppetlabs::Transport.retrieve(:resource_ref => resource[:transport], :catalog => resource.catalog, :provider => 'ssh')
- end
-
- def transport
- self.class.transport(resource)
- end
+ include PuppetX::Puppetlabs::Transport
end
@@ -3,7 +3,7 @@
provider_path = Pathname.new(__FILE__).parent.parent
require File.join(provider_path, 'vcsa')
-Puppet::Type.type(:vcsa_db).provide(:vcsa_db, :parent => Puppet::Provider::Vcsa ) do
+Puppet::Type.type(:vcsa_db).provide(:ssh, :parent => Puppet::Provider::Vcsa ) do
@doc = 'Manages vCSA db'
def create
@@ -3,7 +3,7 @@
provider_path = Pathname.new(__FILE__).parent.parent
require File.join(provider_path, 'vcsa')
-Puppet::Type.type(:vcsa_eula).provide(:vcsa_eula, :parent => Puppet::Provider::Vcsa ) do
+Puppet::Type.type(:vcsa_eula).provide(:ssh, :parent => Puppet::Provider::Vcsa ) do
@doc = 'Manages vCSA EULA'
def accept
@@ -3,7 +3,7 @@
provider_path = Pathname.new(__FILE__).parent.parent
require File.join(provider_path, 'vcsa')
-Puppet::Type.type(:vcsa_java).provide(:vcsa_java, :parent => Puppet::Provider::Vcsa ) do
+Puppet::Type.type(:vcsa_java).provide(:ssh, :parent => Puppet::Provider::Vcsa ) do
@doc = 'Manages vCSA java'
mk_resource_methods
@@ -3,7 +3,7 @@
provider_path = Pathname.new(__FILE__).parent.parent
require File.join(provider_path, 'vcsa')
-Puppet::Type.type(:vcsa_service).provide(:vcsa_service, :parent => Puppet::Provider::Vcsa ) do
+Puppet::Type.type(:vcsa_service).provide(:ssh, :parent => Puppet::Provider::Vcsa ) do
@doc = 'Manages vCSA service'
def create
@@ -3,7 +3,7 @@
provider_path = Pathname.new(__FILE__).parent.parent
require File.join(provider_path, 'vcsa')
-Puppet::Type.type(:vcsa_sso).provide(:vcsa_sso, :parent => Puppet::Provider::Vcsa ) do
+Puppet::Type.type(:vcsa_sso).provide(:ssh, :parent => Puppet::Provider::Vcsa ) do
@doc = 'Manages vCSA sso'
def create
@@ -1,45 +0,0 @@
-# Copyright (C) 2013 VMware, Inc.
-require 'net/ssh' if Puppet.features.ssh? and ! Puppet.run_mode.master?
-
-module PuppetX::Puppetlabs::Transport
- class Ssh
- attr_accessor :ssh
- attr_reader :name, :user, :password, :host
-
- def initialize(opt)
- @name = opt[:name]
- @user = opt[:username]
- @password = opt[:password]
- @host = opt[:server]
- # symbolize keys for options
- options = opt[:options] || {}
- @options = options.inject({}){|h, (k, v)| h[k.to_sym] = v; h}
- @options[:password] = @password
- default = {:timeout => 10}
- @options = default.merge(@options)
- Puppet.debug("#{self.class} initializing connection to: #{@host}")
- end
-
- def connect
- @ssh ||= Net::SSH.start(@host, @user, @options)
- end
-
- # wrapper for debugging
- def exec!(command)
- Puppet.debug("Executing on #{@host}:\n#{command}")
- result = @ssh.exec!(command)
- Puppet.debug("Execution result:\n#{result}")
- result
- end
-
- def exec(command)
- Puppet.debug("Executing on #{@host}:\n#{command}")
- @ssh.exec(command)
- end
-
- def close
- Puppet.debug("#{self.class} closing connection to: #{@host}")
- @ssh.close if @ssh
- end
- end
-end

0 comments on commit 5f7b615

Please sign in to comment.