Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
provision
Commits
b5ed469e
Commit
b5ed469e
authored
Jul 22, 2010
by
Adrian Rossouw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
leave dns work for next alpha.
parent
5bfb1067
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
72 deletions
+41
-72
dns/dns.drush.inc
dns/dns.drush.inc
+12
-30
provision.config.inc
provision.config.inc
+1
-15
provision.service.inc
provision.service.inc
+28
-27
No files found.
dns/dns.drush.inc
View file @
b5ed469e
...
...
@@ -84,6 +84,12 @@ class provisionService_dns_basic extends provisionService_dns {
$this
->
server
->
dns_zoned_path
=
"
{
$app_dir
}
/zone.d"
;
$this
->
server
->
dns_hostd_path
=
"
{
$app_dir
}
/host.d"
;
}
$this
->
server
->
setProperty
(
'dns_ttl'
,
86400
);
# 24h
$this
->
server
->
setProperty
(
'dns_refresh'
,
21600
);
# 6h
$this
->
server
->
setProperty
(
'dns_retry'
,
3600
);
# 1h
$this
->
server
->
setProperty
(
'dns_expire'
,
604800
);
# 7d
$this
->
server
->
setProperty
(
'dns_negativettl'
,
86400
);
# 24h
}
function
verify
()
{
...
...
@@ -128,22 +134,18 @@ class provisionService_dns_basic extends provisionService_dns {
* This creates a zone, which mostly consists of adding the SOA record.
*/
function
create_zone
(
$zone
)
{
$config
=
$this
->
config_load
(
'server'
);
$config
->
store
->
records
[
$zone
]
=
$zone
;
$config
->
write
();
$this
->
config
(
'server'
)
->
record_set
(
$zone
,
$zone
)
->
write
();
$config
=
$this
->
config
_load
(
'zone'
,
array
(
'name'
=>
$zone
));
$config
->
store
->
records
[
'SOA'
]
=
$zone
;
$config
->
write
();
$this
->
config
(
'zone'
)
->
record_set
(
'soa'
,
array
(
'name'
=>
$this
->
server
->
remote_host
,
))
->
write
();
}
/**
* This completely drops a zone, without any checks.
*/
function
delete_zone
(
$zone
)
{
$config
=
d
()
->
service
(
'dns'
)
->
config_load
(
'server'
);
$config
->
store
->
records
[
$zone
]
=
FALSE
;
$config
->
write
();
$this
->
config
(
'server'
)
->
record_del
(
$zone
)
->
write
();
}
...
...
@@ -151,27 +153,7 @@ class provisionService_dns_basic extends provisionService_dns {
class
provisionService_dns_complex
extends
provisionService_dns_basic
{
function
init
()
{
parent
::
init
();
$this
->
server
->
setProperty
(
'dns_ttl'
,
86400
);
# 24h
$this
->
server
->
setProperty
(
'dns_refresh'
,
21600
);
# 6h
$this
->
server
->
setProperty
(
'dns_retry'
,
3600
);
# 1h
$this
->
server
->
setProperty
(
'dns_expire'
,
604800
);
# 7d
$this
->
server
->
setProperty
(
'dns_negativettl'
,
86400
);
# 24h
}
function
verify
()
{
switch
(
$this
->
context
->
type
)
{
case
'site'
:
$this
->
create_host
();
break
;
}
// This will restart the server if needed.
parent
::
verify
();
}
/**
/**
* Determine if a zone is defined on the nameserver.
*
* To be implemented by engines.
...
...
provision.config.inc
View file @
b5ed469e
...
...
@@ -81,28 +81,15 @@ class provisionConfig {
if
(
sizeof
(
$data
))
{
$this
->
data
=
$data
;
}
//$this->parsed_data = $this->parse();
//$this->data = array_merge($this->parsed_data, $this->data);
if
(
!
is_null
(
$this
->
data_store_class
)
&&
class_exists
(
$this
->
data_store_class
))
{
$class
=
$this
->
data_store_class
;
$this
->
store
=
new
$class
(
$owner
,
$data
);
}
}
/**
* Parse the existing config to load data
*
* This is called in the constructor, and should take care of
* opening the file and parsing it into the data array.
*/
function
parse
()
{
return
array
();
}
/**
* Process and add to $data before writing the configuration.
*
...
...
@@ -148,7 +135,6 @@ class provisionConfig {
$class_name
=
get_parent_class
(
$class_name
);
}
}
return
false
;
...
...
@@ -227,7 +213,7 @@ class provisionConfig {
* Remove configuration file as specified by filename().
*/
function
unlink
()
{
provision_file
()
->
unlink
(
$this
->
filename
())
->
status
();
return
provision_file
()
->
unlink
(
$this
->
filename
())
->
status
();
}
}
...
...
provision.service.inc
View file @
b5ed469e
...
...
@@ -18,6 +18,8 @@ class provisionService extends provisionChainedState {
protected
$configs
=
array
();
protected
$config_cache
=
array
();
private
$_config
=
null
;
// All services have the ability to have an associated restart command and listen port.
function
init
()
{
...
...
@@ -40,7 +42,9 @@ class provisionService extends provisionChainedState {
return
false
;
}
function
&
config_load
(
$config
,
$data
=
array
())
{
function
config
(
$config
,
$data
=
array
())
{
$this
->
_config
=
null
;
if
(
!
isset
(
$this
->
config_cache
[
$this
->
context
->
name
][
$config
]))
{
foreach
((
array
)
$this
->
configs
[
$config
]
as
$class
)
{
$this
->
config_cache
[
$this
->
context
->
name
][
$config
]
=
new
$class
(
$this
->
context
,
array_merge
(
$this
->
config_data
(
$config
),
$data
));
...
...
@@ -48,9 +52,27 @@ class provisionService extends provisionChainedState {
}
if
(
isset
(
$this
->
config_cache
[
$this
->
context
->
name
][
$config
]))
{
return
$this
->
config_cache
[
$this
->
context
->
name
][
$config
];
$this
->
_config
=
$this
->
config_cache
[
$this
->
context
->
name
][
$config
];
}
return
false
;
return
$this
;
}
function
record_set
(
$arg1
,
$arg2
=
null
)
{
if
(
is_object
(
$this
->
_config
))
{
if
(
is_object
(
$this
->
_config
->
store
))
{
if
(
is_array
(
$arg1
))
{
$this
->
_config
->
store
->
records
=
array_merge
(
$this
->
_config
->
store
->
records
,
$arg1
);
}
elseif
(
!
is_numeric
(
$arg1
))
{
$this
->
_config
->
store
->
records
[
$arg1
]
=
$arg2
;
}
}
}
return
$this
;
}
function
record_del
(
$record
)
{
return
$this
->
record_set
(
$record
,
null
);
}
/**
...
...
@@ -59,18 +81,8 @@ class provisionService extends provisionChainedState {
* This method will fetch the class to instantiate from the internal
* $this->configs control array.
*/
function
create_config
(
$config
)
{
if
(
isset
(
$this
->
configs
[
$config
]))
{
try
{
$object
=&
$this
->
config_load
(
$config
);
$object
->
write
();
}
catch
(
provisionException_continue
$e
)
{
drush_log
(
$e
->
getMessage
());
// The service or configuration class has signaled that the config file
// was uneccesary, and we should continue normally.
}
}
function
create_config
(
$config
,
$data
=
array
())
{
$this
->
config
(
$config
,
$data
)
->
write
();
}
/**
...
...
@@ -80,18 +92,7 @@ class provisionService extends provisionChainedState {
* $this->configs control array.
*/
function
delete_config
(
$config
)
{
if
(
isset
(
$this
->
configs
[
$config
]))
{
try
{
$object
=&
$this
->
config_load
(
$config
);
$object
->
unlink
();
}
catch
(
provisionException_continue
$e
)
{
drush_log
(
$e
->
getMessage
());
// The service or configuration class has signaled that the config file
// was uneccesary, and we should continue normally.
}
}
$this
->
config
(
$config
,
$data
)
->
unlink
();
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment