示例#1
0
def _enumerate_services(grph, subscription_name):
    subscription_id, certificate_path = lib_credentials.GetCredentials(
        "Azure", subscription_name)

    sms = ServiceManagementService(subscription_id, certificate_path)

    subscription_node = subscription.MakeUri(subscription_name)

    try:
        lst_srvs = sms.list_hosted_services()
    except Exception as exc:
        lib_common.ErrorMessageHtml("Unexpected error:" + str(exc))

    for srv in lst_srvs:
        serv_node = service.MakeUri(srv.service_name, subscription_name)
        grph.add(
            (subscription_node, lib_common.MakeProp("Service"), serv_node))

        # There will be duplicates.
        loca_node = location.MakeUri(srv.hosted_service_properties.location,
                                     subscription_name)
        grph.add((serv_node, lib_common.MakeProp("Location"), loca_node))

        grph.add((serv_node, pc.property_rdf_data_nolist1,
                  lib_common.NodeUrl(srv.url)))
def Main():
    cgiEnv = lib_common.CgiEnv()

    grph = cgiEnv.GetGraph()

    # subscriptionName=Azure.DefaultSubscription()
    subscriptionName = cgiEnv.m_entity_id_dict["Subscription"]

    (subscription_id, certificate_path) = lib_credentials.GetCredentials(
        "Azure", subscriptionName)

    sms = ServiceManagementService(subscription_id, certificate_path)

    subscriptionNode = subscription.MakeUri(subscriptionName)

    try:
        # This throws when running with Apache. OK with cgiserver.py
        lstSrvs = sms.list_hosted_services()
    except:
        lib_common.ErrorMessageHtml("Unexpected error:" + str(sys.exc_info()))

    for srv in lstSrvs:
        servNode = service.MakeUri(srv.service_name, subscriptionName)
        grph.add((subscriptionNode, lib_common.MakeProp("Service"), servNode))

        # There will be duplicates.
        locaNode = location.MakeUri(srv.hosted_service_properties.location,
                                    subscriptionName)
        grph.add((servNode, lib_common.MakeProp("Location"), locaNode))

        grph.add((servNode, pc.property_rdf_data_nolist1,
                  lib_common.NodeUrl(srv.url)))

    cgiEnv.OutCgiRdf()
示例#3
0
def Main():
	cgiEnv = lib_common.CgiEnv()

	# TODO: The subscription will become a parameter with a default value.
	# serviceName = cgiEnv.GetId()
	diskName = cgiEnv.m_entity_id_dict["Disk"]

	# TODO: This should be a parameter.
	subscriptionName = cgiEnv.m_entity_id_dict["Subscription"]
	# subscriptionName=Azure.DefaultSubscription()

	grph = cgiEnv.GetGraph()

	(subscription_id,certificate_path) = lib_credentials.GetCredentials( "Azure", subscriptionName )

	sms = ServiceManagementService(subscription_id, certificate_path)

	subscriptionNode = subscription.MakeUri( subscriptionName )

	dsk = sms.get_disk(diskName)

	sys.stderr.write("dsk=%s\n"% str(dir(dsk)))

	diskNode = disk.MakeUri( diskName, subscriptionName )
	grph.add( ( subscriptionNode, lib_common.MakeProp("Service"), diskNode ) )

	# grph.add( ( diskNode, lib_common.MakeProp("xxx"), lib_common.NodeLiteral(str(dir(dsk))) ) )

	grph.add( ( diskNode, lib_common.MakeProp("affinity_group"), lib_common.NodeLiteral(dsk.affinity_group)))
	# grph.add( ( diskNode, lib_common.MakeProp("attached_to"), lib_common.NodeLiteral(str(dir(dsk.attached_to)))) )
	grph.add( ( diskNode, lib_common.MakeProp("has_operating_system"), lib_common.NodeLiteral(dsk.has_operating_system)))
	grph.add( ( diskNode, lib_common.MakeProp("is_corrupted"), lib_common.NodeLiteral(dsk.is_corrupted)) )
	grph.add( ( diskNode, lib_common.MakeProp("label"), lib_common.NodeLiteral(dsk.label)) )
	grph.add( ( diskNode, lib_common.MakeProp("Size"), lib_common.NodeLiteral(dsk.logical_disk_size_in_gb)))
	grph.add( ( diskNode, lib_common.MakeProp("name"), lib_common.NodeLiteral(dsk.name)))
	grph.add( ( diskNode, lib_common.MakeProp("os"), lib_common.NodeLiteral(dsk.os)))
	grph.add( ( diskNode, lib_common.MakeProp("source_image_name"), lib_common.NodeLiteral(dsk.source_image_name)))
	grph.add( ( diskNode, lib_common.MakeProp("media link"), lib_common.NodeUrl(dsk.media_link)))

	locaNode = location.MakeUri( dsk.location, subscriptionName )
	grph.add( ( diskNode, lib_common.MakeProp("Location"), locaNode ) )

	srvNode = service.MakeUri( dsk.attached_to.hosted_service_name, subscriptionName )
	grph.add( ( srvNode, lib_common.MakeProp("Role"), lib_common.NodeLiteral(dsk.attached_to.role_name) ) )
	grph.add( ( srvNode, lib_common.MakeProp("Deployment"), lib_common.NodeLiteral(dsk.attached_to.deployment_name) ) )
	grph.add( ( diskNode, lib_common.MakeProp("Service"), srvNode ) )

	# media_link

	cgiEnv.OutCgiRdf("LAYOUT_RECT_TB")
示例#4
0
def Main():
    cgiEnv = lib_common.ScriptEnvironment()

    disk_name = cgiEnv.m_entity_id_dict["Disk"]

    subscription_name = cgiEnv.m_entity_id_dict["Subscription"]
    # subscription_name=Azure.DefaultSubscription()

    grph = cgiEnv.GetGraph()

    subscription_id, certificate_path = lib_credentials.GetCredentials("Azure", subscription_name)

    sms = ServiceManagementService(subscription_id, certificate_path)

    subscription_node = subscription.MakeUri(subscription_name)

    dsk = sms.get_disk(disk_name)

    logging.debug("dsk=%s", str(dir(dsk)))

    disk_node = disk.MakeUri(disk_name, subscription_name)
    grph.add((subscription_node, lib_common.MakeProp("Service"), disk_node))

    grph.add((disk_node, lib_common.MakeProp("affinity_group"), lib_util.NodeLiteral(dsk.affinity_group)))
    # grph.add((disk_node, lib_common.MakeProp("attached_to"), lib_util.NodeLiteral(str(dir(dsk.attached_to)))))
    grph.add((disk_node, lib_common.MakeProp("has_operating_system"), lib_util.NodeLiteral(dsk.has_operating_system)))
    grph.add((disk_node, lib_common.MakeProp("is_corrupted"), lib_util.NodeLiteral(dsk.is_corrupted)))
    grph.add((disk_node, lib_common.MakeProp("label"), lib_util.NodeLiteral(dsk.label)))
    grph.add((disk_node, lib_common.MakeProp("Size"), lib_util.NodeLiteral(dsk.logical_disk_size_in_gb)))
    grph.add((disk_node, lib_common.MakeProp("name"), lib_util.NodeLiteral(dsk.name)))
    grph.add((disk_node, lib_common.MakeProp("os"), lib_util.NodeLiteral(dsk.os)))
    grph.add((disk_node, lib_common.MakeProp("source_image_name"), lib_util.NodeLiteral(dsk.source_image_name)))
    grph.add((disk_node, lib_common.MakeProp("media link"), lib_common.NodeUrl(dsk.media_link)))

    loca_node = location.MakeUri( dsk.location, subscription_name)
    grph.add((disk_node, lib_common.MakeProp("Location"), loca_node))

    srv_node = service.MakeUri( dsk.attached_to.hosted_service_name, subscription_name)
    grph.add((srv_node, lib_common.MakeProp("Role"), lib_util.NodeLiteral(dsk.attached_to.role_name)))
    grph.add((srv_node, lib_common.MakeProp("Deployment"), lib_util.NodeLiteral(dsk.attached_to.deployment_name)))
    grph.add((disk_node, lib_common.MakeProp("Service"), srv_node))

    # media_link

    cgiEnv.OutCgiRdf("LAYOUT_RECT_TB")
示例#5
0
def Main():
    cgiEnv = lib_common.CgiEnv()

    # TODO: The subscription will become a parameter with a default value.
    # serviceName = cgiEnv.GetId()
    serviceName = cgiEnv.m_entity_id_dict["Id"]

    # subscriptionName=Azure.DefaultSubscription()
    subscriptionName = cgiEnv.m_entity_id_dict["Subscription"]

    grph = cgiEnv.GetGraph()

    (subscription_id, certificate_path) = lib_credentials.GetCredentials(
        "Azure", subscriptionName)

    sms = ServiceManagementService(subscription_id, certificate_path)

    subscriptionNode = subscription.MakeUri(subscriptionName)

    srv = sms.get_hosted_service_properties(serviceName)

    sys.stderr.write("srv=%s\n" % str(dir(srv)))
    sys.stderr.write("deployments=%s\n" % str(srv.deployments))
    sys.stderr.write("srv.hosted_service_properties=%s\n" %
                     str(dir(srv.hosted_service_properties)))
    sys.stderr.write(
        "srv.hosted_service_properties.extended_properties=%s\n" %
        str(dir(srv.hosted_service_properties.extended_properties)))

    servNode = service.MakeUri(srv.service_name, subscriptionName)
    grph.add((subscriptionNode, lib_common.MakeProp("Service"), servNode))

    locaNode = location.MakeUri(srv.hosted_service_properties.location,
                                subscriptionName)
    grph.add((servNode, lib_common.MakeProp("Location"), locaNode))

    grph.add(
        (servNode, pc.property_rdf_data_nolist1, lib_common.NodeUrl(srv.url)))

    grph.add((servNode, lib_common.MakeProp("deployments"),
              lib_common.NodeLiteral(str(srv.deployments))))

    # With a dot ".", they come first.
    grph.add(
        (servNode, lib_common.MakeProp(".affinity_group"),
         lib_common.NodeLiteral(srv.hosted_service_properties.affinity_group)))
    grph.add(
        (servNode, lib_common.MakeProp(".date_created"),
         lib_common.NodeLiteral(srv.hosted_service_properties.date_created)))
    grph.add((servNode, lib_common.MakeProp(".date_last_modified"),
              lib_common.NodeLiteral(
                  srv.hosted_service_properties.date_last_modified)))
    grph.add(
        (servNode, lib_common.MakeProp(".description"),
         lib_common.NodeLiteral(srv.hosted_service_properties.description)))
    grph.add((servNode, lib_common.MakeProp(".label"),
              lib_common.NodeLiteral(srv.hosted_service_properties.label)))
    grph.add((servNode, lib_common.MakeProp(".status"),
              lib_common.NodeLiteral(srv.hosted_service_properties.status)))

    for extProp in srv.hosted_service_properties.extended_properties:
        extVal = srv.hosted_service_properties.extended_properties[extProp]
        grph.add((servNode, lib_common.MakeProp(extProp),
                  lib_common.NodeLiteral(extVal)))

    cgiEnv.OutCgiRdf()
示例#6
0
def Main():
    cgiEnv = lib_common.ScriptEnvironment()

    service_name = cgiEnv.m_entity_id_dict["Id"]

    subscription_name = cgiEnv.m_entity_id_dict["Subscription"]

    grph = cgiEnv.GetGraph()

    subscription_id, certificate_path = lib_credentials.GetCredentials(
        "Azure", subscription_name)

    sms = ServiceManagementService(subscription_id, certificate_path)

    subscription_node = subscription.MakeUri(subscription_name)

    srv = sms.get_hosted_service_properties(service_name)

    logging.debug("srv=%s", str(dir(srv)))
    logging.debug("deployments=%s", str(srv.deployments))
    logging.debug("srv.hosted_service_properties=%s",
                  str(dir(srv.hosted_service_properties)))
    logging.debug("srv.hosted_service_properties.extended_properties=%s",
                  str(dir(srv.hosted_service_properties.extended_properties)))

    serv_node = service.MakeUri(srv.service_name, subscription_name)
    grph.add((subscription_node, lib_common.MakeProp("Service"), serv_node))

    loca_node = location.MakeUri(srv.hosted_service_properties.location,
                                 subscription_name)
    grph.add((serv_node, lib_common.MakeProp("Location"), loca_node))

    grph.add(
        (serv_node, pc.property_rdf_data_nolist1, lib_common.NodeUrl(srv.url)))

    grph.add((serv_node, lib_common.MakeProp("deployments"),
              lib_util.NodeLiteral(str(srv.deployments))))

    # With a dot ".", they come first.
    grph.add(
        (serv_node, lib_common.MakeProp(".affinity_group"),
         lib_util.NodeLiteral(srv.hosted_service_properties.affinity_group)))
    grph.add(
        (serv_node, lib_common.MakeProp(".date_created"),
         lib_util.NodeLiteral(srv.hosted_service_properties.date_created)))
    grph.add((serv_node, lib_common.MakeProp(".date_last_modified"),
              lib_util.NodeLiteral(
                  srv.hosted_service_properties.date_last_modified)))
    grph.add((serv_node, lib_common.MakeProp(".description"),
              lib_util.NodeLiteral(srv.hosted_service_properties.description)))
    grph.add((serv_node, lib_common.MakeProp(".label"),
              lib_util.NodeLiteral(srv.hosted_service_properties.label)))
    grph.add((serv_node, lib_common.MakeProp(".status"),
              lib_util.NodeLiteral(srv.hosted_service_properties.status)))

    for ext_prop in srv.hosted_service_properties.extended_properties:
        ext_val = srv.hosted_service_properties.extended_properties[ext_prop]
        grph.add((serv_node, lib_common.MakeProp(ext_prop),
                  lib_util.NodeLiteral(ext_val)))

    cgiEnv.OutCgiRdf()