예제 #1
0
def remove_service_attribute(opts):
    print "Remove_record %s " % opts
    service_id, service_type = extract_identifier(opts)
    if not service_id:
        return
    sql = "delete from service_registry_attribute where " + \
        "service_id = %d and name = '%s' and value = '%s'" % \
        (service_id, opts.name, opts.value)
    print "remove_service_attribute: %s" % sql
    cmd = CMD_PREFIX + [sql]
    output = grab_output_from_subprocess(cmd)
예제 #2
0
def remove_service_attribute(opts):
    print "Remove_record %s " % opts
    service_id, service_type = extract_identifier(opts)
    if not service_id:
        return
    sql = "delete from service_registry_attribute where " + \
        "service_id = %d and name = '%s' and value = '%s'" % \
        (service_id, opts.name, opts.value)
    print "remove_service_attribute: %s" % sql
    cmd = CMD_PREFIX + [sql]
    output = grab_output_from_subprocess(cmd)
예제 #3
0
def add_service_attribute(opts):
    service_id, service_type = extract_identifier(opts)
    if not service_id:
        return
    if not validate_name_value(opts.name, opts.value, service_type):
        print "Invalid name/value pair for service attribute: %s %s" % \
            (opts.name, opts.value)
        return
    sql = "insert into service_registry_attribute (service_id, name, value) "+\
        " values (%d, '%s', '%s')" % (service_id, opts.name, opts.value)
    print "add_service_attribute: %s " % sql
    cmd = CMD_PREFIX + [sql]
    output = grab_output_from_subprocess(cmd)
예제 #4
0
def add_service_attribute(opts):
    service_id, service_type = extract_identifier(opts)
    if not service_id:
        return
    if not validate_name_value(opts.name, opts.value, service_type):
        print "Invalid name/value pair for service attribute: %s %s" % \
            (opts.name, opts.value)
        return
    sql = "insert into service_registry_attribute (service_id, name, value) "+\
        " values (%d, '%s', '%s')" % (service_id, opts.name, opts.value)
    print "add_service_attribute: %s " % sql
    cmd = CMD_PREFIX + [sql]
    output = grab_output_from_subprocess(cmd)
예제 #5
0
def extract_identifier(opts):
    prefix = "select id, service_type from service_registry where "
    if opts.uid:
        sql = prefix + ("id = '%s'" % opts.uid)
    elif opts.urn:
        sql = prefix + ("service_urn = '%s'" % opts.urn)
    elif opts.url:
        sql = prefix + ("service_url = '%s'" % opts.url)
    else:
        print "None of UID, URN or URL defined"
        return None, None

    cmd = ['psql', '-U', 'portal', '-h', 'localhost', '-t', '-c', sql]
    output = grab_output_from_subprocess(cmd)
    lines = output.strip().split('\n')
    if len(lines) != 1 or len(lines[0]) == 0:
        print "Can't find unique value for query %s" % sql
        return None, None
    uid, type = lines[0].split('|')
    uid = int(uid.strip())
    type = int(type.strip())
    return uid, type
예제 #6
0
def extract_identifier(opts):
    prefix = "select id, service_type from service_registry where "
    if opts.uid:
        sql = prefix + ("id = '%s'" % opts.uid)
    elif opts.urn:
        sql = prefix + ("service_urn = '%s'" % opts.urn)
    elif opts.url:
        sql = prefix + ("service_url = '%s'" % opts.url)
    else:
        print "None of UID, URN or URL defined"
        return None, None

    cmd = ['psql', '-U', 'portal', '-h', 'localhost', '-t', '-c', sql]
    output = grab_output_from_subprocess(cmd)
    lines = output.strip().split('\n')
    if len(lines) != 1 or len(lines[0]) == 0:
        print "Can't find unique value for query %s" % sql
        return None, None
    uid, type = lines[0].split('|')
    uid = int(uid.strip())
    type = int(type.strip())
    return uid, type