def __main__():

  global debug, user, password, base_url

  try:
    opts, args = getopt.getopt(sys.argv[1:], "hs:u:p:v", ['help','server=', 'user='******'password='******'-v':
      debug = True
    elif o in ('-h', '--help'):
      usage()
      sys.exit()
    elif o in ( '-s', '--server'):
      base_url = a
    elif o in ( '-u', '--user'):
      user = a
    elif o in ( '-p', '--password'):
      password = a
    else:
      assert False, "unhandled option"
      usage()
      sys.exit()

  if not base_url or not password:
    print('Missing required arguments')
    usage()
    sys.exit()

  # Peel and specfic arguments off the end for this call
  arg1, arg2 = sys.argv[-2:]

  ucr = ucrclient.ucrclient( base_url, user, password , debug )

  # Find your snapshot
  snapshot_id = "b4ad4aab-a05f-486f-8ba1-924a1b30b3a9"

  # Get a snapshot version
  snapshot = ucr.get_json( '/versions/%s' % ( snapshot_id) )
  pprint( snapshot )

  # Get the statuses you can apply
  statuses = ucr.get_json( '/status/editableByUser' )
  pprint( statuses )

  # Pick your status
  status_id = "87bfccb1-40d5-4b2c-bbd9-05fb02ac3638"

  # Build status update
  status_to_add = {"appVersion": snapshot_id, "status": status_id ,"canEdit":True }

  # Add Status to version
  r = ucr.post( uri='/versionStatus/', data=json.dumps( status_to_add ) )
  ucr.debug_response( r )
def __main__():

  global debug, user, password, base_url

  try:
    opts, args = getopt.getopt(sys.argv[1:], "hs:u:p:v", ['help','server=', 'user='******'password='******'-v':
      debug = True
    elif o in ('-h', '--help'):
      usage()
      sys.exit()
    elif o in ( '-s', '--server'):
      base_url = a
    elif o in ( '-u', '--user'):
      user = a
    elif o in ( '-p', '--password'):
      password = a
    else:
      assert False, "unhandled option"
      usage()
      sys.exit()

  if not base_url or not password:
    print('Missing required arguments')
    usage()
    sys.exit()

  # Peel and specfic arguments off the end for this call
  arg1, arg2 = sys.argv[-2:]

  ucr = ucrclient.ucrclient( base_url, user, password , debug )

  start_time_ms = 1438401600000
  end_time_ms = 1441080000000

  c_start = time.gmtime( start_time_ms / 1000 )
  c_end = time.gmtime( end_time_ms / 1000 )

  #  print "Times: "
  #  print ts_tostr( c_start )
  #  print ts_tostr( c_end )

  #r = ucr.get( get_specific_deployment )
  #pprint( r.json() )

  releases = ucr.get_releases()

  for release in releases:
    cur_release = ucr.get_release( id=release['id'], format='pipeline' )
    target_date = utils.javats_tostr( cur_release['targetDate'] ) if 'targetDate' in cur_release else '[No Target Date Set]'
    print( '%s - %s ' % ( cur_release['name'], target_date ) )
def __main__():

    global debug, user, password, base_url

    try:
        opts, args = getopt.getopt(sys.argv[1:], "hs:u:p:v",
                                   ['help', 'server=', 'user='******'password='******'-v':
            debug = True
        elif o in ('-h', '--help'):
            usage()
            sys.exit()
        elif o in ('-s', '--server'):
            base_url = a
        elif o in ('-u', '--user'):
            user = a
        elif o in ('-p', '--password'):
            password = a
        else:
            assert False, "unhandled option"
            usage()
            sys.exit()

    if not base_url or not password:
        print('Missing required arguments')
        usage()
        sys.exit()

    # Login and pull the license url
    ucr = ucrclient.ucrclient(base_url, user, password, debug)

    licenses = ucr.get_json('/license')
    # pprint( licenses )

    print('Licenses: ')
    for license in licenses:
        if license['available'] == -99:
            print(' %s ( No licenses of this type )' % (license['feature']))
        else:
            print(' %s ( %s / %s )' %
                  (license['feature'], license['used'], license['available']))
Esempio n. 4
0
def __main__():

    global debug, user, password, base_url

    try:
        opts, args = getopt.getopt(sys.argv[1:], "hs:u:p:v",
                                   ['help', 'server=', 'user='******'password='******'-v':
            debug = True
        elif o in ('-h', '--help'):
            usage()
            sys.exit()
        elif o in ('-s', '--server'):
            base_url = a
        elif o in ('-u', '--user'):
            user = a
        elif o in ('-p', '--password'):
            password = a
        else:
            assert False, "unhandled option"
            usage()
            sys.exit()

    if not base_url or not password:
        print('Missing required arguments')
        usage()
        sys.exit()

    # Peel and specfic arguments off the end for this call
    arg1, arg2 = sys.argv[-2:]

    ucr = ucrclient.ucrclient(base_url, user, password, debug)
Esempio n. 5
0
def __main__():

    global debug, user, password, base_url

    try:
        opts, args = getopt.getopt(sys.argv[1:], "hs:u:p:v",
                                   ['help', 'server=', 'user='******'password='******'-v':
            debug = True
        elif o in ('-h', '--help'):
            usage()
            sys.exit()
        elif o in ('-s', '--server'):
            base_url = a
        elif o in ('-u', '--user'):
            user = a
        elif o in ('-p', '--password'):
            password = a
        else:
            assert False, "unhandled option"
            usage()
            sys.exit()

    if not base_url or not password:
        print('Missing required arguments')
        usage()
        sys.exit()

    # Peel and specfic arguments off the end for this call
    arg1, arg2 = sys.argv[-2:]

    ucr = ucrclient.ucrclient(base_url, user, password, debug)

    # Find your snapshot
    snapshot_id = "b4ad4aab-a05f-486f-8ba1-924a1b30b3a9"

    # Get a snapshot version
    snapshot = ucr.get_json('/versions/%s' % (snapshot_id))
    pprint(snapshot)

    # Get the statuses you can apply
    statuses = ucr.get_json('/status/editableByUser')
    pprint(statuses)

    # Pick your status
    status_id = "87bfccb1-40d5-4b2c-bbd9-05fb02ac3638"

    # Build status update
    status_to_add = {
        "appVersion": snapshot_id,
        "status": status_id,
        "canEdit": True
    }

    # Add Status to version
    r = ucr.post(uri='/versionStatus/', data=json.dumps(status_to_add))
    ucr.debug_response(r)
Esempio n. 6
0
def __main__():

  global debug, user, password, base_url, release_name
  release_id = ''

  try:
    opts, args = getopt.getopt(sys.argv[1:], "hs:u:p:r:v", ['help','server=', 'user='******'password='******'release='])
  except getopt.GetoptError as err:
    # print help information and exit:
    print(err) # will print something like "option -a not recognized"
    usage()
    sys.exit(2)

  for o, a in opts:
    if o == '-v':
      debug = True
    elif o in ('-h', '--help'):
      usage()
      sys.exit()
    elif o in ( '-s', '--server'):
      base_url = a
    elif o in ( '-u', '--user'):
      user = a
    elif o in ( '-p', '--password'):
      password = a
    elif o in ( '-r', '--release'):
      release_name = a
    else:
      assert False, "unhandled option"
      usage()
      sys.exit()

  if not base_url or not password or not release_name:
    print('Missing required arguments')
    usage()
    sys.exit()

  ucr = ucrclient.ucrclient( base_url, user, password , debug )

  # Given a specific release by name, first translate that to the id

  # list of available releases
  releases = ucr.get_json( '/releases/?format=name&name=*' )

  for release in releases:
    if release_name == release['name']:
      release_id = release['id']
      break

  if not release_id:
    print( ' Available releases: [%s]' % ( ', '.join([ release['name'] for release in releases  ]) ) )
    raise Exception( 'Release %s not found' % ( release_name ) )

  ## First get the 4 queries the web client uses to build the pipeline view

  # 1. Get specific Release
  #/releases/90e0edce-092d-48bc-8313-5ca81083e7e7?format=pipeline
  release_pipeline = ucr.get_json( '/releases/%s?format=pipeline' % ( release_id ) )
  pdb.set_trace()

  # 2. Get deployments for this Release
  # /pipelineView/90e0edce-092d-48bc-8313-5ca81083e7e7/releaseDeployments
  pipeline_release_deployments = ucr.get_json( '/pipelineView/%s/releaseDeployments' % ( release_id ) )

  # 3. Get Applications for rhis Releas
  # /pipelineView/90e0edce-092d-48bc-8313-5ca81083e7e7/allApplicationVersions
  pipeline_all_application_versions = ucr.get_json( '/pipelineView/%s/allApplicationVersions' % ( release_id ) )

  # 4. Get Latest Application Versions for this Release
  # http://ucr02/pipelineView/<release_id>/latestApplicationVersions
  pipeline_latest_application_versions = ucr.get_json( '/pipelineView/%s/latestApplicationVersions' % ( release_id ) )

  # Write out the starter json as refernce to the weeds we are hacking through
  utils.write_pretty_json( 'release_pipeline.json', release_pipeline )
  utils.write_pretty_json( 'pipeline_release_deployments.json', pipeline_release_deployments )
  utils.write_pretty_json( 'pipeline_all_application_versions.json', pipeline_all_application_versions )
  utils.write_pretty_json( 'pipeline_latest_application_versions.json', pipeline_latest_application_versions )


  ## Start disecting this information into a more useful format

  # Get participating applications
  # key by app id for later and store latest version information here!
  applications = {}
  for app in pipeline_latest_application_versions:
    if 'children' not in app:
      pass

    children = []
    for child in app['children']:
      children.append( {
        'id' : child['application']['id'],
        'name': child['application']['name'],
        'latestVersion': { 'id': child['id'], 'name': child['name'] },
      })
    applications[ app['application']['id'] ] = {
      'id': app['application']['id'],
      'name': app['application']['name'],
      'latestVersion': { 'id': app['id'], 'name': app['name'] },
      'children': children
     }

  #pprint( applications )

  # Get phaseModel name & environments in a useful format
  my_phases = []

  for phase in release_pipeline['phases']:
    # First build up the basic current phase information
    cur_phase = {
      'environments': {},
      'gates': [ gate['status']['name'] for gate in phase['phaseModel']['gates'] ],
      'id': phase['id'],
      'name': phase['phaseModel']['name'],
    }

    for env in phase['environments']:
      cur_phase['environments'][ env['id'] ] = {
        'applicationTargets': {},
        'id' : env['id'],
        'name': env['name'],
        'deployed': [],
        'deployments': {}
        }

      # Build a view of what is already deployed
      for app_id, app in pipeline_all_application_versions.items():
        if env['id'] in app.keys():
          cur_phase['environments'][ env['id'] ]['deployed'].append( {
            'id': app_id,
            'versionId': app[ env['id'] ]['id'],
            'version': app[ env['id'] ]['name'] } )

      # Bring in the deployments if they exist
      if env['id'] in pipeline_release_deployments:
        # Bring in current deployments for either last or next
        #   last - provides currently deployed
        #   next - provides scheduled to be deployed
        for key, deploy in pipeline_release_deployments[ env['id'] ].items() :
          # Pull the useful fields from this object
          cur_phase['environments'][ env['id'] ]['deployments'][ key ] = {
            'id' : deploy['id'],
            'status' : deploy['deploymentExecution']['status'],
            'execution_id' : deploy['deploymentExecution']['id'],
            'dateCreated' : deploy['dateCreated'],
            'scheduledDate': deploy['scheduledDate'],
            # Build a simple list of application/versions & component/versions
            # Need to handle Snapshots, Applications, and Component levels
            'versions': [ process_version(version) for version in deploy['versions']  ]
            }

      # Store the application environments, is this useful...
      for app_env in env['applicationTargets']:
        cur_phase['environments'][ env['id'] ]['applicationTargets'][ app_env['id'] ] = {
          'id' : app_env['id'],
          'name': app_env['name']
          }

    # Store in my custom phases array
    my_phases.append( cur_phase )

  ## At this point all the data I think we need is in release_pipeline and my_phases
  utils.write_pretty_json( 'my_phases.json', my_phases )
  # pprint( my_phases )

  ## Example output of the results that can be formatted or used as a base to tweaking
  ## what information you want to report on.
  ## This is already getting too complex to be useful, time to switch to a template...
  print( 'Release: %s \n  %s\n  %s' % ( release_pipeline['name'], utils.javats_tostr( release_pipeline['targetDate'] ), release_pipeline['description'] ) )
  print( '  Applications: %s ' % (','.join( applications )) )

  print( 'Phases:' )
  for phase in my_phases:
    print( '  %s(%s)  Requires[%s]' % ( phase['name'], phase['id'], ','.join( phase['gates'] ) ) )

    for env_id, env in phase['environments'].items():
      print( '%sEnvironments:' % ('\t' * 1) )
      print( '%s %s (%s):' % ('\t' * 1, env['name'], env['id']) )

      # Made up of the following application environments
      print( '%sApplication Targets:' % ('\t' * 2) )
      for target in env['applicationTargets'].values():
        print( '%s  %s (%s)' % ( '\t' * 3, target['name'], target['id'] ) )

      print( '%sDeployed: ' % ('\t' * 2) )
      for app in env['deployed']:
        print( '%s  %s - %s' % ( '\t' * 3, applications[ app['id'] ]['name'], app['version'] ) )

      # show next and last deployments
      print( '%sDeployments: ' % ('\t' * 2) )
      for key, deployment in env['deployments'].items():
        print( '%s%s: %s - %s' % ( '\t' * 3, key, utils.javats_tostr( deployment['scheduledDate'] ), deployment['status'] ) )
        print( '%sVersions Deployed: ' % ( '\t' * 4 ) )

        for version in deployment['versions']:
          print( '%s %s: %s v%s [%s]' % ( '\t' * 5, version['type'], version['name'], version['version'], ','.join( version['statuses']) ) )

          if version['type'] == 'SUITE':
            for app in version['applications']:
              comps = [ '%s: %s v%s [%s]' % ( comp['type'], comp['name'], comp['version'], ','.join(comp['statuses']) ) for comp in app['components'] ]
              print( '%s %s: %s v%s [%s]' % ( '\t' * 6, app['type'], app['name'], app['version'], ','.join(app['statuses']) ) )
              for comp in comps:
                print( '%s %s' % ('\t' * 7, comp) )
          else:
            comps = [ '%s: %s v%s [%s]' % ( comp['type'], comp['name'], comp['version'], ','.join(comp['statuses']) ) for comp in version['components'] ]
            for comp in comps:
              print( '%s %s' % ('\t' * 6,comp) )
Esempio n. 7
0
def __main__():

    global debug, user, password, base_url

    try:
        opts, args = getopt.getopt(sys.argv[1:], "hs:u:p:v",
                                   ['help', 'server=', 'user='******'password='******'-v':
            debug = True
        elif o in ('-h', '--help'):
            usage()
            sys.exit()
        elif o in ('-s', '--server'):
            base_url = a
        elif o in ('-u', '--user'):
            user = a
        elif o in ('-p', '--password'):
            password = a
        else:
            assert False, "unhandled option"
            usage()
            sys.exit()

    if not base_url or not password:
        print('Missing required arguments')
        usage()
        sys.exit()

    # Peel and specfic arguments off the end for this call
    arg1, arg2 = sys.argv[-2:]

    max_initiatives = 100
    max_changes_per_initiatve = 50

    ucr = ucrclient.ucrclient(base_url, user, password, debug)

    change_types = ucr.get_change_types()
    #print "Change Types: "
    #pprint( change_types )

    change_statuses = ucr.get_change_statuses()
    #print "Change statuses: "
    #pprint( change_statuses )

    applications = ucr.get_applications()
    #print "Applications(%d): " % ( len(applications) )
    #pprint( applications )

    releases = ucr.get_releases_editable()
    #print "Releases editable(%d)):" % ( len(releases) )
    #pprint( releases )

    initiatives = ucr.get_initiatives()
    #print "Initiatives: "
    #pprint( initiatives )

    changes = ucr.get_changes()
    #print "Changes(%d): " % ( len(changes) )
    #pprint( changes )
    '''
   Cleanup all the existing Changed and Initiatives
  '''
    print "Deleting all the existing Changes (%d)" % (len(changes))
    for change in changes:
        #pprint( change )
        ucr.delete_change(change['id'])
        print '.',

    print "Deleting all the existing Initiatives (%s)" % (len(initiatives))
    for initiative in initiatives:
        #pprint( initiative )
        ucr.delete_initiative(initiative['id'])
        print '.',

    # Get a dictionary of words, Unix specific example
    word_file = "/usr/share/dict/words"
    WORDS = open(word_file).read().splitlines()

    for i in range(max_initiatives):

        initiative = ucr.create_initative(name='project%3d - %s' %
                                          (i, random.choice(WORDS)))
        num_changes = random.randint(0, max_changes_per_initiatve)

        # Pick a release to file them against
        releaseId = releases[random.randint(0, len(releases) - 1)]['id']
        release = ucr.get_release(releaseId)
        apps = [app['id'] for app in release['applications']]

        print "Creating %d changes for this initiative %s against release %s" % (
            num_changes, initiative['name'], release['name'])

        for j in range(num_changes):
            # generate some of this data
            name = "Test Change %s" % (random.choice(WORDS))
            description = "Description"
            severity = "S1"

            applicationId = apps[random.randint(0, len(apps) - 1)]
            initiativeId = initiative['id']
            releaseId = release['id']
            status = random.choice(change_statuses.keys())
            change_type = change_types[random.randint(0,
                                                      len(change_types) - 1)]
            # This is not required, but I think should be the behavior
            typeId = change_type['id']

            change = ucr.create_change(typeId=typeId,
                                       name=name,
                                       status=status,
                                       severity=severity,
                                       releaseId=releaseId,
                                       applicationId=applicationId,
                                       initiativeId=initiativeId,
                                       description=description,
                                       change_type=change_type)
Esempio n. 8
0
  elif( cur_version['type'] == 'COMPONENT' ):
    # Should be base of recursion
    pass
  else:
    raise Exception('Processing versions failed on an unknown type %s' % (version_type) )

  return cur_version


'''
 Setup Application and routes
'''
app = Flask(__name__)
cache = SimpleCache()
cache_timeout = 5 * 60
ucr = ucrclient.ucrclient( base_url, user, password , debug )

'''
 Add some variables that can be used in templates
'''
@app.context_processor
def inject_config():
    return dict(user=user, base_url=base_url, cache_timeout=cache_timeout)

@app.template_filter('timestamptostr')
def tstostr_filter(s):
  # Need to return '' value when this is undefined as the util function is not tolerant of empty values
  return utils.javats_tostr( s ) if s else ''

@app.route("/")
def index():
def __main__():

  global debug, user, password, base_url

  try:
    opts, args = getopt.getopt(sys.argv[1:], "hs:u:p:v", ['help','server=', 'user='******'password='******'-v':
      debug = True
    elif o in ('-h', '--help'):
      usage()
      sys.exit()
    elif o in ( '-s', '--server'):
      base_url = a
    elif o in ( '-u', '--user'):
      user = a
    elif o in ( '-p', '--password'):
      password = a
    else:
      assert False, "unhandled option"
      usage()
      sys.exit()

  if not base_url or not password:
    print('Missing required arguments')
    usage()
    sys.exit()

  # Peel and specfic arguments off the end for this call
  arg1, arg2 = sys.argv[-2:]

  max_initiatives = 100
  max_changes_per_initiatve = 50

  ucr = ucrclient.ucrclient( base_url, user, password , debug )

  change_types = ucr.get_change_types()
  #print "Change Types: "
  #pprint( change_types )

  change_statuses = ucr.get_change_statuses()
  #print "Change statuses: "
  #pprint( change_statuses )

  applications = ucr.get_applications()
  #print "Applications(%d): " % ( len(applications) )
  #pprint( applications )

  releases = ucr.get_releases_editable()
  #print "Releases editable(%d)):" % ( len(releases) )
  #pprint( releases )

  initiatives = ucr.get_initiatives()
  #print "Initiatives: "
  #pprint( initiatives )

  changes = ucr.get_changes()
  #print "Changes(%d): " % ( len(changes) )
  #pprint( changes )

  '''
   Cleanup all the existing Changed and Initiatives
  '''
  print "Deleting all the existing Changes (%d)" % ( len(changes) )
  for change in changes:
    #pprint( change )
    ucr.delete_change( change['id'] )
    print '.',

  print "Deleting all the existing Initiatives (%s)" % ( len( initiatives ) )
  for initiative in initiatives:
    #pprint( initiative )
    ucr.delete_initiative( initiative['id'] )
    print '.',

  # Get a dictionary of words, Unix specific example
  word_file = "/usr/share/dict/words"
  WORDS = open(word_file).read().splitlines()

  for i in range( max_initiatives ):

    initiative = ucr.create_initative( name='project%3d - %s' % (i, random.choice(WORDS) ) )
    num_changes = random.randint( 0, max_changes_per_initiatve )

    # Pick a release to file them against
    releaseId = releases[ random.randint(0, len(releases) - 1) ]['id']
    release = ucr.get_release( releaseId )
    apps = [ app['id'] for app in release['applications'] ]

    print "Creating %d changes for this initiative %s against release %s" % ( num_changes, initiative['name'], release['name'] )

    for j in range( num_changes ):
     # generate some of this data
      name = "Test Change %s" % ( random.choice(WORDS) )
      description = "Description"
      severity = "S1"

      applicationId = apps[ random.randint( 0, len(apps) - 1 ) ]
      initiativeId = initiative['id']
      releaseId = release['id']
      status = random.choice( change_statuses.keys() )
      change_type = change_types[ random.randint( 0, len(change_types) - 1 ) ]
      # This is not required, but I think should be the behavior
      typeId = change_type['id']

      change =  ucr.create_change( typeId=typeId, name=name, status=status, severity=severity, releaseId=releaseId, applicationId=applicationId, initiativeId=initiativeId, description=description, change_type=change_type)
Esempio n. 10
0
def __main__():

    global debug, user, password, base_url

    try:
        opts, args = getopt.getopt(sys.argv[1:], "hs:u:p:v", ["help", "server=", "user="******"password="******"option -a not recognized"
        usage()
        sys.exit(2)

    for o, a in opts:
        if o == "-v":
            debug = True
        elif o in ("-h", "--help"):
            usage()
            sys.exit()
        elif o in ("-s", "--server"):
            base_url = a
        elif o in ("-u", "--user"):
            user = a
        elif o in ("-p", "--password"):
            password = a
        else:
            assert False, "unhandled option"
            usage()
            sys.exit()

    if not base_url or not password:
        print ("Missing required arguments")
        usage()
        sys.exit()

    # Peel and specfic arguments off the end for this call
    arg1, arg2 = sys.argv[-2:]

    ucr = ucrclient.ucrclient(base_url, user, password, debug)

    # GET http://base_url/releases/
    # ?filterFields=dateCreated
    # &filterType_dateCreated=gt
    # &filterClass_dateCreated=Long
    # &filterValue_dateCreated=1421171883574
    # &orderField=dateCreated
    # &sortType=asc
    event_name = "201605"
    event_query = "/events?filterFields=name&filterType_name=eq&filterClass_name=String&filterValue_name=%s" % (
        event_name
    )

    events = ucr.get_json(event_query)
    # pprint( events )

    if len(events) > 1:
        print ("Returned more than one event, not sure what to do with this")
        pprint(events)
        sys.exit(1)

    relatedDeployment = ucr.get_json("/relatedDeployments/%s?format=details" % (events[0]["relatedDeployment"]["id"]))
    # pprint( relatedDeployment )

    scheduledDeployments = [current["id"] for current in relatedDeployment["scheduledDeployments"]]
    pprint(scheduledDeployments)

    for sd_id in scheduledDeployments:
        scheduledDeployment = ucr.get_json("/scheduledDeployment/%s" % (sd_id))
        pprint(scheduledDeployment, depth=1)

        de = scheduledDeployment["deploymentExecution"]

        print ("#" * 120)
        # {u'approval': {...},
        #  u'autoManualTaskNotification': False,
        #  u'autoPickVersions': False,
        #  u'autoStart': False,
        #  u'dateCreated': 1462906112415,
        #  u'deploymentExecution': {...},
        #  u'derivedName': u'Sample Release:DEV-1 at May 10, 2016 at 7:48:00 PM GMT',
        #  u'environment': {...},
        #  u'executingUser': u'admin',
        #  u'gateStatus': u'PASSED',
        #  u'id': u'3354ab35-a97f-4ef0-ae13-d4dde07066fe',
        #  u'phase': {...},
        #  u'phases': [...],
        #  u'regexPattern': False,
        #  u'release': {...},
        #  u'scheduledDate': 1462909680000,
        #  u'shortName': u'May 10, 2016 at 7:48:00 PM GMT',
        #  u'status': u'COMPLETE',
        #  u'statusState': u'GREEN',
        #  u'transientProgress': 100,
        #  u'version': 4,
        #  u'versions': [...]}

        print (scheduledDeployment["id"])
        print (scheduledDeployment["derivedName"])
        print (scheduledDeployment["shortName"])

        print ("Deployment Execution: ")
        # u'deploymentExecution': {u'dateCreated': 1462906112421,
        #                       u'endTimeActual': 1462906215330,
        #                       u'endTimeEstimated': 1462906215287,
        #                       u'endTimePlanned': 1462910880000,
        #                       u'ghostedDate': 0,
        #                       u'hasEdit': True,
        #                       u'id': u'c04930da-f0b5-4047-bb81-22fe53d92c02',
        #                       u'locked': False,
        #                       u'name': u'Default Plan',
        #                       u'notifications': [],
        #                       u'segments': [...],
        #                       u'startTimeActual': 1462906165941,
        #                       u'status': u'COMPLETE',
        #                       u'stopSync': False,
        #                       u'suggestedTasks': [],
        #                       u'syncSegments': True,
        #                       u'version': 2},
        print ("\t" + de["id"])
        print ("\t" + de["name"])
        print ("\t" + de["status"])

        print ("\tSegments:")
        for segment in de["segments"]:
            #   {u'autostart': False,
            #                                      u'dateCreated': 1462914544830,
            #                                      u'durationPlanned': 0,
            #                                      u'endTimeActual': 0,
            #                                      u'enforceSequential': False,
            #                                      u'executionPattern': u'SEQUENTIAL',
            #                                      u'id': u'a9745833-4d32-4be0-90a1-00f2af9210ef',
            #                                      u'lastRefresh': 1462914544830,
            #                                      u'name': u'Pre-Deployment Tasks',
            #                                      u'opened': False,
            #                                      u'orderedTaskIds': u'',
            #                                      u'prerequisiteOverride': False,
            #                                      u'prerequisites': [],
            #                                      u'relativePosition': 0,
            #                                      u'startTimePlanned': 1462918380000,
            #                                      u'status': u'EMPTY',
            #                                      u'syncProperties': True,
            #                                      u'syncTasks': True,
            #                                      u'tasks': [],
            #                                      u'userCanExecute': True,
            #                                      u'version': 0},
            print ("\t\t" + segment["name"])

        print ("#" * 120)
Esempio n. 11
0
def __main__():

    global debug, user, password, base_url

    try:
        opts, args = getopt.getopt(sys.argv[1:], "hs:u:p:v",
                                   ['help', 'server=', 'user='******'password='******'-v':
            debug = True
        elif o in ('-h', '--help'):
            usage()
            sys.exit()
        elif o in ('-s', '--server'):
            base_url = a
        elif o in ('-u', '--user'):
            user = a
        elif o in ('-p', '--password'):
            password = a
        else:
            assert False, "unhandled option"
            usage()
            sys.exit()

    if not base_url or not password:
        print('Missing required arguments')
        usage()
        sys.exit()

    # Peel and specfic arguments off the end for this call
    arg1, arg2 = sys.argv[-2:]

    ucr = ucrclient.ucrclient(base_url, user, password, debug)

    start_time_ms = 1438401600000
    end_time_ms = 1441080000000

    c_start = time.gmtime(start_time_ms / 1000)
    c_end = time.gmtime(end_time_ms / 1000)

    #  print "Times: "
    #  print ts_tostr( c_start )
    #  print ts_tostr( c_end )

    #r = ucr.get( get_specific_deployment )
    #pprint( r.json() )

    releases = ucr.get_releases()

    for release in releases:
        cur_release = ucr.get_release(id=release['id'], format='pipeline')
        target_date = utils.javats_tostr(
            cur_release['targetDate']
        ) if 'targetDate' in cur_release else '[No Target Date Set]'
        print('%s - %s ' % (cur_release['name'], target_date))
Esempio n. 12
0
        # Should be base of recursion
        pass
    else:
        raise Exception('Processing versions failed on an unknown type %s' %
                        (version_type))

    return cur_version


'''
 Setup Application and routes
'''
app = Flask(__name__)
cache = SimpleCache()
cache_timeout = 5 * 60
ucr = ucrclient.ucrclient(base_url, user, password, debug)
'''
 Add some variables that can be used in templates
'''


@app.context_processor
def inject_config():
    return dict(user=user, base_url=base_url, cache_timeout=cache_timeout)


@app.template_filter('timestamptostr')
def tstostr_filter(s):
    # Need to return '' value when this is undefined as the util function is not tolerant of empty values
    return utils.javats_tostr(s) if s else ''