if ($context->object->isPreRule()) { $context->object->owner->API_moveRuleToPostRulebase($context->object); } else { if ($context->object->isPostRule()) { $context->object->owner->API_moveRuleToPreRulebase($context->object); } else { derr('unsupported'); } } } }); $supportedActions['copy'] = array('name' => 'copy', 'MainFunction' => function (CallContext $context) { $rule = $context->object; $args =& $context->arguments; $location = $args['location']; $pan = PH::findRootObjectOrDie($rule); if ($args['preORpost'] == "post") { $preORpost = true; } else { $preORpost = false; } /** @var RuleStore $ruleStore */ $ruleStore = null; $variableName = $rule->storeVariableName(); if (strtolower($location) == 'shared') { if ($pan->isPanOS()) { derr("Rules cannot be copied to SHARED location on a firewall, only in Panorama"); } $ruleStore = $pan->{$variableName}; } else { $sub = $pan->findSubSystemByName($location);
} } }, 'args' => array('objectName' => array('type' => 'string', 'default' => '*nodefault*'))); $supportedActions['move'] = array('name' => 'move', 'MainFunction' => function (ServiceCallContext $context) { $object = $context->object; $localLocation = 'shared'; if (!$object->owner->owner->isPanorama() && !$object->owner->owner->isPanOS()) { $localLocation = $object->owner->owner->name(); } $targetLocation = $context->arguments['location']; $targetStore = null; if ($localLocation == $targetLocation) { print $context->padding . " * SKIPPED because original and target destinations are the same: {$targetLocation}\n"; return; } $rootObject = PH::findRootObjectOrDie($object->owner->owner); if ($targetLocation == 'shared') { $targetStore = $rootObject->serviceStore; } else { $findSubSystem = $rootObject->findSubSystemByName($targetLocation); if ($findSubSystem === null) { derr("cannot find VSYS/DG named '{$targetLocation}'"); } $targetStore = $findSubSystem->serviceStore; } if ($localLocation == 'shared') { print $context->padding . " * SKIPPED : moving from SHARED to sub-level is not yet supported\n"; return; } if ($localLocation != 'shared' && $targetLocation != 'shared') { print $context->padding . " * SKIPPED : moving between 2 VSYS/DG is not supported yet\n";