def post(method, hmc, uri, uri_parms, body, logon_required,
             wait_for_completion):
        """Operation: Create Storage Group."""
        assert wait_for_completion is True  # async not supported yet
        check_required_fields(method, uri, body, ['name', 'cpc-uri', 'type'])
        cpc_uri = body['cpc-uri']
        try:
            cpc = hmc.lookup_by_uri(cpc_uri)
        except KeyError:
            raise InvalidResourceError(method, uri)
        if not cpc.dpm_enabled:
            raise CpcNotInDpmError(method, uri, cpc)
        check_valid_cpc_status(method, uri, cpc)

        # Reflect the result of creating the storage group

        body2 = body.copy()
        sv_requests = body2.pop('storage-volumes', None)
        new_storage_group = hmc.consoles.console.storage_groups.add(body2)

        sv_uris = []
        if sv_requests:
            for sv_req in sv_requests:
                check_required_fields(method, uri, sv_req, ['operation'])
                operation = sv_req['operation']
                if operation == 'create':
                    sv_props = sv_req.copy()
                    del sv_props['operation']
                    if 'element-uri' in sv_props:
                        raise BadRequestError(
                            method, uri, 7,
                            "The 'element-uri' field in storage-volumes is "
                            "invalid for the create operation")
                    sv_uri = new_storage_group.storage_volumes.add(sv_props)
                    sv_uris.append(sv_uri)
                else:
                    raise BadRequestError(
                        method, uri, 5,
                        "Invalid value for storage-volumes 'operation' "
                        "field: %s" % operation)

        return {
            'object-uri': new_storage_group.uri,
            'element-uris': sv_uris,
        }
def post ( method , hmc , uri , uri_parms , body , logon_required , wait_for_completion ) : assert wait_for_completion is True check_required_fields ( method , uri , body , [ 'name' , 'cpc-uri' , 'type' ] ) cpc_uri = body [ 'cpc-uri' ] try : cpc = hmc . lookup_by_uri ( cpc_uri ) except KeyError : raise InvalidResourceError ( method , uri ) if not cpc . dpm_enabled : raise CpcNotInDpmError ( method , uri , cpc ) check_valid_cpc_status ( method , uri , cpc ) body2 = body . copy ( ) sv_requests = body2 . pop ( 'storage-volumes' , None ) new_storage_group = hmc . consoles . console . storage_groups . add ( body2 ) sv_uris = [ ] if sv_requests : for sv_req in sv_requests : check_required_fields ( method , uri , sv_req , [ 'operation' ] ) operation = sv_req [ 'operation' ] if operation == 'create' : sv_props = sv_req . copy ( ) del sv_props [ 'operation' ] if 'element-uri' in sv_props : raise BadRequestError ( method , uri , 7 , "The 'element-uri' field in storage-volumes is " "invalid for the create operation" ) sv_uri = new_storage_group . storage_volumes . add ( sv_props ) sv_uris . append ( sv_uri ) else : raise BadRequestError ( method , uri , 5 , "Invalid value for storage-volumes 'operation' " "field: %s" % operation ) return { 'object-uri' : new_storage_group . uri , 'element-uris' : sv_uris , }
Operation: Create Storage Group.