コード例 #1
0
 def __rds_inst_display(dbinstance, disp, pg):
     """Display information about the specified RDS instance.
     """
     if disp.display == DisplayOptions.LONG:
         pg.prt("%-20s %-10s %-10s %s",
                 dbinstance.id, dbinstance.status,
                 dbinstance.instance_class,
                 amazon2localtime(dbinstance.create_time))
     elif disp.display == DisplayOptions.EXTENDED:
         pg.prt("%s", dbinstance.id)
         pg.prt("%15s : %s", "Status", dbinstance.status)
         pg.prt("%15s : %s", "Creation-time", 
                         amazon2localtime(dbinstance.create_time))
         pg.prt("%15s : %s", "Class", dbinstance.instance_class)
         pg.prt("%15s : %s", "Engine", dbinstance.engine)
         pg.prt("%15s : %s", "Storage", dbinstance.allocated_storage)
         pg.prt("%15s : %s", "DNS-name", dbinstance.endpoint[0])
         pg.prt("%15s : %s", "Port", dbinstance.endpoint[1])
         pg.prt("%15s : %s", "MultiZone",
                             "True" if dbinstance.multi_az else "False")
         if dbinstance.availability_zone:
             pg.prt("%15s : %s", "Zone", dbinstance.availability_zone)
         pg.prt("%15s : %s", "Groups", " ".join(
                 [dbgroup.name for dbgroup in dbinstance.security_groups]))
     else:
         pg.prt("%s", dbinstance.id)
コード例 #2
0
 def __vol_display(self, vol, disp, pg, region):
     """Display volume info
     """
     self.cache_insert(region, [vol.id])
     if disp.display_size:
         pg.prt("%-14s %4s", vol.id, vol.size)
     else:
         if disp.display == DisplayOptions.LONG:
             snapshot_id = vol.snapshot_id.strip()
             if not snapshot_id:
                 snapshot_id = '-'
             pg.wrt("%-14s %-10s %-12s %4s %-14s",
                     vol.id, vol.status, vol.zone, vol.size, snapshot_id)
             if vol.snapshot_id:
                 self.cache_insert(region, [vol.snapshot_id])
             if vol.attach_data and vol.attach_data.instance_id:
                 attach_str = "%s:%s" % (vol.attach_data.instance_id,
                                             vol.attach_data.device)
             else:
                 attach_str = "-"
             pg.wrt(" %-22s", attach_str)
             if disp.display_name:
                 vol_name = vol.tags.get("Name")
                 if vol_name:
                     pg.wrt(" %s", vol_name)
             pg.wrt("\n")
         elif disp.display == DisplayOptions.EXTENDED:
             pg.prt("%s", vol.id)
             pg.prt("%15s : %s", "Status", vol.status)
             pg.prt("%15s : %s", "Size", vol.size)
             pg.prt("%15s : %s", "Creation-time",
                                     amazon2localtime(vol.create_time))
             if vol.snapshot_id:
                 pg.prt("%15s : %s", "Snapshot", vol.snapshot_id)
                 self.cache_insert(region, [vol.snapshot_id])
             pg.prt("%15s : %s", "Zone", vol.zone)
             pg.prt("%15s : %s", "Type", vol.type)
             if vol.iops:
                 pg.prt("%15s : %s", "IOPS", vol.iops)
             if vol.attach_data:
                 atd = vol.attach_data
                 if atd.instance_id:
                     pg.prt("%15s : %s", "Instance-id", atd.instance_id)
                 if atd.device:
                     pg.prt("%15s : %s", "Device", atd.device)
                 if atd.status:
                     pg.prt("%15s : %s", "Attach-status", atd.status)
                 if atd.attach_time:
                     pg.prt("%15s : %s", "Attach-time",
                                     amazon2localtime(atd.attach_time))
             if disp.display_tags:
                 common.display_tags(vol.tags, pg)
         else:
             pg.prt("%s", vol.id)
             if disp.display_tags:
                 common.display_tags(vol.tags, pg)
コード例 #3
0
 def __eni_display(eni, disp, pg):
     """Display eni info
     """
     if disp.display == DisplayOptions.LONG:
         pg.prt("%-14s %-8s %-14s %-18s %-10s", eni.id, eni.status, eni.vpc_id, eni.subnet_id, eni.availability_zone)
     elif disp.display == DisplayOptions.EXTENDED:
         pg.prt("%s", eni.id)
         pg.prt("%15s : %s", "Status", eni.status)
         if eni.description:
             pg.prt("%15s : %s", "Description", eni.description)
         pg.prt("%15s : %s", "MAC", eni.mac_address)
         pg.prt("%15s : %s", "Zone", eni.availability_zone)
         pg.prt("%15s : %s", "VPC", eni.vpc_id)
         pg.prt("%15s : %s", "Subnet", eni.subnet_id)
         pg.prt("%15s : %s", "Req-managed", eni.requester_managed)
         if eni.private_ip_address:
             pg.prt("%15s : %s", "Primary-IP", eni.private_ip_address)
         if eni.private_ip_addresses:
             pg.prt("%15s : %s", "Private-IPs", ", ".join([x.private_ip_address for x in eni.private_ip_addresses]))
         if eni.groups:
             pg.prt("%15s : %s", "Groups", " ".join([group.id for group in eni.groups]))
         pg.prt("%15s : %s", "SRC/DST-check", eni.source_dest_check)
         if eni.attachment:
             att = eni.attachment
             pg.prt("%15s : %s", "Instance", optional(att.instance_id))
             pg.prt("%15s : %s", "Device-index", att.device_index)
             pg.prt("%15s : %s", "Attach-time", amazon2localtime(att.attach_time))
             pg.prt("%15s : %s", "DoT", att.delete_on_termination)
         if disp.display_tags:
             common.display_tags(eni.tags, pg)
     else:
         pg.prt("%s", eni.id)
         if disp.display_tags:
             common.display_tags(eni.tags, pg)
コード例 #4
0
 def __cert_server_display(server_cert, disp, pg):
     """Display server certificate information
     """
     if disp.display == DisplayOptions.LONG:
         pg.prt("%-14s", server_cert.server_certificate_name)
     elif disp.display == DisplayOptions.EXTENDED:
         pg.prt("%s:", server_cert.server_certificate_name)
         pg.prt("%15s : %-12s", "ARN", server_cert.arn)
         pg.prt("%15s : %s", "Cert-id", server_cert.server_certificate_id)
         pg.prt("%15s : %s", "Upload-date",
                         amazon2localtime(server_cert.upload_date))
     else:
         pg.prt("%s", server_cert.server_certificate_name)
コード例 #5
0
 def __snap_display(self, snapshot, disp, pg, region):
     """Display snapshot info
     """
     self.cache_insert(region, [snapshot.id])
     if disp.display_size:
         pg.prt("%-14s %4s", snapshot.id, snapshot.volume_size)
     else:
         if disp.display == DisplayOptions.LONG:
             if disp.display_name:
                 last_field = snapshot.tags.get("Name", "-")
             else:
                 last_field = snapshot.description
             pg.prt("%-14s %-10s %6s %4s '%s'",
                 snapshot.id, snapshot.status,
                 amazon2localtime(snapshot.start_time),
                 snapshot.volume_size, last_field)
         elif disp.display == DisplayOptions.EXTENDED:
             pg.prt("%s", snapshot.id)
             pg.prt("%15s : %s", "Status", snapshot.status)
             pg.prt("%15s : %s", "Progress", snapshot.progress)
             pg.prt("%15s : %s", "Description", snapshot.description)
             pg.prt("%15s : %s", "Start-time", 
                                     amazon2localtime(snapshot.start_time))
             pg.prt("%15s : %s", "Size", snapshot.volume_size)
             pg.prt("%15s : %s", "Volume", snapshot.volume_id)
             self.cache_insert(region, [snapshot.volume_id])
             try:
                 snapshot_attr_list = snapshot.get_permissions()
                 for snapshot_attr in snapshot_attr_list:
                     pg.prt("%15s : %s",
                             snapshot_attr, 
                             ", ".join(snapshot_attr_list[snapshot_attr]))
             except Exception, ex:
                 pg.prt("No permissions for %s: %s", snapshot.id, ex)
             if disp.display_tags:
                 common.display_tags(snapshot.tags, pg)
         else:
コード例 #6
0
 def __inst_display(self, instance, disp, pg, region):
     """Display information about the specified instance.
     """
     res_id_list = [instance.id]
     if disp.display == DisplayOptions.LONG:
         if disp.display_name:
             last_field = instance.tags.get("Name", "-")
         else:
             last_field = amazon2localtime(instance.launch_time)
         pg.prt("%-12s %-10s %-12s %-10s %s",
                 instance.id, instance.state,
                 instance.placement,
                 instance.instance_type,
                 last_field)
     elif disp.display == DisplayOptions.EXTENDED:
         pg.prt("%s", instance.id)
         pg.prt("%15s : %-12s", "State", instance.state)
         pg.prt("%15s : %s", "Launch-time", 
                         amazon2localtime(instance.launch_time))
         pg.prt("%15s : %s", "Location", instance.placement)
         pg.prt("%15s : %s %s %s %s", "Hardware",
                                     instance.instance_type,
                                     instance.architecture,
                                     instance.virtualization_type,
                                     instance.hypervisor,
                                     )
         pg.prt("%15s : %s %s %s %s", "Software",
                                     instance.platform,
                                     instance.image_id,
                                     instance.kernel,
                                     instance.ramdisk)
         res_id_list.append(instance.image_id)
         if instance.kernel:
             res_id_list.append(instance.kernel)
         if instance.ramdisk:
             res_id_list.append(instance.ramdisk)
         pg.prt("%15s : %-12s %s", "Root",
                                     instance.root_device_name,
                                     instance.root_device_type)
         pg.prt("%15s : %s", "EBS-optimized",
                     "True" if instance.ebs_optimized else "False")
         if instance.vpc_id:
             pg.prt("%15s : %-14s %-16s", "VPC-info",
                                 instance.vpc_id, instance.subnet_id)
             res_id_list.extend([instance.vpc_id, instance.subnet_id])
         if instance.private_ip_address:
             pg.prt("%15s : %s %s", "IP",
                                     instance.ip_address,
                                     instance.private_ip_address)
         for netif in instance.interfaces:
             pg.prt("%15s : %-15s idx=%-2s %-16s SDC=%s",
                             "Interface",
                             netif.id,
                             netif.attachment.device_index,
                             netif.private_ip_address,
                             "on" if netif.source_dest_check else "off"
                             )
             res_id_list.append(netif.id)
         if instance.groups:
             group_id_list = [group.id for group in instance.groups]
             pg.prt("%15s : %s", "Groups", " ".join(group_id_list))
             res_id_list.extend(group_id_list)
         bdev_list = instance.block_device_mapping.keys()
         bdev_list.sort()
         for bdev in bdev_list:
             bdev_info = instance.block_device_mapping[bdev]
             pg.prt("%15s : %-12s %-12s %s dot=%s",
                     "Device", bdev,
                     bdev_info.volume_id,
                     bdev_info.status,
                     bdev_info.delete_on_termination)
             res_id_list.append(bdev_info.volume_id)
         if disp.display_tags:
             common.display_tags(instance.tags, pg)
     else:
         pg.prt("%s", instance.id)
         if disp.display_tags:
             common.display_tags(instance.tags, pg)
     self.cache_insert(region, res_id_list)
コード例 #7
0
 def __elb_display(self, elb, disp, pg, region):
     """Display information about the specified ELB.
     """
     if disp.display_policies:
         pg.prt("%s", elb.name)
         if elb.policies.app_cookie_stickiness_policies:
             for policy in elb.policies.app_cookie_stickiness_policies:
                 pg.prt("%15s : %-15s cookie=%s",
                             "App-cookie",
                             policy.policy_name,
                             policy.cookie_name)
         if elb.policies.lb_cookie_stickiness_policies:
             for policy in elb.policies.lb_cookie_stickiness_policies:
                 pg.prt("%15s : %-15s expiration=%s",
                             "LB-cookie",
                             policy.policy_name,
                             policy.cookie_expiration_period)
     elif disp.display == DisplayOptions.LONG:
         pg.prt("%-20s %-30s %s",
                 elb.name,
                 elb.dns_name,
                 optional(elb.vpc_id))
     elif disp.display == DisplayOptions.EXTENDED:
         pg.prt("%s", elb.name)
         pg.prt("%15s : %s", "DNS-name", elb.dns_name)
         pg.prt("%15s : %s", "CNAME", elb.canonical_hosted_zone_name)
         pg.prt("%15s : %s", "Create-time",
                         amazon2localtime(elb.created_time))
         for listener in elb.listeners:
             pg.prt("%15s : in=%-4s out=%-4s proto=%-5s",
                             "Listener",
                             listener.load_balancer_port,
                             listener.instance_port,
                             listener.protocol)
             if listener.policy_names:
                 pg.prt("%15s   policy=%s", "", listener.policy_names[0])
             if listener.ssl_certificate_id:
                 cert_name = listener.ssl_certificate_id.split('/', 1)[1]
                 pg.prt("%15s   cert=%s", "", cert_name)
         pg.prt("%15s : %s" % ("Group", elb.source_security_group.name))
         if elb.vpc_id:
             pg.prt("%15s : %s", "VPC-id", elb.vpc_id)
             self.cache_insert(region, [elb.vpc_id])
         if elb.subnets:
             pg.prt("%15s : %s", "Subnets", ", ".join(elb.subnets))
             self.cache_insert(region, elb.subnets)
         if elb.availability_zones:
             pg.prt("%15s : %s", "Zones", ", ".join(elb.availability_zones))
         if elb.health_check:
             pg.prt("%15s : i=%s t=%s ht=%s ut=%s %s",
                             "Healthcheck",
                             elb.health_check.interval,
                             elb.health_check.timeout,
                             elb.health_check.healthy_threshold,
                             elb.health_check.unhealthy_threshold,
                             optional(elb.health_check.target))
         if elb.policies.app_cookie_stickiness_policies:
             for policy in elb.policies.app_cookie_stickiness_policies:
                 pg.prt("%15s : %-15s cookie=%s",
                             "App-cookie",
                             policy.policy_name,
                             policy.cookie_name)
         if elb.policies.lb_cookie_stickiness_policies:
             for policy in elb.policies.lb_cookie_stickiness_policies:
                 pg.prt("%15s : %-15s expiration=%s",
                             "LB-cookie",
                             policy.policy_name,
                             policy.cookie_expiration_period)
         if elb.instances:
             for instance_info in elb.instances:
                 pg.prt("%15s : %-12s", "Instance", instance_info.id)
                 self.cache_insert(region, [instance_info.id])
     else:
         pg.prt("%s", elb.name)