コード例 #1
0
    def to_xml(self):
        x = XMLBuilder('Resource',
                       xmlns="http://schemas.microsoft.com/windowsazure")
        x.CloudServiceSettings()
        x.ETag(self.incarnation_id)
        x.IntrinsicSettings()
        x.Name(self.name)

        with x.OperationStatus:
            x.Result("Succeeded")
        with x.OutputItems:
            for key in self.output_items.keys():
                with x.OutputItem:
                    x.Key(key)
                    x.Value(self.output_items[key])
        x.Plan(self.plan)
        x.State(self.state)
        x.SubState(self.sub_state)

        with x.UsageMeters:
            for usage_meter in self.usage_meters:
                with x.UsageMeter:
                    x.Included(usage_meter["Included"])
                    x.Name(usage_meter["Name"])
                    x.Unit(usage_meter["Unit"])
                    x.Used(usage_meter["Used"])

        x.Type(self.resource_type)
        return str(x)
コード例 #2
0
    def to_xml(self):
        resources = self.resources
        x = XMLBuilder('CloudService',
                       xmlns="http://schemas.microsoft.com/windowsazure")
        x['xml_header'] = True
        x.GeoRegion(self.geo_region)
        with x.Resources:
            for resource in self.resources:
                with x.Resource:
                    x.ETag(resource.incarnation_id)
                    x.Name(resource.name)
                    with x.OperationStatus:
                        x.Result("Succeeded")
                    x.Plan(resource.plan)
                    x.State("Started")
                    x.SubState("Ready to go")
                    x.Type(resource.resource_type)
                    with x.UsageMeters:
                        for usage_meter in resource.usage_meters:
                            with x.UsageMeter:
                                x.Included(usage_meter["Included"])
                                x.Name(usage_meter["Name"])
                                x.Unit(usage_meter["Unit"])
                                x.Used(usage_meter["Used"])

        return str(x)
コード例 #3
0
def xml_for_create_resource(region="West US",
                            promotion_code=None,
                            intrinsic_settings=None,
                            etag=None,
                            plan="Free"):
    if not etag:
        etag = str(uuid.uuid1())

    headers = [('Content-Type', 'application/xml')]
    x = XMLBuilder('Resource',
                   xmlns='http://schemas.microsoft.com/windowsazure')
    with x.CloudServiceSettings:
        x.GeoRegion(region)
    x.ETag(etag)
    x.IntrinsicSettings(intrinsic_settings)
    x.PromotionCode(promotion_code)
    x.Plan(plan)
    x.SchemaVersion("1.0")
    x.Type("cloudkeys")
    x.Version("1.0")
    return str(x)