def test_args_array_to_patch(self):
     my_args = {
         'attributes': [
             'str=foo', 'int=1', 'bool=true', 'list=[1, 2, 3]',
             'dict={"foo": "bar"}'
         ],
         'op':
         'add',
     }
     patch = utils.args_array_to_patch(my_args['op'], my_args['attributes'])
     self.assertEqual([{
         'op': 'add',
         'value': 'foo',
         'path': '/str'
     }, {
         'op': 'add',
         'value': 1,
         'path': '/int'
     }, {
         'op': 'add',
         'value': True,
         'path': '/bool'
     }, {
         'op': 'add',
         'value': [1, 2, 3],
         'path': '/list'
     }, {
         'op': 'add',
         'value': {
             "foo": "bar"
         },
         'path': '/dict'
     }], patch)
Exemple #2
0
def do_cluster_template_update(cs, args):
    """Updates one or more cluster template attributes."""
    patch = magnum_utils.args_array_to_patch(args.op, args.attributes[0])

    cluster_template = cs.cluster_templates.update(args.cluster_template,
                                                   patch)
    _show_cluster_template(cluster_template)
def do_cluster_update(cs, args):
    """Update information about the given cluster."""
    patch = magnum_utils.args_array_to_patch(args.op, args.attributes[0])
    cluster = cs.clusters.update(args.cluster, patch)
    if args.magnum_api_version and args.magnum_api_version == '1.1':
        _show_cluster(cluster)
    else:
        print("Request to update cluster %s has been accepted." % args.cluster)
Exemple #4
0
def do_bay_update(cs, args):
    """Update information about the given bay."""
    patch = magnum_utils.args_array_to_patch(args.op, args.attributes[0])
    bay = cs.bays.update(args.bay, patch)
    if args.magnum_api_version and args.magnum_api_version == '1.1':
        _show_bay(bay)
    else:
        print("Request to update bay %s has been accepted." % args.bay)
Exemple #5
0
def do_baymodel_update(cs, args):
    """Updates one or more baymodel attributes.

    (Deprecated in favor of cluster-template-update.)
    """
    patch = magnum_utils.args_array_to_patch(args.op, args.attributes[0])

    baymodel = cs.baymodels.update(args.baymodel, patch)
    _show_baymodel(baymodel)
    def take_action(self, parsed_args):
        self.log.debug("take_action(%s)", parsed_args)

        mag_client = self.app.client_manager.container_infra
        patch = magnum_utils.args_array_to_patch(parsed_args.op,
                                                 parsed_args.attributes[0])
        name = getattr(parsed_args, 'cluster-template', None)
        ct = mag_client.cluster_templates.update(name, patch)
        return _show_cluster_template(ct)
 def test_args_array_to_patch_remove(self):
     my_args = {
         'attributes': ['/foo', 'extra/bar'],
         'op': 'remove',
     }
     patch = utils.args_array_to_patch(my_args['op'],
                                       my_args['attributes'])
     self.assertEqual([{'op': 'remove', 'path': '/foo'},
                       {'op': 'remove', 'path': '/extra/bar'}], patch)
    def take_action(self, parsed_args):
        self.log.debug("take_action(%s)", parsed_args)

        mag_client = self.app.client_manager.container_infra
        patch = magnum_utils.args_array_to_patch(parsed_args.op,
                                                 parsed_args.attributes[0])
        name = getattr(parsed_args, 'cluster-template', None)
        ct = mag_client.cluster_templates.update(name, patch)
        return _show_cluster_template(ct)
Exemple #9
0
 def test_args_array_to_patch_remove(self):
     my_args = {
         'attributes': ['/foo', 'extra/bar'],
         'op': 'remove',
     }
     patch = utils.args_array_to_patch(my_args['op'],
                                       my_args['attributes'])
     self.assertEqual([{'op': 'remove', 'path': '/foo'},
                       {'op': 'remove', 'path': '/extra/bar'}], patch)
def do_pod_update(cs, args):
    """Update information about the given pod."""
    patch = magnum_utils.args_array_to_patch(args.op, args.attributes[0])
    p = patch[0]
    if p['path'] == '/manifest' and os.path.isfile(p['value']):
        with open(p['value'], 'r') as f:
            p['value'] = f.read()

    pod = cs.pods.update(args.pod, args.bay, patch)
    _show_pod(pod)
Exemple #11
0
def do_rc_update(cs, args):
    """Update information about the given replication controller."""
    patch = magnum_utils.args_array_to_patch(args.op, args.attributes[0])
    p = patch[0]
    if p['path'] == '/manifest' and os.path.isfile(p['value']):
        with open(p['value'], 'r') as f:
            p['value'] = f.read()

    rc = cs.rcs.update(args.rc, patch)
    _show_rc(rc)
Exemple #12
0
def do_service_update(cs, args):
    """Update information about the given service."""
    patch = magnum_utils.args_array_to_patch(args.op, args.attributes[0])
    p = patch[0]
    if p['path'] == '/manifest' and os.path.isfile(p['value']):
        with open(p['value'], 'r') as f:
            p['value'] = f.read()

    service = cs.services.update(args.service, patch)
    _show_service(service)
def do_pod_update(cs, args):
    """Update information about the given pod."""
    patch = magnum_utils.args_array_to_patch(args.op, args.attributes[0])
    p = patch[0]
    if p['path'] == '/manifest' and os.path.isfile(p['value']):
        with open(p['value'], 'r') as f:
            p['value'] = f.read()

    pod = cs.pods.update(args.pod, args.bay, patch)
    _show_pod(pod)
def do_coe_service_update(cs, args):
    """Update information about the given coe service."""
    patch = magnum_utils.args_array_to_patch(args.op, args.attributes[0])
    p = patch[0]
    if p["path"] == "/manifest" and os.path.isfile(p["value"]):
        with open(p["value"], "r") as f:
            p["value"] = f.read()

    service = cs.services.update(args.services, args.bay, patch)
    _show_coe_service(service)
def do_baymodel_update(cs, args):
    """Updates one or more baymodel attributes."""
    patch = magnum_utils.args_array_to_patch(args.op, args.attributes[0])
    p = patch[0]
    if p['path'] == '/manifest' and os.path.isfile(p['value']):
        with open(p['value'], 'r') as f:
            p['value'] = f.read()

    baymodel = cs.baymodels.update(args.baymodel, patch)
    _show_baymodel(baymodel)
def do_rc_update(cs, args):
    """Update information about the given replication controller."""
    patch = magnum_utils.args_array_to_patch(args.op, args.attributes[0])
    p = patch[0]
    if p['path'] == '/manifest' and os.path.isfile(p['value']):
        with open(p['value'], 'r') as f:
            p['value'] = f.read()

    rc = cs.rcs.update(args.rc, args.bay, patch)
    _show_rc(rc)
def do_baymodel_update(cs, args):
    """Updates one or more baymodel attributes."""
    patch = magnum_utils.args_array_to_patch(args.op, args.attributes[0])
    p = patch[0]
    if p['path'] == '/manifest' and os.path.isfile(p['value']):
        with open(p['value'], 'r') as f:
            p['value'] = f.read()

    baymodel = cs.baymodels.update(args.baymodel, patch)
    _show_baymodel(baymodel)
Exemple #18
0
def do_coe_service_update(cs, args):
    """Update information about the given coe service."""
    patch = magnum_utils.args_array_to_patch(args.op, args.attributes[0])
    p = patch[0]
    if p['path'] == '/manifest' and os.path.isfile(p['value']):
        with open(p['value'], 'r') as f:
            p['value'] = f.read()

    service = cs.services.update(args.service, args.bay, patch)
    _show_coe_service(service)
def do_cluster_template_update(cs, args):
    """Updates one or more cluster template attributes."""
    patch = magnum_utils.args_array_to_patch(args.op, args.attributes[0])
    p = patch[0]
    if p['path'] == '/manifest' and os.path.isfile(p['value']):
        with open(p['value'], 'r') as f:
            p['value'] = f.read()

    cluster_template = cs.cluster_templates.update(args.cluster_template,
                                                   patch)
    _show_cluster_template(cluster_template)
    def take_action(self, parsed_args):
        self.log.debug("take_action(%s)", parsed_args)

        mag_client = self.app.client_manager.container_infra

        patch = magnum_utils.args_array_to_patch(parsed_args.op,
                                                 parsed_args.attributes[0])

        mag_client.clusters.update(parsed_args.cluster, patch)
        print("Request to update cluster %s has been accepted." %
              parsed_args.cluster)
def do_cluster_update(cs, args):
    """Update information about the given cluster."""
    if args.rollback and args.magnum_api_version and \
            args.magnum_api_version in ('1.0', '1.1', '1.2'):
        raise exceptions.CommandError("Rollback is not supported in API v%s. "
                                      "Please use API v1.3+." %
                                      args.magnum_api_version)
    patch = magnum_utils.args_array_to_patch(args.op, args.attributes[0])
    cluster = cs.clusters.update(args.cluster, patch, args.rollback)
    if args.magnum_api_version and args.magnum_api_version == '1.1':
        _show_cluster(cluster)
    else:
        print("Request to update cluster %s has been accepted." % args.cluster)
 def test_args_array_to_patch(self):
     my_args = {
         'attributes': ['str=foo', 'int=1', 'bool=true',
                        'list=[1, 2, 3]', 'dict={"foo": "bar"}'],
         'op': 'add',
     }
     patch = utils.args_array_to_patch(my_args['op'],
                                       my_args['attributes'])
     self.assertEqual([{'op': 'add', 'value': 'foo', 'path': '/str'},
                       {'op': 'add', 'value': 1, 'path': '/int'},
                       {'op': 'add', 'value': True, 'path': '/bool'},
                       {'op': 'add', 'value': [1, 2, 3], 'path': '/list'},
                       {'op': 'add', 'value': {"foo": "bar"},
                        'path': '/dict'}], patch)
def do_bay_update(cs, args):
    """Update information about the given bay.

    (Deprecated in favor of cluster-update.)
    """
    if args.rollback and args.magnum_api_version and \
            args.magnum_api_version in ('1.0', '1.1', '1.2'):
        raise exceptions.CommandError(
            "Rollback is not supported in API v%s. "
            "Please use API v1.3+." % args.magnum_api_version)
    patch = magnum_utils.args_array_to_patch(args.op, args.attributes[0])
    bay = cs.bays.update(args.bay, patch, args.rollback)
    if args.magnum_api_version and args.magnum_api_version == '1.1':
        _show_bay(bay)
    else:
        print("Request to update bay %s has been accepted." % args.bay)
def do_bay_update(cs, args):
    """Update information about the given bay.

    (Deprecated in favor of cluster-update.)
    """
    if args.rollback and args.magnum_api_version and \
            args.magnum_api_version in ('1.0', '1.1', '1.2'):
        raise exceptions.CommandError("Rollback is not supported in API v%s. "
                                      "Please use API v1.3+." %
                                      args.magnum_api_version)
    patch = magnum_utils.args_array_to_patch(args.op, args.attributes[0])
    bay = cs.bays.update(args.bay, patch, args.rollback)
    if args.magnum_api_version and args.magnum_api_version == '1.1':
        _show_bay(bay)
    else:
        print("Request to update bay %s has been accepted." % args.bay)
Exemple #25
0
def do_bay_update(cs, args):
    """Update information about the given bay."""
    patch = magnum_utils.args_array_to_patch(args.op, args.attributes[0])
    bay = cs.bays.update(args.bay, patch)
    _show_bay(bay)
def do_baymodel_update(cs, args):
    """Updates one or more baymodel attributes."""
    patch = magnum_utils.args_array_to_patch(args.op, args.attributes[0])

    baymodel = cs.baymodels.update(args.baymodel, patch)
    _show_baymodel(baymodel)