Exemplo n.º 1
0
def _build_identities_info(identities):
    identities = identities or []
    identity_type = ResourceIdentityType.none
    if not identities or MSI_LOCAL_ID in identities:
        identity_type = ResourceIdentityType.system_assigned
    external_identities = [x for x in identities if x != MSI_LOCAL_ID]
    if external_identities and identity_type == ResourceIdentityType.system_assigned:
        identity_type = ResourceIdentityType.system_assigned_user_assigned
    elif external_identities:
        identity_type = ResourceIdentityType.user_assigned
    identity = ContainerGroupIdentity(type=identity_type)
    if external_identities:
        identity.user_assigned_identities = {e: {} for e in external_identities}
    return identity
Exemplo n.º 2
0
def _build_identities_info(identities):
    identities = identities or []
    identity_type = ResourceIdentityType.none
    if not identities or MSI_LOCAL_ID in identities:
        identity_type = ResourceIdentityType.system_assigned
    external_identities = [x for x in identities if x != MSI_LOCAL_ID]
    if external_identities and identity_type == ResourceIdentityType.system_assigned:
        identity_type = ResourceIdentityType.system_assigned_user_assigned
    elif external_identities:
        identity_type = ResourceIdentityType.user_assigned
    identity = ContainerGroupIdentity(type=identity_type)
    if external_identities:
        identity.user_assigned_identities = {e: {} for e in external_identities}
    return identity
Exemplo n.º 3
0
    def create(self):
        if self._exists():
            return

        ci_client = _get_ci_client(self.config)
        ci = AciContainer(self.logger, self.config)
        container = ci.create()

        group = ContainerGroup(
            location=self.config.resource_group_loation,
            containers=[container],
            os_type=OperatingSystemTypes.linux,
            restart_policy=ContainerGroupRestartPolicy.never,
            identity=ContainerGroupIdentity(
                type=ResourceIdentityType.system_assigned))

        try:
            result = ci_client.container_groups.create_or_update(
                self.config.resource_group_name,
                self.config.container_group_name, group)

            _poll_for_complete(result)
        except CloudError as ce:
            if ce.inner_exception.error == "InaccessibleImage":
                self.logger.logger.warning("Did you forget to push the image?")

        self.logger.container_group_created()