Skip to content

Instantly share code, notes, and snippets.

@kapilt
Last active October 27, 2016 19:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kapilt/d326b853e4606f9203e9 to your computer and use it in GitHub Desktop.
Save kapilt/d326b853e4606f9203e9 to your computer and use it in GitHub Desktop.
svc host fault upgrade size power ip
42fzbcx2ev juju0nezlcysed3o... 0 0 Small Started 10.0.0.20
42fzbcx2ev juju9bd6mjna00h0... 0 4 Small Started 10.0.0.60
42fzbcx2ev juju9ygqoy9qjkdq... 1 1 Small Started 10.0.0.28
42fzbcx2ev jujufrh460g4vyra... 1 0 Small Started 10.0.0.68
42fzbcx2ev jujukhrocaqpux90... 1 3 Small Started 10.0.0.52
42fzbcx2ev jujuzbbtbkk8tdo6... 0 2 Small Started 10.0.0.44
47rntclyak jujugk2ygbnatkhc... 0 0 Small Started 10.0.0.4
51etwr329x juju6329s6bqqao2... 0 0 Small Started 10.0.0.12
51etwr329x jujuuxa3sfxyp12f... 1 1 Small Started 10.0.0.36
import argparse
import yaml
import os
import subprocess
from azure.servicemanagement import ServiceManagementService
def main():
home = os.path.expanduser(os.environ.get('JUJU_HOME', '~/.juju'))
env_conf = os.path.join(home, 'environments.yaml')
env_name = subprocess.check_output(['juju', 'env']).strip()
with open(env_conf) as fh:
data = yaml.safe_load(fh.read())
env_data = data['environments'][env_name]
assert env_data['type'] == 'azure'
sm = ServiceManagementService(
env_data['management-subscription-id'],
env_data['management-certificate-path'])
header = "{:<15} {:<20} {:<5} {:<8} {:<12} {:<6} {:<10}".format(
"svc", "host", "fault", "upgrade", "size", "power", "ip")
svc_prefix = "juju-%s-" % env_name
for svc in sm.list_hosted_services().hosted_services:
deployment = sm.get_deployment_by_slot(
svc.service_name, 'Production')
for i in deployment.role_instance_list.role_instances:
if header:
print header
header = None
print("{:<15} {:<20} {:<5} {:<8} {:<12} {:<6} {:<10}".format(
svc.service_name[len(svc_prefix):],
i.host_name[:16]+'...',
i.instance_fault_domain,
i.instance_upgrade_domain,
i.instance_size,
i.power_state,
i.ip_address))
if __name__ == '__main__':
main()
environment: azure
machines:
"0":
agent-state: started
agent-version: 1.20.5
dns-name: juju-azure-47rntclyak.cloudapp.net
instance-id: juju-azure-47rntclyak-jujugk2ygbnatkhcas68exaoi8x9bcnbu31wyxeuhhjigkbesf
instance-state: ReadyRole
series: trusty
hardware: arch=amd64 cpu-cores=1 mem=1792M root-disk=130048M
state-server-member-status: has-vote
"1":
agent-state: started
agent-version: 1.20.5
dns-name: juju-azure-51etwr329x.cloudapp.net
instance-id: juju-azure-51etwr329x-juju6329s6bqqao2sd2yne9hsu1v3p5mlgrffr0xj7x3bneznz
instance-state: ReadyRole
series: trusty
hardware: arch=amd64 cpu-cores=1 mem=1792M root-disk=130048M
"2":
agent-state: started
agent-version: 1.20.5
dns-name: juju-azure-42fzbcx2ev.cloudapp.net
instance-id: juju-azure-42fzbcx2ev-juju0nezlcysed3ohjwuthzpvaxnwyyi2ctx8wdcr8108zearb
instance-state: RoleStateUnknown
series: precise
hardware: arch=amd64 cpu-cores=1 mem=1792M root-disk=130048M
"3":
agent-state: started
agent-version: 1.20.5
dns-name: juju-azure-42fzbcx2ev.cloudapp.net
instance-id: juju-azure-42fzbcx2ev-juju9ygqoy9qjkdqll74l6e8ufocceounauygind537p8g0bds
instance-state: ReadyRole
series: precise
hardware: arch=amd64 cpu-cores=1 mem=1792M root-disk=130048M
"4":
agent-state: started
agent-version: 1.20.5
dns-name: juju-azure-51etwr329x.cloudapp.net
instance-id: juju-azure-51etwr329x-jujuuxa3sfxyp12fu0efxxt51v8zjtoqw4ri36ztk3jt91rn58
instance-state: ReadyRole
series: trusty
hardware: arch=amd64 cpu-cores=1 mem=1792M root-disk=130048M
"5":
agent-state: started
agent-version: 1.20.5
dns-name: juju-azure-42fzbcx2ev.cloudapp.net
instance-id: juju-azure-42fzbcx2ev-jujuzbbtbkk8tdo6mu6goee6rpymqm0o529yu6wvgxp6p8c040
instance-state: ReadyRole
series: precise
hardware: arch=amd64 cpu-cores=1 mem=1792M root-disk=130048M
"6":
agent-state: pending
dns-name: juju-azure-42fzbcx2ev.cloudapp.net
instance-id: juju-azure-42fzbcx2ev-jujukhrocaqpux90xti5kdqo8isfe0kkzfebtgbxdkcwig2j87
instance-state: ReadyRole
series: precise
hardware: arch=amd64 cpu-cores=1 mem=1792M root-disk=130048M
"7":
agent-state: pending
dns-name: juju-azure-42fzbcx2ev.cloudapp.net
instance-id: juju-azure-42fzbcx2ev-juju9bd6mjna00h0q0lj9290kcm6q2xwsals2sxyxh023oy33i
instance-state: ReadyRole
series: precise
hardware: arch=amd64 cpu-cores=1 mem=1792M root-disk=130048M
"8":
agent-state: pending
dns-name: juju-azure-42fzbcx2ev.cloudapp.net
instance-id: juju-azure-42fzbcx2ev-jujufrh460g4vyra6fnwg9dbp5qavm77osvlvdnpngde29vxll
instance-state: ReadyRole
series: precise
hardware: arch=amd64 cpu-cores=1 mem=1792M root-disk=130048M
services:
mysql:
charm: cs:trusty/mysql-4
exposed: false
relations:
cluster:
- mysql
db:
- wordpress
units:
mysql/0:
agent-state: started
agent-version: 1.20.5
machine: "1"
public-address: juju-azure-51etwr329x.cloudapp.net
mysql/1:
agent-state: started
agent-version: 1.20.5
machine: "4"
public-address: juju-azure-51etwr329x.cloudapp.net
wordpress:
charm: cs:precise/wordpress-25
exposed: false
relations:
db:
- mysql
loadbalancer:
- wordpress
units:
wordpress/0:
agent-state: started
agent-version: 1.20.5
machine: "2"
open-ports:
- 80/tcp
public-address: juju-azure-42fzbcx2ev.cloudapp.net
wordpress/1:
agent-state: started
agent-version: 1.20.5
machine: "3"
open-ports:
- 80/tcp
public-address: juju-azure-42fzbcx2ev.cloudapp.net
wordpress/2:
agent-state: started
agent-version: 1.20.5
machine: "5"
open-ports:
- 80/tcp
public-address: juju-azure-42fzbcx2ev.cloudapp.net
wordpress/3:
agent-state: pending
machine: "6"
public-address: juju-azure-42fzbcx2ev.cloudapp.net
wordpress/4:
agent-state: pending
machine: "7"
public-address: juju-azure-42fzbcx2ev.cloudapp.net
wordpress/5:
agent-state: pending
machine: "8"
public-address: juju-azure-42fzbcx2ev.cloudapp.net
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment