{"body":"import os\n\nfrom charmhelpers.core import hookenv\nfrom charms.reactive import hook, RelationBase, scopes\n\nclass MasterConfigPeer(RelationBase):\n\n\tscope = scopes.UNIT;\n\n\t@hook(\"{peers:master-config}-relation-{joined}\")\n\tdef joined(self):\n\t\tconv = self.conversation();\n\t\tconv.set_state(\"{relation_name}.connected\");\n\n\t@hook(\"{peers:master-config}-relation-{changed}\")\n\tdef changed(self):\n\t\tconv = self.conversation();\n\t\tif conv.get_remote('central_ip'):\n\t\t\tconv.set_state(\"{relation_name}.master_ip.available\");\n\t\telif conv.get_remote('cert_to_sign'):\n\t\t\tconv.set_state(\"{relation_name}.unsigned.cert.available\");\n\t\telif conv.get_remote('signed_cert'):\n\t\t\tconv.set_state(\"{relation_name}.signed.cert.available\");\n\t\telif conv.get_remote('ip_request'):\n\t\t\tconv.set_state(\"{relation_name}.ip_request\");\n\n\t@hook(\"{peers:master-config}-relation-{departed}\")\n\tdef departed(self):\n\t\tconv = self.conversation();\n\t\tconv.remove_state(\"{relation_name}.connected\");\n\n\tdef send_config(self, config):\n\t\tconvs = self.conversations();\n\n\t\tfor conv in convs:\n\t\t\tconv.set_remote(data=config);\n\n\tdef get_config(self, key):\n\t\tconvs = self.conversations();\n\n\t\tfinal = [];\n\t\tfor conv in convs:\n\t\t\tif conv.get_remote(key):\n\t\t\t\tfinal.append(conv.get_remote(key));\n\n\t\treturn final;","name":"","extension":"txt","url":"https://www.irccloud.com/pastebin/cFegoDAR","modified":1500381736,"id":"cFegoDAR","size":1252,"lines":46,"own_paste":false,"theme":"","date":1500381736}