libraries/docker.rb
# A Groovy snippet that will add a new docker host given a hostname and IP address
# @param [String] hostname
# @param [String] IP address
A Groovy snippet that will add a new docker host given a hostname and IP address
A Groovy snippet that will add a new docker host given a hostname and IP address
def add_docker_host(hostname, ip, credentials)
      if credentials.nil?
        <<-EOH
          DockerServerEndpoint endpoint_#{hostname.tr('.-', '_')} = new DockerServerEndpoint(
            'tcp://#{ip}:2375',     // uri
            ''                      // credentials
          )
          dkCloud.add(
            new DockerCloud(
              '#{hostname}',
              dkTemplates,
              endpoint_#{hostname.tr('.-', '_')}, // endpoint
              400,                  // containerCapStr
              5,                    // connectTimeout
              600,                  // readTimeout
              '',                   // version
              ''                    // dockerHostname
            )
          );
        EOH
      else
        <<-EOH
          DockerServerEndpoint endpoint_#{hostname.tr('.-', '_')} = new DockerServerEndpoint(
            'tcp://#{ip}:2376',     // uri
            '#{credentials}'        // credentials
          )
          dkCloud.add(
            new DockerCloud(
              '#{hostname}',
              dkTemplates,
              endpoint_#{hostname.tr('.-', '_')}, // endpoint
              400,                  // containerCapStr
              5,                    // connectTimeout
              600,                  // readTimeout
              '',                   // version
              ''                    // dockerHostname
            )
          );
        EOH
      end
    end
def add_docker_host ( hostname , ip , credentials ) if credentials . nil? <<-EOH 
          DockerServerEndpoint endpoint_ #{ hostname . tr ( '.-' , '_' ) }  = new DockerServerEndpoint(
            'tcp:// #{ ip } :2375',     // uri
            ''                      // credentials
          )
          dkCloud.add(
            new DockerCloud(
              ' #{ hostname } ',
              dkTemplates,
              endpoint_ #{ hostname . tr ( '.-' , '_' ) } , // endpoint
              400,                  // containerCapStr
              5,                    // connectTimeout
              600,                  // readTimeout
              '',                   // version
              ''                    // dockerHostname
            )
          );

         EOH else <<-EOH 
          DockerServerEndpoint endpoint_ #{ hostname . tr ( '.-' , '_' ) }  = new DockerServerEndpoint(
            'tcp:// #{ ip } :2376',     // uri
            ' #{ credentials } '        // credentials
          )
          dkCloud.add(
            new DockerCloud(
              ' #{ hostname } ',
              dkTemplates,
              endpoint_ #{ hostname . tr ( '.-' , '_' ) } , // endpoint
              400,                  // containerCapStr
              5,                    // connectTimeout
              600,                  // readTimeout
              '',                   // version
              ''                    // dockerHostname
            )
          );

         EOH end end
A Groovy snippet that will add a new docker host given a hostname and IP address
A Groovy snippet that will add a new docker host given a hostname and IP address
hostname
ip
credentials
None