Пример #1
0
def iot_hub_create(client,
                   hub_name,
                   resource_group_name,
                   location=None,
                   sku=IotHubSku.f1.value,
                   unit=1):
    name_availability = client.check_name_availability(hub_name)
    logger.info('name availability info: %s', name_availability)
    if name_availability is not None and not name_availability.name_available:
        raise CLIError(name_availability.message)

    if location is None:
        logger.info(
            'Location is none. Use location of resource group as default.')
        resource_group_client = resource_service_factory().resource_groups
        group_info = resource_group_client.get(resource_group_name)
        location = group_info.location
        logger.info('Location to use: %s', location)

    iot_hub_description = IotHubDescription(location=location,
                                            sku=IotHubSkuInfo(name=sku,
                                                              capacity=unit))
    result = client.create_or_update(resource_group_name=resource_group_name,
                                     resource_name=hub_name,
                                     iot_hub_description=iot_hub_description)
    return result
Пример #2
0
def iot_hub_create(client, hub_name, resource_group_name,
                   location=None, sku=IotHubSku.f1.value, unit=1):
    name_availability = client.check_name_availability(hub_name)
    logger.info('name availability info: %s', name_availability)
    if name_availability is not None and not name_availability.name_available:
        raise CLIError(name_availability.message)
    location = _ensure_location(resource_group_name, location)
    iot_hub_description = IotHubDescription(location=location,
                                            sku=IotHubSkuInfo(name=sku, capacity=unit))
    result = client.create_or_update(resource_group_name=resource_group_name, resource_name=hub_name,
                                     iot_hub_description=iot_hub_description)
    return result
Пример #3
0
def iot_hub_create(client,
                   hub_name,
                   resource_group_name,
                   location=None,
                   sku=IotHubSku.f1.value,
                   unit=1):
    _check_name_availability(client, hub_name)
    location = _ensure_location(resource_group_name, location)
    hub_description = IotHubDescription(location=location,
                                        sku=IotHubSkuInfo(name=sku,
                                                          capacity=unit))
    return client.create_or_update(resource_group_name, hub_name,
                                   hub_description)
Пример #4
0
def iot_hub_create(cmd,
                   client,
                   hub_name,
                   resource_group_name,
                   location=None,
                   sku=IotHubSku.f1.value,
                   unit=1):
    cli_ctx = cmd.cli_ctx
    _check_name_availability(client.iot_hub_resource, hub_name)
    location = _ensure_location(cli_ctx, resource_group_name, location)
    hub_description = IotHubDescription(
        location, client.iot_hub_resource.config.subscription_id,
        resource_group_name, IotHubSkuInfo(name=sku, capacity=unit))
    return client.iot_hub_resource.create_or_update(resource_group_name,
                                                    hub_name, hub_description)