{"id":20111724,"url":"https://github.com/openstack/charm-interface-hacluster","last_synced_at":"2026-03-11T20:01:42.134Z","repository":{"id":66174645,"uuid":"62715620","full_name":"openstack/charm-interface-hacluster","owner":"openstack","description":"Charm Interface - HA Cluster. Mirror of code maintained at opendev.org.","archived":false,"fork":false,"pushed_at":"2023-11-28T19:07:33.000Z","size":59,"stargazers_count":9,"open_issues_count":0,"forks_count":6,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-06T11:34:50.073Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://opendev.org/openstack/charm-interface-hacluster","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/openstack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-07-06T11:22:52.000Z","updated_at":"2023-10-24T15:32:25.000Z","dependencies_parsed_at":"2025-05-06T11:41:16.801Z","dependency_job_id":null,"html_url":"https://github.com/openstack/charm-interface-hacluster","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/openstack/charm-interface-hacluster","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openstack%2Fcharm-interface-hacluster","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openstack%2Fcharm-interface-hacluster/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openstack%2Fcharm-interface-hacluster/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openstack%2Fcharm-interface-hacluster/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openstack","download_url":"https://codeload.github.com/openstack/charm-interface-hacluster/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openstack%2Fcharm-interface-hacluster/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30398170,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-11T18:46:22.935Z","status":"ssl_error","status_checked_at":"2026-03-11T18:46:17.045Z","response_time":84,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T18:17:29.864Z","updated_at":"2026-03-11T20:01:42.104Z","avatar_url":"https://github.com/openstack.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Overview\n\nThis interface handles the communication with the hacluster subordinate\ncharm using the `ha` interface protocol.\n\n# Usage\n\n## Requires\n\nThe interface layer will set the following reactive states, as appropriate:\n\n  * `{relation_name}.connected` The relation is established and ready for\n    the local charm to configure the hacluster subordinate charm. The\n    configuration of the resources to manage for the hacluster charm\n    can be managed via one of the following methods:\n\n    * `manage_resources` method\n    * `bind_on` method\n\n    Configuration of the managed resources within the hacluster can be\n    managed by passing `common.CRM` object definitions to the\n    `manage_resources` method.\n\n  * `{relation_name}.available` The hacluster is up and ready.\n\nFor example:\n```python\nfrom charms.reactive import when, when_not\nfrom charms.reactive import set_state, remove_state\n\nfrom relations.hacluster.common import CRM\n\n\n@when('ha.connected')\ndef cluster_connected(hacluster):\n\n    resources = CRM()\n    resources.primitive('res_vip', 'ocf:IPAddr2',\n                        params='ip=10.0.3.100 nic=eth0',\n                        op='monitor interval=\"10s\"')\n    resources.clone('cl_res_vip', 'res_vip')\n\n    hacluster.bind_on(iface='eth0', mcastport=4430)\n    hacluster.manage_resources(resources)\n```\n\nAdditionally, for more code clarity a custom object implements the interface\ndefined in common.ResourceDescriptor can be used to simplify the code for\nreuse.\n\nFor example:\n```python\nimport ipaddress\n\nfrom relation.hacluster.common import CRM\nfrom relation.hacluster.common import ResourceDescriptor\n\nclass VirtualIP(ResourceDescriptor):\n    def __init__(self, vip, nic='eth0'):\n        self.vip = vip\n        self.nic = 'eth0'\n\n    def configure_resource(self, crm):\n        ipaddr = ipaddress.ip_address(self.vip)\n        if isinstance(ipaddr, ipaddress.IPv4Address):\n            res_type = 'ocf:heartbeat:IPAddr2'\n            res_parms = 'ip={ip} nic={nic}'.format(ip=self.vip,\n                                                   nic=self.nic)\n        else:\n            res_type = 'ocf:heartbeat:IPv6addr'\n            res_params = 'ipv6addr={ip} nic={nic}'.format(ip=self.vip,\n                                                          nic=self.nic)\n\n        crm.primitive('res_vip', res_type, params=res_params,\n                      op='monitor interval=\"10s\"')\n        crm.clone('cl_res_vip', 'res_vip')\n```\n\nOnce the VirtualIP class above has been defined in charm code, it can make\nthe code a bit cleaner. The example above can thusly be written as:\n\n```python\n@when('ha.connected')\ndef cluster_connected(hacluster):\n    resources = CRM()\n    resources.add(VirtualIP('10.0.3.100'))\n\n    hacluster.bind_on(iface='eth0', mcastport=4430)\n    hacluster.manage_resources(resources)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenstack%2Fcharm-interface-hacluster","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenstack%2Fcharm-interface-hacluster","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenstack%2Fcharm-interface-hacluster/lists"}