Browse Source

Merge "Graph-based switch-controlplane. Python part."

changes/20/386620/1
Jenkins 2 years ago
parent
commit
71d959595f
1 changed files with 65 additions and 1 deletions
  1. 65
    1
      octane/commands/upgrade_controlplane.py

+ 65
- 1
octane/commands/upgrade_controlplane.py View File

@@ -9,13 +9,20 @@
9 9
 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10 10
 # License for the specific language governing permissions and limitations
11 11
 # under the License.
12
+
13
+import logging
14
+
12 15
 from cliff import command as cmd
13 16
 from fuelclient.objects import environment as environment_obj
17
+from fuelclient.objects import node as node_obj
14 18
 
19
+from octane.util import deployment as deploy
15 20
 from octane.util import env as env_util
16 21
 from octane.util import maintenance
17 22
 from octane.util import network
18 23
 
24
+LOG = logging.getLogger(__name__)
25
+
19 26
 
20 27
 def upgrade_control_plane(orig_id, seed_id):
21 28
     orig_env = environment_obj.Environment(orig_id)
@@ -50,6 +57,54 @@ def upgrade_control_plane(orig_id, seed_id):
50 57
     seed_env.delete_facts("deployment")
51 58
 
52 59
 
60
+def upgrade_control_plane_with_graph(orig_id, seed_id):
61
+    """Switch controlplane using deployment graphs"""
62
+
63
+    orig_env = environment_obj.Environment(orig_id)
64
+    seed_env = environment_obj.Environment(seed_id)
65
+
66
+    deploy.upload_graphs(orig_id, seed_id)
67
+
68
+    try:
69
+        # Start openstack services on the seed controller
70
+        deploy.execute_graph_and_wait('switch-control-1', seed_id)
71
+
72
+        # Kill pacemaker on the original controllers
73
+        deploy.execute_graph_and_wait('switch-control-1', orig_id)
74
+
75
+        # Cut off the original controller from network
76
+        roles = ['primary-controller', 'controller']
77
+        for node, info in env_util.iter_deployment_info(orig_env, roles):
78
+            network.delete_patch_ports(node, info)
79
+
80
+        # Restore transformations for the seed environment
81
+        seed_env.delete_facts("deployment")
82
+
83
+        # Connect the seed controller to a physical network
84
+        deploy.execute_graph_and_wait('switch-control-2', seed_id)
85
+
86
+        # Decommission the orig controllers by stopping OpenStack services
87
+        deploy.execute_graph_and_wait('switch-control-2', orig_id)
88
+    except Exception:
89
+        LOG.info('Trying to rollback switch-control phase')
90
+
91
+        # Cut off the seed controller from networks
92
+        roles = ['primary-controller', 'controller']
93
+
94
+        for info in seed_env.get_default_facts('deployment'):
95
+            if set(info['roles']) & set(roles):
96
+                network.delete_patch_ports(node_obj.Node(info['uid']), info)
97
+
98
+        # Restore network connectivity for the original controller
99
+        # Recreate cluster
100
+        deploy.execute_graph_and_wait('switch-control-rollback', orig_id)
101
+
102
+        # Stop openstack services on the seed controller
103
+        deploy.execute_graph_and_wait('switch-control-rollback', seed_id)
104
+
105
+        raise
106
+
107
+
53 108
 class UpgradeControlPlaneCommand(cmd.Command):
54 109
     """Switch control plane to the seed environment"""
55 110
 
@@ -61,7 +116,16 @@ class UpgradeControlPlaneCommand(cmd.Command):
61 116
         parser.add_argument(
62 117
             'seed_id', type=int, metavar='SEED_ID',
63 118
             help="ID of seed environment")
119
+        parser.add_argument(
120
+            '--with-graph', action='store_true',
121
+            help='EXPERIMENTAL: Use Fuel deployment graphs'
122
+                 ' instead of python-based commands.')
64 123
         return parser
65 124
 
66 125
     def take_action(self, parsed_args):
67
-        upgrade_control_plane(parsed_args.orig_id, parsed_args.seed_id)
126
+        if parsed_args.with_graph:
127
+            upgrade_control_plane_with_graph(
128
+                parsed_args.orig_id,
129
+                parsed_args.seed_id)
130
+        else:
131
+            upgrade_control_plane(parsed_args.orig_id, parsed_args.seed_id)

Loading…
Cancel
Save