Removed all projects except Glazier Dashboard

This commit is contained in:
Serg Melikyan 2013-04-09 14:52:04 +04:00
parent c3083f5f6a
commit 4c36d11381
410 changed files with 0 additions and 25692 deletions

View File

View File

@ -1,29 +0,0 @@
{
"Scripts": [
"DQpGdW5jdGlvbiBJbnN0YWxsLVJvbGVQcmltYXJ5RG9tYWluQ29udHJvbGxlcg0Kew0KPCMNCi5TWU5PUFNJUw0KQ29uZmlndXJlIG5vZGUncyBuZXR3b3JrIGFkYXB0ZXJzLg0KQ3JlYXRlIGZpcnN0IGRvbWFpbiBjb250cm9sbGVyIGluIHRoZSBmb3Jlc3QuDQoNCi5FWEFNUExFDQpQUz4gSW5zdGFsbC1Sb2xlUHJpbWFyeURvbWFpbkNvbnRyb2xsZXIgLURvbWFpbk5hbWUgYWNtZS5sb2NhbCAtU2FmZU1vZGVQYXNzd29yZCAiUEBzc3cwcmQiDQoNCkluc3RhbGwgRE5TIGFuZCBBRERTLCBjcmVhdGUgZm9yZXN0IGFuZCBkb21haW4gJ2FjbWUubG9jYWwnLg0KU2V0IERDIHJlY292ZXJ5IG1vZGUgcGFzc3dvcmQgdG8gJ1BAc3N3MHJkJy4NCiM+DQoJDQoJcGFyYW0NCgkoDQoJCVtTdHJpbmddDQoJCSMgTmV3IGRvbWFpbiBuYW1lLg0KCQkkRG9tYWluTmFtZSwNCgkJDQoJCVtTdHJpbmddDQoJCSMgRG9tYWluIGNvbnRyb2xsZXIgcmVjb3ZlcnkgbW9kZSBwYXNzd29yZC4NCgkJJFNhZmVNb2RlUGFzc3dvcmQNCgkpDQoNCgl0cmFwIHsgU3RvcC1FeGVjdXRpb24gJF8gfQ0KDQogICAgICAgICMgQWRkIHJlcXVpcmVkIHdpbmRvd3MgZmVhdHVyZXMNCglBZGQtV2luZG93c0ZlYXR1cmVXcmFwcGVyIGANCgkJLU5hbWUgIkROUyIsIkFELURvbWFpbi1TZXJ2aWNlcyIsIlJTQVQtREZTLU1nbXQtQ29uIiBgDQoJCS1JbmNsdWRlTWFuYWdlbWVudFRvb2xzIGANCiAgICAgICAgLU5vdGlmeVJlc3RhcnQNCg0KDQoJV3JpdGUtTG9nICJDcmVhdGluZyBmaXJzdCBkb21haW4gY29udHJvbGxlciAuLi4iDQoJCQ0KCSRTTUFQID0gQ29udmVydFRvLVNlY3VyZVN0cmluZyAtU3RyaW5nICRTYWZlTW9kZVBhc3N3b3JkIC1Bc1BsYWluVGV4dCAtRm9yY2UNCgkJDQoJSW5zdGFsbC1BRERTRm9yZXN0IGANCgkJLURvbWFpbk5hbWUgJERvbWFpbk5hbWUgYA0KCQktU2FmZU1vZGVBZG1pbmlzdHJhdG9yUGFzc3dvcmQgJFNNQVAgYA0KCQktRG9tYWluTW9kZSBEZWZhdWx0IGANCgkJLUZvcmVzdE1vZGUgRGVmYXVsdCBgDQoJCS1Ob1JlYm9vdE9uQ29tcGxldGlvbiBgDQoJCS1Gb3JjZSBgDQoJCS1FcnJvckFjdGlvbiBTdG9wIHwgT3V0LU51bGwNCg0KCVdyaXRlLUxvZyAiV2FpdGluZyBmb3IgcmVib290IC4uLiIJCQ0KIwlTdG9wLUV4ZWN1dGlvbiAtRXhpdENvZGUgMzAxMCAtRXhpdFN0cmluZyAiQ29tcHV0ZXIgbXVzdCBiZSByZXN0YXJ0ZWQgdG8gZmluaXNoIGRvbWFpbiBjb250cm9sbGVyIHByb21vdGlvbi4iDQojCVdyaXRlLUxvZyAiUmVzdGFyaW5nIGNvbXB1dGVyIC4uLiINCiMJUmVzdGFydC1Db21wdXRlciAtRm9yY2UNCn0NCg=="
],
"Commands": [
{
"Name": "Import-Module",
"Arguments": {
"Name": "CoreFunctions"
}
},
{
"Name": "Set-LocalUserPassword",
"Arguments": {
"UserName": "Administrator",
"Password": "P@ssw0rd123",
"Force": true
}
},
{
"Name": "Install-RolePrimaryDomainController",
"Arguments": {
"DomainName": "acme.local",
"SafeModePassword": "P@ssw0rd"
}
}
],
"RebootOnCompletion": 1
}

View File

@ -1,9 +0,0 @@
include Install-RolePrimaryDomainController.ps1
call Import-Module Name="CoreFunctions"
call Set-LocalUserPassword UserName="Administrator" , Password="P@ssw0rd123" , Force=true
call Install-RolePrimaryDomainController DomainName="acme.local" , SafeModePassword="P@ssw0rd"
reboot 1
out CreatePrimaryDC.json

View File

@ -1 +0,0 @@
..\ExecutionPlanGenerator.exe ExecutionPlan.txt

View File

@ -1,53 +0,0 @@

Function Install-RolePrimaryDomainController
{
<#
.SYNOPSIS
Configure node's network adapters.
Create first domain controller in the forest.
.EXAMPLE
PS> Install-RolePrimaryDomainController -DomainName acme.local -SafeModePassword "P@ssw0rd"
Install DNS and ADDS, create forest and domain 'acme.local'.
Set DC recovery mode password to 'P@ssw0rd'.
#>
param
(
[String]
# New domain name.
$DomainName,
[String]
# Domain controller recovery mode password.
$SafeModePassword
)
trap { Stop-Execution $_ }
# Add required windows features
Add-WindowsFeatureWrapper `
-Name "DNS","AD-Domain-Services","RSAT-DFS-Mgmt-Con" `
-IncludeManagementTools `
-NotifyRestart
Write-Log "Creating first domain controller ..."
$SMAP = ConvertTo-SecureString -String $SafeModePassword -AsPlainText -Force
Install-ADDSForest `
-DomainName $DomainName `
-SafeModeAdministratorPassword $SMAP `
-DomainMode Default `
-ForestMode Default `
-NoRebootOnCompletion `
-Force `
-ErrorAction Stop | Out-Null
Write-Log "Waiting for reboot ..."
# Stop-Execution -ExitCode 3010 -ExitString "Computer must be restarted to finish domain controller promotion."
# Write-Log "Restaring computer ..."
# Restart-Computer -Force
}

View File

@ -1,9 +0,0 @@
call Import-Module Name="CoreFunctions"
call Set-NetworkAdapterConfiguration FirstAvailable=true , DNSServer="10.0.102.2"
call Join-Domain DomainName="acme.local" , Username="Administrator" , Password="P@ssw0rd123"
reboot 1
out out.json

View File

@ -1 +0,0 @@
..\ExecutionPlanGenerator.exe ExecutionPlan.txt

View File

@ -1,27 +0,0 @@
{
"Scripts": [],
"Commands": [
{
"Name": "Import-Module",
"Arguments": {
"Name": "CoreFunctions"
}
},
{
"Name": "Set-NetworkAdapterConfiguration",
"Arguments": {
"FirstAvailable": true,
"DNSServer": "10.0.102.2"
}
},
{
"Name": "Join-Domain",
"Arguments": {
"DomainName": "acme.local",
"Username": "Administrator",
"Password": "P@ssw0rd123"
}
}
],
"RebootOnCompletion": 1
}

View File

@ -1,8 +0,0 @@
include Install-RoleSecondaryDomainController.ps1
call Import-Module Name="CoreFunctions"
call Install-RoleSecondaryDomainController DomainName="acme.local" , UserName="Administrator" , Password="P@ssw0rd123" , SafeModePassword="P@ssw0rd"
reboot 1
out out.json

View File

@ -1 +0,0 @@
..\ExecutionPlanGenerator.exe ExecutionPlan.txt

View File

@ -1,54 +0,0 @@
Function Install-RoleSecondaryDomainController
{
<#
.SYNOPSIS
Install additional (secondary) domain controller.
#>
param
(
[String]
# Domain name to join to.
$DomainName,
[String]
# Domain user who is allowed to join computer to domain.
$UserName,
[String]
# User's password.
$Password,
[String]
# Domain controller recovery mode password.
$SafeModePassword
)
trap { Stop-Execution $_ }
$Credential = New-Credential -UserName "$DomainName\$UserName" -Password $Password
# Add required windows features
Add-WindowsFeatureWrapper `
-Name "DNS","AD-Domain-Services","RSAT-DFS-Mgmt-Con" `
-IncludeManagementTools `
-NotifyRestart
Write-Log "Adding secondary domain controller ..."
$SMAP = ConvertTo-SecureString -String $SafeModePassword -AsPlainText -Force
Install-ADDSDomainController `
-DomainName $DomainName `
-SafeModeAdministratorPassword $SMAP `
-Credential $Credential `
-NoRebootOnCompletion `
-Force `
-ErrorAction Stop | Out-Null
Write-Log "Waiting for restart ..."
# Stop-Execution -ExitCode 3010 -ExitString "Computer must be restarted to finish domain controller promotion."
# Write-Log "Restarting computer ..."
# Restart-Computer -Force
}

View File

@ -1,23 +0,0 @@
{
"Scripts": [
"RnVuY3Rpb24gSW5zdGFsbC1Sb2xlU2Vjb25kYXJ5RG9tYWluQ29udHJvbGxlcg0Kew0KPCMNCi5TWU5PUFNJUw0KSW5zdGFsbCBhZGRpdGlvbmFsIChzZWNvbmRhcnkpIGRvbWFpbiBjb250cm9sbGVyLg0KDQojPg0KCXBhcmFtDQoJKA0KCQlbU3RyaW5nXQ0KCQkjIERvbWFpbiBuYW1lIHRvIGpvaW4gdG8uDQoJCSREb21haW5OYW1lLA0KCQkNCgkJW1N0cmluZ10NCgkJIyBEb21haW4gdXNlciB3aG8gaXMgYWxsb3dlZCB0byBqb2luIGNvbXB1dGVyIHRvIGRvbWFpbi4NCgkJJFVzZXJOYW1lLA0KCQkNCgkJW1N0cmluZ10NCgkJIyBVc2VyJ3MgcGFzc3dvcmQuDQoJCSRQYXNzd29yZCwNCgkJDQoJCVtTdHJpbmddDQoJCSMgRG9tYWluIGNvbnRyb2xsZXIgcmVjb3ZlcnkgbW9kZSBwYXNzd29yZC4NCgkJJFNhZmVNb2RlUGFzc3dvcmQNCgkpDQoNCgl0cmFwIHsgU3RvcC1FeGVjdXRpb24gJF8gfQ0KCQ0KCSRDcmVkZW50aWFsID0gTmV3LUNyZWRlbnRpYWwgLVVzZXJOYW1lICIkRG9tYWluTmFtZVwkVXNlck5hbWUiIC1QYXNzd29yZCAkUGFzc3dvcmQNCgkJDQoJIyBBZGQgcmVxdWlyZWQgd2luZG93cyBmZWF0dXJlcw0KCUFkZC1XaW5kb3dzRmVhdHVyZVdyYXBwZXIgYA0KCQktTmFtZSAiRE5TIiwiQUQtRG9tYWluLVNlcnZpY2VzIiwiUlNBVC1ERlMtTWdtdC1Db24iIGANCgkJLUluY2x1ZGVNYW5hZ2VtZW50VG9vbHMgYA0KICAgICAgICAgICAgICAgIC1Ob3RpZnlSZXN0YXJ0DQoJCQ0KCQ0KICAgICAgICBXcml0ZS1Mb2cgIkFkZGluZyBzZWNvbmRhcnkgZG9tYWluIGNvbnRyb2xsZXIgLi4uIg0KICAgIA0KCSRTTUFQID0gQ29udmVydFRvLVNlY3VyZVN0cmluZyAtU3RyaW5nICRTYWZlTW9kZVBhc3N3b3JkIC1Bc1BsYWluVGV4dCAtRm9yY2UNCg0KCUluc3RhbGwtQUREU0RvbWFpbkNvbnRyb2xsZXIgYA0KCQktRG9tYWluTmFtZSAkRG9tYWluTmFtZSBgDQoJCS1TYWZlTW9kZUFkbWluaXN0cmF0b3JQYXNzd29yZCAkU01BUCBgDQoJCS1DcmVkZW50aWFsICRDcmVkZW50aWFsIGANCgkJLU5vUmVib290T25Db21wbGV0aW9uIGANCgkJLUZvcmNlIGANCgkJLUVycm9yQWN0aW9uIFN0b3AgfCBPdXQtTnVsbA0KDQoJV3JpdGUtTG9nICJXYWl0aW5nIGZvciByZXN0YXJ0IC4uLiINCiMJU3RvcC1FeGVjdXRpb24gLUV4aXRDb2RlIDMwMTAgLUV4aXRTdHJpbmcgIkNvbXB1dGVyIG11c3QgYmUgcmVzdGFydGVkIHRvIGZpbmlzaCBkb21haW4gY29udHJvbGxlciBwcm9tb3Rpb24uIg0KIwlXcml0ZS1Mb2cgIlJlc3RhcnRpbmcgY29tcHV0ZXIgLi4uIg0KIwlSZXN0YXJ0LUNvbXB1dGVyIC1Gb3JjZQ0KfQ0K"
],
"Commands": [
{
"Name": "Import-Module",
"Arguments": {
"Name": "CoreFunctions"
}
},
{
"Name": "Install-RoleSecondaryDomainController",
"Arguments": {
"DomainName": "acme.local",
"UserName": "Administrator",
"Password": "P@ssw0rd123",
"SafeModePassword": "P@ssw0rd"
}
}
],
"RebootOnCompletion": 1
}

View File

@ -1,10 +0,0 @@
include Install-RoleSecondaryDomainController.ps1
call Import-Module Name="CoreFunctions"
call Set-NetworkAdapterConfiguration FirstAvailable=true , DNSServer="10.0.102.2"
call Join-Domain DomainName="acme.local" , Username="Administrator" , Password="P@ssw0rd123" , AllowRestart=true
call Install-RoleSecondaryDomainController DomainName="acme.local" , UserName="Administrator" , Password="P@ssw0rd123" , SafeModePassword="P@ssw0rd"
reboot 1
out out.json

View File

@ -1 +0,0 @@
..\ExecutionPlanGenerator.exe ExecutionPlan.txt

View File

@ -1,54 +0,0 @@
Function Install-RoleSecondaryDomainController
{
<#
.SYNOPSIS
Install additional (secondary) domain controller.
#>
param
(
[String]
# Domain name to join to.
$DomainName,
[String]
# Domain user who is allowed to join computer to domain.
$UserName,
[String]
# User's password.
$Password,
[String]
# Domain controller recovery mode password.
$SafeModePassword
)
trap { Stop-Execution $_ }
$Credential = New-Credential -UserName "$DomainName\$UserName" -Password $Password
# Add required windows features
Add-WindowsFeatureWrapper `
-Name "DNS","AD-Domain-Services","RSAT-DFS-Mgmt-Con" `
-IncludeManagementTools `
-NotifyRestart
Write-Log "Adding secondary domain controller ..."
$SMAP = ConvertTo-SecureString -String $SafeModePassword -AsPlainText -Force
Install-ADDSDomainController `
-DomainName $DomainName `
-SafeModeAdministratorPassword $SMAP `
-Credential $Credential `
-NoRebootOnCompletion `
-Force `
-ErrorAction Stop | Out-Null
Write-Log "Waiting for restart ..."
# Stop-Execution -ExitCode 3010 -ExitString "Computer must be restarted to finish domain controller promotion."
# Write-Log "Restarting computer ..."
# Restart-Computer -Force
}

View File

@ -1,39 +0,0 @@
{
"Scripts": [
"RnVuY3Rpb24gSW5zdGFsbC1Sb2xlU2Vjb25kYXJ5RG9tYWluQ29udHJvbGxlcg0Kew0KPCMNCi5TWU5PUFNJUw0KSW5zdGFsbCBhZGRpdGlvbmFsIChzZWNvbmRhcnkpIGRvbWFpbiBjb250cm9sbGVyLg0KDQojPg0KCXBhcmFtDQoJKA0KCQlbU3RyaW5nXQ0KCQkjIERvbWFpbiBuYW1lIHRvIGpvaW4gdG8uDQoJCSREb21haW5OYW1lLA0KCQkNCgkJW1N0cmluZ10NCgkJIyBEb21haW4gdXNlciB3aG8gaXMgYWxsb3dlZCB0byBqb2luIGNvbXB1dGVyIHRvIGRvbWFpbi4NCgkJJFVzZXJOYW1lLA0KCQkNCgkJW1N0cmluZ10NCgkJIyBVc2VyJ3MgcGFzc3dvcmQuDQoJCSRQYXNzd29yZCwNCgkJDQoJCVtTdHJpbmddDQoJCSMgRG9tYWluIGNvbnRyb2xsZXIgcmVjb3ZlcnkgbW9kZSBwYXNzd29yZC4NCgkJJFNhZmVNb2RlUGFzc3dvcmQNCgkpDQoNCgl0cmFwIHsgU3RvcC1FeGVjdXRpb24gJF8gfQ0KCQ0KCSRDcmVkZW50aWFsID0gTmV3LUNyZWRlbnRpYWwgLVVzZXJOYW1lICIkRG9tYWluTmFtZVwkVXNlck5hbWUiIC1QYXNzd29yZCAkUGFzc3dvcmQNCgkJDQoJIyBBZGQgcmVxdWlyZWQgd2luZG93cyBmZWF0dXJlcw0KCUFkZC1XaW5kb3dzRmVhdHVyZVdyYXBwZXIgYA0KCQktTmFtZSAiRE5TIiwiQUQtRG9tYWluLVNlcnZpY2VzIiwiUlNBVC1ERlMtTWdtdC1Db24iIGANCgkJLUluY2x1ZGVNYW5hZ2VtZW50VG9vbHMgYA0KICAgICAgICAgICAgICAgIC1Ob3RpZnlSZXN0YXJ0DQoJCQ0KCQ0KICAgICAgICBXcml0ZS1Mb2cgIkFkZGluZyBzZWNvbmRhcnkgZG9tYWluIGNvbnRyb2xsZXIgLi4uIg0KICAgIA0KCSRTTUFQID0gQ29udmVydFRvLVNlY3VyZVN0cmluZyAtU3RyaW5nICRTYWZlTW9kZVBhc3N3b3JkIC1Bc1BsYWluVGV4dCAtRm9yY2UNCg0KCUluc3RhbGwtQUREU0RvbWFpbkNvbnRyb2xsZXIgYA0KCQktRG9tYWluTmFtZSAkRG9tYWluTmFtZSBgDQoJCS1TYWZlTW9kZUFkbWluaXN0cmF0b3JQYXNzd29yZCAkU01BUCBgDQoJCS1DcmVkZW50aWFsICRDcmVkZW50aWFsIGANCgkJLU5vUmVib290T25Db21wbGV0aW9uIGANCgkJLUZvcmNlIGANCgkJLUVycm9yQWN0aW9uIFN0b3AgfCBPdXQtTnVsbA0KDQoJV3JpdGUtTG9nICJXYWl0aW5nIGZvciByZXN0YXJ0IC4uLiINCiMJU3RvcC1FeGVjdXRpb24gLUV4aXRDb2RlIDMwMTAgLUV4aXRTdHJpbmcgIkNvbXB1dGVyIG11c3QgYmUgcmVzdGFydGVkIHRvIGZpbmlzaCBkb21haW4gY29udHJvbGxlciBwcm9tb3Rpb24uIg0KIwlXcml0ZS1Mb2cgIlJlc3RhcnRpbmcgY29tcHV0ZXIgLi4uIg0KIwlSZXN0YXJ0LUNvbXB1dGVyIC1Gb3JjZQ0KfQ0K"
],
"Commands": [
{
"Name": "Import-Module",
"Arguments": {
"Name": "CoreFunctions"
}
},
{
"Name": "Set-NetworkAdapterConfiguration",
"Arguments": {
"FirstAvailable": true,
"DNSServer": "10.0.102.2"
}
},
{
"Name": "Join-Domain",
"Arguments": {
"DomainName": "acme.local",
"Username": "Administrator",
"Password": "P@ssw0rd123",
"AllowRestart": true
}
},
{
"Name": "Install-RoleSecondaryDomainController",
"Arguments": {
"DomainName": "acme.local",
"UserName": "Administrator",
"Password": "P@ssw0rd123",
"SafeModePassword": "P@ssw0rd"
}
}
],
"RebootOnCompletion": 1
}

View File

@ -1,7 +0,0 @@
include Get-DnsListeningIpAddress.ps1
call Get-DnsListeningIpAddress
reboot 0
out out.json

View File

@ -1 +0,0 @@
..\ExecutionPlanGenerator.exe ExecutionPlan.txt

View File

@ -1,5 +0,0 @@
function Get-DnsListeningIpAddress {
Import-Module DnsServer
(Get-DNSServer -ComputerName localhost).ServerSetting.ListeningIpAddress |
Where-Object { $_ -match "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}" }
}

View File

@ -1,12 +0,0 @@
{
"Scripts": [
"ZnVuY3Rpb24gR2V0LURuc0xpc3RlbmluZ0lwQWRkcmVzcyB7DQogICAgSW1wb3J0LU1vZHVsZSBEbnNTZXJ2ZXINCiAgICAoR2V0LUROU1NlcnZlciAtQ29tcHV0ZXJOYW1lIGxvY2FsaG9zdCkuU2VydmVyU2V0dGluZy5MaXN0ZW5pbmdJcEFkZHJlc3MgfA0KICAgICAgICBXaGVyZS1PYmplY3QgeyAkXyAtbWF0Y2ggIlxkezEsM31cLlxkezEsM31cLlxkezEsM31cLlxkezEsM30iIH0NCn0NCg=="
],
"Commands": [
{
"Name": "Get-DnsListeningIpAddress",
"Arguments": {}
}
],
"RebootOnCompletion": 0
}

View File

@ -1,7 +0,0 @@
include Install-WebServer.ps1
call Install-WebServer
reboot 0
out out.json

View File

@ -1 +0,0 @@
..\ExecutionPlanGenerator.exe ExecutionPlan.txt

View File

@ -1,4 +0,0 @@
function Install-WebServer {
Import-Module ServerManager
Install-WindowsFeature Web-Server -IncludeManagementTools
}

View File

@ -1,12 +0,0 @@
{
"Scripts": [
"ZnVuY3Rpb24gSW5zdGFsbC1XZWJTZXJ2ZXIgew0KICAgIEltcG9ydC1Nb2R1bGUgU2VydmVyTWFuYWdlcg0KICAgIEluc3RhbGwtV2luZG93c0ZlYXR1cmUgV2ViLVNlcnZlciAtSW5jbHVkZU1hbmFnZW1lbnRUb29scw0KfQ0K"
],
"Commands": [
{
"Name": "Install-WebServer",
"Arguments": {}
}
],
"RebootOnCompletion": 0
}

View File

@ -1,44 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="specialize">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<TimeZone>Pacific Standard Time</TimeZone>
</component>
</settings>
<settings pass="oobeSystem">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<AutoLogon>
<Password>
<Value>UABAAHMAcwB3ADAAcgBkAFAAYQBzAHMAdwBvAHIAZAA=</Value>
<PlainText>false</PlainText>
</Password>
<Username>Administrator</Username>
<LogonCount>1</LogonCount>
<Enabled>false</Enabled>
</AutoLogon>
<UserAccounts>
<AdministratorPassword>
<Value>UABAAHMAcwB3ADAAcgBkAEEAZABtAGkAbgBpAHMAdAByAGEAdABvAHIAUABhAHMAcwB3AG8AcgBkAA==</Value>
<PlainText>false</PlainText>
</AdministratorPassword>
</UserAccounts>
<RegisteredOrganization>-</RegisteredOrganization>
<RegisteredOwner>-</RegisteredOwner>
<OOBE>
<HideEULAPage>true</HideEULAPage>
</OOBE>
</component>
<component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<InputLocale>en-US</InputLocale>
<SystemLocale>en-US</SystemLocale>
<UILanguage>en-US</UILanguage>
<UserLocale>en-US</UserLocale>
</component>
</settings>
<settings pass="generalize">
<component name="Microsoft-Windows-Security-SPP" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SkipRearm>1</SkipRearm>
</component>
</settings>
<cpi:offlineImage cpi:source="wim:d:/aik/install.wim#Windows Server 2012 SERVERSTANDARDCORE" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>

View File

@ -1,51 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="specialize">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<TimeZone>Pacific Stantard Time</TimeZone>
</component>
</settings>
<settings pass="oobeSystem">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<AutoLogon>
<Password>
<Value>UABAAHMAcwB3ADAAcgBkAFAAYQBzAHMAdwBvAHIAZAA=</Value>
<PlainText>false</PlainText>
</Password>
<LogonCount>1</LogonCount>
<Username>Administrator</Username>
<Enabled>true</Enabled>
</AutoLogon>
<UserAccounts>
<AdministratorPassword>
<Value>UABAAHMAcwB3ADAAcgBkAEEAZABtAGkAbgBpAHMAdAByAGEAdABvAHIAUABhAHMAcwB3AG8AcgBkAA==</Value>
<PlainText>false</PlainText>
</AdministratorPassword>
</UserAccounts>
<RegisteredOrganization>-</RegisteredOrganization>
<RegisteredOwner>-</RegisteredOwner>
<OOBE>
<HideEULAPage>true</HideEULAPage>
</OOBE>
<FirstLogonCommands>
<SynchronousCommand wcm:action="add">
<RequiresUserInput>true</RequiresUserInput>
<CommandLine>powershell.exe -File C:\Deploy\Scripts\FirstLogon.ps1</CommandLine>
<Order>1</Order>
</SynchronousCommand>
</FirstLogonCommands>
</component>
<component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<InputLocale>en-US</InputLocale>
<SystemLocale>en-US</SystemLocale>
<UILanguage>en-US</UILanguage>
<UserLocale>en-US</UserLocale>
</component>
</settings>
<settings pass="generalize">
<component name="Microsoft-Windows-Security-SPP" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SkipRearm>1</SkipRearm>
</component>
</settings>
<cpi:offlineImage cpi:source="wim:d:/aik/install.wim#Windows Server 2012 SERVERSTANDARD" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>

View File

@ -1,28 +0,0 @@
<#
Naming convention:
== Normal variables
** Set: $NormalVar = 123
** Get: Write-Host $NormalVar
== Script-scope variables
** Set: $script:__ScriptScopeVar = 123
** Get: Write-Host $__ScriptScopeVar
== Global-scope variables
** Set: $global:__GlobalScopeVar__ = 123
** Get: Write-Host $__GlobalScopeVar__
#>
$script:__ModulePath = $PsScriptRoot
$script:__ModuleName = $PsScriptRoot.Split("\")[-1]
$script:__DefaultLogPath = [IO.Path]::Combine([IO.Path]::GetTempPath(), "PowerShell_$__ModuleName.log")
$script:__RequiredModules = @("ServerManager", "DnsClient")
$script:__ImportModulesExplicitely = $true
$script:__ImportModulesErrorAction = "Stop"
$global:__StopExecutionPreference__ = "Exit"

View File

@ -1,36 +0,0 @@
# Import config first
. "$PsScriptRoot\Config.ps1"
# Import functions from 'Include' subfolder
Get-ChildItem "$PsScriptRoot\Include" -Filter "*.ps1" |
ForEach-Object {
. "$($_.FullName)"
}
trap { Stop-Execution $_ }
Export-ModuleMember -Function * -Alias *
<#
if ($__ImportModulesExplicitely) {
foreach ($Module in $__RequiredModules) {
Write-Log "Importing module '$Module' ..."
Import-Module -Name "$Module" -ErrorAction "$__ImportModulesErrorAction"
}
}
#>
Write-Log "Module loaded from '$PsScriptRoot'"
#-------------------------------------------------------------------------------
switch ($Args[0]) {
'installTo' {
Install-Module -InstallPath $args[1] -ModulePath $PsScriptRoot
}
'register' {
Register-Module "$PsScriptRoot"
}
default {
}
}

View File

@ -1,99 +0,0 @@
Function ConvertTo-Base64String {
<#
#>
[CmdletBinding(DefaultParameterSetName="FromString")]
param (
[Parameter(Position=1,ParameterSetName="FromString")]
[String] $String,
[Parameter(ParameterSetName="FromFile")]
[String] $Path,
[Parameter(ParameterSetName="FromFile")]
[Int] $ChunkSize = 5KB,
[Parameter(ParameterSetName="FromFile")]
[Switch] $OneChunk
)
switch($PSCmdlet.ParameterSetName) {
"FromString" {
[System.Text.Encoding]::UTF8.GetBytes($String)
[System.Convert]::ToBase64String($Bytes)
}
"FromFile" {
$FileStream = [IO.File]::Open($Path, [System.IO.FileMode]::Open)
$BytesToRead = $FileStream.Length
if ($OneChunk) {
$ChunkSize = $BytesToRead
}
$Bytes = New-Object Byte[] $ChunkSize
while ($BytesToRead -gt 0) {
if ($BytesToRead -lt $ChunkSize) {
$ChunkSize = $BytesToRead
$Bytes = New-Object Byte[] $ChunkSize
}
#Write-Host ("BytesToRead: {0}, ChunkSize: {1}" -f $BytesToRead, $ChunkSize )
$BytesRead = $FileStream.Read($Bytes, 0, $ChunkSize)
$BytesToRead -= $BytesRead
[System.Convert]::ToBase64String($Bytes)
}
$FileStream.Close()
}
}
}
Function ConvertFrom-Base64String {
<#
#>
[CmdletBinding(DefaultParameterSetName="ToByteArray")]
param (
[Parameter(Position=1,ValueFromPipeline=$true)]
[String] $Base64String,
[Parameter(ParameterSetName="ToFile")]
[String] $Path,
[Parameter(ParameterSetName="ToString")]
[Switch] $ToString
)
begin {
switch($PSCmdlet.ParameterSetName) {
"ToFile" {
if ([IO.File]::Exists($Path)) {
[IO.File]::Delete($Path)
}
$FileStream = [IO.File]::Open($Path, [IO.FileMode]::Append)
}
}
}
process {
foreach( $Line in ($Base64String -split '\n')) {
$Bytes = [System.Convert]::FromBase64String($Line)
switch($PSCmdlet.ParameterSetName) {
"ToFile" {
$FileStream.Write($Bytes, 0, $Bytes.Length)
}
"ToString" {
[System.Text.Encoding]::UTF8.GetString($Bytes)
}
"ToByteArray" {
$Bytes
}
}
}
}
end {
switch($PSCmdlet.ParameterSetName) {
"ToFile" {
$FileStream.Close()
}
}
}
}

View File

@ -1,388 +0,0 @@
Function Stop-Execution {
<#
.SYNOPSIS
Breaks execution with specified error code.
.DESCRIPTION
Function break script execution with error code provided. Error code may be 0 in case of non-error stop.
It also tries to parse ErrorRecord or Exception object (if provided) and logs this information.
#>
[CmdletBinding(DefaultParameterSetName="Exception")]
param (
[Parameter(Position=1,ParameterSetName="Exception")]
$InputObject = $null,
[Parameter(ParameterSetName="ErrorString")]
[String] $ExitString = "",
[Parameter(ParameterSetName="ErrorString")]
[Int] $ExitCode = 0,
[Parameter(ParameterSetName="ErrorString")]
[Switch] $Success
)
Function Exit-Function {
if ($ExitCode -eq 0) {
Write-LogInfo ( "STOP ({0}):`n{1}" -f $ExitCode, $ExitString )
}
else {
Write-LogFatal ( "STOP ({0}):`n{1}" -f $ExitCode, $ExitString )
}
Write-Log "__StopExecutionPreference__ = '$__StopExecutionPreference__'"
switch ("$__StopExecutionPreference__") {
"Exit" {
exit $ExitCode
}
"ThrowIfException" {
if ($InputObject -eq $null) {
exit $ExitCode
}
else {
throw $InputObject
}
}
"ThrowAlways" {
throw $InputObject
}
default {
throw "Unknown value for __StopExecutionPreference__: '$__StopExecutionPreference__'"
}
}
}
switch($PSCmdlet.ParameterSetName) {
"Exception" {
#----------
if ($InputObject -eq $null) {
$ExitString = "***** SCRIPT INTERRUPTED *****"
$ExitCode = 255
Exit-Function
}
#----------
#----------
try {
$ErrorRecord = [System.Management.Automation.ErrorRecord] $InputObject
<#
$ExitString = @"
$($ErrorRecord.ToString())
*** Invocation Info ***
$($ErrorRecord.InvocationInfo.PositionMessage)
*** CategoryInfo ***
$($ErrorRecord.CategoryInfo.ToString())
*** FullyQualifiedErrorId ***
$($ErrorRecord.FullyQualifiedErrorId.ToString())
*** ScriptStackTrace ***
$($ErrorRecord.ScriptStackTrace.ToString())
*** *** ***
"@
#>
$ExitString = Out-String -InputObject $InputObject
$ExitCode = 255
Exit-Function
}
catch {
$ErrorRecord = $null
Write-LogWarning "Unable to cast InputObject to [System.Management.Automation.ErrorRecord]"
}
#----------
#----------
try {
$Exception = [System.Exception] $InputObject
#$ExitString = $Exception.ToString()
$ExitString = Out-String -InputObject $InputObject
$ExitCode = 255
Exit-Function
}
catch {
$Exception = $null
Write-LogWarning "Unable to cast InputObject to [System.Exception]"
}
#----------
#----------
try {
$ExitString = Out-String -InputObject $InputObject
$ExitCode = 255
Exit-Function
}
catch {
Write-LogWarning "Unable to cast InputObject of type [$($InputObject.GetType())] to any of supported types."
}
#----------
}
"ErrorString" {
if ($Success) {
$ExitString = "Script stopped with NO ERROR."
$ExitCode = 0
}
Exit-Function
}
}
$ExitString = "Unknown error occured in Stop-Execution"
$ExitCode = 255
Exit-Function
}
Function Get-PasswordAsSecureString {
<#
.SYNOPSIS
Convert to / request password as secure string.
#>
[CmdletBinding()]
param (
[String] $Password = "",
[String] $Prompt = "Please enter password"
)
if ($Password -eq "") {
Read-Host -Prompt $Prompt -AsSecureString
}
else {
ConvertTo-SecureString -String "$Password" -AsPlainText -Force
}
}
Function New-Credential {
<#
.SYNOPSIS
Create new creadential object with username and password provided.
#>
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[String] $UserName,
[String] $Password
)
$SecurePassword = Get-PasswordAsSecureString -Password "$Password"
New-Object System.Management.Automation.PSCredential( "$UserName", $SecurePassword )
}
Function Invoke-WMSettingsChange {
if (-not ("win32.nativemethods" -as [type])) {
# Import SendMessageTimeout from Win32
Add-Type -Namespace Win32 -Name NativeMethods -MemberDefinition @"
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr SendMessageTimeout(
IntPtr hWnd, uint Msg, UIntPtr wParam, string lParam,
uint fuFlags, uint uTimeout, out UIntPtr lpdwResult);
"@
}
$HWND_BROADCAST = [IntPtr]0xFFFF
$WM_SETTINGCHANGE = 0x001A
$result = [UIntPtr]::Zero
# Notify all windows of environment block change
Write-Log "Executing 'SendMessageTimeout' ..."
$retval = [Win32.NativeMethods]::SendMessageTimeout($HWND_BROADCAST, $WM_SETTINGCHANGE,
[UIntPtr]::Zero, "Environment", 2, 5000, [ref] $result)
Write-Log "'SendMessageTimeout' returned '$retval' (non-zero is OK)"
}
Function Start-Program {
param (
[String] $FilePath,
[String[]] $ArgumentList = @(' '),
[Int] $Timeout = 0,
[Switch] $NoWait,
[Switch] $PassThru,
[String] $WorkingDir = (Get-Location).ProviderPath
)
trap {
Write-LogError $_.Exception.Message
return $null
}
Write-Log "Starting program: $FilePath $ArgumentList"
$ProcessStartInfo = New-Object System.Diagnostics.ProcessStartInfo
$ProcessStartInfo.FileName = $FilePath
$ProcessStartInfo.Arguments = $ArgumentList
$ProcessStartInfo.CreateNoWindow = $true
$ProcessStartInfo.RedirectStandardOutput = $true
$ProcessStartInfo.RedirectStandardError = $true
$ProcessStartInfo.UseShellExecute = $false
$ProcessStartInfo.WorkingDirectory = $WorkingDir
$Process = [System.Diagnostics.Process]::Start($ProcessStartInfo)
if ($NoWait) {
if ($PassThru) {
return $Process
}
else {
return $null
}
}
else {
if ($Timeout -eq 0) {
$Process.WaitForExit()
}
else {
$Process.WaitForExit($Timeout)
}
}
$ProcessResult = New-Object PSObject |
Add-Member -Name "ExitCode" -MemberType NoteProperty -Value $Process.ExitCode -PassThru |
Add-Member -Name "StdOut" -MemberType NoteProperty -Value $Process.StandardOutput.ReadToEnd() -PassThru |
Add-Member -Name "StdErr" -MemberType NoteProperty -Value $Process.StandardError.ReadToEnd() -PassThru
$Process = $null
Write-Log ( "STDOUT:`n{0}" -f $ProcessResult.StdOut )
Write-Log ":STDOUT"
Write-Log ( "STDERR:`n{0}" -f $ProcessResult.StdErr )
Write-Log ":STDERR"
Write-Log "Program has finished with exit code ($($ProcessResult.ExitCode))"
if ($PassThru) {
return $ProcessResult
}
else {
return $null
}
}
New-Alias -Name Exec -Value Start-Program
Function Backup-File {
param (
[String] $Path
)
$BackupFile = "$Path.bak"
if (-not [IO.File]::Exists($Path)) {
Write-LogError "Unable to backup file '$Path': file not exists."
return
}
if ([IO.File]::Exists($BackupFile)) {
try {
[IO.File]::Delete($BackupFile)
}
catch {
Write-LogError "Unable to delete existing .bak file '$BackupFile'."
return
}
}
Write-Log "Backing up file '$Path' to '$BackupFile'"
[IO.File]::Copy($Path, $BackupFile, $true)
}
Function Install-Module {
param (
[String] $InstallPath,
[String] $ModulePath,
[String] $ModuleName
)
if ($ModuleName -eq "") {
if ($ModulePath -eq "") {
Stop-Execution -ExitString "Don't know which module should be installed."
}
else {
$ModuleName = $ModulePath.Split("\")[-1]
}
}
if ($InstallPath -eq "") {
Stop-Execution -ExitString "To install the module destination path must be provided."
}
else {
Write-Log "Installing the module to '$InstallPath'"
$NewModulePath = [IO.Path]::Combine($InstallPath, $ModuleName)
if ([IO.Directory]::Exists($NewModulePath)) {
[IO.Directory]::Delete($NewModulePath, $true)
}
Copy-Item -Path $ModulePath -Destination $InstallPath -Recurse -Force -ErrorAction Stop
Update-PsModulePath -AddPath "$InstallPath"
}
}
Function Register-Module {
param (
[String] $ModulePath
)
$ModuleRoot = Split-Path -Path $ModulePath -Parent
Write-Log "Registering the module at '$ModuleRoot'"
Update-PsModulePath -AddPath "$ModuleRoot"
}
function Test-ModuleVersion {
<#
.SYNOPSIS
Test module version.
.DESCRIPTION
Function specified module (current module by default), and compares it's version to version provided.
Returned values:
* -2 : error occured
* -1 : module's version is lower than one provided
* 0 : module's version is equal to one provided
* 1 : module's version is greater than one provided
#>
param (
[String] $Name = "$__ModuleName",
[String] $Version
)
$ModuleVersion = (Get-Module -Name $Name -ListAvailable).Version
if ($ModuleVersion -eq $null) {
Write-Log "Module '$Name' not found."
return -2
}
try {
$RequiredVersion = [System.Version]::Parse($Version)
}
catch {
Write-Log "'$Version' is not a correct version string."
return -2
}
$ModuleVersion.CompareTo($RequiredVersion)
}

View File

@ -1,137 +0,0 @@
Function Initialize-Logger {
param (
[String] $ModuleName = $__ModuleName,
[String] $LogPath = $__DefaultLogPath
)
if (-not ("log4net.LogManager" -as [type])) {
$FileStream = ([System.IO.FileInfo] (Get-Item "$__ModulePath\log4net.dll")).OpenRead()
$AssemblyBytes = New-Object Byte[] $FileStream.Length
[Void] $FileStream.Read($AssemblyBytes, 0, $FileStream.Length)
$FileStream.Close()
[Void] [System.Reflection.Assembly]::Load($AssemblyBytes)
}
[log4net.GlobalContext]::Properties["LogPath"] = $LogPath
[log4net.GlobalContext]::Properties["ModuleName"] = $ModuleName
$script:__Logger = [log4net.LogManager]::GetLogger("PowerShell")
$Log4NetConfig = New-Object System.IO.FileInfo("$__ModulePath\log4net.config")
[log4net.Config.XmlConfigurator]::Configure($Log4NetConfig)
$__Logger.info("Logger initialized. Log file: '$LogPath'`n")
}
Function Out-LogInfo {
param (
[Parameter(ValueFromPipeline=$true)]
$InputObject,
[Switch] $EntireObject
)
process {
if ($EntireObject) {
$__Logger.info("`n$(Out-String -InputObject $InputObject)")
}
else {
foreach ($Object in $InputObject) {
$__Logger.info((Out-String -InputObject $Object))
}
}
}
}
New-Alias -Name Out-Log -Value Out-LogInfo
New-Alias -Name Write-Log -Value Out-LogInfo
Function Out-LogWarning {
param (
[Parameter(ValueFromPipeline=$true)]
$InputObject,
[Switch] $EntireObject
)
process {
if ($EntireObject) {
$__Logger.warn("`n$(Out-String -InputObject $InputObject)")
}
else {
foreach ($Object in $InputObject) {
$__Logger.warn((Out-String -InputObject $Object))
}
}
}
}
New-Alias -Name Write-LogWarning -Value Out-LogWarning
Function Out-LogError {
param (
[Parameter(ValueFromPipeline=$true)]
$InputObject,
[Switch] $EntireObject
)
process {
if ($EntireObject) {
$__Logger.error("`n$(Out-String -InputObject $InputObject)")
}
else {
foreach ($Object in $InputObject) {
$__Logger.error((Out-String -InputObject $Object))
}
}
}
}
New-Alias -Name Write-LogError -Value Out-LogError
Function Out-LogFatal {
param (
[Parameter(ValueFromPipeline=$true)]
$InputObject,
[Switch] $EntireObject
)
process {
if ($EntireObject) {
$__Logger.fatal("`n$(Out-String -InputObject $InputObject)")
}
else {
foreach ($Object in $InputObject) {
$__Logger.fatal((Out-String -InputObject $Object))
}
}
}
}
New-Alias -Name Write-LogFatal -Value Out-LogFatal
Function Out-LogDebug {
param (
[Parameter(ValueFromPipeline=$true)]
$InputObject,
[Switch] $EntireObject
)
process {
if ($EntireObject) {
$__Logger.debug("`n$(Out-String -InputObject $InputObject)")
}
else {
foreach ($Object in $InputObject) {
$__Logger.debug((Out-String -InputObject $Object))
}
}
}
}
New-Alias -Name Write-LogDebug -Value Out-LogDebug
Initialize-Logger

View File

@ -1,814 +0,0 @@
Function Set-LocalUserPassword {
param (
[String] $UserName,
[String] $Password,
[Switch] $Force
)
trap { Stop-Execution $_ }
if ((Get-WmiObject Win32_UserAccount -Filter "LocalAccount = 'True' AND Name='$UserName'") -eq $null) {
throw "Unable to find local user account '$UserName'"
}
if ($Force) {
Write-Log "Changing password for user '$UserName' to '*****'" # :)
([ADSI] "WinNT://./$UserName").SetPassword($Password) | Out-Null
}
else {
Write-LogWarning "You are trying to change the password for the user '$UserName'. To do this please run the command again with -Force parameter."
}
}
Function Set-AutoLogonCredentials {
param (
[String] $DomainName,
[String] $UserName,
[String] $Password
)
$KeyName = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
if ($DomainName -ne "") {
$UserName = "$DomainName\$UserName"
}
Write-Log "Setting AutoLogon credentials ..."
try {
[Microsoft.Win32.Registry]::SetValue($KeyName, "DefaultUserName", "$UserName", [Microsoft.Win32.RegistryValueKind]::String)
[Microsoft.Win32.Registry]::SetValue($KeyName, "DefaultPassword", "$Password", [Microsoft.Win32.RegistryValueKind]::String)
[Microsoft.Win32.Registry]::SetValue($KeyName, "AutoAdminLogon", "1", [Microsoft.Win32.RegistryValueKind]::String)
[Microsoft.Win32.Registry]::SetValue($KeyName, "ForceAutoLogon", "1", [Microsoft.Win32.RegistryValueKind]::String)
}
catch {
Write-LogError "FAILED"
return
}
Write-Log "SUCCESS"
}
Function Join-Domain {
<#
.SYNOPSIS
Executes "Join domain" action.
#>
param (
[String] $DomainName,
[String] $UserName,
[String] $Password,
[Switch] $AllowRestart
)
$Credential = New-Credential -UserName "$DomainName\$UserName" -Password $Password
# Add the computer to the domain
if (Test-ComputerName -DomainName $DomainName) {
#Stop-Execution -Success -ExitString "Computer already joined to domain '$DomainName'"
Write-LogWarning "Computer already joined to domain '$DomainName'"
}
else {
Write-Log "Joining computer to domain '$DomainName' ..."
Add-Computer -DomainName $DomainName -Credential $Credential -Force -ErrorAction Stop
if ($AllowRestart) {
Write-Log "Restarting computer ..."
Restart-Computer -Force
}
else {
#Stop-Execution -ExitCode 3010 -ExitString "Please restart the computer now."
Write-Log "Please restart the computer now."
}
}
}
Function Expand-Template {
param (
[String] $TemplateFile,
[String] $OutputFile,
[System.Collections.Hashtable] $ReplacementList,
[String] $Encoding = "Ascii"
)
if (-not [IO.File]::Exists($TemplateFile)) {
Write-Error "File '$TemplateFile' not exists"
return $null
}
if ([IO.File]::Exists($OutputFile)) {
[IO.File]::Delete($OutputFile)
}
Get-Content $TemplateFile -Encoding $Encoding |
ForEach-Object {
$Line = $_
foreach ($Key in $ReplacementList.Keys) {
$Line = $Line.Replace("%_$($Key)_%", $ReplacementList[$Key])
}
Add-Content -Path $OutputFile -Encoding $Encoding -Value $Line
}
}
Function Add-WindowsFeatureWrapper {
<#
.SYNOPSIS
Wraps Install-WindowsFeature function.
.DESCRIPTION
This function adds some logic to multiple feature installation.
It fails if any of required features fails.
It reports that reboot required if it is required, or restarts the computer.
#>
param (
[Parameter(Mandatory=$true)]
[String[]] $Name,
[Switch] $IncludeManagementTools,
[Switch] $AllowRestart,
[Switch] $NotifyRestart
)
$RestartNeeded = $false
foreach ($Feature in $Name) {
Write-Log "Installing feature '$Feature' ..."
$Action = Install-WindowsFeature `
-Name $Feature `
-IncludeManagementTools:$IncludeManagementTools `
-ErrorAction Stop
if ($Action.Success -eq $true) {
if ($Action.FeatureResult.RestartNeeded -eq $true) {
Write-LogWarning "Restart required"
$RestartNeeded = $true
}
Write-Log "Feature '$Feature' installed successfully"
}
else {
Stop-Execution "Failed to install feature '$Feature'"
}
}
if ($RestartNeeded) {
Write-Log "Restart required to finish feature(s) installation."
if ($AllowRestart) {
Write-Log "Restarting computer ..."
Restart-Computer -Force
}
elseif ($NotifyRestart) {
Stop-Execution -ExitCode 3010 -ExitString "Please restart the computer now."
}
}
}
Function Test-WmiReturnValue {
<#
.SYNOPSIS
Check the ReturnValue property of the object provided.
.DESCRIPTION
This funciton checks if ReturnValue property is equal to 0.
=== TODO ===
If it is not, then funtion should try to provide desctiption for the error code based on the WMI object type.
WMI object type must be provided explicitely.
#>
param (
[Parameter(ValueFromPipeline=$true,Mandatory=$true)]
$InputObject,
[String] $Type = ""
)
try {
$ReturnValue = $InputObject.ReturnValue
}
catch {
throw "Property 'ReturnValue' not found on this object"
}
if ($ReturnValue -eq 0) {
Write-Log "WMI operation completed successfully"
}
else {
throw "Operation failed with status code = $ReturnValue"
}
}
Function Set-NetworkAdapterConfiguration {
<#
.SYNOPSIS
Set network adapter configuration.
.DESCRIPTION
.EXAMPLE
PS> Set-NetworkAdapterConfiguration -MACAddress aa:bb:cc:dd:ee:ff -Auto
Convert "dynamic" parameters (DHCP) to "static" (manual) for network adapter with MAC address aa:bb:cc:dd:ee:ff
.EXAMPLE
PS> Set-NetworkAdapterConfiguration -MACAddress aa:bb:cc:dd:ee:ff -DNSServer "192.168.0.1","192.168.0.2"
Configure DNS servers list for network adapter with MAC address aa:bb:cc:dd:ee:ff
#>
param (
[String] $MACAddress = "",
[Parameter(ParameterSetName="ManualConfig")]
[String] $IPAddress = "",
[Parameter(ParameterSetName="ManualConfig")]
[String] $IPNetmask = "",
[Parameter(ParameterSetName="ManualConfig")]
[String[]] $IPGateway = @(),
[Parameter(ParameterSetName="ManualConfig")]
[String[]] $DNSServer = @(),
[Parameter(ParameterSetName="ManualConfig")]
[Switch] $FirstAvailable,
[String] $Name = "",
[Parameter(ParameterSetName="AutoConfig",Mandatory=$true)]
[Switch] $Auto,
[Parameter(ParameterSetName="AutoConfig")]
[Switch] $All
)
Write-Log "Configuring network adapter(s) ..."
:SetIPAddress switch($PSCmdlet.ParameterSetName) {
"AutoConfig" {
Write-Log "'auto' mode"
$IPv4RegExp = "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"
if ($All -eq $true) {
$Filter = { $_.AdapterTypeId -eq 0 }
$Name = ""
}
else {
$Filter = { $_.MACAddress -eq $MACAddress }
}
Get-WmiObject Win32_NetworkAdapter |
Where-Object $Filter |
ForEach-Object {
$NetworkAdapter = $_
$AdapterConfig = Get-WmiObject Win32_NetworkAdapterConfiguration |
Where-Object { $_.Index -eq $NetworkAdapter.DeviceId }
Write-Log "Configuring '$($NetworkAdapter.Name)' ..."
for ($i = 0; $i -lt $AdapterConfig.IPAddress.Length; $i++) {
if ($AdapterConfig.IPAddress[$i] -match $IPv4RegExp) {
$IPAddress = $AdapterConfig.IPAddress[$i]
$IPNetmask = $AdapterConfig.IPSubnet[$i]
$IPGateway = $AdapterConfig.DefaultIPGateway
$DNSServer = $AdapterConfig.DNSServerSearchOrder
Write-Log "Setting IP address ($IPAddress), netmask ($IPNetmask) ..."
$AdapterConfig.EnableStatic($IPAddress, $IPNetmask) | Out-Null
Write-Log "Setting default gateways ($IPGateway) ..."
$AdapterConfig.SetGateways($IPGateway) | Out-Null
Write-Log "Setting DNS servers ($DNSServer) ..."
$AdapterConfig.SetDNSServerSearchOrder($DNSServer) | Out-Null
}
}
Write-Log "'$($NetworkAdapter.Name)' configured"
}
}
"ManualConfig" {
Write-Log "'manual' mode"
if ( $FirstAvailable ) {
Write-Log "Selecting first available network adapter ..."
$NetworkAdapter = Get-WmiObject Win32_NetworkAdapter |
Where-Object { $_.AdapterTypeId -eq 0 } |
Select-Object -First 1
}
else {
$NetworkAdapter = Get-WmiObject Win32_NetworkAdapter |
Where-Object { $_.MACAddress -eq $MACAddress }
}
if ( $NetworkAdapter -eq $null ) {
Write-LogError "Network adapter with MAC = '$MACAddress' not found."
return
}
$AdapterConfig = Get-WmiObject Win32_NetworkAdapterConfiguration |
Where-Object { $_.Index -eq $NetworkAdapter.DeviceId }
if (($IPAddress -ne "") -and ($IPNetmask -ne "")) {
Write-Log "Configuring IP address / netmask for '$($NetworkAdapter.Name)' ..."
<#
for ($i = 0; $i -lt $AdapterConfig.IPAddress.Length; $i++)
{
if (($AdapterConfig.IPAddress[$i] -eq $IPAddress) -and ($AdapterConfig.IPSubnet[$i] -eq $IPNetmask))
{
Write-Log "There is an adapter with required configuration."
break SetIPAddress
}
}
#>
Write-Log "Setting IP address $IPAddress, netmask $IPNetmask"
$AdapterConfig.EnableStatic("$IPAddress", "$IPNetmask") | Out-Null
Write-Log "IP address configured."
}
if ($IPGateway.Count -gt 0) {
Write-Log "Configuring IP gateway for '$($NetworkAdapter.Name)' ..."
$AdapterConfig.SetGateways($IPGateway) | Out-Null
Write-Log "IP gateway configured."
}
if ($DNSServer.Count -gt 0) {
Write-Log "Configuring DNS server(s) for '$($NetworkAdapter.Name)' ..."
$AdapterConfig.SetDNSServerSearchOrder($DNSServer) | Out-Null
Write-Log "DNS configured."
}
}
}
if ($Name -ne "") {
Write-Log "Changing adapter name '$($NetworkAdapter.NetConnectionId)' --> '$Name'"
$NetworkAdapter.NetConnectionId = "$Name"
$NetworkAdapter.Put() | Out-Null
}
}
Function Show-EthernetNetworkAdapters {
Get-WmiObject Win32_NetworkAdapter -Filter "PhysicalAdapter = 'True' AND AdapterTypeId = '0'" |
Select-Object 'Index','MACAddress','NetConnectionId'
}
Function Test-ComputerName {
<#
.SYNOPSIS
Test if computer name is set, and the computer belongs to specified domain / workgroup.
.DESCRIPTION
Function tests the following conditions:
* the computer name is equal to the provided one
* the computer is a part of domain
* the computer belongs to the specified domain
* the computer belongs to the specified workgroup
Multiple checks are logically ANDed.
#>
[CmdletBinding()]
param (
[String] $ComputerName,
[String] $DomainName,
[String] $WorkgroupName,
[Switch] $PartOfDomain
)
process {
$ComputerSystem = Get-WmiObject Win32_ComputerSystem
if (($ComputerName -ne "") -and ($ComputerSystem.Name -ne "$ComputerName")) {
Write-Error "ComputerName is not equal to '$ComputerName'"
return $false
}
if (($DomainName -ne "") -and ($ComputerSystem.Domain -ne "$DomainName")) {
Write-Error "DomainName is not equal to '$DomainName'"
return $false
}
if (($WorkgroupName -ne "") -and ($ComputerSystem.Workgroup -ne "$WorkgroupName")) {
Write-Error "WorkgroupName is not equal to '$WorkgroupName'"
return $false
}
if (($PartOfDOmain -eq $true) -and ($ComputerSystem.PartOfDomain -eq $false)) {
Write-Error "Computer is not the part of any domain."
return $false
}
return $true
}
}
Function Set-ComputerName {
param (
[String] $Name
)
# Rename the computer
if ($Name -ne "") {
if (Test-ComputerName -ComputerName $Name) {
Stop-Execution -Success -ExitString "Computer name already configured"
}
else {
Write-Log "Renaming computer to '$Name'"
Rename-Computer -NewName $NewName -Force -ErrorAction Stop
Stop-Execution -ExitCode 3010 -ExitString "Please restart the computer now"
}
}
}
Function Resolve-LdapDnsName {
param (
[String] $DomainName
)
Resolve-DNSName -Type "SRV" -Name "_ldap._tcp.dc._msdcs.$DomainName" |
Where-Object { $_.Type -eq "A" } |
Select-Object -Property Name,IPAddress
}
Function Wait-LdapServerAvailable {
param (
[String] $DomainName,
[Int] $PingSeqCountThreshold = 10,
[Int] $PingSeqPerHostThreshold = 5
)
$LdapServerList = @( Resolve-LdapDnsName $DomainName )
Write-Log @( "Ldap server list:", ( $LdapServerList | Out-String ) )
:MainLoop foreach ($LdapServer in $LdapServerList) {
$PingSeqCount = 0
$PingSeqPerHost = 0
while ($PingSeqPerHost -lt $PingSeqPerHostThreshold) {
if (Test-Connection -ComputerName $LdapServer.IpAddress -Count 1 -Quiet) {
Write-Log "Ping '$($LdapServer.Name)' OK"
$PingSeqCount++
}
else {
Write-Log "Ping '$($LdapServer.Name)' FAILED"
$PingSeqCount = 0
$PingSeqPerHost++
}
if ($PingSeqCount -ge $PingSeqCountThreshold) {
Write-Log "Returning true"
return $true
}
Start-Sleep -Seconds 1
}
}
Write-Log "Returning false"
return $false
}
Function Get-ConfigDriveObject {
[CmdletBinding()]
param (
[Parameter(ParameterSetName="MetaData")]
[Switch] $MetaData,
[Parameter(ParameterSetName="UserData")]
[Switch] $UserData,
[Parameter(ParameterSetName="CustomObject")]
[String] $CustomObject,
[String] $Path = "openstack/latest"
)
$ConfigDrivePrefix = "http://169.254.169.154/$Path"
try {
switch($PSCmdlet.ParameterSetName) {
"MetaData" {
$ConfigDriveObjectUrl = "$ConfigDrivePrefix/meta_data.json"
$MetaData = Invoke-WebRequest $ConfigDriveObjectUrl
ConvertFrom-Json $MetaData.Content
}
"UserData" {
$ConfigDriveObjectUrl = "$ConfigDrivePrefix/user_data"
$UserData = Invoke-WebRequest $ConfigDriveObjectUrl
$UserData.Content
}
"CustomObject" {
$ConfigDriveObjectUrl = "$ConfigDrivePrefix/$CustomObject"
$CustomObject = Invoke-WebRequest $ConfigDriveObjectUrl
$CustomObject.Content
}
}
}
catch {
Write-Error "Unable to retrieve object from 'ConfigDriveObjectUrl'"
return $null
}
}
Function Update-AgentConfig {
param (
[String] $RootPath = "C:\Keero\Agent"
)
try {
$MetaData = Get-ConfigDriveObject -MetaData -ErrorAction Stop
if ($MetaData.meta -ne $null) {
Stop-Service "Keero Agent" -Force
Expand-Template -TemplateFile "$RootPath\WindowsAgent.exe.config.template" -OutputFile "$RootPath\WindowsAgent.exe.config" -ReplacementList $MetaData.meta
Start-Service "Keero Agent"
}
}
catch {
Write-LogError "Failed to update agent configuration"
}
}
Function Update-PsModulePath {
param (
[String] $AddPath = ""
)
$NewPsModulePath = (
@([Environment]::GetEnvironmentVariable("PsModulePath", [EnvironmentVariableTarget]::Machine) -split ";") + @($AddPath) `
| Select-Object -Unique
) -join ';'
[Environment]::SetEnvironmentVariable("PsModulePath", $NewPsModulePath, [EnvironmentVariableTarget]::Machine)
Invoke-WMSettingsChange
}
Function Get-ModuleHelp {
param (
[String] $ModuleName = $__ModuleName,
[String] $Path = "",
[Switch] $File,
[Int] $Width = 80
)
$sb = {
$Module = Get-Module $ModuleName
"`n"
"Module: $($Module.Name)"
"Module version: $($Module.Version)"
"`n"
"{0} Module Description {0}" -f ('=' * 30)
"`n"
Get-Help "about_$($Module.Name)" | Out-String -Width $Width
"{0} Exported Functions {0}" -f ('=' * 30)
"`n"
foreach ($CommandName in $Module.ExportedCommands.Keys) {
'-' * 80
Get-Help -Name $CommandName -Detailed | Out-String -Width $Width
}
}
if (($File) -and ($Path -eq "")) {
$Path = [IO.Path]::GetTempFileName()
}
if ($Path -ne "") {
& $sb | Out-File -FilePath $Path -Force
}
else {
& $sb | Out-Default
}
if ($File) {
notepad.exe "$Path"
}
}
Function New-ModuleTemplate {
param (
[Parameter(Mandatory=$true)]
[String] $Name,
[String] $Path = "$($Env:USERPROFILE)\Documents\WindowsPowerShell\Modules",
[Switch] $Force
)
if ([IO.Directory]::Exists("$Path\$Name")) {
if ($Force) {
[IO.Directory]::Delete("$Path\$Name", $true)
}
else {
Write-Error "Folder '$Path\$Name' already exists. Remove it manually or specify -Force switch."
return
}
}
[IO.Directory]::CreateDirectory("$Path\$Name")
[IO.Directory]::CreateDirectory("$Path\$Name\en-US")
[IO.Directory]::CreateDirectory("$Path\$Name\include")
Set-Content -Path "$Path\$Name\en-US\about_$Name.help.txt" -Value @'
'@
Set-Content -Path "$Path\$Name\Config.ps1" -Value @'
$script:__ModulePath = $PsScriptRoot
$script:__ModuleName = $PsScriptRoot.Split("\")[-1]
$script:__DefaultLogPath = [IO.Path]::Combine([IO.Path]::GetTempPath(), "PowerShell_$__ModuleName.log")
$global:__StopExecutionExitsSession__ = $false
'@
Set-Content -Path "$Path\$Name\$Name.psm1" -Value @'
# Import config first
. "$PsScriptRoot\Config.ps1"
# Import functions from 'Include' subfolder
Get-ChildItem "$PsScriptRoot\Include" -Filter "*.ps1" |
ForEach-Object {
. "$($_.FullName)"
}
Export-ModuleMember -Function * -Alias *
Initialize-Logger -ModuleName $__ModuleName -LogPath $__DefaultLogPath
Write-Log "Module loaded from '$PsScriptRoot'"
'@
New-ModuleManifest `
-Path "$Path\$Name\$Name.psd1" `
-ModuleToProcess "$Name.psm1" `
-RequiredModules "CoreFunctions"
}
function New-SqlServerConnection {
param (
[String] $ServerName,
[String] $UserName = '',
[String] $Password = '',
$Credentials,
[Switch] $SqlAuth
)
if ($Credentials -eq $null) {
if ($UserName -eq '') {
throw "User name must be provided in order to create credentials object!"
}
$Credentials = New-Credential -UserName $UserName -Password $Password
}
$Server = New-Object `
-TypeName Microsoft.SqlServer.Management.Smo.Server `
-ArgumentList $ServerName
$LoginName = $Credentials.UserName -replace("^\\", "")
try {
if ($SqlAuth) {
$Server.ConnectionContext.set_LoginSecure($false)
$Server.ConnectionContext.set_Login($LoginName)
$Server.ConnectionContext.set_SecurePassword($Credentials.Password)
}
else {
throw "Not implemented!"
}
}
catch {
return $null
}
$Server
}
function Import-SqlServerAssemblies {
<#
.SYNOPSIS
Import assemblies required to work with Sql Server instance from PowerShell
.DESCRIPTION
Possible assembly list:
"Microsoft.SqlServer.Management.Common"
"Microsoft.SqlServer.Smo"
"Microsoft.SqlServer.Dmf"
"Microsoft.SqlServer.Instapi"
"Microsoft.SqlServer.SqlWmiManagement"
"Microsoft.SqlServer.ConnectionInfo"
"Microsoft.SqlServer.SmoExtended"
"Microsoft.SqlServer.SqlTDiagM"
"Microsoft.SqlServer.SString"
"Microsoft.SqlServer.Management.RegisteredServers"
"Microsoft.SqlServer.Management.Sdk.Sfc"
"Microsoft.SqlServer.SqlEnum"
"Microsoft.SqlServer.RegSvrEnum"
"Microsoft.SqlServer.WmiEnum"
"Microsoft.SqlServer.ServiceBrokerEnum"
"Microsoft.SqlServer.ConnectionInfoExtended"
"Microsoft.SqlServer.Management.Collector"
"Microsoft.SqlServer.Management.CollectorEnum"
"Microsoft.SqlServer.Management.Dac"
"Microsoft.SqlServer.Management.DacEnum"
"Microsoft.SqlServer.Management.Utility"
.LINKS
http://msdn.microsoft.com/en-us/library/cc281962%28v=sql.105%29.aspx
#>
$AssemblyList = @(
"Microsoft.SqlServer.Smo"
"Microsoft.SqlServer.SmoExtended"
)
foreach ($asm in $AssemblyList) {
[System.Reflection.Assembly]::LoadWithPartialName($asm) | Out-Null
}
}
function Import-SqlServerProvider {
$SqlPsReg="HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.SqlServer.Management.PowerShell.sqlps"
if (Get-ChildItem $SqlPsReg -ErrorAction "SilentlyContinue") {
throw "SQL Server Provider for Windows PowerShell is not installed."
}
else {
$Item = Get-ItemProperty $SqlPsReg
$SqlPsPath = [System.IO.Path]::GetDirectoryName($Item.Path)
}
#
# Set mandatory variables for the SQL Server provider
#
$global:SqlServerMaximumChildItems = 0
$global:SqlServerConnectionTimeout = 30
$global:SqlServerIncludeSystemObjects = $false
$global:SqlServerMaximumTabCompletion = 1000
#
# Load the snapins, type data, format data
#
Push-Location
Set-Location $sqlpsPath
Add-PSSnapin SqlServerCmdletSnapin100
Add-PSSnapin SqlServerProviderSnapin100
Update-TypeData -PrependPath SQLProvider.Types.ps1xml
Update-FormatData -PrependPath SQLProvider.Format.ps1xml
Pop-Location
}

View File

@ -1,69 +0,0 @@
[Void] [System.Reflection.Assembly]::LoadFrom("$__ModulePath\Ionic.Zip.dll")
Function Compress-Folder {
<#
#>
[CmdLetBinding()]
param (
[Parameter(Mandatory=$true)]
[String] $Path,
[String] $ZipFile = "",
[Switch] $TempFile,
[Switch] $ContentOnly
)
if (-not [IO.Directory]::Exists($Path)) {
Write-LogError "Directory '$Path' not found."
return
}
if ($TempFile) {
$ZipFile = [IO.Path]::GetTempFileName()
}
if ($ZipFile -eq "") {
$ZipFile = "$Path.zip"
}
if ([IO.File]::Exists($ZipFile)) {
[IO.File]::Delete($ZipFile)
}
$zip = New-Object Ionic.Zip.ZipFile
if ($ContentOnly) {
[Void] $zip.AddDirectory($Path)
}
else {
[Void] $zip.AddDirectory($Path, (Split-Path -Path $Path -Leaf))
}
$zip.Save($ZipFile)
$zip.Dispose()
return $ZipFile
}
Function Expand-Zip {
<#
#>
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[String] $Path,
[String] $Destination
)
if (-not [IO.File]::Exists($Path)) {
Write-LogError "File not found '$Path'"
return
}
$zip = [Ionic.Zip.ZipFile]::Read($Path)
$zip.ExtractAll($Destination, [Ionic.Zip.ExtractExistingFileAction]::OverwriteSilently)
$zip.Dispose()
}

View File

@ -1,42 +0,0 @@
<log4net>
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender" >
<param name="File" type="log4net.Util.PatternString" value="%property{LogPath}" />
<param name="AppendToFile" value="true" />
<param name="RollingStyle" value="Size" />
<param name="MaxSizeRollBackups" value="100" />
<param name="MaximumFileSize" value="1024KB" />
<param name="StaticLogFileName" value="true" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%date [%-5level] [%property{ModuleName}] %message" />
</layout>
</appender>
<appender name="ColoredConsoleAppender" type="log4net.Appender.ColoredConsoleAppender">
<mapping>
<level value="error" />
<foreColor value="Red, HighIntensity" />
</mapping>
<mapping>
<level value="warn" />
<foreColor value="Yellow, HighIntensity" />
</mapping>
<mapping>
<level value="info" />
<foreColor value="Green, HighIntensity" />
</mapping>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%-5level] [%property{ModuleName}] %message" />
</layout>
</appender>
<!--root>
<level value="info" />
</root-->
<logger name="PowerShell" additivity="false">
<!--level value="info" /-->
<appender-ref ref="ColoredConsoleAppender" />
<appender-ref ref="RollingFileAppender" />
</logger>
</log4net>

View File

@ -1,11 +0,0 @@
[DEFAULT]
username=Admin
groups=Administrators
inject_user_password=false
network_adapters=
config_drive_raw_hdd=false
config_drive_cdrom=false
verbose=true
logdir=C:\Program Files (x86)\Cloudbase Solutions\Cloudbase-Init\log\
logfile=cloudbase-init.log
plugins=cloudbaseinit.plugins.windows.userdata.UserDataPlugin

View File

@ -1,37 +0,0 @@
import codecs
from cloudbaseinit.osutils.factory import *
from cloudbaseinit.plugins.base import *
from cloudbaseinit.openstack.common import log as logging
opts = [
cfg.StrOpt('agent_config_file', default='C:\\Keero\\Agent\\WindowsAgent.exe.config', help='')
]
CONF = cfg.CONF
CONF.register_opts(opts)
LOG = logging.getLogger(__name__)
class SetHostNamePlugin(BasePlugin):
def execute(self, service):
meta_data = service.get_meta_data('openstack')
if 'meta' not in meta_data:
LOG.debug("Section 'meta' not found in metadata")
return False
if 'agent_config_xml' not in meta_data['meta']:
LOG.debug("Config for agent not found in metadata section")
return False
try:
configFile=codecs.open(CONF.agent_config_file, encoding='utf-8', mode='w+')
configFile.write(meta_data['meta']['agent_config_xml'])
configFile.close()
except:
LOG.error("Unable to update agent file.")
return False
return True

View File

@ -1,20 +0,0 @@
from cloudbaseinit.osutils.factory import *
from cloudbaseinit.plugins.base import *
from cloudbaseinit.openstack.common import log as logging
LOG = logging.getLogger(__name__)
class SetHostNamePlugin(BasePlugin):
def execute(self, service):
meta_data = service.get_meta_data('openstack')
if 'name' not in meta_data:
LOG.debug('Name not found in metadata')
return False
osutils = OSUtilsFactory().get_os_utils()
new_host_name = meta_data['name'].replace('.', '-')
return osutils.set_host_name(new_host_name)

View File

@ -1,119 +0,0 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import re
import tempfile
import uuid
import email
import tempfile
import os
import errno
from cloudbaseinit.openstack.common import cfg
from cloudbaseinit.openstack.common import log as logging
from cloudbaseinit.osutils.factory import *
from cloudbaseinit.plugins.base import *
LOG = logging.getLogger(__name__)
opts = [
cfg.StrOpt('user_data_folder', default='cloud-data',
help='Specifies a folder to store multipart data files.'),
]
CONF = cfg.CONF
CONF.register_opts(opts)
class UserDataPlugin():
def __init__(self, cfg=CONF):
self.cfg = cfg
self.msg = None
return
def execute(self, service):
user_data = service.get_user_data('openstack')
if not user_data:
return False
LOG.debug('User data content:\n%s' % user_data)
if user_data.startswith('Content-Type: multipart'):
for part in self.parse_MIME(user_data):
self.process_part(part)
else:
self.handle(user_data)
return
def process_part(self, part):
if part.get_filename() == 'cfn-userdata':
self.handle(part.get_payload())
return
def parse_MIME(self, user_data):
folder = self.cfg.user_data_folder
self.create_folder(folder)
self.msg = email.message_from_string(user_data)
return self.msg.walk()
def create_folder(self, folder):
try:
os.mkdir(folder)
except os.OSError, e:
if e.errno != errno.EEXIST:
raise e
return
def handle(self, user_data):
osutils = OSUtilsFactory().get_os_utils()
target_path = os.path.join(tempfile.gettempdir(), str(uuid.uuid4()))
if re.search(r'^rem cmd\s', user_data, re.I):
target_path += '.cmd'
args = [target_path]
shell = True
elif re.search(r'^#!', user_data, re.I):
target_path += '.sh'
args = ['bash.exe', target_path]
shell = False
elif re.search(r'^#ps1\s', user_data, re.I):
target_path += '.ps1'
args = ['powershell.exe', '-ExecutionPolicy', 'RemoteSigned',
'-NonInteractive', target_path]
shell = False
else:
# Unsupported
LOG.warning('Unsupported user_data format')
return False
try:
with open(target_path, 'wb') as f:
f.write(user_data)
(out, err, ret_val) = osutils.execute_process(args, shell)
LOG.info('User_data script ended with return code: %d' % ret_val)
LOG.debug('User_data stdout:\n%s' % out)
LOG.debug('User_data stderr:\n%s' % err)
except Exception, ex:
LOG.warning('An error occurred during user_data execution: \'%s\'' % ex)
finally:
if os.path.exists(target_path):
os.remove(target_path)
return False

View File

@ -1,24 +0,0 @@
Import-Module CoreFunctions
$ModuleBase = "C:\Keero\Modules"
$NewModule_Name = "ModuleName"
$NewModule_Base64 = @'
%BASE64_STRINGS%
'@
$AgentConfig_Path = "C:\Keero\Agent\WindowsAgent.exe.config"
$AgentConfig_Base64 = @'
%AGENT_CONFIG_BASE64%
'@
ConvertFrom-Base64String -Base64String $NewModule_Base64 -Path "$ModuleBase\$NewModule_Name.zip"
Remove-Item -Path "$ModuleBase\$NewModule_Name" -Recurse -Force
Expand-Zip -Path "$ModuleBase\$NewModule_Name.zip" -Destination "$ModuleBase\$NewModule_Name"
Remove-Item -Path $AgentConfig_Path -Force
ConvertFrom-Base64String -Base64String $NewModule_Base64 -Path $AgentConfig_Path

View File

@ -1,51 +0,0 @@
# Devstack's config file for COMPUTE intallation
lab_id=102
lab_password=swordfish
lab_controller=172.18.124.100
SERVICE_HOST=$lab_controller
HOST_IP=172.18.124.${lab_id}
MULTI_HOST=1
FLAT_INTERFACE=eth1
#PUBLIC_INTERFACE=eth0.261
FIXED_RANGE=192.168.102.0/24
FIXED_NETWORK_SIZE=254
FLOATING_RANGE=172.18.124.228/27
MYSQL_HOST=$lab_controller
RABBIT_HOST=$lab_controller
GLANCE_HOSTPORT=$lab_controller:9292
KEYSTONE_AUTH_HOST=$lab_controller
KEYSTONE_SERVICE_HOST=$lab_controller
VNCSERVER_LISTEN=$HOST_IP
VNCSERVER_PROXYCLIENT_ADDRESS=$HOST_IP
ADMIN_PASSWORD=$lab_password
MYSQL_PASSWORD=$lab_password
RABBIT_PASSWORD=$lab_password
SERVICE_PASSWORD=$lab_password
SERVICE_TOKEN=tokentoken
ENABLED_SERVICES=n-cpu,n-net,n-api,n-vol,n-novnc
SCREEN_LOGDIR=/opt/stack/log/
LOGFILE=$SCREEN_LOGDIR/stack.sh.log
API_RATE_LIMIT=False
EXTRA_OPTS=(force_config_drive=true libvirt_images_type=qcow2 force_raw_images=false sql_connection=mysql://root:${MYSQL_PASSWORD}@${MYSQL_HOST}/nova?charset=utf8)

View File

@ -1,45 +0,0 @@
# Devstack's localrc for CONTROLLER installation
lab_id=100
lab_password=swordfish
HOST_IP=172.18.124.${lab_id}
FLAT_INTERFACE=eth1
#PUBLIC_INTERFACE=eth0.261
FIXED_RANGE=192.168.102.0/24
FIXED_NETWORK_SIZE=254
PUBLIC_RANGE=172.18.124.228/27
ADMIN_PASSWORD=$lab_password
MYSQL_PASSWORD=$lab_password
RABBIT_PASSWORD=$lab_password
SERVICE_PASSWORD=$lab_password
SERVICE_TOKEN=tokentoken
disable_service n-cpu
disable_service n-vol
ENABLED_SERVICES+=,heat,h-api,h-api-cfn,h-api-cw,h-eng
ENABLED_SERVICES+=,conductor,portas
SCREEN_LOGDIR=/opt/stack/log/
LOGFILE=$SCREEN_LOGDIR/stack.sh.log
API_RATE_LIMIT=False
MULTI_HOST=1
EXTRA_OPTS=(force_config_drive=true libvirt_images_type=qcow2 force_raw_images=false)

View File

@ -1,28 +0,0 @@
lab_id=101
lab_password=swordfish
HOST_IP=172.18.124.${lab_id}
#PUBLIC_INTERFACE=eth1
FIXED_RANGE=10.0.${lab_id}.0/24
NETWORK_GATEWAY=10.0.${lab_id}.1
#PUBLIC_INTERFACE=eth0
FLAT_INTERFACE=eth1
ADMIN_PASSWORD=$lab_password
MYSQL_PASSWORD=$lab_password
RABBIT_PASSWORD=$lab_password
SERVICE_PASSWORD=$lab_password
SERVICE_TOKEN=tokentoken
ENABLED_SERVICES+=,heat,h-api,h-api-cfn,h-api-cw,h-eng
ENABLED_SERVICES+=,conductor,portas
LOGFILE=/opt/stack/devstack/stack.sh.log
SCREEN_LOGDIR=/opt/stack/log/
#SCREEN_LOGDIR=/dev/null
API_RATE_LIMIT=False
EXTRA_OPTS=(force_config_drive=true libvirt_images_type=qcow2 force_raw_images=false)

View File

@ -1,148 +0,0 @@
#!/bin/bash
# Checks an environment variable is not set or has length 0 OR if the
# exit code is non-zero and prints "message" and exits
# NOTE: env-var is the variable name without a '$'
# die_if_not_set env-var "message"
function die_if_not_set() {
local exitcode=$?
set +o xtrace
local evar=$1; shift
if ! is_set $evar || [ $exitcode != 0 ]; then
if [[ -z "$1" ]] ; then
die "Env var '$evar' is not set!"
else
die $@
fi
fi
}
function restart_service {
while [[ -n "$1" ]] ; do
_echo "Restarting service '$1' ..."
sudo service $1 restart
shift 1
done
}
function move_mysql_data_to_ramdrive {
# Moving MySQL database to tmpfs
#-------------------------------
if [[ $(trueorfalse True $MYSQL_DB_TMPFS) = "True" ]] ; then
die_if_not_set MYSQL_DB_TMPFS_SIZE
mount_dir=/var/lib/mysql
sudo -s << EOF
echo "Stopping MySQL Server"
service mysql stop
umount $mount_dir
mount -t tmpfs -o size=$MYSQL_DB_TMPFS_SIZE tmpfs $mount_dir
chmod 700 $mount_dir
chown mysql:mysql $mount_dir
mysql_install_db
/usr/bin/mysqld_safe --skip-grant-tables &
sleep 5
EOF
sudo mysql << EOF
FLUSH PRIVILEGES;
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('swordfish');
SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('swordfish');
EOF
sudo -s << EOF
killall mysqld
sleep 5
echo "Starting MySQL Server"
service mysql start
EOF
else
_echo "MYSQL_DB_TMPFS = '$MYSQL_DB_TMPFS'"
fi
#-------------------------------
}
function move_nova_cache_to_ramdrive {
# Moving nova images cache to tmpfs
#----------------------------------
if [[ $(trueorfalse True $NOVA_CACHE_TMPFS) = "True" ]] ; then
die_if_not_set NOVA_CACHE_TMPFS_SIZE
mount_dir=/opt/stack/data/nova/instances
sudo -s << EOF
umount $mount_dir
mount -t tmpfs -o size=$NOVA_CACHE_TMPFS_SIZE tmpfs $mount_dir
chmod 775 $mount_dir
chown stack:stack $mount_dir
EOF
else
_echo "NOVA_CACHE_TMPFS = '$NOVA_CACHE_TMPFS'"
fi
#----------------------------------
}
function check_if_folder_exists {
if [[ ! -d "$1" ]] ; then
_echo "Folder '$1' not exists!"
return 1
fi
return 0
}
function validate_install_mode {
case $INSTALL_MODE in
'standalone')
check_if_folder_exists "$SCRIPTS_DIR/standalone" || exit
;;
'multihost')
check_if_folder_exists "$SCRIPTS_DIR/controller" || exit
check_if_folder_exists "$SCRIPTS_DIR/compute" || exit
;;
'controller')
check_if_folder_exists "$SCRIPTS_DIR/controller" || exit
;;
'compute')
check_if_folder_exists "$SCRIPTS_DIR/compute" || exit
;;
*)
_echo "Wrong install mode '$INSTALL_MODE'"
exit
;;
esac
}
function update_devstack_localrc {
local $__install_mode=$1
[[ -z "$__install_mode" ]] \
&& die "Install mode for update_devstack_localrc not provided!"
# Replacing devstack's localrc config
#------------------------------------
devstack_localrc="$SCRIPTS_DIR/$__install_mode/devstack.localrc"
if [[ -f $devstack_localrc ]] ; then
rm -f "$DEVSTACK_DIR/localrc"
cp $devstack_localrc "$DEVSTACK_DIR/localrc"
else
_echo "File '$devstack_localrc' not found!"
fi
#------------------------------------
}
function _echo {
echo "[$(hostname)] $@"
}

View File

@ -1,21 +0,0 @@
#!/bin/bash
SCRIPTS_DIR=$( cd $( dirname "$0" ) && pwd )
source $SCRIPTS_DIR/localrc
groupadd stack
useradd -g stack -s /bin/bash -m stack
echo 'stack ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/stack
chmod 0440 /etc/sudoers.d/stack
mkdir -p $DEVSTACK_INSTALL_DIR
chmod stack:stack $DEVSTACK_INSTALL_DIR
sudo -u stack << EOF
cd
rm -rf devstack
git clone git://github.com/openstack-dev/devstack.git
EOF

View File

@ -1,20 +0,0 @@
#!/bin/bash
DEVSTACK_DIR=/home/stack/devstack
DEVSTACK_INSTALL_DIR=/opt/stack
MYSQL_DB_TMPFS=true
MYSQL_DB_TMPFS_SIZE=128M
NOVA_CACHE_TMPFS=true
NOVA_CACHE_TMPFS_SIZE=24G
GLANCE_IMAGE_LIST=""
COMPUTE_NODE_LIST="172.18.124.102"
#======================================
if [[ -d "$DEVSTACK_DIR" ]] ; then
source $DEVSTACK_DIR/openrc admin admin
fi
source $SCRIPTS_DIR/functions.sh

View File

@ -1,109 +0,0 @@
#!/bin/bash
if [[ -z "$1" ]] ; then
SCRIPTS_DIR=$( cd $( dirname "$0" ) && pwd )
source $SCRIPTS_DIR/localrc
fi
function glance_image_create {
local __image_path=$1
if [[ -z "$__image_path" ]] ; then
echo "Image path is missed!"
return
fi
local __image_name=${__image_path##*/}
__image_name=${__image_name%.*}
echo "Importing image '$__image_name' into Glance ..."
glance image-delete "$__image_name"
if [[ ^http =~ $__image_path]] ; then
glance image-create \
--name "$__image_name" \
--disk-format qcow2 \
--container-format bare \
--is-public true \
--copy-from "$__image_path"
else
glance image-create \
--name "$__image_name" \
--disk-format qcow2 \
--container-format bare \
--is-public true \
--file "$__image_path"
fi
}
# Executing post-stack actions
#===============================================================================
if [[ ,$INSTALL_MODE, =~ ',standalone,compute,' ]] ; then
echo "Adding iptables rule to allow Internet access from instances..."
__iptables_rule="POSTROUTING -t nat -s '$FIXED_RANGE' ! -d '$FIXED_RANGE' -j MASQUERADE"
sudo iptables -C $__iptables_rule
if [[ $? == 0 ]] ; then
echo "Iptables rule already exists."
else
sudo iptables -A $__iptables_rule
fi
fi
if [[ $INSTALL_MODE == 'compute' ]] ; then
return
fi
if [[ -z "$(sudo rabbitmqctl list_users | grep keero)" ]] ; then
echo "Adding RabbitMQ 'keero' user"
sudo rabbitmqctl add_user keero keero
else
echo "User 'Keero' already exists."
fi
if [[ -z "$(sudo rabbitmq-plugins list -e | grep rabbitmq_management)" ]] ; then
echo "Enabling RabbitMQ management plugin"
sudo rabbitmq-plugins enable rabbitmq_management
echo "Restarting RabbitMQ ..."
restart_service rabbitmq-server
else
echo "RabbitMQ management plugin already enabled."
fi
echo "* Removing nova flavors ..."
for id in $(nova flavor-list | awk '$2 ~ /[[:digit:]]/ {print $2}') ; do
echo "** Removing flavor '$id'"
nova flavor-delete $id
done
echo "* Creating new flavors ..."
nova flavor-create m1.small auto 768 40 1
nova flavor-create m1.medium auto 1024 40 1
nova flavor-create m1.large auto 1280 40 2
echo "* Creating security group rules ..."
nova secgroup-add-rule default tcp 1 65535 0.0.0.0/0
nova secgroup-add-rule default udp 1 65535 0.0.0.0/0
nova secgroup-add-rule default icmp 0 8 0.0.0.0/0
if [[ -z "$(nova keypair-list | grep keero_key)" ]] ; then
echo "Creating keypair 'keero_key' ..."
nova keypair-add keero_key
else
echo "Keypair 'keero_key' already exists"
fi
#===============================================================================
for $image in $GLANCE_IMAGE_LIST ; do
glance_image_create "$image"
done

View File

@ -1,36 +0,0 @@
#!/bin/bash
if [[ -z "$1" ]] ; then
SCRIPTS_DIR=$( cd $( dirname "$0" ) && pwd )
source $SCRIPTS_DIR/localrc
fi
#Remove certificates
echo "* Removing old certificate files"
for file in $(sudo find $DEVSTACK_DIR/accrc/ -type f -regex ".+.pem.*") ; do
echo "Removing file '$file'"
sudo rm -f "$file"
done
# Remove logs
echo "* Removing 'devstack' logs ..."
sudo rm -f /opt/stack/log/*
echo "* Removing 'apache2' logs ..."
for file in $(sudo find /var/log/apache2 -type f) ; do
echo "Removing file '$file'"
sudo rm -f "$file"
done
echo "* Stopping all VMs ..."
sudo killall kvm
sleep 2
echo "* Unmounting ramdrive ..."
umount /opt/stack/data/nova/instances

View File

@ -1,55 +0,0 @@
#!/bin/bash
if [[ -z "$1" ]] ; then
SCRIPTS_DIR=$( cd $( dirname "$0" ) && pwd )
source $SCRIPTS_DIR/localrc
fi
# Executing pre-stack actions
#===============================================================================
# Executing checks
#-----------------
die_if_not_set DEVSTACK_DIR
die_if_not_set MYSQL_DB_TMPFS_SIZE
die_if_not_set NOVA_CACHE_TMPFS_SIZE
#-----------------
if [[ ,$INSTALL_MODE, =~ ',standalone,multihost,controller,' ]] ; then
restart_service dbus rabbitmq-server
fi
if [[ ,$INSTALL_MODE, =~ ',standalone,multihost,controller,' ]] ; then
move_mysql_data_to_ramdrive
fi
# Devstack log folder
#--------------------
sudo -s << EOF
mkdir -p $SCREEN_LOGDIR
chown stack:stack $SCREEN_LOGDIR
EOF
#--------------------
case $INSTALL_MODE in
'standalone')
update_devstack_localrc 'standalone'
;;
'multihost')
update_devstack_localrc 'controller'
;;
'controller')
update_devstack_localrc 'controller'
;;
'compute')
update_devstack_localrc 'compute'
;;
esac
#===============================================================================

View File

@ -1,7 +0,0 @@
#!/bin/bash
if [[ -z "$1" ]] ; then
SCRIPTS_DIR=$( cd $( dirname "$0" ) && pwd )
source $SCRIPTS_DIR/localrc
fi

View File

@ -1,53 +0,0 @@
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 67.207.197.34
netmask 255.255.255.240
gateway 67.207.197.33
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 208.166.50.13 67.207.201.6
dns-search svwh.net
auto eth0.260
iface eth0.260 inet manual
vlan-raw-device eth0
post-up ifconfig $IFACE 172.18.124.102/29
# post-up route add -net 172.18.0.0/16 gw 172.18.124.97
# pre-down route del -net 172.18.0.0/16 gw 172.18.124.97
post-up ip route add default via 172.18.124.97 dev $IFACE table 260
post-up ip rule add from 172.18.124.96/29 to 172.18.0.0/16 table 260
pre-down ip rule del from 172.18.124.96/29 to 172.18.0.0/16
pre-down ip route del table 260
pre-down ifconfig $IFACE 0.0.0.0
auto eth0.261
iface eth0.261 inet manual
vlan-raw-device eth0
post-up ifconfig $IFACE 172.18.124.202/26
post-up route add -net 172.18.0.0/16 gw 172.18.124.193 dev $IFACE
pre-down route del -net 172.18.0.0/16 gw 172.18.124.193 dev $IFACE
pre-down ifconfig $IFACE 0.0.0.0
auto eth1
iface eth1 inet manual
up ifconfig $IFACE up
down ifconfig $IFACE down
# up ifconfig $IFACE 0.0.0.0
#auto eth1.221
#iface eth1.221 inet manual
# vlan-raw-device eth1
# pre-up ifconfig $IFACE up
# post-down ifconfig $IFACE down
# up ifconfig $IFACE 0.0.0.0

View File

@ -1,54 +0,0 @@
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 67.207.197.36
netmask 255.255.255.240
network 67.207.197.32
broadcast 67.207.197.47
gateway 67.207.197.33
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 208.166.50.13 67.207.206.1
dns-search svwh.net
auto eth0.260
iface eth0.260 inet manual
vlan-raw-device eth0
post-up ifconfig $IFACE 172.18.124.100/29
post-up ip route add default via 172.18.124.97 dev $IFACE table 260
post-up ip rule add from 172.18.124.96/29 to 172.18.0.0/16 table 260
pre-down ip rule del from 172.18.124.96/29 to 172.18.0.0/16 table 260
pre-down ip route del table 260
pre-down ifconfig $IFACE 0.0.0.0
# post-up route add -net 172.18.0.0/16 gw 172.18.124.97
# post-down route del -net 172.18.0.0/16 gw 172.18.124.97
auto eth1
iface eth1 inet manual
up ifconfig $IFACE up
down ifconfig $IFACE down
# up ifconfig $IFACE 0.0.0.0
auto eth0.261
iface eth0.261 inet manual
vlan-raw-device eth0
post-up ifconfig $IFACE 172.18.124.200/26
post-up route add -net 172.18.0.0/16 gw 172.18.124.193 dev $IFACE
pre-down route del -net 172.18.0.0/16 gw 172.18.124.192 dev $IFACE
pre-down ifconfig $IFACE 0.0.0.0
#auto eth1.221
#iface eth1.221 inet manual
# vlan-raw-device eth1
# pre-up ifconfig $IFACE up
# post-down ifcofnig $IFACE down

View File

@ -1,27 +0,0 @@
# Devstack's config file for STANDALONE installation
lab_id=101
lab_password=swordfish
HOST_IP=172.18.124.${lab_id}
FIXED_RANGE=10.0.${lab_id}.0/24
FLAT_INTERFACE=eth1
ADMIN_PASSWORD=$lab_password
MYSQL_PASSWORD=$lab_password
RABBIT_PASSWORD=$lab_password
SERVICE_PASSWORD=$lab_password
SERVICE_TOKEN=tokentoken
ENABLED_SERVICES+=,heat,h-api,h-api-cfn,h-api-cw,h-eng
ENABLED_SERVICES+=,conductor,portas
SCREEN_LOGDIR=/opt/stack/log/
LOGFILE=$SCREEN_LOGDIR/stack.sh.log
API_RATE_LIMIT=False
EXTRA_OPTS=(force_config_drive=true libvirt_images_type=qcow2 force_raw_images=false)

View File

@ -1,63 +0,0 @@
#!/bin/bash
SCRIPTS_DIR=$( cd $( dirname "$0" ) && pwd )
source $SCRIPTS_DIR/localrc
INSTALL_MODE="$1"
validate_install_mode
# Update devstack-scripts if multihost
#===============================================================================
if [[ "$INSTALL_MODE" == 'multihost' ]] ; then
_echo "* Copying devstack-scripts to compute nodes ..."
for __compute_node in $COMPUTE_NODE_LIST ; do
_echo "** Removing devstack-scripts on '$__compute_node' ..."
ssh stack@$__compute_node rm -rf ~/devstack-scripts
_echo "** Copying devstack-scripts to '$__compute_node' ..."
scp -r $SCRIPTS_DIR stack@$__compute_node:~/
done
fi
#===============================================================================
# Executing pre-stack actions
#===============================================================================
_echo "* Executing pre-stack actions ..."
source $SCRIPTS_DIR/pre-stack.sh no-localrc
#===============================================================================
# Creating stack
#===============================================================================
_echo "* Starting devstack ..."
$DEVSTACK_DIR/stack.sh
#===============================================================================
# Executing post-stack actions
#===============================================================================
_echo "* Executing post-stack actions ..."
source $SCRIPTS_DIR/post-stack.sh no-localrc
#source $SCRIPTS_DIR/start-keero.sh no-localrc
#===============================================================================
# Start installation on compute nodes
#===============================================================================
if [[ "$INSTALL_MODE" == 'multihost' ]] ; then
_echo "* Starting devstack on compute nodes ..."
for __compute_node in $COMPUTE_NODE_LIST ; do
_echo "** Starting devstack on '$__compute_node' ..."
ssh stack@$__compute_node $SCRIPTS_DIR/start-devstack.sh compute
done
fi
#===============================================================================

View File

@ -1,26 +0,0 @@
#!/bin/bash
if [[ -z "$1" ]] ; then
SCRIPTS_DIR=$( cd $( dirname "$0" ) && pwd )
source $SCRIPTS_DIR/localrc
fi
die_if_not_set INSTALL_DIR
# Starting Portas
#================
if [[ ! -d "$INSTALL_DIR/portas" ]] ; then
mkdir -p "$INSTALL_DIR/portas"
fi
cp "$INSTALL_DIR/keero/portas/etc" "$INSTALL_DIR/portas/etc"
screen_it portas "cd $INSTALL_DIR/portas && portas-api --config-file=$INSTALL_DIR/portas/etc/portas-api.conf"
#================
# Starting Conductor
#===================
screen_it conductor "cd $INSTALL_DIR/keero/conductor && bash ./tools/with_venv.sh ./bin/app.py"
#===================

View File

@ -1,22 +0,0 @@
#!/bin/bash
image_file=$1
function die {
echo "$@"
exit 1
}
[ -z "$image_file" ] && die "VM name MUST be provided!"
[ -f "$image_file" ] || die "File '$image_file' not found."
echo "Starting VM '$image_file' ..."
kvm \
-m 2048 \
-drive file="$image_file",if=virtio \
-redir tcp:3389::3389 -redir tcp:3390::3390 \
-nographic \
-usbdevice tablet \
-vnc :20

View File

@ -1,45 +0,0 @@
#!/bin/bash
SCRIPTS_DIR=$( cd $( dirname "$0" ) && pwd )
source $SCRIPTS_DIR/localrc
INSTALL_MODE="$1"
validate_install_mode
# Executing pre-unstack actions
#===============================================================================
_echo "* Executing pre-unstack actions ..."
source $SCRIPTS_DIR/pre-unstack.sh no-localrc
#===============================================================================
# Executing unstack.sh
#===============================================================================
_echo "* Executing stop devstack ..."
$DEVSTACK_DIR/unstack.sh
#===============================================================================
# Executing post-unstack actions
#===============================================================================
_echo "* Executing post-unstack actions ..."
source $SCRIPTS_DIR/post-unstack.sh no-localrc
#source $SCRIPTS_DIR/stop-keero.sh no-localrc
#===============================================================================
# Stop installation on compute nodes
#===============================================================================
if [[ "$INSTALL_MODE" == 'multihost' ]] ; then
_echo "* Stopping devstack on compute nodes ..."
for $__compute_node in $COMPUTE_NODE_LIST ; do
_echo "** Stopping devstack on '$__compute_node' ..."
ssh stack@$__compute_node $SCRIPTS_DIR/stop-devstack.sh
done
fi
#===============================================================================

View File

@ -1,13 +0,0 @@
#!/bin/bash
if [[ -z "$1" ]] ; then
SCRIPTS_DIR=$( cd $( dirname "$0" ) && pwd )
source $SCRIPTS_DIR/localrc
fi
# Stopping Keero components
#==========================
for serv in conductor portas ; do
screen -S $SCREEN_NAME -p $serv -X kill
done
#==========================

View File

@ -1,17 +0,0 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
# Build results
[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>

View File

@ -1,62 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{501BE151-4B8C-4355-88DC-3AEF1921B2D7}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ConsoleApplication1</RootNamespace>
<AssemblyName>ExecutionPlanGenerator</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -1,141 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace ConsoleApplication1
{
class Command
{
public string Name { get; set; }
public Dictionary<string, object> Arguments { get; set; }
}
class ExecutionPlan
{
public List<string> Scripts { get; set; }
public List<Command> Commands { get; set; }
public int RebootOnCompletion { get; set; }
}
class Program
{
static void Main(string[] args)
{
if (args.Length < 1 || args.Length > 2)
{
Console.WriteLine("Usage: ExecutionPlanGenerator inputfile [outputfile]");
return;
}
var outFile = args.Length == 2 ? args[1] : null;
var plan = new ExecutionPlan {
Scripts = new List<string>(),
Commands = new List<Command>()
};
var lines = File.ReadAllLines(args[0]);
foreach (var statement in lines
.Select(t => t.Split(new[] { ' ', '\t' }, 2))
.Where(t => t.Length == 2)
.Select(t => new Tuple<string, string>(t[0].Trim().ToLower(), t[1].Trim())))
{
switch (statement.Item1)
{
case "include":
Include(statement.Item2, plan, args[0]);
break;
case "call":
Call(statement.Item2, plan);
break;
case "reboot":
plan.RebootOnCompletion = int.Parse(statement.Item2);
break;
case "out":
if (args.Length < 2)
{
var path = statement.Item2;
if (!Path.IsPathRooted(path))
{
path = Path.Combine(Path.GetDirectoryName(args[0]), path);
}
outFile = path;
}
break;
}
}
var data = JsonConvert.SerializeObject(plan, Formatting.Indented);
if (outFile == null)
{
Console.WriteLine(data);
}
else
{
File.WriteAllText(outFile, data);
}
}
private static void Call(string line, ExecutionPlan plan)
{
var parts = line.Split(new[] { ' ', '\t'}, 2);
var command = new Command() {
Name = parts[0].Trim(),
Arguments = new Dictionary<string, object>()
};
if (parts.Length == 2)
{
foreach (var x in parts[1]
.Split(',')
.Select(t => t.Split('='))
.Where(t => t.Length == 2)
.Select(t => new KeyValuePair<string, string>(t[0].Trim(), t[1].Trim())))
{
object value = null;
long num;
bool boolean;
if (x.Value.StartsWith("\""))
{
value = x.Value.Substring(1, x.Value.Length - 2);
}
else if (long.TryParse(x.Value, out num))
{
value = num;
}
else if (bool.TryParse(x.Value, out boolean))
{
value = boolean;
}
else
{
continue;
}
command.Arguments.Add(x.Key, value);
}
}
plan.Commands.Add(command);
}
private static void Include(string file, ExecutionPlan plan, string dslPath)
{
var path = file;
if (!Path.IsPathRooted(file))
{
path = Path.Combine(Path.GetDirectoryName(dslPath), path);
}
var text = File.ReadAllText(path, Encoding.UTF8);
plan.Scripts.Add(Convert.ToBase64String(Encoding.UTF8.GetBytes(text)));
}
}
}

View File

@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ConsoleApplication1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ConsoleApplication1")]
[assembly: AssemblyCopyright("Copyright © 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("9aab688a-ce5f-402e-8891-2d7b4ae85ea3")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="4.5.11" targetFramework="net45" />
</packages>

Binary file not shown.

View File

@ -1,26 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsAgent", "WindowsAgent\WindowsAgent.csproj", "{F7E2A8D5-6D24-4651-A4BC-1024D59F4903}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExecutionPlanGenerator", "ExecutionPlanGenerator\ExecutionPlanGenerator.csproj", "{501BE151-4B8C-4355-88DC-3AEF1921B2D7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F7E2A8D5-6D24-4651-A4BC-1024D59F4903}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F7E2A8D5-6D24-4651-A4BC-1024D59F4903}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F7E2A8D5-6D24-4651-A4BC-1024D59F4903}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F7E2A8D5-6D24-4651-A4BC-1024D59F4903}.Release|Any CPU.Build.0 = Release|Any CPU
{501BE151-4B8C-4355-88DC-3AEF1921B2D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{501BE151-4B8C-4355-88DC-3AEF1921B2D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{501BE151-4B8C-4355-88DC-3AEF1921B2D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{501BE151-4B8C-4355-88DC-3AEF1921B2D7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="file" xsi:type="File" fileName="${basedir}/log.txt"
layout="${date} ${level}: &lt;${logger:shortName=true}&gt; ${message} ${exception:format=tostring}"/>
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="file" />
</rules>
</nlog>
<appSettings>
<add key="rabbitmq.host" value="localhost"/>
<add key="rabbitmq.user" value="keero"/>
<add key="rabbitmq.password" value="keero"/>
<add key="rabbitmq.vhost" value="keero"/>
<add key="rabbitmq.resultExchange" value=""/>
<add key="rabbitmq.resultRoutingKey" value="-execution-results"/>
<add key="rabbitmq.durableMessages" value="true"/>
</appSettings>
</configuration>

View File

@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mirantis.Keero.WindowsAgent
{
class ExecutionPlan
{
public class Command
{
public string Name { get; set; }
public Dictionary<string, object> Arguments { get; set; }
}
public string[] Scripts { get; set; }
public LinkedList<Command> Commands { get; set; }
public int RebootOnCompletion { get; set; }
}
}

View File

@ -1,30 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mirantis.Keero.WindowsAgent
{
class MqMessage
{
private readonly Action ackFunc;
public MqMessage(Action ackFunc)
{
this.ackFunc = ackFunc;
}
public MqMessage()
{
}
public string Body { get; set; }
public string Id { get; set; }
public void Ack()
{
ackFunc();
}
}
}

View File

@ -1,176 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
using System.Text;
using NLog;
using Newtonsoft.Json;
namespace Mirantis.Keero.WindowsAgent
{
class PlanExecutor
{
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
class ExecutionResult
{
public bool IsException { get; set; }
public object Result { get; set; }
}
private readonly string path;
public PlanExecutor(string path)
{
this.path = path;
}
public bool RebootNeeded { get; set; }
public void Execute()
{
RebootNeeded = false;
var resultPath = this.path + ".result";
Runspace runSpace = null;
try
{
var plan = JsonConvert.DeserializeObject<ExecutionPlan>(File.ReadAllText(this.path));
List<ExecutionResult> currentResults = null;
try
{
currentResults = JsonConvert.DeserializeObject<List<ExecutionResult>>(File.ReadAllText(resultPath));
}
catch
{
currentResults = new List<ExecutionResult>();
}
runSpace = RunspaceFactory.CreateRunspace();
runSpace.Open();
var runSpaceInvoker = new RunspaceInvoke(runSpace);
runSpaceInvoker.Invoke("Set-ExecutionPolicy Unrestricted");
if (plan.Scripts != null)
{
foreach (var script in plan.Scripts)
{
runSpaceInvoker.Invoke(Encoding.UTF8.GetString(Convert.FromBase64String(script)));
}
}
while (plan.Commands != null && plan.Commands.Any())
{
var command = plan.Commands.First();
var pipeline = runSpace.CreatePipeline();
var psCommand = new Command(command.Name);
if (command.Arguments != null)
{
foreach (var kvp in command.Arguments)
{
psCommand.Parameters.Add(kvp.Key, kvp.Value);
}
}
Log.Info("Executing {0} {1}", command.Name, string.Join(" ",
(command.Arguments ?? new Dictionary<string, object>()).Select(
t => string.Format("{0}={1}", t.Key, t.Value == null ? "null" : t.Value.ToString()))));
pipeline.Commands.Add(psCommand);
try
{
var result = pipeline.Invoke();
if (result != null)
{
currentResults.Add(new ExecutionResult {
IsException = false,
Result = result.Select(SerializePsObject).Where(obj => obj != null).ToList()
});
}
}
catch (Exception exception)
{
currentResults.Add(new ExecutionResult {
IsException = true,
Result = new[] {
exception.GetType().FullName, exception.Message
}
});
break;
}
finally
{
plan.Commands.RemoveFirst();
File.WriteAllText(path, JsonConvert.SerializeObject(plan));
File.WriteAllText(resultPath, JsonConvert.SerializeObject(currentResults));
}
}
runSpace.Close();
var executionResult = JsonConvert.SerializeObject(new ExecutionResult {
IsException = false,
Result = currentResults
}, Formatting.Indented);
if (plan.RebootOnCompletion > 0)
{
if (plan.RebootOnCompletion == 1)
{
RebootNeeded = !currentResults.Any(t => t.IsException);
}
else
{
RebootNeeded = true;
}
}
File.WriteAllText(resultPath, executionResult);
}
catch (Exception ex)
{
File.WriteAllText(resultPath, JsonConvert.SerializeObject(new ExecutionResult {
IsException = true,
Result = ex.Message
}, Formatting.Indented));
}
finally
{
if (runSpace != null)
{
try
{
runSpace.Close();
}
catch
{}
}
}
}
private static object SerializePsObject(PSObject obj)
{
if (obj.BaseObject is PSCustomObject)
{
var result = new Dictionary<string, object>();
foreach (var property in obj.Properties.Where(p => p.IsGettable))
{
try
{
result[property.Name] = property.Value.ToString();
}
catch
{
}
}
return result;
}
else
{
return obj.BaseObject;
}
}
}
}

View File

@ -1,168 +0,0 @@
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Management.Automation;
using System.Net;
using System.Text;
using System.Threading;
using NLog;
namespace Mirantis.Keero.WindowsAgent
{
[DisplayName("Keero Agent")]
sealed public class Program : WindowsService
{
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
private volatile bool stop;
private Thread thread;
private RabbitMqClient rabbitMqClient;
private int delayFactor = 1;
private string plansDir;
static void Main(string[] args)
{
Start(new Program(), args);
}
protected override void OnStart(string[] args)
{
base.OnStart(args);
Log.Info("Version 0.3");
this.rabbitMqClient = new RabbitMqClient();
var basePath = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
this.plansDir = Path.Combine(basePath, "plans");
if (!Directory.Exists(plansDir))
{
Directory.CreateDirectory(plansDir);
}
this.thread = new Thread(Loop);
this.thread.Start();
}
void Loop()
{
const string unknownName = "unknown";
while (!stop)
{
try
{
foreach (var file in Directory.GetFiles(this.plansDir, "*.json.result")
.Where(file => !File.Exists(Path.Combine(this.plansDir, Path.GetFileNameWithoutExtension(file)))))
{
var id = Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(file)) ?? unknownName;
if (id.Equals(unknownName, StringComparison.InvariantCultureIgnoreCase))
{
id = "";
}
var result = File.ReadAllText(file);
Log.Info("Sending results for {0}", id ?? unknownName);
rabbitMqClient.SendResult(new MqMessage { Body = result, Id = id });
File.Delete(file);
}
var path = Directory.EnumerateFiles(this.plansDir, "*.json").FirstOrDefault();
if (path == null)
{
var message = rabbitMqClient.GetMessage();
var id = message.Id;
if(string.IsNullOrEmpty(id))
{
id = unknownName;
}
path = Path.Combine(this.plansDir, string.Format("{0}.json", id));
File.WriteAllText(path, message.Body);
Log.Info("Received new execution plan {0}", id);
message.Ack();
}
else
{
var id = Path.GetFileNameWithoutExtension(path);
Log.Info("Executing exising plan {0}", id);
}
var executor = new PlanExecutor(path);
executor.Execute();
File.Delete(path);
delayFactor = 1;
if (stop) break;
if (executor.RebootNeeded)
{
Reboot();
}
}
catch (Exception exception)
{
WaitOnException(exception);
}
}
}
private void Reboot()
{
Log.Info("Going for reboot!!");
LogManager.Flush();
/*try
{
System.Diagnostics.Process.Start("shutdown.exe", "-r -t 0");
}
catch (Exception ex)
{
Log.ErrorException("Cannot execute shutdown.exe", ex);
}*/
try
{
PowerShell.Create().AddCommand("Restart-Computer").AddParameter("Force").Invoke();
}
catch (Exception exception)
{
Log.FatalException("Reboot exception", exception);
}
finally
{
Log.Info("Waiting for reboot");
for (var i = 0; i < 10 * 60 * 5 && !stop; i++)
{
Thread.Sleep(100);
}
Log.Info("Done waiting for reboot");
}
}
private void WaitOnException(Exception exception)
{
if (stop) return;
Log.WarnException("Exception in main loop", exception);
var i = 0;
while (!stop && i < 10 * (delayFactor * delayFactor))
{
Thread.Sleep(100);
i++;
}
delayFactor = Math.Min(delayFactor + 1, 6);
}
protected override void OnStop()
{
stop = true;
this.rabbitMqClient.Dispose();
base.OnStop();
}
}
}

View File

@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("WindowsAgent")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WindowsAgent")]
[assembly: AssemblyCopyright("Copyright © 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("9591bf2c-f38b-47e0-a39d-ea9849356371")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,128 +0,0 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using NLog;
using RabbitMQ.Client;
namespace Mirantis.Keero.WindowsAgent
{
class RabbitMqClient : IDisposable
{
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
private static readonly ConnectionFactory connectionFactory;
private IConnection currentConnecton;
static RabbitMqClient()
{
connectionFactory = new ConnectionFactory {
HostName = ConfigurationManager.AppSettings["rabbitmq.host"] ?? "localhost",
UserName = ConfigurationManager.AppSettings["rabbitmq.user"] ?? "guest",
Password = ConfigurationManager.AppSettings["rabbitmq.password"] ??"guest",
Protocol = Protocols.FromEnvironment(),
VirtualHost = ConfigurationManager.AppSettings["rabbitmq.vhost"] ?? "/",
RequestedHeartbeat = 10
};
}
public RabbitMqClient()
{
}
public MqMessage GetMessage()
{
var queueName = ConfigurationManager.AppSettings["rabbitmq.inputQueue"] ?? Dns.GetHostName().ToLower();
try
{
IConnection connection = null;
lock (this)
{
connection = this.currentConnecton = this.currentConnecton ?? connectionFactory.CreateConnection();
}
var session = connection.CreateModel();
session.BasicQos(0, 1, false);
//session.QueueDeclare(queueName, true, false, false, null);
var consumer = new QueueingBasicConsumer(session);
var consumeTag = session.BasicConsume(queueName, false, consumer);
var e = (RabbitMQ.Client.Events.BasicDeliverEventArgs) consumer.Queue.Dequeue();
Action ackFunc = delegate {
session.BasicAck(e.DeliveryTag, false);
session.BasicCancel(consumeTag);
session.Close();
};
return new MqMessage(ackFunc) {
Body = Encoding.UTF8.GetString(e.Body),
Id = e.BasicProperties.MessageId
};
}
catch (Exception exception)
{
Dispose();
throw;
}
}
public void SendResult(MqMessage message)
{
var exchangeName = ConfigurationManager.AppSettings["rabbitmq.resultExchange"] ?? "";
var resultRoutingKey = ConfigurationManager.AppSettings["rabbitmq.resultRoutingKey"] ?? "-execution-results";
bool durable = bool.Parse(ConfigurationManager.AppSettings["rabbitmq.durableMessages"] ?? "true");
try
{
IConnection connection = null;
lock (this)
{
connection = this.currentConnecton = this.currentConnecton ?? connectionFactory.CreateConnection();
}
var session = connection.CreateModel();
/*if (!string.IsNullOrEmpty(resultQueue))
{
//session.QueueDeclare(resultQueue, true, false, false, null);
if (!string.IsNullOrEmpty(exchangeName))
{
session.ExchangeBind(exchangeName, resultQueue, resultQueue);
}
}*/
var basicProperties = session.CreateBasicProperties();
basicProperties.SetPersistent(durable);
basicProperties.MessageId = message.Id;
basicProperties.ContentType = "application/json";
session.BasicPublish(exchangeName, resultRoutingKey, basicProperties, Encoding.UTF8.GetBytes(message.Body));
session.Close();
}
catch (Exception)
{
Dispose();
throw;
}
}
public void Dispose()
{
lock (this)
{
try
{
if (this.currentConnecton != null)
{
this.currentConnecton.Close();
}
}
catch
{
}
finally
{
this.currentConnecton = null;
}
}
}
}
}

View File

@ -1,37 +0,0 @@
{
"Scripts":
[
"ZnVuY3Rpb24gdDMgeyAxMjsgcmV0dXJuICJ0ZXN0IiB9",
"ZnVuY3Rpb24gTmV3LVBlcnNvbigpDQp7DQogIHBhcmFtICgkRmlyc3ROYW1lLCAkTGFzdE5hbWUsICRQaG9uZSkNCg0KICAkcGVyc29uID0gbmV3LW9iamVjdCBQU09iamVjdA0KDQogICRwZXJzb24gfCBhZGQtbWVtYmVyIC10eXBlIE5vdGVQcm9wZXJ0eSAtTmFtZSBGaXJzdCAtVmFsdWUgJEZpcnN0TmFtZQ0KICAkcGVyc29uIHwgYWRkLW1lbWJlciAtdHlwZSBOb3RlUHJvcGVydHkgLU5hbWUgTGFzdCAtVmFsdWUgJExhc3ROYW1lDQogICRwZXJzb24gfCBhZGQtbWVtYmVyIC10eXBlIE5vdGVQcm9wZXJ0eSAtTmFtZSBQaG9uZSAtVmFsdWUgJFBob25lDQoNCiAgcmV0dXJuICRwZXJzb24NCn0=",
"ZnVuY3Rpb24gVGVzdFRocm93KCkNCnsNCglUaHJvdyBbc3lzdGVtLkluZGV4T3V0T2ZSYW5nZUV4Y2VwdGlvbl0gDQp9"
],
"Commands" :
[
{
"Name": "New-Person",
"Arguments" :
{
"FirstName": "MyFirstName",
"LastName": "MyLastName",
"Phone": "123-456"
}
},
{
"Name": "t3",
"Arguments" :
{
}
},
{
"Name": "Get-Date",
},
{
"Name": "TestThrow",
}
],
"RebootOnCompletion": 0
}

View File

@ -1,111 +0,0 @@
using System;
using System.Configuration.Install;
using System.Reflection;
using System.ServiceProcess;
using NLog;
namespace Mirantis.Keero.WindowsAgent
{
public class ServiceManager
{
private readonly string serviceName;
public ServiceManager(string serviceName)
{
this.serviceName = serviceName;
}
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
public bool Restart(string[] args, TimeSpan timeout)
{
var service = new ServiceController(serviceName);
try
{
var millisec1 = TimeSpan.FromMilliseconds(Environment.TickCount);
service.Stop();
service.WaitForStatus(ServiceControllerStatus.Stopped, timeout);
Log.Info("Service is stopped");
// count the rest of the timeout
var millisec2 = TimeSpan.FromMilliseconds(Environment.TickCount);
timeout = timeout - (millisec2 - millisec1);
service.Start(args);
service.WaitForStatus(ServiceControllerStatus.Running, timeout);
Log.Info("Service has started");
return true;
}
catch (Exception ex)
{
Log.ErrorException("Cannot restart service " + serviceName, ex);
return false;
}
}
public bool Stop(TimeSpan timeout)
{
var service = new ServiceController(serviceName);
try
{
service.Stop();
service.WaitForStatus(ServiceControllerStatus.Stopped, timeout);
return true;
}
catch (Exception ex)
{
Log.ErrorException("Cannot stop service " + serviceName, ex);
return false;
}
}
public bool Start(string[] args, TimeSpan timeout)
{
var service = new ServiceController(serviceName);
try
{
service.Start(args);
service.WaitForStatus(ServiceControllerStatus.Running, timeout);
return true;
}
catch (Exception ex)
{
Log.ErrorException("Cannot start service " + serviceName, ex);
return false;
}
}
public bool Install()
{
try
{
ManagedInstallerClass.InstallHelper(
new string[] { Assembly.GetEntryAssembly().Location });
}
catch(Exception ex)
{
Log.ErrorException("Cannot install service " + serviceName, ex);
return false;
}
return true;
}
public bool Uninstall()
{
try
{
ManagedInstallerClass.InstallHelper(
new string[] { "/u", Assembly.GetEntryAssembly().Location });
}
catch (Exception ex)
{
Log.ErrorException("Cannot uninstall service " + serviceName, ex);
return false;
}
return true;
}
}
}

View File

@ -1,94 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F7E2A8D5-6D24-4651-A4BC-1024D59F4903}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Mirantis.Keero.WindowsAgent</RootNamespace>
<AssemblyName>WindowsAgent</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog">
<HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="RabbitMQ.Client">
<HintPath>..\packages\RabbitMQ.Client.3.0.2\lib\net30\RabbitMQ.Client.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Core" />
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell\3.0\System.Management.Automation.dll</HintPath>
</Reference>
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ExecutionPlan.cs" />
<Compile Include="MqMessage.cs" />
<Compile Include="PlanExecutor.cs" />
<Compile Include="Program.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RabbitMqClient.cs" />
<Compile Include="ServiceManager.cs" />
<Compile Include="WindowsService.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="WindowsServiceInstaller.cs">
<SubType>Component</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
<None Include="SampleExecutionPlan.json" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>$(SolutionDir)Tools\nuget install $(ProjectDir)packages.config -o $(SolutionDir)Packages</PreBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -1,95 +0,0 @@
using System;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Reflection;
using System.ServiceProcess;
using NLog;
namespace Mirantis.Keero.WindowsAgent
{
public abstract class WindowsService : ServiceBase
{
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
public bool RunningAsService { get; private set; }
protected static void Start(WindowsService service, string[] arguments)
{
Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));
if (arguments.Contains("/install", StringComparer.OrdinalIgnoreCase))
{
new ServiceManager(service.ServiceName).Install();
}
else if (arguments.Contains("/uninstall", StringComparer.OrdinalIgnoreCase))
{
new ServiceManager(service.ServiceName).Uninstall();
}
else if (arguments.Contains("/start", StringComparer.OrdinalIgnoreCase))
{
new ServiceManager(service.ServiceName).Start(Environment.GetCommandLineArgs(), TimeSpan.FromMinutes(1));
}
else if (arguments.Contains("/stop", StringComparer.OrdinalIgnoreCase))
{
new ServiceManager(service.ServiceName).Stop(TimeSpan.FromMinutes(1));
}
else if (arguments.Contains("/restart", StringComparer.OrdinalIgnoreCase))
{
new ServiceManager(service.ServiceName).Restart(Environment.GetCommandLineArgs(), TimeSpan.FromMinutes(1));
}
else if (!arguments.Contains("/console", StringComparer.OrdinalIgnoreCase))
{
service.RunningAsService = true;
Run(service);
}
else
{
try
{
service.RunningAsService = false;
Console.Title = service.ServiceName;
service.OnStart(Environment.GetCommandLineArgs());
service.WaitForExitSignal();
}
finally
{
service.OnStop();
service.Dispose();
}
}
}
protected WindowsService()
{
var displayNameAttribute =
this.GetType().GetCustomAttributes(typeof (DisplayNameAttribute), false).Cast<DisplayNameAttribute>().
FirstOrDefault();
if(displayNameAttribute != null)
{
ServiceName = displayNameAttribute.DisplayName;
}
}
protected virtual void WaitForExitSignal()
{
Console.WriteLine("Press ESC to exit");
while (Console.ReadKey(true).Key != ConsoleKey.Escape)
{
}
}
protected override void OnStart(string[] args)
{
Log.Info("Service {0} started", ServiceName);
base.OnStart(args);
}
protected override void OnStop()
{
Log.Info("Service {0} exited", ServiceName);
base.OnStop();
}
}
}

View File

@ -1,39 +0,0 @@
using System.ComponentModel;
using System.Configuration.Install;
using System.Linq;
using System.Reflection;
using System.ServiceProcess;
namespace Mirantis.Keero.WindowsAgent
{
[RunInstaller(true)]
public class WindowsServiceInstaller : Installer
{
public WindowsServiceInstaller()
{
var processInstaller = new ServiceProcessInstaller { Account = ServiceAccount.LocalSystem };
foreach (var type in Assembly.GetEntryAssembly().GetExportedTypes().Where(t => t.IsSubclassOf(typeof(ServiceBase))))
{
var nameAttribute = type.GetCustomAttributes(typeof (DisplayNameAttribute), false)
.Cast<DisplayNameAttribute>().FirstOrDefault();
if(nameAttribute == null) continue;
var serviceInstaller = new ServiceInstaller {
StartType = ServiceStartMode.Automatic,
ServiceName = nameAttribute.DisplayName,
DisplayName = nameAttribute.DisplayName
};
var descriptionAttribute = type.GetCustomAttributes(typeof(DescriptionAttribute), false)
.Cast<DescriptionAttribute>().FirstOrDefault();
if(descriptionAttribute != null)
{
serviceInstaller.Description = descriptionAttribute.Description;
}
Installers.Add(serviceInstaller);
}
Installers.Add(processInstaller);
}
}
}

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="4.5.11" targetFramework="net45" />
<package id="NLog" version="2.0.0.2000" targetFramework="net45" />
<package id="RabbitMQ.Client" version="3.0.2" targetFramework="net45" />
</packages>

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<repositories>
<repository path="..\WindowsAgent\packages.config" />
</repositories>

23
api/.gitignore vendored
View File

@ -1,23 +0,0 @@
#IntelJ Idea
.idea/
#virtualenv
.venv/
#Build results
build/
dist/
*.egg-info/
#Python
*.pyc
#Translation build
*.mo
*.pot
#SQLite Database files
*.sqlite
#Autogenerated Documentation
doc/source/api

View File

@ -1,7 +0,0 @@
Glazier API README
=====================
Glazier API is a project that provides access to engine via API.
SEE ALSO
--------
* `Glazier <http://glazier.mirantis.com>`__

View File

@ -1 +0,0 @@
[python: **.py]

View File

@ -1,54 +0,0 @@
#!/usr/bin/env python
#
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.from oslo.config import cfg
import gettext
import os
import sys
# If ../glazierapi/__init__.py exists, add ../ to Python search path, so that
# it will override what happens to be installed in /usr/(local/)lib/python...
from glazierapi.common.service import TaskResultHandlerService
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
os.pardir,
os.pardir))
if os.path.exists(os.path.join(possible_topdir, 'portas', '__init__.py')):
sys.path.insert(0, possible_topdir)
from glazierapi.common import config
from glazierapi.openstack.common import log
from glazierapi.openstack.common import wsgi
from glazierapi.openstack.common import service
gettext.install('glazierapi', './glazierapi/locale', unicode=1)
if __name__ == '__main__':
try:
config.parse_args()
log.setup('glazierapi')
launcher = service.ServiceLauncher()
api_service = wsgi.Service(config.load_paste_app(),
port=config.CONF.bind_port,
host=config.CONF.bind_host)
launcher.launch_service(api_service)
launcher.launch_service(TaskResultHandlerService())
launcher.wait()
except RuntimeError, e:
sys.stderr.write("ERROR: %s\n" % e)
sys.exit(1)

View File

@ -1,241 +0,0 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2010 OpenStack Foundation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Portas documentation build configuration file, created by
# sphinx-quickstart on Tue February 28 13:50:15 2013.
#
# This file is execfile()'d with the current directory set to its containing
# dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import os
import sys
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path = [os.path.abspath('../../glazierapi'),
os.path.abspath('../..'),
os.path.abspath('../../bin')] + sys.path
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinx.ext.coverage',
'sphinx.ext.pngmath',
'sphinx.ext.ifconfig',
'sphinx.ext.graphviz']
# Add any paths that contain templates here, relative to this directory.
templates_path = []
if os.getenv('HUDSON_PUBLISH_DOCS'):
templates_path = ['_ga', '_templates']
else:
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'Glazier APIs'
copyright = u'2013, Mirantis, Inc'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
from glazierapi.version import version_info as portas_version
# The full version, including alpha/beta/rc tags.
release = portas_version.version_string_with_vcs()
# The short X.Y version.
version = portas_version.canonical_version_string()
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of documents that shouldn't be included in the build.
#unused_docs = []
# List of directories, relative to source directory, that shouldn't be searched
# for source files.
exclude_trees = ['api']
# The reST default role (for this markup: `text`) to use for all documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
show_authors = True
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
modindex_common_prefix = ['glazierapi.']
# -- Options for man page output --------------------------------------------
# Grouping the document tree for man pages.
# List of tuples 'sourcefile', 'target', u'title', u'Authors name', 'manual'
man_pages = [
('man/glazierapi', 'glazier-api', u'Glazier API Server',
[u'Mirantis, Inc'], 1)
]
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. Major themes that come with
# Sphinx are currently 'default' and 'sphinxdoc'.
html_theme_path = ["."]
html_theme = '_theme'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = ['_theme']
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
git_cmd = "git log --pretty=format:'%ad, commit %h' --date=local -n1"
html_last_updated_fmt = os.popen(git_cmd).read()
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
html_use_modindex = False
# If false, no index is generated.
html_use_index = False
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = ''
# Output file base name for HTML help builder.
htmlhelp_basename = 'glazierapidoc'
# -- Options for LaTeX output ------------------------------------------------
# The paper size ('letter' or 'a4').
#latex_paper_size = 'letter'
# The font size ('10pt', '11pt' or '12pt').
#latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author,
# documentclass [howto/manual]).
latex_documents = [
('index', 'Glazier.tex', u'Glazier Documentation',
u'Mirantis, Inc', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# Additional stuff for the LaTeX preamble.
#latex_preamble = ''
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_use_modindex = True
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'python': ('http://docs.python.org/', None)}

View File

@ -1,114 +0,0 @@
..
Copyright (c) 2013 Mirantis, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may
not use this file except in compliance with the License. You may obtain
a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.
==============================================
Welcome to Glazier API Service!
==============================================
Glazier API is a project that provides access to engine via API.
This document describes Glazier API for contributors of the project,
and assumes that you are already familiar with Glazier API from an
`end-user perspective`_.
.. _`end-user perspective`: http://glazier.mirantis.com/
This documentation is generated by the Sphinx toolkit and lives in the source
tree.
Installation Guide
==================
Install
-------
1. Check out sources to some directory (<home>/glazier)::
user@work:~/$ git clone ssh://<user>@gerrit.mirantis.com:29418/keero/keero.git
2. Install Glazier API::
user@work:~/$ cd glazier/api && sudo python setup.py install
Configure
---------
1. Open first configuration file for editing::
user@work:~/$ cd glazier/api/etc && nano glazier-api.conf
2. Configure according to you environment (please note rabbitmq section)::
[DEFAULT]
# Show more verbose log output (sets INFO log level output)
verbose = True
# Show debugging output in logs (sets DEBUG log level output)
debug = True
# Address to bind the server to
bind_host = 0.0.0.0
# Port the bind the server to
bind_port = 8082
# Log to this file. Make sure the user running skeleton-api has
# permissions to write to this file!
log_file = /tmp/glazier-api.log
#A valid SQLAlchemy connection string for the metadata database
sql_connection = sqlite:///glazier.sqlite
[reports]
results_exchange = task-results
results_queue = task-results
reports_exchange = task-reports
reports_queue = task-reports
[rabbitmq]
host = localhost
port = 5672
virtual_host = keero
login = keero
password = keero
3. Open second configuration file for editing::
smelikyan@work:~/cd glazier/api/etc && nano glazier-api.conf
4. Configure according to you environment (please note filter:authtoken section)::
[pipeline:glazier-api]
pipeline = authtoken context apiv1app
[app:apiv1app]
paste.app_factory = glazierapi.api.v1.router:API.factory
[filter:context]
paste.filter_factory = glazierapi.api.middleware.context:ContextMiddleware.factory
[filter:authtoken]
paste.filter_factory = keystoneclient.middleware.auth_token:filter_factory
auth_host = localhost
auth_port = 35357
auth_protocol = http
admin_tenant_name = admin
admin_user = admin
admin_password = password
signing_dir = /tmp/keystone-signing-glazierapi
Run
----
Run Glazier API and supply valid configuration file::
user@work:~/$ glazier-api --config-file=./glazier/api/etc/glazier-api.conf
Man Pages
=========
.. toctree::
:maxdepth: 1
man/glazierapi

View File

@ -1,69 +0,0 @@
..
Copyright (c) 2013 Mirantis, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may
not use this file except in compliance with the License. You may obtain
a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.
==========
glazier-api
==========
-----------------------------
Glazier API Server
-----------------------------
:Author: smelikyan@mirantis.com
:Date: 2013-04-04
:Copyright: Mirantis, Inc.
:Version: 2013.1-dev
:Manual section: 1
:Manual group: cloud computing
SYNOPSIS
========
glazier-api [options]
DESCRIPTION
===========
glazier-api is a server daemon that serves the Glazier API
OPTIONS
=======
**General options**
**-v, --verbose**
Print more verbose output
**--config-file**
Config file used for running service
**--bind-host=HOST**
Address of host running ``glazier-api``. Defaults to `0.0.0.0`.
**--bind-port=PORT**
Port that ``glazier-api`` listens on. Defaults to `8082`.
FILES
=====
* /etc/glazier/glazier-api.conf
* /etc/glazier/glazier-api-paste.conf
SEE ALSO
========
* `Glazier <http://glazier.mirantis.com>`__

View File

@ -1,18 +0,0 @@
[pipeline:glazier-api]
pipeline = authtoken context apiv1app
[app:apiv1app]
paste.app_factory = glazierapi.api.v1.router:API.factory
[filter:context]
paste.filter_factory = glazierapi.api.middleware.context:ContextMiddleware.factory
[filter:authtoken]
paste.filter_factory = keystoneclient.middleware.auth_token:filter_factory
auth_host = localhost
auth_port = 35357
auth_protocol = http
admin_tenant_name = admin
admin_user = admin
admin_password = password
signing_dir = /tmp/keystone-signing-portas

View File

@ -1,32 +0,0 @@
[DEFAULT]
# Show more verbose log output (sets INFO log level output)
verbose = True
# Show debugging output in logs (sets DEBUG log level output)
debug = True
# Address to bind the server to
bind_host = 0.0.0.0
# Port the bind the server to
bind_port = 8082
# Log to this file. Make sure the user running skeleton-api has
# permissions to write to this file!
log_file = /tmp/portas-api.log
#A valid SQLAlchemy connection string for the metadata database
sql_connection = sqlite:///glazier.sqlite
[reports]
results_exchange = task-results
results_queue = task-results
reports_exchange = task-reports
reports_queue = task-reports
[rabbitmq]
host = localhost
port = 5672
virtual_host = keero
login = keero
password = keero

View File

@ -1,13 +0,0 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

View File

@ -1,14 +0,0 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.from oslo.config import cfg

View File

@ -1,14 +0,0 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.from oslo.config import cfg

Some files were not shown because too many files have changed in this diff Show More