ocp
Why another command line tool for the OpenShift Container Platform? The current Golang based command line tool oc is solid, plus its written in Golang! This is just an academic attempt to build a tool in Ruby.
The intent is to use it in ManageIQ/CloudForms.
Usage
$ git clone https://github.com/kevensen/ocpcmd
$ cd ocpcmd
$ ./ocp.rb help
Install as a Gem
$ git clone https://github.com/kevensen/ocpcmd
$ cd ocpcmd
$ gem build ./ocp.gemspec
$ gem install ocp-0.0.1.gem
Use the Gem in IRB
$ irb
irb(main):001:0> require 'ocp'
=> true
irb(main):002:0> ocpconfig = OcpConfig.new
=> #<OcpConfig:0x007fb2058c3598 @master=nil, @token=nil, @noverifyssl=false, @output=:json, @debug=false, @pretty=false, @clientcertfile=nil, @clientkeyfile=nil, @clientcafile=nil, @clientcert=nil, @clientkey=nil>
irb(main):003:0> ocpconfig.set_config_by_file("path..to../config.yaml")
=> nil
irb(main):004:0> ocpapi = OcpApi.new
=> #<OcpApi:0x007fb2029acf48 @api_ver="v1", @client=#<OcpClient:0x007fb2029aced0 @method=nil, @url=nil, @token=nil, @noverifyssl=false, @pretty=false, @clientcert=nil, @clientkey=nil, @clientca=nil, @clientcafile=nil, @debug=nil>, @api="oapi", @version="v1", @name=nil>
irb(main):005:0> ocpapi.setup(ocpconfig)
=> nil
irb(main):006:0> puts "#{ocpapi}"
Or Use the Gem from the Command Line
$ ocp getapi -c config.yaml
Sample Config File
Place this file in the ocpcmd directory
#
# YAML Config file for sat6cmd
#
# Connection config items
connection:
master: "https://master.example.com:8443"
token: a1nX8rtGt132nLJHkAiGVCJnI4Y4XvtUsThB4xthWOI
no_verify_ssl: false
Another Sample Config File
If you want to access the API with the system:admin user, you can't use a token. This is because the system:admin user doesn't get a token! You need to copy three files to the machine running the gem:
- /etc/origin/master/admin.crt
- /etc/origin/master/admin.key
- /etc/origin/master/ca.crt
Once you have these files, update your config.yaml accordingly.
#
# YAML Config file for sat6cmd
#
# Connection config items
connection:
master: "https://master.example.com:8443"
client-certificate-file: admin.crt
client-key-file: admin.key
client-ca-file: ca.crt
no_verify_ssl: false