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

This commit is contained in:
Jenkins 2016-10-12 12:57:49 +00:00 committed by Gerrit Code Review
commit 71d959595f
1 changed files with 65 additions and 1 deletions

View File

@ -9,13 +9,20 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import logging
from cliff import command as cmd from cliff import command as cmd
from fuelclient.objects import environment as environment_obj from fuelclient.objects import environment as environment_obj
from fuelclient.objects import node as node_obj
from octane.util import deployment as deploy
from octane.util import env as env_util from octane.util import env as env_util
from octane.util import maintenance from octane.util import maintenance
from octane.util import network from octane.util import network
LOG = logging.getLogger(__name__)
def upgrade_control_plane(orig_id, seed_id): def upgrade_control_plane(orig_id, seed_id):
orig_env = environment_obj.Environment(orig_id) orig_env = environment_obj.Environment(orig_id)
@ -50,6 +57,54 @@ def upgrade_control_plane(orig_id, seed_id):
seed_env.delete_facts("deployment") seed_env.delete_facts("deployment")
def upgrade_control_plane_with_graph(orig_id, seed_id):
"""Switch controlplane using deployment graphs"""
orig_env = environment_obj.Environment(orig_id)
seed_env = environment_obj.Environment(seed_id)
deploy.upload_graphs(orig_id, seed_id)
try:
# Start openstack services on the seed controller
deploy.execute_graph_and_wait('switch-control-1', seed_id)
# Kill pacemaker on the original controllers
deploy.execute_graph_and_wait('switch-control-1', orig_id)
# Cut off the original controller from network
roles = ['primary-controller', 'controller']
for node, info in env_util.iter_deployment_info(orig_env, roles):
network.delete_patch_ports(node, info)
# Restore transformations for the seed environment
seed_env.delete_facts("deployment")
# Connect the seed controller to a physical network
deploy.execute_graph_and_wait('switch-control-2', seed_id)
# Decommission the orig controllers by stopping OpenStack services
deploy.execute_graph_and_wait('switch-control-2', orig_id)
except Exception:
LOG.info('Trying to rollback switch-control phase')
# Cut off the seed controller from networks
roles = ['primary-controller', 'controller']
for info in seed_env.get_default_facts('deployment'):
if set(info['roles']) & set(roles):
network.delete_patch_ports(node_obj.Node(info['uid']), info)
# Restore network connectivity for the original controller
# Recreate cluster
deploy.execute_graph_and_wait('switch-control-rollback', orig_id)
# Stop openstack services on the seed controller
deploy.execute_graph_and_wait('switch-control-rollback', seed_id)
raise
class UpgradeControlPlaneCommand(cmd.Command): class UpgradeControlPlaneCommand(cmd.Command):
"""Switch control plane to the seed environment""" """Switch control plane to the seed environment"""
@ -61,7 +116,16 @@ class UpgradeControlPlaneCommand(cmd.Command):
parser.add_argument( parser.add_argument(
'seed_id', type=int, metavar='SEED_ID', 'seed_id', type=int, metavar='SEED_ID',
help="ID of seed environment") help="ID of seed environment")
parser.add_argument(
'--with-graph', action='store_true',
help='EXPERIMENTAL: Use Fuel deployment graphs'
' instead of python-based commands.')
return parser return parser
def take_action(self, parsed_args): def take_action(self, parsed_args):
upgrade_control_plane(parsed_args.orig_id, parsed_args.seed_id) if parsed_args.with_graph:
upgrade_control_plane_with_graph(
parsed_args.orig_id,
parsed_args.seed_id)
else:
upgrade_control_plane(parsed_args.orig_id, parsed_args.seed_id)