Chapter 09/circuit-oneops-1-master/components/cookbooks/f5-bigip/libraries/provider_ltm_ssl.rb
#
# Create a new ssl profile given new_resource attributes
#
Create a new ssl profile given new_resource attributes
Create a new ssl profile given new_resource attributes
def create_ssl(type)
        converge_by("Create #{new_resource} ssl#{type} ") do
          Chef::Log.info "Create #{new_resource} ssl#{type}"
	  if !load_balancer.ltm.ssls("#{new_resource.mode}").find { |p| p =~ /(^|\/)#{new_resource.ssl_id}#{type}$/ }.nil?
          	load_balancer.client['Management.KeyCertificate'].key_delete("MANAGEMENT_MODE_DEFAULT", ["/Common/#{new_resource.ssl_id}#{type}"])
          	load_balancer.client['Management.KeyCertificate'].certificate_delete("MANAGEMENT_MODE_DEFAULT", ["/Common/#{new_resource.ssl_id}#{type}"])
	  end
          key_content_blob = ::File.open("#{new_resource.key_location}", "rb").read
          cert_content_blob = ::File.open("#{new_resource.cert_location}", "rb").read
          cacert_content_blob = ::File.open("#{new_resource.cacert_location}", "rb").read if !new_resource.cacert_location.nil?
          load_balancer.client['Management.KeyCertificate'].certificate_import_from_pem("#{new_resource.mode}", ["#{new_resource.ssl_id}#{type}"], [cert_content_blob],'true')
          load_balancer.client['Management.KeyCertificate'].key_import_from_pem("#{new_resource.mode}", ["#{new_resource.ssl_id}#{type}"], [key_content_blob],'true')
          load_balancer.client['Management.KeyCertificate'].certificate_import_from_pem("#{new_resource.mode}", ["cacert-#{new_resource.ssl_id}#{type}"], [cacert_content_blob],'true') if !cacert_content_blob.nil?
          new_resource.updated_by_last_action(true)
        end
      end
def create_ssl ( type ) converge_by ( "Create #{new_resource} ssl#{type} " ) do Chef :: Log . info "Create #{new_resource} ssl#{type}" if ! load_balancer . ltm . ssls ( "#{new_resource.mode}" ) . find { | p | p =~ / (^| \/ ) #{ new_resource . ssl_id } #{ type } $ / } . nil? load_balancer . client [ 'Management.KeyCertificate' ] . key_delete ( "MANAGEMENT_MODE_DEFAULT" , [ "/Common/#{new_resource.ssl_id}#{type}" ] ) load_balancer . client [ 'Management.KeyCertificate' ] . certificate_delete ( "MANAGEMENT_MODE_DEFAULT" , [ "/Common/#{new_resource.ssl_id}#{type}" ] ) end key_content_blob = :: File . open ( "#{new_resource.key_location}" , "rb" ) . read cert_content_blob = :: File . open ( "#{new_resource.cert_location}" , "rb" ) . read cacert_content_blob = :: File . open ( "#{new_resource.cacert_location}" , "rb" ) . read if ! new_resource . cacert_location . nil? load_balancer . client [ 'Management.KeyCertificate' ] . certificate_import_from_pem ( "#{new_resource.mode}" , [ "#{new_resource.ssl_id}#{type}" ] , [ cert_content_blob ] , 'true' ) load_balancer . client [ 'Management.KeyCertificate' ] . key_import_from_pem ( "#{new_resource.mode}" , [ "#{new_resource.ssl_id}#{type}" ] , [ key_content_blob ] , 'true' ) load_balancer . client [ 'Management.KeyCertificate' ] . certificate_import_from_pem ( "#{new_resource.mode}" , [ "cacert-#{new_resource.ssl_id}#{type}" ] , [ cacert_content_blob ] , 'true' ) if ! cacert_content_blob . nil? new_resource . updated_by_last_action ( true ) end end
Create a new ssl profile given new_resource attributes
Create a new ssl profile given new_resource attributes
# Clean Up of existing unused keys and certificates
type
<not_specific>