def create_binding(site, hostheader='', ipaddress='*', port=80, protocol='http', sslflags=0):
 pscmd = list()
 protocol = str(protocol).lower()
 sslflags = int(sslflags)
 name = _get_binding_info(hostheader, ipaddress, port)
 if (protocol not in _VALID_PROTOCOLS):
  message = "Invalid protocol '{0}' specified. Valid formats: {1}".format(protocol, _VALID_PROTOCOLS)
  raise SaltInvocationError(message)
 if (sslflags not in _VALID_SSL_FLAGS):
  message = "Invalid sslflags '{0}' specified. Valid sslflags range: {1}..{2}".format(sslflags, _VALID_SSL_FLAGS[0], _VALID_SSL_FLAGS[(-1)])
  raise SaltInvocationError(message)
 current_bindings = list_bindings(site)
 if (name in current_bindings):
  _LOG.debug('Binding already present: %s', name)
  return True
 pscmd.append("New-WebBinding -Name '{0}' -HostHeader '{1}'".format(site, hostheader))
 pscmd.append(" -IpAddress '{0}' -Port '{1}'".format(ipaddress, port))
 pscmd.append(" -Protocol '{0}' -SslFlags {1}".format(protocol, sslflags))
 cmd_ret = _srvmgr(str().join(pscmd))
 if (cmd_ret['retcode'] == 0):
  new_bindings = list_bindings(site)
  if (name in new_bindings):
   _LOG.debug('Binding created successfully: %s', name)
   return True
 _LOG.error('Unable to create binding: %s', name)
 return False

def create_binding ( site , hostheader = '' , ipaddress = '*' , port = 80 , protocol = 'http' , sslflags = 0 ) : pscmd = list ( ) protocol = str ( protocol ) . lower ( ) sslflags = int ( sslflags ) name = _get_binding_info ( hostheader , ipaddress , port ) if ( protocol not in _VALID_PROTOCOLS ) : message = "Invalid protocol '{0}' specified. Valid formats: {1}" . format ( protocol , _VALID_PROTOCOLS ) raise SaltInvocationError ( message ) if ( sslflags not in _VALID_SSL_FLAGS ) : message = "Invalid sslflags '{0}' specified. Valid sslflags range: {1}..{2}" . format ( sslflags , _VALID_SSL_FLAGS [ 0 ] , _VALID_SSL_FLAGS [ ( - 1 ) ] ) raise SaltInvocationError ( message ) current_bindings = list_bindings ( site ) if ( name in current_bindings ) : _LOG . debug ( 'Binding already present: %s' , name ) return True pscmd . append ( "New-WebBinding -Name '{0}' -HostHeader '{1}'" . format ( site , hostheader ) ) pscmd . append ( " -IpAddress '{0}' -Port '{1}'" . format ( ipaddress , port ) ) pscmd . append ( " -Protocol '{0}' -SslFlags {1}" . format ( protocol , sslflags ) ) cmd_ret = _srvmgr ( str ( ) . join ( pscmd ) ) if ( cmd_ret [ 'retcode' ] == 0 ) : new_bindings = list_bindings ( site ) if ( name in new_bindings ) : _LOG . debug ( 'Binding created successfully: %s' , name ) return True _LOG . error ( 'Unable to create binding: %s' , name ) return False
create an iis binding .