Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EXPORT: Exports regelmässig auf SFTP hochladen #272

Closed
6 of 7 tasks
Tracked by #302
carlobeltrame opened this issue Jan 31, 2024 · 4 comments · Fixed by #554
Closed
6 of 7 tasks
Tracked by #302

EXPORT: Exports regelmässig auf SFTP hochladen #272

carlobeltrame opened this issue Jan 31, 2024 · 4 comments · Fixed by #554
Assignees
Labels

Comments

@carlobeltrame
Copy link
Member

carlobeltrame commented Jan 31, 2024

Gewisse Exports des SAC müssen für Rückwärtskompatibilität regelmässig erstellt und auf einem SFTP-Ordner abgelegt werden.

Tech Spec

  • Umsetzung im SAC Wagon
  • Liste der relevanten Exports:
    • Adressen_xxxxxxxx.csv für alle Sektionen und Ortsgruppen, wobei xxxxxxxx im Dateinamen die Navision ID (zero-padded auf 8 Stellen) der exportierten Sektion oder Ortsgruppe ist
    • bisher keine weiteren aufgetaucht
  • Kadenz: Nächtlich
  • SFTP-Gem:
    gem "net-ssh", "~> 7.0.0.beta1", require: "net/ssh" # TODO: remove once net-sftp 3 updates ssh 7
    gem "net-sftp"
    
  • SFTP-Verbindung (Beispiel-Implementation):
    class Sftp
      ConnectionError = Class.new(StandardError)
      def remote_files(path, glob: "*")
        connection.dir.glob(path.to_s, glob)
          .select(&:file?)
          .collect(&:name)
          .select { |filename| ::File.fnmatch(glob, filename) }
      end
    
      def download_file(name, target)
        connection.download! name.to_s, target.to_s
      end
    
      def upload_file(name, target)
        connection.upload! name.to_s, target.to_s
      end
    
      def remove_file(path)
        connection.remove! path.to_s
      end
    
      def connection
        @connection ||= Net::SFTP.start(host, user, options).tap(&:connect!)
      rescue => e
        raise ConnectionError.new(e)
      end
    
      def create_remote_dir(name)
        connection.mkdir!(name)
      end
    
      # TODO - how to avoid the following in spec when rescuing specific exception
      # NameError: uninitialized constant #<ClassDouble(Net::SFTP) (anonymous)>::StatusException
      def directory?(name)
        connection.file.directory?(name)
      rescue
        false
      end
    
      private
    
      def options
        credentials = @endpoint.key ? {key_data: [@endpoint.key]} : {password: password}
        credentials.merge(non_interactive: true, port: port).compact
      end
    end
  • Connection Details via Environment Variabeln (auch im Deployment als Secrets einbauen)
  • Ordnerstruktur auf dem FTP-Server: Alle exportierten Dateien des Adress-Exports in den Unterordner "sektionen" hinein, in Unterordnern benannt nach der Navision-ID (ohne führende Nullen) der exportierten Sektion oder Ortsgruppe ablegen:
    <root wo die SFTP Credentials hinzeigen>
      sektionen
        1234
          Adressen_00001234.csv
        2000
          Adressen_00002000.csv
        ...
    

TODO

@carlobeltrame carlobeltrame self-assigned this Jan 31, 2024
@ODI-Navil ODI-Navil added the s_6 Export_Sektionen label Feb 20, 2024
@carlobeltrame carlobeltrame removed their assignment Mar 7, 2024
@carlobeltrame carlobeltrame self-assigned this Mar 21, 2024
@sykesonrocks sykesonrocks removed their assignment Apr 18, 2024
@TheWalkingLeek TheWalkingLeek self-assigned this May 6, 2024
@TheWalkingLeek TheWalkingLeek linked a pull request May 17, 2024 that will close this issue
TheWalkingLeek added a commit that referenced this issue May 17, 2024
TheWalkingLeek added a commit that referenced this issue May 17, 2024
@TheWalkingLeek TheWalkingLeek removed their assignment May 17, 2024
TheWalkingLeek added a commit that referenced this issue May 24, 2024
amaierhofer pushed a commit that referenced this issue May 27, 2024
@amaierhofer
Copy link
Contributor

Ist aus meiner sicht gut, hab noch rebased und einen kosmetischen commit drauf gesetzt und code mässig ist das aus meiner Sicht fertig.

Es gibt aber noch ein Problem beim build. Aus einem mir nicht offensichtlichem Grund sind die Attribute im Graphiti schema anders sortiert. Ist das schonmal wo aufgetreten? Und dann frag ich mich noch ob wir nicht noch Anpassungen am Deployment brauchen. Läuft das separat? Weist du da was? Wäre sicher gut, wenn wir das gleich zusammen ausliefern würden, sodass man auch validieren kann das der upload tatsächlich erfolgt ist.

TheWalkingLeek added a commit that referenced this issue May 28, 2024
@ThomasEllenberger ThomasEllenberger added blocked Waiting for another issue to be finished before this can be continued Sprint 4 and removed Sprint 3 labels May 29, 2024
@ThomasEllenberger
Copy link

@carlobeltrame @TheWalkingLeek Im Jira Ticket sind die Informationen nun vorhanden, respektive sollte euch @sykesonrocks die Zugangsdaten geben können.
Ich gehe davon aus, dass dieses Ticket dadurch nicht mehr blokiert ist?

@carlobeltrame carlobeltrame removed the blocked Waiting for another issue to be finished before this can be continued label Jun 11, 2024
@carlobeltrame
Copy link
Member Author

@carlobeltrame @TheWalkingLeek Im Jira Ticket sind die Informationen nun vorhanden, respektive sollte euch @sykesonrocks die Zugangsdaten geben können. Ich gehe davon aus, dass dieses Ticket dadurch nicht mehr blokiert ist?

Ticket ist jetzt nicht mehr blockiert.

@TheWalkingLeek
Copy link
Member

7abf988

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants