I'm trying to perform remote uploading and deploying via WLST.
I succeed to deploy applications already present in the path of the WebLogic server. But now, I would like to deploy one remotely available.
Is there any possibility to upload WAR/EAR on the WebLogic server via WLST before deploying it?
I'm running weblogic 12C.
I tried with:
java -cp wlserver/server/lib/weblogic.jar weblogic.Deployer -adminurl t3://WeblogicServer:7001 -user weblogic -password weblogic -deploy /tmp/HelloWorld.war -remote -upload
give me as return:
weblogic.Deployer invoked with options: -adminurl t3://WeblogicServer:7001 -user weblogic -deploy /tmp/HelloWorld.war -remote -upload
<6 juil. 2012 17 h 58 CEST> <Info> <J2EE Deployment SPI> <BEA-260121> <Initiating deploy operation for application, HelloWorld [archive: /tmp/HelloWorld.war], to configured targets.>
[J2EE Deployment SPI:260080]Unable to define the application install directory at "/tmp/helloworld.war". Directory could not be created or is a file.
And when i check on the server, nothing is deployed.
I found the solution:
We must not use the /tmp directory as source, because the weblogic.Deployer use this directory.
So the command is:
java -cp wlserver/server/lib/weblogic.jar weblogic.Deployer -adminurl
t3://WeblogicServer:7001 -user weblogic -password weblogic -deploy
/home/admin/HelloWorld.war -remote -upload
Yes, there is. Take a look at WLST deploy command reference (This link is for version 10gR3).
You can specify the remote and the upload options with true, since their default values are false.
PS 1: The remote option is not available on WebLogic 9.0 and older versions (but you can always get a newer weblogic.jar and try.
PS 2: You will need to have remote access to the administrative interfaces (usually ports 7001 and/or 7002). That means opening firewalls, etc.
PS 3: Please provide the version of your WebLogic server, as this might help us help you.
Written myself, can do undeploy + deploy. The deploy line is:
deploy( project, archive
, apptargets, 'stage', plan
, remote='true', upload='true', archiveVersion=archiveversion, planVersion=planversion )
disadvantage of using version number in deploy is that redeploy with plan is not working
Complete script: (line next code out yourself, I had to add some spaces to place it here)
from java.io import FileReader
from datetime import datetime
def deployApp( project, archive, archiveversion, plan, planversion, apptargets ):
#### UNDEPLOY app
try:
domainConfig()
cd('/')
found = false
for app in cmo.getAppDeployments():
name=app.getName()
try:
cd('/AppDeployments/' + name )
applicationName=get('ApplicationName')
if applicationName==project:
print '\n__ FOUND aplication: ', name
found = true
version=get('VersionIdentifier')
sourcePath=get('SourcePath')
planPath=get('PlanPath')
targets=''
for target in cmo.getTargets():
targetName=target.getName()
if targets=='':
targets=targetName
else:
targets=targets + ', ' + targetName
print ' applicationName:\t', applicationName
print ' version:\t\t', version
print ' sourcePath:\t', sourcePath
print ' planPath:\t', planPath
print ' targets:\t\t', targets
if version==archiveversion + '#' + planversion:
print '\nCorrect Application version found. No installation needed\n'
return
else:
print '\n__ REMOVING application: ',applicationName, ' version:', version
undeploy(project)
except:
print "IGNORE ERROR: (deployed applicaties gegevens ophalen) ", sys.exc_info()[0]
if found==false:
print "Application " + project + "not found."
except:
print "Failure in application remove part: ", sys.exc_info()[0]
raise
# get deploy targets
try:
if apptargets==None:
serverConfig()
cd('/')
targetList = []
for cluster in cmo.getClusters():
targetList.append( cluster.getName() )
apptargets = ",".join(targetList)
print 'USING default app target:', apptargets, " (apptargets not found in environmentfile)"
except:
print "Failure while creating default target", sys.exc_info()[0]
raise
#### DEPLOY app
try:
print '\n__ DEPLOYING application: ', project, archiveversion + '#' + planversion + ' target:' + apptargets
deploy( project, archive
, apptargets, 'stage', plan
, remote='true', upload='true', archiveVersion=archiveversion, planVersion=planversion )
except:
print "Failure in deployment part: ", sys.exc_info()[0]
raise
# connect to domein
# 1) in plain passsword
# 1) using encrypted domain credential in separate files
# 2) using encrypted domain credential in home directory user
def Connect( domainproperties ):
plainUser = domainproperties.getProperty("user")
plainPassword = domainproperties.getProperty("password")
if not (plainUser is None) and not (plainPassword is None):
print "Connecting with user & password"
connect( plainUser, plainPassword, domainproperties.getProperty("url"))
return
encryptedUserConfigFile = domainproperties.getProperty("encryptedCredentialsFile")
encryptionKeyFile = domainproperties.getProperty("encryptionKeyFile")
if not (encryptedUserConfigFile is None) and not (encryptionKeyFile is None):
print "Connecting with encryptedCredentialsFile: ", encryptedUserConfigFile, " and encryptionKeyFile: ", encryptionKeyFile
connect(userConfigFile=encryptedUserConfigFile, userKeyFile=encryptionKeyFile, url=domainproperties.getProperty("url"))
return
print "Connecting with encryptedCredentialsFile in home directory"
connect( url=domainproperties.getProperty("url") )
return
try:
print "____ running app_deploy.py at " + str(datetime.now())
project = sys.argv[1]
archive = sys.argv[3]
archiveversion = sys.argv[4]
plan = sys.argv[5]
planversion = sys.argv[6]
environmentfile = sys.argv[2]
propertyfilereader=FileReader(environmentfile)
domainproperties=Properties()
domainproperties.load(propertyfilereader)
print " environment: ", environmentfile
print " Ear: ", archive, " version:", archiveversion
print " plan: ", plan, " version:", planversion
## Connect
#connect( domainproperties.getProperty("user"), domainproperties.getProperty("password"), domainproperties.getProperty("url") )
Connect( domainproperties )
try:
## Deploy
deployApp( project, archive, archiveversion, plan, planversion, domainproperties.getProperty("apptargets") )
finally:
# niet dat het uitmaakt, maar wel zo netjes
disconnect()
except:
print "ABORT APP DEPLOY: ", # sys.exc_info()[0], "_", sys.exc_info()[1]
raise
Have fun with it.
Related
Problem is add-odbcdsn is returning "driver not installed error" , though I can create using the GUI. Below is a piece from my code that returns the error. I also tried to create an ODBC connection using the GUI and specifying the driver. I then do get-odbcdsn for that DSN. Use the output for that and run add-odbcdsn. This action also results in a driver not installed error.
$dsn_object = #{
Name = "123"
DriverName = "C:\app\oracle64\product\12.2.0\client64\BIN\SQORA32.DLL"
DsnType = "System"
Platform = "64-bit"
SetPropertyValue = ""
}
$dsn_values = -split #"
DisableRULEHint=T
Attributes=W
SQLTranslateErrors=F
AggregateSQLType=FLOAT
MaxTokenSize=8192
FetchBufferSize=64000
NumericSetting=NLS
ForceWCHAR=F
FailoverDelay=10
FailoverRetryCount=10
MetadataIdDefault=F
BindAsFLOAT=F
BindAsDATE=F
CloseCursor=F
EXECSchemaOpt=
EXECSyntax=F
Application Attributes=T
QueryTimeout=T
CacheBufferSize=20
StatementCache=F
ResultSets=T
MaxLargeData=0
UseOCIDescribeAny=F
Failover=T
Lobs=T
DisableMTS=T
DisableDPM=F
BatchAutocommitMode=IfAllSuccessful
Description=64 Bit TEST Oracle
ServerName=
Password=
UserID=homersimpson
DSN=64 Bit TEST Oracle
"#
$dsn_object.SetPropertyValue = $dsn_values
Add-OdbcDsn #dsn_object
I have also tried a simple example:
add-OdbcDsn -Name "TEST" -DriverName "C:\app\oracle64\product\12.2.0 \client64\BIN\SQORA32.DLL" -DsnType System
Expect the DSN to be created...
Add-OdbcDsn : The driver {C:\app\oracle64\product\12.2.0\client64\BIN\SQORA32.DLL} is not installed.
Get-OdbcDriver shows the driver is there:
Name
Value
---- -----
APILevel 1
FileUsage 0
Driver C:\app\oracle64\product\12.2.0\client64\BIN\SQORA32.DLL
ConnectFunctions YYY
CPTimeout 60
DriverODBCVer 03.51
SQLLevel 1
Setup C:\app\oracle64\product\12.2.0\client64\BIN\SQORAS32.DLL
After all that, I resolved it. I realized I was using the path to the driver as the name and not the actual name as seen in the ODBC GUI.
I'm attempting to deploy an oracle service bus project to my locally hosted weblogic 12c server in an internet-restricted VM but the tools are indicating my JAR file isn't a valid application file. What is the proper way of building and deploying OSB projects to the weblogic host?
I've attempted to build use both the configjar utility to create jar files as well as exported directly from JDeveloper to a jar file. I've also attempted to use the ant task jwsc to build the osb project, but haven't been successful.
I've attempted to deploy via the deploy() WLST command, the wldeploy ANT task, and the the wldeploy utility tool but they run into an error and quit. I am able to take the .jar file and manually upload it through the service bus console without issue, though.
connect(username, password, adminUrl)
deploy(deploymentName,deploymentFile,targets=deploymentTarget)
startApplication(deploymentName)
I was expecting that the above sample code would deploy the application successfully, but instead the following error code is returned every time:
Deployment Message : weblogic.management.DeploymentException:
[J2EE:160177]The application at
"C:\jdeveloper\mywork\CommonServicesOSB\CrmConnections\test3.jar" was
not recognized as a valid application type. If this is an EAR file,
please ensure the META-INF/application.xml exists. EJB-JARs should
have a META-INF/ejb-jar.xml or corresponding annotations exist. If
this is an exploded WAR, the name of directory must be end with
".war". RARs require a META-INF/ra.xml. A JMS deployment should be an
XML file whose name ends with "-jms.xml". A JDBC deployment should be
an XML file whose name ends with "-jdbc.xml". For other application
types, consult the WebLogic Server documentation.
I'm guessing that I'm missing a crucial file or step, but the documentation I can find hasn't made this any clearer. Does anyone know how this is supposed to work?
In Weblogic 11c i used the following script.
Command to run script:
./oracle_common/common/bin/wlst.sh script.py import.properties path_jar.jar
from java.util import HashMap
from java.util import HashSet
from java.util import ArrayList
from java.io import FileInputStream
from com.bea.wli.sb.util import Refs
from com.bea.wli.config.customization import Customization
from com.bea.wli.sb.management.importexport import ALSBImportOperation
import sys
#=======================================================================================
# Entry function to deploy project configuration and resources
# into a ALSB domain
#=======================================================================================
def importToALSBDomain(importConfigFile, importJarPath):
try:
SessionMBean = None
print 'Loading Deployment config from :', importConfigFile
exportConfigProp = loadProps(importConfigFile)
adminUrl = exportConfigProp.get("adminUrl")
importUser = exportConfigProp.get("importUser")
importPassword = exportConfigProp.get("importPassword")
#importJar = exportConfigProp.get("importJar")
customFile = exportConfigProp.get("customizationFile")
passphrase = exportConfigProp.get("passphrase")
project = exportConfigProp.get("project")
connectToServer(importUser, importPassword, adminUrl)
print 'Attempting to import :', importJarPath, "on ALSB Admin Server listening on :", adminUrl
theBytes = readBinaryFile(importJarPath)
print 'Read file', importJarPath
sessionName = createSessionName()
print 'Created session', sessionName
SessionMBean = getSessionManagementMBean(sessionName)
print 'SessionMBean started session'
ALSBConfigurationMBean = findService(String("ALSBConfiguration.").concat(sessionName), "com.bea.wli.sb.management.configuration.ALSBConfigurationMBean")
print "ALSBConfiguration MBean found", ALSBConfigurationMBean
ALSBConfigurationMBean.uploadJarFile(theBytes)
print 'Jar Uploaded'
if project == None:
print 'No project specified, additive deployment performed'
alsbJarInfo = ALSBConfigurationMBean.getImportJarInfo()
alsbImportPlan = alsbJarInfo.getDefaultImportPlan()
alsbImportPlan.setPassphrase(passphrase)
alsbImportPlan.setPreserveExistingEnvValues(true)
importResult = ALSBConfigurationMBean.importUploaded(alsbImportPlan)
SessionMBean.activateSession(sessionName, "Complete test import with customization using wlst")
else:
print 'ALSB project', project, 'will get overlaid'
alsbJarInfo = ALSBConfigurationMBean.getImportJarInfo()
alsbImportPlan = alsbJarInfo.getDefaultImportPlan()
alsbImportPlan.setPassphrase(passphrase)
operationMap=HashMap()
operationMap = alsbImportPlan.getOperations()
print
print 'Default importPlan'
printOpMap(operationMap)
set = operationMap.entrySet()
alsbImportPlan.setPreserveExistingEnvValues(true)
#boolean
abort = false
#list of created ref
createdRef = ArrayList()
for entry in set:
ref = entry.getKey()
op = entry.getValue()
#set different logic based on the resource type
type = ref.getTypeId
if type == Refs.SERVICE_ACCOUNT_TYPE or type == Refs.SERVICE_PROVIDER_TYPE:
if op.getOperation() == ALSBImportOperation.Operation.Create:
print 'Unable to import a service account or a service provider on a target system', ref
abort = true
elif op.getOperation() == ALSBImportOperation.Operation.Create:
#keep the list of created resources
createdRef.add(ref)
if abort == true :
print 'This jar must be imported manually to resolve the service account and service provider dependencies'
SessionMBean.discardSession(sessionName)
raise
print
print 'Modified importPlan'
printOpMap(operationMap)
importResult = ALSBConfigurationMBean.importUploaded(alsbImportPlan)
printDiagMap(importResult.getImportDiagnostics())
if importResult.getFailed().isEmpty() == false:
print 'One or more resources could not be imported properly'
raise
#customize if a customization file is specified
#affects only the created resources
if customFile != None :
print 'Loading customization File', customFile
print 'Customization applied to the created resources only', createdRef
iStream = FileInputStream(customFile)
customizationList = Customization.fromXML(iStream)
filteredCustomizationList = ArrayList()
setRef = HashSet(createdRef)
# apply a filter to all the customizations to narrow the target to the created resources
for customization in customizationList:
print customization
newcustomization = customization.clone(setRef)
filteredCustomizationList.add(newcustomization)
ALSBConfigurationMBean.customize(filteredCustomizationList)
SessionMBean.activateSession(sessionName, "Complete test import with customization using wlst")
print "Deployment of : " + importJarPath + " successful"
except:
print "Unexpected error:", sys.exc_info()[0]
if SessionMBean != None:
SessionMBean.discardSession(sessionName)
raise
#=======================================================================================
# Utility function to print the list of operations
#=======================================================================================
def printOpMap(map):
set = map.entrySet()
for entry in set:
op = entry.getValue()
print op.getOperation(),
ref = entry.getKey()
print ref
print
#=======================================================================================
# Utility function to print the diagnostics
#=======================================================================================
def printDiagMap(map):
set = map.entrySet()
for entry in set:
diag = entry.getValue().toString()
print diag
print
#=======================================================================================
# Utility function to load properties from a config file
#=======================================================================================
def loadProps(configPropFile):
propInputStream = FileInputStream(configPropFile)
configProps = Properties()
configProps.load(propInputStream)
return configProps
#=======================================================================================
# Connect to the Admin Server
#=======================================================================================
def connectToServer(username, password, url):
connect(username, password, url)
domainRuntime()
#=======================================================================================
# Utility function to read a binary file
#=======================================================================================
def readBinaryFile(fileName):
file = open(fileName, 'rb')
bytes = file.read()
return bytes
#=======================================================================================
# Utility function to create an arbitrary session name
#=======================================================================================
def createSessionName():
sessionName = String("SessionScript"+Long(System.currentTimeMillis()).toString())
return sessionName
#=======================================================================================
# Utility function to load a session MBeans
#=======================================================================================
def getSessionManagementMBean(sessionName):
SessionMBean = findService("SessionManagement", "com.bea.wli.sb.management.configuration.SessionManagementMBean")
SessionMBean.createSession(sessionName)
return SessionMBean
# IMPORT script init
try:
# import the service bus configuration
# argv[1] is the export config properties file
importToALSBDomain(sys.argv[1], sys.argv[2])
except:
print "Unexpected error: ", sys.exc_info()[0]
dumpStack()
raise
and with the following import.properties file:
##################################################################
# OSB Admin Configuration #
##################################################################
adminUrl=t3://localhost:7001
importUser=weblogic
importPassword=weblogic89
In our current Project we are using Deployment Groups to migrate the code from DEV to TEST/PROD servers. We use Repository Manager to Create DG/Deploy the Code. As to reduce the effort on this, we want to perform this using PMREP command.
Issue:
I am deploying a DG which has 8 sessions which belong to a single Workflow ( lets call is wkf_ABC. This workflow contains 20 Sessions in TEST Env). Out of this 8 sessions , one session is new one and rest of the 8 sessions are ones which exist in ENV as well. I have added
a)8 sessions with all dependencies and
b) Workflow with no dependencies
I am deploying it using two methods, one of them is using Repository Manger and other one is using PMREP command.
1) When using Repository Manger, I am able to deploy the DG to TEST env succesfully ( provided I compare the folders - checking the CHECK BOX in Select Compare Folders Option while Deploying the DG - or else its failing with the Error as shown in the screenshot)
2) When using the pmrep deploydeploymentgroup command with the same DG, the DG is not getting deployed showing the below error.
Error: Dependent Session s_123 (id=xxxx) in source repository is required to deploy Workflow wkf_ABC, it is not available in the target repository and is not part of the deployment group.
Copy failed, rolling back changes...
Please help me if I am missing something
More Inputs :
1) s_123 is not part of 8 sessions which are getting deployed and the session s_123 is already in Target repository ( ENV)
2) The Deployment config files which we have used with pmrep command and the one which I have used have same set of attributes.
3) I have seen there are some similar issues when using pmrep command like Object mismatch etc. other than that everything looks good.
Systematic Deployment ( Repository Manager)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE DEPLOYPARAMS SYSTEM "depcntl.dtd">
<DEPLOYPARAMS DEFAULTSERVERNAME = "" COPYPROGRAMINFO = "YES" COPYMAPVARPERVALS = "YES" COPYWFLOWVARPERVALS = "NO" COPYWFLOWSESSLOGS = "NO" COPYDEPENDENCY = "YES" LATESTVERSIONONLY = "NO" RETAINGENERATEDVAL = "YES" RETAINSERVERNETVALS = "YES" RETAINMAPVARPERVALS = "NO">
<DEPLOYGROUP>
<APPLYLABEL SOURCELABELNAME = "" SOURCEMOVELABEL = "NO" TARGETLABELNAME = "" TARGETMOVELABEL = "NO"/>
</DEPLOYGROUP>
</DEPLOYPARAMS>
Deployment Configurant file passed along with pmrep command
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE DEPLOYPARAMS SYSTEM "/dev1/usr/local/informatica/9.1.0/server/bin/depcntl.dtd">
<DEPLOYPARAMS DEFAULTSERVERNAME = "" COPYPROGRAMINFO = "YES" COPYMAPVARPERVALS = "YES" COPYWFLOWVARPERVALS = "NO" COPYWFLOWSESSLOGS = "NO" COPYDEPENDENCY = "YES" LATESTVERSIONONLY = "NO" RETAINGENERATEDVAL = "YES" RETAINSERVERNETVALS = "YES" RETAINMAPVARPERVALS = "NO">
<DEPLOYGROUP CLEARSRCDEPLOYGROUP="NO">
<OVERRIDEFOLDER SOURCEFOLDERNAME = "B_EDW_ODS_ICDS" SOURCEFOLDERTYPE = "LOCAL" TARGETFOLDERNAME = "B_EDW_ODS_ICDS" TARGETFOLDERTYPE = "LOCAL" MODIFIEDMANUALLY = "YES"/>
.
.
.(extra lines for other folders)
<APPLYLABEL SOURCELABELNAME = "" SOURCEMOVELABEL = "NO" TARGETLABELNAME = "" TARGETMOVELABEL = "NO"/>
</DEPLOYGROUP>
</DEPLOYPARAMS>
Informatica(r) PMREP, version [9.1.0 HotFix6], build [496.0111], LINUX 64-bit
I've got some strange behavior between me running a command under my profile, and TeamCity running the same command.
> Import-Module $root\packages\fsm.buildrelease.*\tools\modules\BuildDeployModules -Force
If I run the script manually, the build kicks off as expected. If I let TeamCity execute the script, it pukes with the following.
Import-Module : The specified module 'C:\BuildAgent\work\81eb7c2fdfcfc0af\packages\fsm.buildrelease.*\tools\modules\BuildDeployModules' was not loaded because no valid module file was found in any module directory.
I have double and triple verified that the module exists in that location. And I've gone through my modules and added [cmdletbinding()] before the param, but it doesn't seem to solve this issue.
It's frustrating because it doesn't say "which" module is getting an invalid parameter passed in.
$fsmbrVersion = "1.1.1" # contains the current version of fsm.buildrelease
Write-Host "`nfsm.buildrelease version $fsmbrVersion `nCopyright ($([char]0x00A9)) Future State Mobile Inc. & Contributors`n"
Push-Location $psScriptRoot
. .\Add-HostsFileEntry.ps1
. .\Add-IISHttpVerb.ps1
. .\Add-IISMimeType.ps1
. .\Add-LoopbackFix.ps1
. .\ApplicationAdministration.ps1
. .\AppPoolAdministration.ps1
. .\Approve-Permissions.ps1
. .\Assert-PSVersion.ps1
. .\EntityFramework.ps1
. .\Expand-NugetPackage.ps1
. .\Expand-ZipFile.ps1
. .\Format-TaskNameToHost.ps1
. .\Get-EnvironmentSettings.ps1
. .\Grunt.ps1
. .\Helpers.ps1
. .\Install-WebApplication.ps1
. .\Invoke-Deployment.ps1
. .\Invoke-DeployOctopusNugetPackage.ps1
. .\Invoke-ElevatedCommand.ps1
. .\Invoke-ExternalCommand.ps1
. .\Invoke-Using.ps1
. .\MSBuild.ps1
. .\Nuget.ps1
. .\nUnit.ps1
. .\Set-IISAuthentication.ps1
. .\Set-IISCustomHeader.ps1
. .\SiteAdministration.ps1
. .\Specflow.ps1
. .\SqlHelpers.ps1
. .\Test-PathExtended.ps1
. .\Test-RunAsAdmin.ps1
. .\TextUtils.ps1
. .\Update-AssemblyVersions.ps1
. .\Update-JsonConfigFile.ps1
. .\Update-XmlConfigFile.ps1
. .\WindowsFeatures.ps1
. .\xUnit.ps1
Pop-Location
Export-ModuleMember `
-Alias #(
'*') `
-Function #(
'Add-HostsFileEntry',
'Add-IISHttpVerb',
'Add-IISMimeType',
'Add-LoopbackFix',
'Approve-Permissions',
'Assert-That',
'Assert-PSVersion',
'Confirm-ApplicationExists',
'Confirm-AppPoolExists',
'Confirm-SiteExists',
'Exec',
'Expand-NugetPackage',
'Expand-ZipFile',
'Format-TaskNameToHost',
'Get-Application',
'Get-Applications',
'Get-AppPool',
'Get-AppPools',
'Get-DatabaseConnection',
'Get-EnvironmentSettings',
'Get-Site',
'Get-Sites',
'Get-TestFileName',
'Get-WarningsFromMSBuildLog',
'Get-WindowsFeatures',
'Install-WebApplication',
'Install-WindowsFeatures',
'Invoke-BulkCopy',
'Invoke-DBMigration',
'Invoke-Deployment',
'Invoke-DeployOctopusNugetPackage',
'Invoke-ElevatedCommand',
'Invoke-EntityFrameworkMigrations',
'Invoke-ExternalCommand',
'Invoke-FromBase64',
'Invoke-GruntMinification',
'Invoke-HtmlDecode',
'Invoke-HtmlEncode',
'Invoke-KarmaTests',
'Invoke-MSBuild',
'Invoke-Nunit',
'Invoke-NUnitWithCoverage'
'Invoke-SpecFlow',
'Invoke-SqlFile',
'Invoke-SqlStatement',
'Invoke-ToBase64',
'Invoke-UrlDecode',
'Invoke-UrlEncode',
'Invoke-Using',
'Invoke-XUnit',
'Invoke-XUnitWithCoverage',
'New-Application',
'New-AppPool',
'New-NugetPackage',
'New-Site',
'Remove-Application',
'Remove-AppPool',
'Remove-Site',
'RequiredFeatures',
'Set-IISAuthentication',
'Set-IISCustomHeader',
'Start-Application',
'Start-AppPool',
'Start-Site',
'Step',
'Stop-Application',
'Stop-AppPool',
'Stop-Site',
'Test-PathExtended',
'Test-RunAsAdmin',
'Update-Application',
'Update-AppPool',
'Update-AssemblyVersions',
'Update-JsonConfigValues',
'Update-Site',
'Update-XmlConfigValues'
)
# Messages
DATA msgs {
convertfrom-stringdata #"
error_duplicate_step_name = Step {0} has already been defined.
error_must_supply_a_feature = You must supply at least one Windows Feature.
error_feature_set_invalid = The argument `"{0}`" does not belong to the set `"{1}`".
error_admin_required = You are required to 'Run as Administrator' when running this deployment.
error_loading_sql_file = Error loading '{0}'. {1}.
error_octopus_deploy_failed = Failed to deploy: {0}.
error_specflow_failed = Publishing specflow results for '{0}' failed.
error_coverage_failed = Running code coverage for '{0}' failed.
error_tests_failed = Running tests '{0}' failed.
error_msbuild_compile = Error compiling '{0}'.
wrn_full_permission = You have applied FULL permission to '{0}' for '{1}'. THIS IS DANGEROUS!
wrn_cant_find = Could not find {0} with the name: {0}.
msg_grant_permission = Granting {0} permissions to {1} for {2}.
msg_enabling_windows_feature = Enabling Windows Feature: `"{0}`".
msg_wasnt_found = `"{0}`" wasn't found.
msg_updated_to = Updated `"{0}`" to `"{1}`".
msg_updating_to = Updating `"{0}`" to `"{1}`".
msg_changing_to = Changing `"{0}`" to `"{1}`".
msg_overriding_to = Overriding node `"{0}`" with value `"{1}`".
msg_updating_assembly = Updating AssemblyVersion to '{0}'. Updating AssemblyFileVersion to '{1}'. Updating AssemblyInformationalVersion to '{2}'.
msg_not_updating = Not updating {0}, you must specify the '-updateIfFound' if you wish to update the {0} settings.
msg_custom_header = Setting custom header '{0}' on site '{1}' to value '{2}'.
msg_disable_anon_auth = Disabling Anonymous Authentication for '{0}'.
msg_web_app_success = Successfully deploy Web Application '{0}'.
msg_copying_content = Copying {0} content to {1}.
msg_use_machine_environment = Using config for machine {0} instead of the {1} environment.
msg_octopus_overrides = Checking for Octopus Overrides for environment '{0}'.
msg_teamcity_importdata = ##teamcity[importData type='{0}' tool='{1}' path='{2}']
msg_teamcity_buildstatus = ##teamcity[buildStatus text='{0}']
msg_teamcity_buildstatisticvalue = ##teamcity[buildStatisticValue key='{0}' value='{1}']
msg_add_loopback_fix = Adding loopback fix for '{0}'.
msg_add_mime_type = Adding mime type '{0}' for extension '{1}' to IIS site '{2}'.
msg_add_verb = Adding IIS Http Verb '{0}' to site '{1}'.
msg_add_host_entry = Adding host entry for '{0}' into the hosts file.
msg_validate_host_entry = Validating host entry for '{0} in the hosts file'
msg_loopback_note = note: we're not disabling the loopback check all together, we are simply adding '{0}' to an allowed list.
"#
}
The problem is nothing to do with importing the module; powershell isn't very helpful in leading you to the issue. The root of the issue didn't reveal it's self until I put the -VERBOSE switch on the import. Once I did that, I got a new error above the old one.
: Parameter attributes need to be a constant or a script block.
FullyQualifiedErrorId: ParameterAttributeArgumentNeedsToBeConstandOrScriptBlock
Essentially, I was using ValidatePattern with double quotes instead of single quotes. Check and make sure your writing your regex patterns correctly when you use ValidatePattern
# Bad
[ValidatePattern("^[a-z]$")]
# Good
[ValidatePattern('^[a-z]$')]
I've been working on a custom SNMP Mib and I've come up against a wall while trying to get an agent to return the proper data.
MIB (validated by running smilint -l 6):
IDB-MIB DEFINITIONS ::= BEGIN
IMPORTS
MODULE-IDENTITY, OBJECT-TYPE, Integer32, enterprises
FROM SNMPv2-SMI
MODULE-COMPLIANCE, OBJECT-GROUP FROM SNMPv2-CONF;
idb MODULE-IDENTITY
LAST-UPDATED "201307300000Z" -- Midnight 30 July 2013
ORGANIZATION "*********"
CONTACT-INFO "email: *******"
DESCRIPTION "description"
REVISION "201307300000Z" -- Midnight 29 July 2013
DESCRIPTION "First Draft"
::= { enterprises 42134 }
iDBCompliance MODULE-COMPLIANCE
STATUS current
DESCRIPTION
"Compliance statement for iDB"
MODULE
GROUP testGroup
DESCRIPTION
"This group is a test group"
::= {idb 1}
test2 OBJECT-TYPE
SYNTAX Integer32
UNITS "tests"
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"A test object"
DEFVAL { 5 }
::= { idb 3 }
testGroup OBJECT-GROUP
OBJECTS {
test2
}
STATUS current
DESCRIPTION "all test objects"
::= { idb 2 }
END
Agent file:
#!/usr/bin/perl
use NetSNMP::OID(':all');
use NetSNMP::agent(':all');
use NetSNMP::ASN(':all');
sub myhandler {
my ($handler, $registration_info, $request_info, $requests) = #_;
print "Handling request\n";
for ($request = $requests; $request; $request = $request->next()) {
#
# Work through the list of varbinds
#
my $oid = $request->getOID();
print "Got request for oid $oi\n";
if ($request_info->getMode() == MODE_GET) {
if ($oid == new NetSNMP::OID($rootOID . ".3")) {
$request->setValue(ASN_INTEGER, 2);
}
}
}
}
{
$subagent = 0;
print "Running new agent\n";
my $rootOID = ".1.3.6.1.4.1.42134";
my $regoid = new NetSNMP::OID($rootOID);
if (!$agent) {
$agent = new NetSNMP::agent('Name'=>'my_agent_name','AgentX' => 1);
$subagent = 1;
print "Starting subagent\n";
}
print "Registering agent\n";
$agent->register("my_agent_name", $regoid, \&myhandler);
print "Agent registered\n";
if ($subagent) {
$SIG{'INT'} = \&shut_it_down;
$SIG{'QUIT'} = \&shut_it_down;
$running = 1;
while ($running) {
$agent->agent_check_and_process(1);
}
$agent->shutdown();
}
}
sub shut_it_down() {
$running = 0;
print "Shutting down agent\n";
}
When I run the agent I get the following:
Running new agent
Starting subagent!
Registering agent with oid idb
Agent registered
So I know that much is working. However when I run the following command:
snmpget -v 1 -c mycommunity localhost:161 test2.0
I get this error message:
Error in packet
Reason: (noSuchName) There is no such variable name in this MIB.
Failed object: IDB-MIB::test2.0
I know from snmptranslate that the mib file is set correctly. I have even looked through the debug for snmpget (using -DALL) to make sure that the mib is being loaded and parsed correctly.
So my question is: Why is my subagent not being passed the request?
Update:
I've been told by #EhevuTov that my MIB file is not valid, however smilint does not report any issues and running snmpget -v 2c -c mycommunity localhost:161 .1.3.6.1.4.1.42134.3.0 does report the NAME of the object (IDB-MIB::test2.0) correctly, but does not find any data for it.
I am getting IDB-MIB::test2 = No Such Object available on this agent at this OID, which makes me think that my agent is not registering properly, however it's not throwing any errors.
Update 2:
I've been fiddling around with the agent code a bit. Based on the CPAN documentation (http://metacpan.org/pod/NetSNMP::agent), it looks like the $agent->register function call is supposed to return 0 if successful. So I checked the return code and got this:
Agent registered. Result: NetSNMP::agent::netsnmp_handler_registration=SCALAR(0x201e688)
Printing it out using Data::Dumper results in:
$VAR1 = bless( do{\(my $o = 34434624)}, 'NetSNMP::agent::netsnmp_handler_registration' );
I vaguely understand what bless does, but even so, I have no idea what this result is supposed to mean. So I'm starting to think that the agent is wrong somehow. Does anyone know how to debug these agents? Is there somewhere I can look to see if it's getting loaded properly into the master snmpd?
And I've solved the problem. It wasn't with the MIB, it was with the agent (which I had THOUGHT was working fine the whole time so I never bothered to check it).
I'd been running the agent stand-alone, because it seemed like it was working fine (never threw any errors when registering the handler). Apparently though, it needs to be run directly by snmpd.
I moved it to a directory that snmpd can access (because also apparently snmpd can't run scripts from /root, even though it's running as root), and added these lines in snmpd.conf:
perl print "\nRunning agents now\n";
perl do "/usr/share/snmp/agent.pl" || print "Problem running agent script: $!\n";
perl print "Agents run\n";
Note that these two lines were already present:
disablePerl false
perlInitFile /usr/share/snmp/snmp_perl.pl
I can now run the snmpget command and get the expected response.
> snmpget -v 2c -c mycommunity localhost:161 .1.3.6.1.4.1.42134.3
IDB-MIB::test2 = INTEGER: 2 tests