From 48d76271a4fa8fcfa17dce9c852940e9e73f31fd Mon Sep 17 00:00:00 2001
From: calvinosanc1 <guillermo.calvino@canonical.com>
Date: Wed, 12 Aug 2020 13:18:54 +0200
Subject: [PATCH] hackfest_magma-agw-enb_vnfd and hackfest_gateway_vnfd
 packages updated

Signed-off-by: calvinosanc1 <guillermo.calvino@canonical.com>
---
 .../charms/vyos-config/src/charm.py           | 42 ++++++-------
 .../charms/vyos-config/src/proxy_cluster.py   |  2 +-
 .../charms/enodeb/src/charm.py                | 21 +++----
 .../charms/magmagw/src/charm.py               | 62 +++++++++----------
 .../charms/magmagw/src/proxy_cluster.py       |  2 +-
 5 files changed, 61 insertions(+), 68 deletions(-)

diff --git a/magma/hackfest_gateway_vnfd/charms/vyos-config/src/charm.py b/magma/hackfest_gateway_vnfd/charms/vyos-config/src/charm.py
index 2b9ce7d4..a1c9df2a 100755
--- a/magma/hackfest_gateway_vnfd/charms/vyos-config/src/charm.py
+++ b/magma/hackfest_gateway_vnfd/charms/vyos-config/src/charm.py
@@ -75,29 +75,25 @@ class SimpleHAProxyCharm(CharmBase):
             self.state.is_started = True
 
         # Register all of the events we want to observe
-        for event in (
-            # Charm events
-            self.on.config_changed,
-            self.on.install,
-            self.on.start,
-            self.on.upgrade_charm,
-            # Charm actions (primitives)
-            self.on.configure_remote_action,
-            # OSM actions (primitives)
-            self.on.start_action,
-            self.on.stop_action,
-            self.on.restart_action,
-            self.on.reboot_action,
-            self.on.upgrade_action,
-            # SSH Proxy actions (primitives)
-            self.on.generate_ssh_key_action,
-            self.on.get_ssh_public_key_action,
-            self.on.run_action,
-            self.on.verify_ssh_credentials_action,
-        ):
-            self.framework.observe(event, self)
-
-        self.framework.observe(self.on.proxypeer_relation_changed, self)
+        self.framework.observe(self.on.config_changed, self.on_config_changed)
+        self.framework.observe(self.on.install, self.on_install)
+        self.framework.observe(self.on.start, self.on_start)
+        self.framework.observe(self.on.upgrade_charm, self.on_upgrade_charm)
+        # Charm actions (primitives)
+        self.framework.observe(self.on.configure_remote_action, self.on_configure_remote_action)
+        # OSM actions (primitives)
+        self.framework.observe(self.on.start_action, self.on_start_action)
+        self.framework.observe(self.on.stop_action, self.on_stop_action)
+        self.framework.observe(self.on.restart_action, self.on_restart_action)
+        self.framework.observe(self.on.reboot_action, self.on_reboot_action)
+        self.framework.observe(self.on.upgrade_action, self.on_upgrade_action)
+        # SSH Proxy actions (primitives)
+        self.framework.observe(self.on.generate_ssh_key_action, self.on_generate_ssh_key_action)
+        self.framework.observe(self.on.get_ssh_public_key_action, self.on_get_ssh_public_key_action)
+        self.framework.observe(self.on.run_action, self.on_run_action)
+        self.framework.observe(self.on.verify_ssh_credentials_action, self.on_verify_ssh_credentials_action)
+
+        self.framework.observe(self.on.proxypeer_relation_changed, self.on_proxypeer_relation_changed)
 
     def get_ssh_proxy(self):
         """Get the SSHProxy instance"""
diff --git a/magma/hackfest_gateway_vnfd/charms/vyos-config/src/proxy_cluster.py b/magma/hackfest_gateway_vnfd/charms/vyos-config/src/proxy_cluster.py
index 93cd119d..bbdcb43d 100644
--- a/magma/hackfest_gateway_vnfd/charms/vyos-config/src/proxy_cluster.py
+++ b/magma/hackfest_gateway_vnfd/charms/vyos-config/src/proxy_cluster.py
@@ -24,7 +24,7 @@ class ProxyCluster(Object):
         self._relation_name = relation_name
         self._relation = self.framework.model.get_relation(self._relation_name)
 
-        self.framework.observe(charm.on.ssh_keys_initialized, self)
+        self.framework.observe(charm.on.ssh_keys_initialized, self.on_ssh_keys_initialized)
 
         self.state.set_default(ssh_public_key=None)
         self.state.set_default(ssh_private_key=None)
diff --git a/magma/hackfest_magma-agw-enb_vnfd/charms/enodeb/src/charm.py b/magma/hackfest_magma-agw-enb_vnfd/charms/enodeb/src/charm.py
index 8d0e453b..79d5815e 100755
--- a/magma/hackfest_magma-agw-enb_vnfd/charms/enodeb/src/charm.py
+++ b/magma/hackfest_magma-agw-enb_vnfd/charms/enodeb/src/charm.py
@@ -43,19 +43,16 @@ class EnodebCharm(CharmBase):
         self.state.set_default(is_started=False)
         if not self.state.is_started:
             self.state.is_started = True
+
         # Register all of the events we want to observe
-        for event in (
-            # Charm events
-            self.on.config_changed,
-            self.on.install,
-            self.on.upgrade_charm,
-            self.on.register_action,
-            self.on.attach_ue_action,
-            self.on.unregister_action,
-            self.on.detach_ue_action,
-            self.on.remove_default_gw_action,
-        ):
-            self.framework.observe(event, self)
+        self.framework.observe(self.on.config_changed, self.on_config_changed)
+        self.framework.observe(self.on.install, self.on_install)
+        self.framework.observe(self.on.upgrade_charm, self.on_upgrade_charm)
+        self.framework.observe(self.on.register_action, self.on_register_action)
+        self.framework.observe(self.on.attach_ue_action, self.on_attach_ue_action)
+        self.framework.observe(self.on.unregister_action, self.on_unregister_action)
+        self.framework.observe(self.on.detach_ue_action, self.on_detach_ue_action)
+        self.framework.observe(self.on.remove_default_gw_action, self.on_remove_default_gw_action)
 
     def on_config_changed(self, event):
         """Handle changes in configuration"""
diff --git a/magma/hackfest_magma-agw-enb_vnfd/charms/magmagw/src/charm.py b/magma/hackfest_magma-agw-enb_vnfd/charms/magmagw/src/charm.py
index c19ba711..1e2e6afb 100755
--- a/magma/hackfest_magma-agw-enb_vnfd/charms/magmagw/src/charm.py
+++ b/magma/hackfest_magma-agw-enb_vnfd/charms/magmagw/src/charm.py
@@ -73,36 +73,33 @@ class SimpleHAProxyCharm(CharmBase):
             self.state.is_started = True
 
         # Register all of the events we want to observe
-        for event in (
-            # Charm events
-            self.on.config_changed,
-            self.on.install,
-            self.on.start,
-            self.on.upgrade_charm,
-            # Charm actions (primitives) <-- MAGMA AGW
-            self.on.add_net_action,
-            self.on.add_gw_action,
-            self.on.reset_id_action,
-            self.on.add_hosts_action,
-            self.on.restart_magma_action,
-            self.on.del_gw_action,
-            self.on.reset_id_action,
-            self.on.add_test_subscriber_action,
-            # OSM actions (primitives)
-            self.on.start_action,
-            self.on.stop_action,
-            self.on.restart_action,
-            self.on.reboot_action,
-            self.on.upgrade_action,
-            # SSH Proxy actions (primitives)
-            self.on.generate_ssh_key_action,
-            self.on.get_ssh_public_key_action,
-            self.on.run_action,
-            self.on.verify_ssh_credentials_action,
-        ):
-            self.framework.observe(event, self)
-
-        self.framework.observe(self.on.proxypeer_relation_changed, self)
+        self.framework.observe(self.on.config_changed, self.on_config_changed)
+        self.framework.observe(self.on.install, self.on_install)
+        self.framework.observe(self.on.start, self.on_start)
+        self.framework.observe(self.on.upgrade_charm, self.on_upgrade_charm)
+        # Charm actions (primitives)
+        self.framework.observe(self.on.add_net_action, self.on_add_net_action)
+        self.framework.observe(self.on.add_gw_action, self.on_add_gw_action)
+        self.framework.observe(self.on.reset_id_action, self.on_reset_id_action)
+        self.framework.observe(self.on.add_hosts_action, self.on_add_hosts_action)
+        self.framework.observe(self.on.restart_magma_action, self.on_restart_magma_action)
+        self.framework.observe(self.on.del_gw_action, self.on_del_gw_action)
+        self.framework.observe(self.on.reset_id_action, self.on_reset_id_action)
+        self.framework.observe(self.on.add_test_subscriber_action, self.on_add_test_subscriber_action)
+        # OSM actions (primitives)
+        self.framework.observe(self.on.start_action, self.on_start_action)
+        self.framework.observe(self.on.stop_action, self.on_stop_action)
+        self.framework.observe(self.on.restart_action, self.on_restart_action)
+        self.framework.observe(self.on.reboot_action, self.on_reboot_action)
+        self.framework.observe(self.on.upgrade_action, self.on_upgrade_action)
+        # SSH Proxy actions (primitives)
+        self.framework.observe(self.on.generate_ssh_key_action, self.on_generate_ssh_key_action)
+        self.framework.observe(self.on.get_ssh_public_key_action, self.on_get_ssh_public_key_action)
+        self.framework.observe(self.on.run_action, self.on_run_action)
+        self.framework.observe(self.on.verify_ssh_credentials_action, self.on_verify_ssh_credentials_action)
+
+        self.framework.observe(self.on.proxypeer_relation_changed, self.on_proxypeer_relation_changed)
+        
 
     def get_ssh_proxy(self):
         """Get the SSHProxy instance"""
@@ -137,7 +134,10 @@ class SimpleHAProxyCharm(CharmBase):
             unit.status = BlockedStatus("Invalid SSH credentials.")
 
     def on_install(self, event):
-        pass
+        unit = self.model.unit
+        unit.status = MaintenanceStatus("Installing all SW")
+        SSHProxy.install()
+        unit.status = ActiveStatus()
 
     def on_start(self, event):
         """Called when the charm is being installed"""
diff --git a/magma/hackfest_magma-agw-enb_vnfd/charms/magmagw/src/proxy_cluster.py b/magma/hackfest_magma-agw-enb_vnfd/charms/magmagw/src/proxy_cluster.py
index 93cd119d..bbdcb43d 100644
--- a/magma/hackfest_magma-agw-enb_vnfd/charms/magmagw/src/proxy_cluster.py
+++ b/magma/hackfest_magma-agw-enb_vnfd/charms/magmagw/src/proxy_cluster.py
@@ -24,7 +24,7 @@ class ProxyCluster(Object):
         self._relation_name = relation_name
         self._relation = self.framework.model.get_relation(self._relation_name)
 
-        self.framework.observe(charm.on.ssh_keys_initialized, self)
+        self.framework.observe(charm.on.ssh_keys_initialized, self.on_ssh_keys_initialized)
 
         self.state.set_default(ssh_public_key=None)
         self.state.set_default(ssh_private_key=None)
-- 
GitLab