Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pve-manager
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
pve-manager
Commits
3b51fd13
Commit
3b51fd13
authored
Nov 22, 2013
by
Dietmar Maurer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix osd keyring, use tasks
parent
3712e45b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
112 additions
and
79 deletions
+112
-79
Ceph.pm
PVE/API2/Ceph.pm
+100
-70
pveceph
bin/pveceph
+6
-8
Utils.js
www/manager/Utils.js
+4
-0
Ceph.js
www/manager/node/Ceph.js
+2
-1
No files found.
PVE/API2/Ceph.pm
View file @
3b51fd13
...
...
@@ -567,7 +567,7 @@ __PACKAGE__->register_method ({
}
$cfg
->
{
global
}
->
{
keyring
}
=
'
/etc/pve/priv/$cluster.$name.keyring
';
$cfg
->
{
osd
}
->
{
keyring
}
=
"
/var/lib/ceph/osd/ceph-
$id
/keyring
"
;
$cfg
->
{
osd
}
->
{
keyring
}
=
'
/var/lib/ceph/osd/ceph-$id/keyring
'
;
$cfg
->
{
global
}
->
{'
osd pool default size
'}
=
$param
->
{
size
}
if
$param
->
{
size
};
...
...
@@ -596,7 +596,7 @@ __PACKAGE__->register_method ({
node
=>
get_standard_option
('
pve-node
'),
},
},
returns
=>
{
type
=>
'
null
'
},
returns
=>
{
type
=>
'
string
'
},
code
=>
sub
{
my
(
$param
)
=
@_
;
...
...
@@ -604,20 +604,9 @@ __PACKAGE__->register_method ({
&
$setup_pve_symlinks
();
if
(
!
-
f
$pve_ckeyring_path
)
{
run_command
("
ceph-authtool
$pve_ckeyring_path
--create-keyring
"
.
"
--gen-key -n client.admin
");
}
my
$rpcenv
=
PVE::RPCEnvironment::
get
();
if
(
!
-
f
$pve_mon_key_path
)
{
run_command
("
cp
$pve_ckeyring_path
$pve_mon_key_path
.tmp
");
run_command
("
ceph-authtool
$pve_mon_key_path
.tmp -n client.admin --set-uid=0
"
.
"
--cap mds 'allow'
"
.
"
--cap osd 'allow *'
"
.
"
--cap mon 'allow *'
");
run_command
("
ceph-authtool
$pve_mon_key_path
.tmp --gen-key -n mon. --cap mon 'allow *'
");
run_command
("
mv
$pve_mon_key_path
.tmp
$pve_mon_key_path
");
}
my
$authuser
=
$rpcenv
->
get_user
();
my
$cfg
=
&
$parse_ceph_config
(
$pve_ceph_cfgpath
);
...
...
@@ -653,42 +642,59 @@ __PACKAGE__->register_method ({
die
"
monitor address '
$monaddr
' already in use by '
$monaddrhash
->{
$monaddr
}'
\n
"
if
$monaddrhash
->
{
$monaddr
};
my
$worker
=
sub
{
my
$upid
=
shift
;
my
$mondir
=
"
/var/lib/ceph/mon/
$ccname
-
$monid
";
-
d
$mondir
&&
die
"
monitor filesystem '
$mondir
' already exist
\n
";
my
$monmap
=
"
/tmp/monmap
";
eval
{
mkdir
$mondir
;
if
(
!
-
f
$pve_ckeyring_path
)
{
run_command
("
ceph-authtool
$pve_ckeyring_path
--create-keyring
"
.
"
--gen-key -n client.admin
");
}
if
(
$moncount
>
0
)
{
my
$monstat
=
ceph_mon_status
();
# online test
&
$run_ceph_cmd
(['
mon
',
'
getmap
',
'
-o
',
$monmap
]);
}
else
{
run_command
("
monmaptool --create --clobber --add
$monid
$monaddr
--print
$monmap
");
if
(
!
-
f
$pve_mon_key_path
)
{
run_command
("
cp
$pve_ckeyring_path
$pve_mon_key_path
.tmp
");
run_command
("
ceph-authtool
$pve_mon_key_path
.tmp -n client.admin --set-uid=0
"
.
"
--cap mds 'allow'
"
.
"
--cap osd 'allow *'
"
.
"
--cap mon 'allow *'
");
run_command
("
ceph-authtool
$pve_mon_key_path
.tmp --gen-key -n mon. --cap mon 'allow *'
");
run_command
("
mv
$pve_mon_key_path
.tmp
$pve_mon_key_path
");
}
run_command
("
ceph-mon --mkfs -i
$monid
--monmap
$monmap
--keyring
$pve_mon_key_path
");
};
my
$err
=
$@
;
unlink
$monmap
;
if
(
$err
)
{
File::Path::
remove_tree
(
$mondir
);
die
$err
;
}
my
$mondir
=
"
/var/lib/ceph/mon/
$ccname
-
$monid
";
-
d
$mondir
&&
die
"
monitor filesystem '
$mondir
' already exist
\n
";
my
$monmap
=
"
/tmp/monmap
";
eval
{
mkdir
$mondir
;
if
(
$moncount
>
0
)
{
my
$monstat
=
ceph_mon_status
();
# online test
&
$run_ceph_cmd
(['
mon
',
'
getmap
',
'
-o
',
$monmap
]);
}
else
{
run_command
("
monmaptool --create --clobber --add
$monid
$monaddr
--print
$monmap
");
}
$cfg
->
{
$monsection
}
=
{
'
host
'
=>
$monname
,
'
mon addr
'
=>
$monaddr
,
};
run_command
("
ceph-mon --mkfs -i
$monid
--monmap
$monmap
--keyring
$pve_mon_key_path
");
};
my
$err
=
$@
;
unlink
$monmap
;
if
(
$err
)
{
File::Path::
remove_tree
(
$mondir
);
die
$err
;
}
&
$write_ceph_config
(
$cfg
);
$cfg
->
{
$monsection
}
=
{
'
host
'
=>
$monname
,
'
mon addr
'
=>
$monaddr
,
};
&
$ceph_service_cmd
('
start
',
$monsection
);
&
$write_ceph_config
(
$cfg
);
return
undef
;
&
$ceph_service_cmd
('
start
',
$monsection
);
};
return
$rpcenv
->
fork_worker
('
cephcreatemon
',
$monsection
,
$authuser
,
$worker
);
}});
__PACKAGE__
->
register_method
({
...
...
@@ -708,10 +714,14 @@ __PACKAGE__->register_method ({
},
},
},
returns
=>
{
type
=>
'
null
'
},
returns
=>
{
type
=>
'
string
'
},
code
=>
sub
{
my
(
$param
)
=
@_
;
my
$rpcenv
=
PVE::RPCEnvironment::
get
();
my
$authuser
=
$rpcenv
->
get_user
();
&
$check_ceph_inited
();
my
$cfg
=
&
$parse_ceph_config
(
$pve_ceph_cfgpath
);
...
...
@@ -731,16 +741,20 @@ __PACKAGE__->register_method ({
die
"
can't remove last monitor
\n
"
if
scalar
(
@$monlist
)
<=
1
;
&
$run_ceph_cmd
(['
mon
',
'
remove
',
$monid
]);
my
$worker
=
sub
{
my
$upid
=
shift
;
eval
{
&
$ceph_service_cmd
('
stop
',
$monsection
);
};
warn
$@
if
$@
;
&
$run_ceph_cmd
(['
mon
',
'
remove
',
$monid
]);
delete
$cfg
->
{
$monsection
};
&
$write_ceph_config
(
$cfg
);
File::Path::
remove_tree
(
$mondir
);
eval
{
&
$ceph_service_cmd
('
stop
',
$monsection
);
};
warn
$@
if
$@
;
return
undef
;
delete
$cfg
->
{
$monsection
};
&
$write_ceph_config
(
$cfg
);
File::Path::
remove_tree
(
$mondir
);
};
return
$rpcenv
->
fork_worker
('
cephdestroymon
',
$monsection
,
$authuser
,
$worker
);
}});
__PACKAGE__
->
register_method
({
...
...
@@ -1076,16 +1090,18 @@ __PACKAGE__->register_method ({
}
},
},
returns
=>
{
type
=>
'
null
'
},
returns
=>
{
type
=>
'
string
'
},
code
=>
sub
{
my
(
$param
)
=
@_
;
my
$rpcenv
=
PVE::RPCEnvironment::
get
();
my
$authuser
=
$rpcenv
->
get_user
();
&
$check_ceph_inited
();
&
$setup_pve_symlinks
();
print
"
create OSD on
$param
->{dev}
\n
";
-
b
$param
->
{
dev
}
||
die
"
no such block device '
$param
->{dev}'
\n
";
my
$disklist
=
list_disks
();
...
...
@@ -1108,11 +1124,17 @@ __PACKAGE__->register_method ({
&
$run_ceph_cmd
(['
auth
',
'
get
',
'
client.bootstrap-osd
',
'
-o
',
$ceph_bootstrap_osd_keyring
]);
};
run_command
(['
ceph-disk
',
'
prepare
',
'
--zap-disk
',
'
--fs-type
',
'
xfs
',
'
--cluster
',
$ccname
,
'
--cluster-uuid
',
$fsid
,
'
--
',
$param
->
{
dev
}]);
my
$worker
=
sub
{
my
$upid
=
shift
;
return
undef
;
print
"
create OSD on
$param
->{dev}
\n
";
run_command
(['
ceph-disk
',
'
prepare
',
'
--zap-disk
',
'
--fs-type
',
'
xfs
',
'
--cluster
',
$ccname
,
'
--cluster-uuid
',
$fsid
,
'
--
',
$param
->
{
dev
}]);
};
return
$rpcenv
->
fork_worker
('
cephcreateods
',
$param
->
{
dev
},
$authuser
,
$worker
);
}});
__PACKAGE__
->
register_method
({
...
...
@@ -1132,17 +1154,19 @@ __PACKAGE__->register_method ({
},
},
},
returns
=>
{
type
=>
'
null
'
},
returns
=>
{
type
=>
'
string
'
},
code
=>
sub
{
my
(
$param
)
=
@_
;
my
$rpcenv
=
PVE::RPCEnvironment::
get
();
my
$authuser
=
$rpcenv
->
get_user
();
&
$check_ceph_inited
();
my
$osdid
=
$param
->
{
osdid
};
print
"
destroy OSD
$param
->{osdid}
\n
";
# fixme: not sure what we should do here
# fixme: not 100% sure what we should do here
my
$stat
=
&
$ceph_osd_status
();
...
...
@@ -1164,19 +1188,25 @@ __PACKAGE__->register_method ({
my
$osdsection
=
"
osd.
$osdid
";
eval
{
&
$ceph_service_cmd
('
stop
',
$osdsection
);
};
warn
$@
if
$@
;
my
$worker
=
sub
{
my
$upid
=
shift
;
print
"
Remove
$osdsection
from the CRUSH map
\n
";
&
$run_ceph_cmd
(['
osd
',
'
crush
',
'
remove
',
$osdid
]);
print
"
destroy OSD
$param
->{osdid}
\n
";
print
"
Remove the
$osdsection
authentication key.
\n
"
;
&
$run_ceph_cmd
(['
auth
',
'
del
',
$osdsection
])
;
eval
{
&
$ceph_service_cmd
('
stop
',
$osdsection
);
}
;
warn
$@
if
$@
;
print
"
Remove OSD
$osdsection
\n
";
&
$run_ceph_cmd
(['
osd
',
'
rm
',
$osdid
]);
print
"
Remove
$osdsection
from the CRUSH map
\n
";
&
$run_ceph_cmd
(['
osd
',
'
crush
',
'
remove
',
$osdid
]);
return
undef
;
print
"
Remove the
$osdsection
authentication key.
\n
";
&
$run_ceph_cmd
(['
auth
',
'
del
',
$osdsection
]);
print
"
Remove OSD
$osdsection
\n
";
&
$run_ceph_cmd
(['
osd
',
'
rm
',
$osdid
]);
};
return
$rpcenv
->
fork_worker
('
cephdestroyods
',
$osdsection
,
$authuser
,
$worker
);
}});
__PACKAGE__
->
register_method
({
...
...
bin/pveceph
View file @
3b51fd13
...
...
@@ -124,14 +124,12 @@ my $cmddef = {
}],
createpool
=>
[
'
PVE::API2::Ceph
',
'
createpool
',
['
name
'],
{
node
=>
$nodename
}],
destroypool
=>
[
'
PVE::API2::Ceph
',
'
destroypool
',
['
name
'],
{
node
=>
$nodename
}
],
createosd
=>
[
'
PVE::API2::Ceph
',
'
createosd
',
['
dev
'],
{
node
=>
$nodename
}
],
destroyosd
=>
[
'
PVE::API2::Ceph
',
'
destroyosd
',
['
osdid
'],
{
node
=>
$nodename
}
],
createmon
=>
[
'
PVE::API2::Ceph
',
'
createmon
',
[]
,
{
node
=>
$nodename
}
],
destroymon
=>
[
'
PVE::API2::Ceph
',
'
destroymon
',
['
monid
'],
{
node
=>
$nodename
}
],
start
=>
[
'
PVE::API2::Ceph
',
'
start
',
['
service
'],
{
node
=>
$nodename
},
$upid_exit
],
stop
=>
[
'
PVE::API2::Ceph
',
'
stop
',
['
service
'],
{
node
=>
$nodename
},
$upid_exit
],
createosd
=>
[
'
PVE::API2::Ceph
',
'
createosd
',
['
dev
'],
{
node
=>
$nodename
},
$upid_exit
],
destroyosd
=>
[
'
PVE::API2::Ceph
',
'
destroyosd
',
['
osdid
'],
{
node
=>
$nodename
},
$upid_exit
],
createmon
=>
[
'
PVE::API2::Ceph
',
'
createmon
',
[]
,
{
node
=>
$nodename
},
$upid_exit
],
destroymon
=>
[
'
PVE::API2::Ceph
',
'
destroymon
',
['
monid
'],
{
node
=>
$nodename
},
$upid_exit
],
start
=>
[
'
PVE::API2::Ceph
',
'
start
',
['
service
'],
{
node
=>
$nodename
},
$upid_exit
],
stop
=>
[
'
PVE::API2::Ceph
',
'
stop
',
['
service
'],
{
node
=>
$nodename
},
$upid_exit
],
install
=>
[
__PACKAGE__
,
'
install
',
[]
],
purge
=>
[
__PACKAGE__
,
'
purge
',
[]
],
status
=>
[
'
PVE::API2::Ceph
',
'
status
',
[]
,
{
node
=>
$nodename
},
sub
{
...
...
www/manager/Utils.js
View file @
3b51fd13
...
...
@@ -536,6 +536,10 @@ Ext.define('PVE.Utils', { statics: {
srvstop
:
[
'
SRV
'
,
gettext
(
'
Stop
'
)
],
srvrestart
:
[
'
SRV
'
,
gettext
(
'
Restart
'
)
],
srvreload
:
[
'
SRV
'
,
gettext
(
'
Reload
'
)
],
cephcreatemon
:
[
'
Ceph Monitor
'
,
gettext
(
'
Create
'
)
],
cephdestroymon
:
[
'
Ceph Monitor
'
,
gettext
(
'
Destroy
'
)
],
cephcreateosd
:
[
'
Ceph OSD
'
,
gettext
(
'
Create
'
)
],
cephdestroyosd
:
[
'
Ceph OSD
'
,
gettext
(
'
Destroy
'
)
],
imgcopy
:
[
''
,
gettext
(
'
Copy data
'
)
],
imgdel
:
[
''
,
gettext
(
'
Erase data
'
)
],
download
:
[
''
,
gettext
(
'
Download
'
)
],
...
...
www/manager/node/Ceph.js
View file @
3b51fd13
...
...
@@ -484,7 +484,7 @@ Ext.define('PVE.CephCreateMon', {
{
xtype
:
'
PVE.form.NodeSelector
'
,
submitValue
:
false
,
fieldLabel
:
gettext
(
'
Commen
t
'
),
fieldLabel
:
gettext
(
'
Hos
t
'
),
selectCurNode
:
true
,
allowBlank
:
false
,
listeners
:
{
...
...
@@ -797,6 +797,7 @@ Ext.define('PVE.node.CephStatus', {
}
var
txt
=
value
.
overall_status
;
Ext
.
Array
.
each
(
value
.
summary
,
function
(
d
)
{
txt
+=
"
"
+
d
.
summary
+
'
;
'
;
});
...
...
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