original_docstring: Create share at samba server.
docstring: Create share at samba server.
docstring_tokens: Create share at samba server .
code: def create_export(self, server, share_name, recreate=False):
          """Create share at samba server."""
          share_path = os.path.join(self.configuration.share_mount_path,
                                    share_name)
          create_cmd = [
              'sudo', 'net', 'conf', 'addshare', share_name, share_path,
              'writeable=y', 'guest_ok=y',
          ]
          try:
              self._ssh_exec(
                  server, ['sudo', 'net', 'conf', 'showshare', share_name, ])
          except exception.ProcessExecutionError:
              # Share does not exist, create it
              try:
                  self._ssh_exec(server, create_cmd)
              except Exception as child_e:
                  msg = _("Could not create CIFS export %s.") % share_name
                  LOG.exception(child_e)
                  LOG.error(msg)
                  raise exception.ManilaException(reason=msg)
          else:
              # Share exists
              if recreate:
                  self._ssh_exec(
                      server, ['sudo', 'net', 'conf', 'delshare', share_name, ])
                  try:
                      self._ssh_exec(server, create_cmd)
                  except Exception as e:
                      msg = _("Could not create CIFS export %s.") % share_name
                      LOG.exception(e)
                      LOG.error(msg)
                      raise exception.ManilaException(reason=msg)
              else:
                  msg = _('Share section %s already defined.') % share_name
                  raise exception.ShareBackendException(msg=msg)
  
          for param, value in self.parameters.items():
              self._ssh_exec(server, ['sudo', 'net', 'conf', 'setparm',
                             share_name, param, value])
  
          return self.export_format % (server['public_address'], share_name)
code_tokens: def create_export ( self , server , share_name , recreate = False ) : share_path = os . path . join ( self . configuration . share_mount_path , share_name ) create_cmd = [ 'sudo' , 'net' , 'conf' , 'addshare' , share_name , share_path , 'writeable=y' , 'guest_ok=y' , ] try : self . _ssh_exec ( server , [ 'sudo' , 'net' , 'conf' , 'showshare' , share_name , ] ) except exception . ProcessExecutionError : try : self . _ssh_exec ( server , create_cmd ) except Exception as child_e : msg = _ ( "Could not create CIFS export %s." ) % share_name LOG . exception ( child_e ) LOG . error ( msg ) raise exception . ManilaException ( reason = msg ) else : if recreate : self . _ssh_exec ( server , [ 'sudo' , 'net' , 'conf' , 'delshare' , share_name , ] ) try : self . _ssh_exec ( server , create_cmd ) except Exception as e : msg = _ ( "Could not create CIFS export %s." ) % share_name LOG . exception ( e ) LOG . error ( msg ) raise exception . ManilaException ( reason = msg ) else : msg = _ ( 'Share section %s already defined.' ) % share_name raise exception . ShareBackendException ( msg = msg ) for param , value in self . parameters . items ( ) : self . _ssh_exec ( server , [ 'sudo' , 'net' , 'conf' , 'setparm' , share_name , param , value ] ) return self . export_format % ( server [ 'public_address' ] , share_name )
short_docstring: Create share at samba server.
short_docstring_tokens: Create share at samba server .
comment: """Create share at samba server."""$SEP$# Share does not exist, create it$SEP$# Share exists