Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: instance create command + ops config + fix stats [pod rename] #336

Merged
merged 5 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions azext_edge/edge/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,18 @@ def load_iotops_help():
az iot ops update --name myinstance -g myresourcegroup --desc "Fabrikam Widget Factory B42"
"""

helps[
"iot ops create"
] = """
type: command
short-summary: Create an IoT Operations instance.

examples:
- name: Create the target instance with minimum input.
text: >
az iot ops create --name myinstance --cluster mycluster -g myresourcegroup
"""

helps[
"iot ops asset"
] = """
Expand Down
7 changes: 4 additions & 3 deletions azext_edge/edge/command_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ def load_iotops_commands(self, _):
) as cmd_group:
cmd_group.command("check", "check")
cmd_group.command("init", "init")
cmd_group.command("delete", "delete")
cmd_group.command("verify-host", "verify_host")
cmd_group.command("create", "create_instance")
cmd_group.command("update", "update_instance")
cmd_group.show_command("show", "show_instance")
cmd_group.command("list", "list_instances")
cmd_group.command("update", "update_instance")
cmd_group.command("delete", "delete")
cmd_group.command("verify-host", "verify_host")

with self.command_group(
"iot ops support",
Expand Down
84 changes: 76 additions & 8 deletions azext_edge/edge/commands_edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def init(
kubernetes_distro: str = KubernetesDistroType.k8s.value,
trust_source: str = TrustSourceType.self_signed.value,
enable_fault_tolerance: Optional[bool] = None,
ops_config: Optional[List[str]] = None,
mi_user_assigned_identities: Optional[List[str]] = None,
# Broker
custom_broker_config_file: Optional[str] = None,
Expand All @@ -132,23 +133,16 @@ def init(
broker_frontend_replicas: int = 2,
add_insecure_listener: Optional[bool] = None,
no_progress: Optional[bool] = None,
context_name: Optional[str] = None,
ensure_latest: Optional[bool] = None,
**kwargs,
# TODO - @digimaun csi_driver_config: Optional[List[str]] = None,
# keyvault_resource_id: Optional[str] = None, # TODO - @digimaun
# template_path: Optional[str] = None,
) -> Union[Dict[str, Any], None]:
from .common import INIT_NO_PREFLIGHT_ENV_KEY
from .providers.orchestration import WorkManager
from .util import (
# assemble_nargs_to_dict,
is_env_flag_enabled,
read_file_content,
)

# TODO - @digimaun, is necessary?
load_config_context(context_name=context_name)
no_pre_flight = is_env_flag_enabled(INIT_NO_PREFLIGHT_ENV_KEY)

# TODO - @digimaun
Expand Down Expand Up @@ -178,6 +172,7 @@ def init(
container_runtime_socket=container_runtime_socket,
kubernetes_distro=kubernetes_distro,
enable_fault_tolerance=enable_fault_tolerance,
ops_config=ops_config,
trust_source=trust_source,
schema_registry_resource_id=schema_registry_resource_id,
mi_user_assigned_identities=mi_user_assigned_identities,
Expand All @@ -190,7 +185,80 @@ def init(
broker_backend_redundancy_factor=broker_backend_redundancy_factor,
broker_frontend_workers=broker_frontend_workers,
broker_frontend_replicas=broker_frontend_replicas,
# keyvault_resource_id=keyvault_resource_id,
)


def create_instance(
cmd,
cluster_name: str,
resource_group_name: str,
instance_name: str,
cluster_namespace: str = DEFAULT_NAMESPACE,
location: Optional[str] = None,
custom_location_name: Optional[str] = None,
disable_rsync_rules: Optional[bool] = None,
instance_description: Optional[str] = None,
dataflow_profile_instances: int = 1,
mi_user_assigned_identities: Optional[List[str]] = None,
# Broker
custom_broker_config_file: Optional[str] = None,
broker_memory_profile: str = MqMemoryProfile.medium.value,
broker_service_type: str = MqServiceType.cluster_ip.value,
broker_backend_partitions: int = 2,
broker_backend_workers: int = 2,
broker_backend_redundancy_factor: int = 2,
broker_frontend_workers: int = 2,
broker_frontend_replicas: int = 2,
add_insecure_listener: Optional[bool] = None,
tags: Optional[dict] = None,
no_progress: Optional[bool] = None,
**kwargs,
) -> Union[Dict[str, Any], None]:
from .common import INIT_NO_PREFLIGHT_ENV_KEY
from .providers.orchestration import WorkManager
from .util import (
is_env_flag_enabled,
read_file_content,
)

no_pre_flight = is_env_flag_enabled(INIT_NO_PREFLIGHT_ENV_KEY)

# TODO - @digimaun
custom_broker_config = None
if custom_broker_config_file:
custom_broker_config = json.loads(read_file_content(file_path=custom_broker_config_file))

if broker_service_type == MqServiceType.load_balancer.value and add_insecure_listener:
raise ArgumentUsageError(
f"--add-insecure-listener cannot be used when --broker-service-type is {MqServiceType.load_balancer.value}."
)

work_manager = WorkManager(cmd)
return work_manager.execute_ops_init(
show_progress=not no_progress,
pre_flight=not no_pre_flight,
apply_foundation=False,
cluster_name=cluster_name,
resource_group_name=resource_group_name,
cluster_namespace=cluster_namespace,
location=location,
custom_location_name=custom_location_name,
disable_rsync_rules=disable_rsync_rules,
instance_name=instance_name,
instance_description=instance_description,
add_insecure_listener=add_insecure_listener,
dataflow_profile_instances=dataflow_profile_instances,
mi_user_assigned_identities=mi_user_assigned_identities,
# Broker
custom_broker_config=custom_broker_config,
broker_memory_profile=broker_memory_profile,
broker_service_type=broker_service_type,
broker_backend_partitions=broker_backend_partitions,
broker_backend_workers=broker_backend_workers,
broker_backend_redundancy_factor=broker_backend_redundancy_factor,
broker_frontend_workers=broker_frontend_workers,
broker_frontend_replicas=broker_frontend_replicas,
tags=tags,
)


Expand Down
4 changes: 2 additions & 2 deletions azext_edge/edge/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,10 @@ class BundleResourceKind(Enum):
configmap = "ConfigMap"


# MQ runtime attributes
# Broker runtime attributes

AIO_MQ_RESOURCE_PREFIX = "aio-mq-"
AIO_MQ_DIAGNOSTICS_SERVICE = "aio-mq-diagnostics-service"
AIO_BROKER_DIAGNOSTICS_SERVICE = "aio-broker-diagnostics-service"
AIO_MQ_OPERATOR = "aio-mq-operator"
METRICS_SERVICE_API_PORT = 9600
PROTOBUF_SERVICE_API_PORT = 9800
Expand Down
Loading