예제 #1
0
    def get_status_text(self):
        instance = self.instance_deployment.get_instance()
        if not instance:
            raise InstanceNotRunningError(self.instance_config.name)

        table = [
            ('Instance State', instance.state),
            ('Instance Type', instance.instance_type),
            ('Availability Zone', instance.availability_zone),
        ]

        if instance.public_ip_address:
            table.append(('Public IP Address', instance.public_ip_address))

        table.append(('Launch Time',
                      instance.launch_time.strftime('%Y-%m-%d %H:%M:%S')))

        if instance.lifecycle == 'spot':
            spot_price = instance.get_spot_price()
            table.append(('Purchasing Option', 'Spot Instance'))
            table.append(('Spot Instance Price', '$%.04f' % spot_price))
        else:
            table.append(('Purchasing Option', 'On-Demand Instance'))

        return render_table(table)
    def get_status_text(self):
        if self.is_container_running():
            msg = 'Container is running.'
        else:
            msg = 'Container is not running.'

        return render_table([(msg,)])
예제 #3
0
    def get_status_text(self):
        instance = self.instance_deployment.get_instance()
        if not instance:
            raise InstanceNotRunningError(self.instance_config.name)

        table = [
            ('Instance State', instance.state),
            ('Instance Type', instance.instance_type),
            ('Availability Zone', instance.availability_zone),
        ]

        if instance.public_ip_address:
            table.append(('Public IP Address', instance.public_ip_address))

        if instance.lifecycle == 'spot':
            spot_price = instance.get_spot_price()
            table.append(('Purchasing Option', 'Spot Instance'))
            table.append(('Spot Instance Price', '$%.04f' % spot_price))
        else:
            on_demand_price = instance.get_on_demand_price()
            table.append(('Purchasing Option', 'On-Demand Instance'))
            table.append(('Instance Price',
                          ('$%.04f (us-east-1)' %
                           on_demand_price) if on_demand_price else 'Unknown'))

        return render_table(table)
예제 #4
0
    def get_status_text(self) -> str:
        instance = self.instance_deployment.get_instance()
        if not instance:
            raise InstanceNotRunningError(self.instance_config.name)

        table = [
            ('Instance Status', instance.status),
            ('Machine Type', instance.machine_type),
            ('Zone', instance.zone),
        ]

        if instance.public_ip_address:
            table.append(('Public IP Address', instance.public_ip_address))

        table.append(('Launch Time', instance.creation_timestamp.today().strftime('%Y-%m-%d %H:%M:%S')))
        table.append(('Purchasing Option', 'Preemtible VM' if instance.is_preemtible else 'On-demand VM'))

        return render_table(table)
예제 #5
0
def render_volumes_info_table(volume_mounts: List[VolumeMount],
                              volumes: List[AbstractInstanceVolume]):
    table = [('Name', 'Mount Path', 'Type', 'Deletion Policy')]

    # add volume mounts to the info table
    volumes_dict = {volume.name: volume for volume in volumes}
    for volume_mount in volume_mounts:
        if not volume_mount.hidden:
            # the volume will be mounted to the container
            volume = volumes_dict[volume_mount.name]
            vol_mount_name = '-' if volume_mount.name == PROJECT_VOLUME_MOUNT_NAME else volume_mount.name
            deletion_policy = volume.deletion_policy_title if volume.deletion_policy_title else '-'
            table.append((vol_mount_name, volume_mount.mount_path,
                          volume.title, deletion_policy))

    # add volumes that were not mounted to the container to the info table
    volume_mounts_dict = {volume_mount.name for volume_mount in volume_mounts}
    for volume in volumes:
        if volume.name not in volume_mounts_dict:
            deletion_policy = volume.deletion_policy_title if volume.deletion_policy_title else '-'
            table.append((volume.name, '-', volume.title, deletion_policy))

    return render_table(table, separate_title=True)
예제 #6
0
def render_volumes_info_table(volume_mounts: List[VolumeMount], volumes: List[AbstractInstanceVolume]):
    table = [('Name', 'Container Dir', 'Type', 'Deletion Policy')]

    # add volume mounts to the info table
    volumes_dict = {volume.name: volume for volume in volumes}
    for volume_mount in volume_mounts:
        if volume_mount.name in volumes_dict:
            # the volume will be mounted to the container
            volume = volumes_dict[volume_mount.name]
            deletion_policy = volume.deletion_policy_title if volume.deletion_policy_title else '-'
            table.append((volume_mount.name, volume_mount.container_dir, volume.title, deletion_policy))
        else:
            # a temporary directory will be mounted to the container
            vol_mount_name = '-' if volume_mount.name is None else volume_mount.name
            table.append((vol_mount_name, volume_mount.container_dir, 'temporary directory', '-'))

    # add volumes that were not mounted to the container to the info table
    volume_mounts_dict = {volume_mount.name for volume_mount in volume_mounts}
    for volume in volumes:
        if volume.name not in volume_mounts_dict:
            deletion_policy = volume.deletion_policy_title if volume.deletion_policy_title else '-'
            table.append((volume.name, '-', volume.title, deletion_policy))

    return render_table(table, separate_title=True)