if not svm.state == "Running":
                    print "SSVM has state " + svm.state + " waiting for it to become Running"
                else:
                    ssvm = svm
    except urllib2.HTTPError, e:
        print "Cmd Failed : " + str(e.msg)

    if ssvm:
        print "Found " + ssvm.name
        print "Determining state"

        listhosts = listHosts.listHostsCmd()
        listhosts.name = ssvm.name

        try:
            resp = apiclient.listHosts(listhosts)
            if not resp == None and len(resp) == 1:
                ssvmstate = resp[0]
            else:
                continue

        except urllib2.HTTPError, e:
            print "Cmd Failed : " + str(e.msg)

        if ssvmstate.state == "Up":
            print "SSVM " + ssvm.name + " is " + ssvm.state + " and the agent is " + ssvmstate.state
            break
        else:
            print "SSVM Agent not yet Up, current state is  " + ssvmstate.state

if count == 0: