Thursday May 15, 2014

Unbreakable Linux Network APIs example

I posted a short blog entry about the recently released ULN APIs the other day with a sample of how to call the different APIs. Here is a concrete example to use the API to find a package in a channel and download it.

$ ./ulnget.py kernel-headers.2.6.32-71.29 ol6_x86_64_latest
Searching for 'kernel-headers.2.6.32-71.29' in channel 'ol6_x86_64_latest'

Logging in...
Logged in...
Retrieving all packages...
Found kernel-headers.2.6.32-71.29.1.el6
Getting package details...
Downloading https://uln.oracle.com/XMLRPC/GET-REQ/ol6_x86_64_latest/
kernel-headers-2.6.32-71.29.1.el6.x86_64.rpm...

Logged out...

The code for the above is pasted below, this is just a very simplistic example...

#!/usr/bin/python
try:
    import os
    import sys
    import getpass
    import datetime
    import xmlrpclib

except ImportError, e:
    raise ImportError (str(e) + ': Module  not found')

if len(sys.argv) != 3:
   print "Usage : ulnget.py [packagename] [channelname]"
   exit(1) 

search = str(sys.argv[1])
channelLabel = str(sys.argv[2])

print "Searching for '%s' in channel '%s'" % (search, channelLabel)

SERVER_URL = 'https://linux-update.oracle.com/rpc/api'

USERNAME = 'username'
PASSWORD = 'password'

# channelLabel = 'ol6_x86_64_latest'

client = xmlrpclib.Server(SERVER_URL)

print ""

# login
print "Logging in..."
sessionKey = client.auth.login(USERNAME,PASSWORD)
if len(sessionKey) != 43:
   print "Invalid %d sessionKey : '%s'" % sessionKey
   exit(1)

print "Logged in..." 

print "Retrieving all packages..."
packageList = client.channel.software.listAllPackages(sessionKey, channelLabel)

for package in packageList:
   packageName = '%s.%s-%s' % (package['package_name'],package['package_version']
      ,package['package_release'])
   if search in packageName:
      print "Found %s" % packageName
      pid = package['package_id']
      print "Getting package details..."
      packageDetail = client.packages.getDetails(sessionKey, pid)
      url = packageDetail['download_urls'][0]
      import  urllib2
      req = urllib2.Request(url,headers={'X-ULN-API-User-Key': sessionKey})
      try:
          print "Downloading %s..." %url
          response = urllib2.urlopen(req)
          contents = response.read()
      except urllib2.HTTPError, e:
          print
          print "HTTP error code  : %d" %e.code
      except Exception, e:
          print
          print str(e)

print ""

retval = client.auth.logout(sessionKey)
if retval == 1:
  print "Logged out..."
else:
  print "Failed to log out..."

Tuesday May 13, 2014

Channel subscription from command-line support added to the Unbreakable Linux Network(ULN)

Until recently, to add channels to a server or to register a server as a yum-repository server, one had to log into ULN and manually do this. First a server had to be tagged as a yum server and then any channels that would be included, would have to be added to this server. While this is an easy task, it does involve logging into the website, and manually following a few steps and it could not be automated.

We provided an updated rhn-setup RPM that now adds a new tool called uln-channel which allows users with ULN access to enable a server as a yum server and also add/remove/list channels for this server. This will allow for easy automation.

The latest version of the rhn-setup rpm is rhn-setup-1.0.0.1-16.0.9.el6.noarch. The uln-channel rpm is currently only supported with Oracle Linux version 6.

# uln-channel -h
Usage: uln-channel [options]

Options:
  -c CHANNEL, --channel=CHANNEL
                        name of channel you want to (un)subscribe
  -a, --add             subscribe to channel
  -r, --remove          unsubscribe from channel
  -l, --list            list channels
  -b, --base            show base channel of a system
  -L, --available-channels
                        list all available child channels
  -v, --verbose         verbose output
  -u USER, --user=USER  your user name
  -p PASSWORD, --password=PASSWORD
                        your password
  --enable-yum-server   enable yum server setting
  --disable-yum-server  disable yum server setting
  -h, --help            show this help message and exit

# uln-channel --list
Username: wim@company.com
Password:
ol6_i386_UEK_latest
ol6_i386_ksplice
ol6_i386_latest

# uln-channel --base
Username: wim@company.com
Password:
ol6_i386_ksplice
ol6_i386_latest
ol6_i386_UEK_latest

# uln-channel --enable-yum-server
Username: wim@company.com
Password:

# uln-channel --disable-yum-server
Username: wim@company.com
Password:


# uln-channel --available-channels
Username: wim@company.com
Password:
 el3_i386_latest
el3_u8_i386_patch
el3_u8_x86_64_patch
el3_u9_i386_base
el3_u9_i386_patch
el3_u9_x86_64_base
el3_u9_x86_64_patch
el3_x86_64_latest
...
ol6_x86_64_Dtrace_BETA
ol6_x86_64_Dtrace_latest
ol6_x86_64_Dtrace_userspace_latest
ol6_x86_64_MySQL
ol6_x86_64_MySQL56
ol6_x86_64_UEKR3_latest
ol6_x86_64_UEK_BETA
ol6_x86_64_UEK_base
ol6_x86_64_UEK_latest
ol6_x86_64_addons
ol6_x86_64_gdm_multiseat
ol6_x86_64_ksplice
ol6_x86_64_latest
ol6_x86_64_mysql-ha-utils
ol6_x86_64_ofed_UEK
ol6_x86_64_oracle
ovm22_2.2.0_i386_base
ovm22_2.2.0_i386_patch
ovm22_2.2.1_i386_base
ovm22_2.2.1_i386_patch
ovm22_2.2.2_i386_base
ovm22_2.2.2_i386_patch
ovm22_2.2.3_i386_base
ovm22_2.2.3_i386_patch
ovm22_i386_latest
ovm22_i386_oracle
ovm2_2.1.0_i386_base
ovm2_2.1.0_i386_patch
ovm2_2.1.1_i386_base
ovm2_2.1.1_i386_patch
ovm2_2.1.2_i386_base
ovm2_2.1.2_i386_patch
ovm2_2.1.5_i386_base
ovm2_2.1.5_i386_patch
ovm2_i386_latest
ovm3_3.0.2_x86_64_base
ovm3_3.0.3_x86_64_base
ovm3_3.0.3_x86_64_patch
ovm3_3.0_x86_64_base
ovm3_3.0_x86_64_patch
ovm3_3.1.1_x86_64_base
ovm3_3.1.1_x86_64_patch
ovm3_3.2.1_x86_64_base
ovm3_3.2.1_x86_64_patch
ovm3_x86_64_latest

# uln-channel --add --channel=ol6_x86_64_oracle
Username: wim@company.com
Password:

# uln-channel --list
Username: wim@company.com
Password:
ol6_i386_UEK_latest
ol6_i386_ksplice
ol6_i386_latest
ol6_x86_64_oracle

Monday Oct 07, 2013

Oracle Linux 5.10 channels are now published

We just released Oracle Linux 5.10 channels on both http://public-yum.oracle.com and on the Unbreakable Linux Network. ISO's are going to be updated on edelivery in a few days. The channels are available immediately.

As many of you know, we are now using a CDN to distribute the RPMS for public-yum globally so you should have good bandwidth everywhere to freely access the RPMs.

Wednesday Jan 16, 2013

Oracle Linux 5.9

Oracle Linux 5.9 was uploaded yesterday to http://linux.oracle.com (ULN) and to http://public-yum.oracle.com. The _latest channels are current and the 5.9_base channels contain the core.

ISO images will be available shortly from http://edelivery.oracle.com. If there is an urgent need to get the ISOs through My Oracle Support, simply file a service request.

Release notes are here.

About

Wim Coekaerts is the Senior Vice President of Linux and Virtualization Engineering for Oracle. He is responsible for Oracle's complete desktop to data center virtualization product line and the Oracle Linux support program.

You can follow him on Twitter at @wimcoekaerts

Search

Categories
Archives
« April 2015
SunMonTueWedThuFriSat
   
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
  
       
Today