Setting up Your Open-Source Development Environment
Total Page:16
File Type:pdf, Size:1020Kb
Setting Up Your Open-Source Development Environment Mark Irish [email protected] Staff Software Developer IBM April 28, 2021 POW3R Digital Outline Open-Source Software on IBM i Setting Up Your Development Environment Access Client Solutions Installing Yum Setting up SSH Mounting the File System Using a Sane Text Editor Setting up ODBC Containers (optional) © 2021 IBM Corporation Open-Source Software on IBM i © 2021 IBM Corporation Open-Source Software (OSS) Open-source software has publicly available source code Why would anyone make open-source software? – Greater transparency of what software does – Others can find/fix bugs and add functionality – Wider adoption and popularity “Free”, but... Use of open-source software is dictated by a license © 2021 IBM Corporation Open-Source Software on IBM i Delivered on PASE (Portable Application Solutions Environment) Delivered through yum (package manager) – Very “normal”, will feel familiar to Unix users (Linux, Mac) 600+ packages available DO NOT USE 5733-OPS (out of support) © 2021 IBM Corporation OSS as a Gateway Artificial Intelligence (AI) / Machine Learning (ML) – IBM Watson Solutions ● Watson Studio ● Watson Machine Learning ● Watson Machine Learning Accelerator Quantum Computing Internet of Things (IoT) REST APIs and more! © 2021 IBM Corporation Things That Don’t Go Together © 2021 IBM Corporation Things That Don’t Go Together © 2021 IBM Corporation Things That Don’t Go Together © 2021 IBM Corporation Need a More “Normal” Environment The 5250 “green screen” terminal isn’t going to cut it for developing open- source applications on/with IBM i Need to set up a “normal” environment, that involves: – An SSH terminal – A mounted file-system on the development machine – A modern text-editor – An ODBC connection to Db2 for i © 2021 IBM Corporation Using Access Client Solutions © 2021 IBM Corporation Access Client Solutions (ACS) I’ve never met an IBM i developer who didn’t already use ACS, but… ...you need to install ACS ACS will allow us to: – Manage our open-source software – Run a 5250 emulator when we need to do 5250 things – Create and explore database schemas/tables/views with a GUI – Easily run SQL commands (and see what syntax errors exist) – Much more! © 2021 IBM Corporation Access Client Solutions (ACS) ACS is a platform-independent dashboard for managing IBM i Is Java based, and can be run on almost any OS that supports Java – Linux – Mac – Windows – IBM i Not strictly required, but makes managing OSS much easier https://www.ibm.com/support/pages/ibm-i-access-client-solutions © 2021 IBM Corporation Installing ACS Installation steps depend on where you are installing it General steps: – Download the zipped archive – Unzip the archive – Run the included program (install_acs_64) – Launch ACS © 2021 IBM Corporation Access Client Solutions (ACS) © 2021 IBM Corporation The Open-Source Environment © 2021 IBM Corporation Getting “The Open-Source Environment” “The Open-Source Environment” is really just yum yum manages RPMs on IBM i yum searches repositories hosted on the internet (or intranet) for packages IBM-hosted public repository for IBM i RPMs: – ftp://public.dhe.ibm.com/software/ibmi/products/pase/rpms/repo Community-hosted repositories also exist yum will automatically manage dependencies for your installations © 2021 IBM Corporation RPMs yum allows us to install RPMs RPM stands for RPM Package Manager Contain pre-compiled binaries (and other files), packaged by IBM RPM file names look like: <name>-<version>-<release>.<os>.<architecture>.rpm – e.g.: nodejs10-10.15.0-2.ibmi7.2.ppc64.rpm © 2021 IBM Corporation Getting yum with ACS http://ibm.biz/ibmi-rpms Make sure SSHD is running on your system – STRTCPSVR *SSHD In ACS, go to Tools > Open Source Package Management – You will be prompted to install the “Open source environment” – IBM-hosted IBM i RPM repository will automatically be configured © 2021 IBM Corporation Getting yum with ACS © 2021 IBM Corporation Using SSH to use a Remote Terminal © 2021 IBM Corporation SSH to IBM i Running QSH in 5250 doesn’t cut it Need a more “normal” development environment like what open-source software expects © 2021 IBM Corporation SSH to IBM i Need to have SSHD running – STRTCPSVR *SSHD If you don’t have the SSH daemon on your system, or haven’t generated host keys, consult: – https://www.ibm.com/support/pages/starting-openssh-server-sshd © 2021 IBM Corporation Getting bash on IBM i bash is an industry-standard shell Most open-source software tutorials you see will assume you are using bash Using ACS, go to Tools > Open Source Package Management Select “Available Packages”, then install bash © 2021 IBM Corporation Getting bash on IBM i © 2021 IBM Corporation Getting bash on IBM i Just because we have bash, doesn’t mean that bash will be used by default There is a helpful SQL procedure to set it correctly! Simply run: CALL QSYS2.SET_PASE_SHELL_INFO('<UID>', '/QOpenSys/pkgs/bin/bash') Now when you login with SSH, you will automatically be using bash, like most other open-source users! © 2021 IBM Corporation SSH to IBM i from Windows Download PuTTY from – https://www.putty.org/ © 2021 IBM Corporation SSH to IBM i from Windows © 2021 IBM Corporation SSH to IBM i from Windows Can save system and username so you only have to enter password © 2021 IBM Corporation SSH to IBM i from Mac or Linux Need to download openssh – MIGHT be already installed on your OS, can check by running something like: which ssh How to install will depend on your OS / distribution, but generally will look something like <pkg-manager> install openssh © 2021 IBM Corporation SSH to IBM i from Mac or Linux Generate a public and private key using ssh-keygen: ssh-keygen -t rsa -b 4096 This will likely place the keys under your home directory in the .ssh directory Public: id_rsa.pub is often shared with other services servers Private: id_rsa is for you to protect! © 2021 IBM Corporation SSH to IBM i from Mac or Linux Can connect to IBM i by running ssh <UID>@<SYSTEM> ...and then entering your password A better solution exists... © 2021 IBM Corporation SSH to IBM i from Mac or Linux In your ~/.ssh directory, create or edit a file called config Host <easy server name> HostName <actual server name> User <UID> ForwardAgent yes ServerAliveInterval 5 Now you can just run ssh <easy-server-name> and it will known which username to use and forward your SSH key to use for other services Still have to enter password, but... © 2021 IBM Corporation SSH to IBM i from Mac or Linux Set up the public key on the server using ssh-copy-id: ssh-copy-id -i ~/.ssh/id_rsa.pub <config server name> You can now login without a password! Simply run ssh <config server name> and you will be logged in to a terminal session running on IBM i, using your default shell © 2021 IBM Corporation Mounting the File System © 2021 IBM Corporation Mounting the File System Mounting the file system means creating a link from a directory on your development system to a remote file system In this case, we want to access the IFS as if it were on our local machine Allows us to use development tools (IDEs) more easily Changes we make are (nearly) instantly propagated to the IFS © 2021 IBM Corporation Mounting the File System on Windows Windows makes this a little more difficult than it needs to be… There is a Win-SSHFS that will allow you to connect to a POSIX file system (like PASE!) Instructions and download can be found at: – https://github.com/billziss-gh/sshfs-win © 2021 IBM Corporation Mounting the File System (Linux/Mac) Going to use sshfs, which is transferring file system data over the same SSH protocols used to get a remote terminal session Installation – Mac: https://github.com/osxfuse/sshfs/releases – Linux: See if it is preinstalled with your OS, or use your package manager ● Package name might be something like fuse-sshfs © 2021 IBM Corporation Using sshfs Need to create a directory to use as our mount point – mkdir /mnt/myibmisystem Then simply mount the part of the IFS you want to use! – sudo sshfs -o allow_other [email protected]:/ /mnt/myibmisystem -o allow_other : Allows you to access the mounted files without using sudo [email protected]:/ : Mount the file system from the root /mnt/myibmisystem : The directory where the file system is mounted © 2021 IBM Corporation Using a Modern IDE / Text Editor © 2021 IBM Corporation Visual Studio Code A modern, fast, light-weight text editor Syntax highlighting for almost every language Built-in debugging for most languages Extension support (Several IBM i extensions) NOT VISUAL STUDIO Sometimes called “VS Code” or “Code” © 2021 IBM Corporation Visual Studio Code © 2021 IBM Corporation ODBC to Connect to the Database © 2021 IBM Corporation ODBC Open Database Connectivity (ODBC) is a standardized database interface maintained by Microsoft © 2021 IBM Corporation ODBC ODBC is the preferred/recommended method of connecting to open-source on IBM i – Robust IBM i driver allows for MOST everything you need to do – ODBC connectors already exist for most open-source languages There is some setup required, but once you set it up, you don’t have to worry about it again I have an entire hour-long presentation on ODBC (I’ve included it at the end of this presentation!), but the gist is... © 2021 IBM Corporation ODBC Driver Manager On Windows, pre-installed (ODBC Data Source Administrator) On Linux/Mac, need to use package manager to download unixODBC