Browse files

merged dev.

  • Loading branch information...
2 parents 36c4876 + 367bd97 commit 509a0172672e5be5aa3b5fdc7db41b2fba914f96 @Licenser Licenser committed Apr 21, 2013
View
2 apps/chunter/src/chunter.app.src
@@ -1,6 +1,6 @@
{application, chunter,
[{description, "SmartOS hypervisor manager."},
- {vsn, "0.3.7p6"},
+ {vsn, "0.3.8"},
{registered, []},
{applications, [
kernel,
View
3 apps/chunter/src/chunter_protocol.erl
@@ -133,7 +133,8 @@ handle_info({_Closed, _}, State = #state{ closed = _Closed}) ->
handle_info(_Info, State) ->
{noreply, State}.
--spec handle_message(Message::fifo:chunter_message(), State::term()) -> {stop, term()}.
+-spec handle_message(Message::fifo:chunter_message(), State::term()) ->
+ {stop, term()} | {stop, term(), term()}.
handle_message({machines, start, UUID}, State) when is_binary(UUID) ->
chunter_vmadm:start(UUID),
View
22 apps/chunter/src/chunter_spec.erl
@@ -113,13 +113,14 @@ generate_spec(Package, Dataset, OwnerData) ->
_ ->
0
end,
+ RamShare = round(1024*RamPerc),
Base0 = jsxd:thread([{select, [<<"uuid">>, <<"alias">>]},
{set, <<"resolvers">>, [<<"8.8.8.8">>, <<"8.8.4.4">>]},
- {set, <<"cpu_shares">>, jsxd:get(<<"cpu_shares">>, round((1024*RamPerc)), Package)},
- {set, <<"zfs_io_priority">>, jsxd:get(<<"zfs_io_priority">>, round((2048*RamPerc)), Package)},
+ {set, <<"cpu_shares">>, jsxd:get(<<"cpu_shares">>, RamShare, Package)},
+ {set, <<"zfs_io_priority">>, jsxd:get(<<"zfs_io_priority">>, RamShare, Package)},
{set, [<<"internal_metadata">>, <<"package">>],
jsxd:get(<<"uuid">>, <<"-">>, Package)},
- {merge, jsxd:select([<<"cpu_cap">>], Package)},
+ {set, <<"cpu_cap">>, jsxd:get([<<"cpu_cap">>], 100, Package)},
{merge, jsxd:select([<<"nic_driver">>,
<<"disk_driver">>], Dataset)}],
OwnerData),
@@ -278,6 +279,7 @@ type_test() ->
InD = jsxd:from_list([{<<"type">>, <<"zone">>}, {<<"dataset">>, <<"d">>}]),
InO = jsxd:from_list([{<<"alias">>, <<"a">>}, {<<"hostname">>, <<"h">>}, {<<"uuid">>, <<"z">>}]),
In = jsxd:thread([{merge, InP}, {merge, InD},
+ {set, <<"cpu_cap">>, 100},
{set, <<"resolvers">>, [<<"8.8.8.8">>, <<"8.8.4.4">>]},
{delete, <<"name">>},
{set, <<"package">>, <<"p">>},
@@ -294,6 +296,8 @@ disk_driver_test() ->
{<<"disk_driver">>, <<"virtio">>}]),
InO = jsxd:from_list([{<<"uuid">>, <<"z">>}]),
In = jsxd:thread([{merge, InP}, {merge, InD},
+ {set, <<"cpu_cap">>, 100},
+ {set, <<"vcpus">>, 1},
{set, <<"resolvers">>, [<<"8.8.8.8">>, <<"8.8.4.4">>]},
{delete, <<"name">>},
{set, <<"disks">>,
@@ -316,6 +320,8 @@ created_at_test() ->
InD = jsxd:from_list([{<<"type">>, <<"kvm">>}, {<<"dataset">>, <<"d">>}]),
InO = jsxd:from_list([{<<"uuid">>, <<"z">>}]),
In = jsxd:thread([{merge, InP}, {merge, InD},
+ {set, <<"cpu_cap">>, 100},
+ {set, <<"vcpus">>, 1},
{set, <<"resolvers">>, [<<"8.8.8.8">>, <<"8.8.4.4">>]},
{delete, <<"name">>},
{set, <<"disks">>,
@@ -342,6 +348,8 @@ nic_driver_test() ->
{<<"nic_driver">>, <<"virtio">>}]),
InO = jsxd:from_list([{<<"uuid">>, <<"z">>}]),
In = jsxd:thread([{merge, InP}, {merge, InD},
+ {set, <<"cpu_cap">>, 100},
+ {set, <<"vcpus">>, 1},
{set, <<"resolvers">>, [<<"8.8.8.8">>, <<"8.8.4.4">>]},
{delete, <<"name">>},
{set, <<"disks">>,
@@ -362,6 +370,7 @@ zone_ram_test() ->
InD = jsxd:from_list([{<<"type">>, <<"zone">>}, {<<"dataset">>, <<"d">>}]),
InO = jsxd:from_list([{<<"uuid">>, <<"z">>}]),
In = jsxd:thread([{merge, InP}, {merge, InD},
+ {set, <<"cpu_cap">>, 100},
{set, <<"resolvers">>, [<<"8.8.8.8">>, <<"8.8.4.4">>]},
{delete, <<"name">>},
{set, <<"package">>, <<"p">>},
@@ -378,6 +387,8 @@ kvm_ram_test() ->
InD = jsxd:from_list([{<<"type">>, <<"kvm">>}, {<<"dataset">>, <<"d">>}]),
InO = jsxd:from_list([{<<"uuid">>, <<"z">>}]),
In = jsxd:thread([{merge, InP}, {merge, InD},
+ {set, <<"cpu_cap">>, 100},
+ {set, <<"vcpus">>, 1},
{set, <<"resolvers">>, [<<"8.8.8.8">>, <<"8.8.4.4">>]},
{delete, <<"name">>},
{set, <<"disks">>,
@@ -504,6 +515,7 @@ resolver_test() ->
InD = jsxd:from_list([{<<"type">>, <<"zone">>}, {<<"dataset">>, <<"d">>}]),
InO = jsxd:from_list([{<<"uuid">>, <<"z">>}, {<<"resolvers">>, [<<"8.8.8.8">>]}]),
In = jsxd:thread([{merge, InP},
+ {set, <<"cpu_cap">>, 100},
{delete, <<"name">>},
{set, <<"package">>, <<"p">>},
{merge, InD},
@@ -520,6 +532,7 @@ ssh_test() ->
{<<"ssh_keys">>,
<<"ssh-rsa">>}]),
In = jsxd:thread([{merge, InP},
+ {set, <<"cpu_cap">>, 100},
{delete, <<"name">>},
{set, <<"package">>, <<"p">>},
{set, <<"resolvers">>, [<<"8.8.8.8">>, <<"8.8.4.4">>]},
@@ -537,6 +550,7 @@ passwd_test() ->
{<<"admin_pw">>, <<"admin">>},
{<<"root_pw">>, <<"root">>}]),
In = jsxd:thread([{merge, InP},
+ {set, <<"cpu_cap">>, 100},
{delete, <<"name">>},
{set, <<"package">>, <<"p">>},
{set, <<"resolvers">>, [<<"8.8.8.8">>, <<"8.8.4.4">>]},
@@ -554,6 +568,7 @@ metadata_test() ->
{<<"admin_pw">>, <<"admin">>},
{<<"metadata">>, [{<<"key">>, <<"value">>}]}]),
In = jsxd:thread([{merge, InP},
+ {set, <<"cpu_cap">>, 100},
{delete, <<"name">>},
{set, <<"package">>, <<"p">>},
{set, <<"resolvers">>, [<<"8.8.8.8">>, <<"8.8.4.4">>]},
@@ -571,6 +586,7 @@ nics_test() ->
{<<"nic_tag">>, <<"admin">>}]]}]),
InO = jsxd:from_list([{<<"uuid">>, <<"z">>}]),
In = jsxd:thread([{merge, InP},
+ {set, <<"cpu_cap">>, 100},
{delete, <<"name">>},
{set, <<"resolvers">>, [<<"8.8.8.8">>, <<"8.8.4.4">>]},
{set, <<"package">>, <<"p">>},
View
47 apps/chunter/src/chunter_vm_fsm.erl
@@ -171,7 +171,7 @@ init([UUID]) ->
%% @end
%%--------------------------------------------------------------------
--spec initialized(Action::lad |
+-spec initialized(Action::load |
{create, PackageSpec::fifo:package(),
DatasetSpec::fifo:dataset(), VMSpec::fifo:config()}, State::term()) ->
{next_state, loading, State::term()} |
@@ -353,7 +353,7 @@ handle_event({update, Package, Config}, StateName, State = #state{uuid = UUID})
end;
handle_event(remove, _StateName, State) ->
- libsniffle:vm_delete(State#state.uuid),
+ libsniffle:vm_unregister(State#state.uuid),
{stop, normal, State};
handle_event(delete, StateName, State) ->
@@ -462,7 +462,12 @@ handle_info(Info, StateName, State) ->
%% @end
%%--------------------------------------------------------------------
terminate(_Reason, _StateName, State = #state{console = _C}) when is_port(_C) ->
- port_close(State#state.console),
+ case erlang:port_info(State#state.console) of
+ undefined ->
+ ok;
+ _ ->
+ port_close(State#state.console)
+ end,
ok;
terminate(_Reason, _StateName, _State) ->
@@ -528,10 +533,40 @@ write_image(Port, UUID, [Idx|R]) ->
port_command(Port, B),
write_image(Port, UUID, R);
-write_image(Port, _UUID, []) ->
- lager:debug("<IMG> done going to wait 2m.", []),
+write_image(Port, UUID, []) ->
+ lager:debug("<IMG> done going to wait for imgamd.", []),
port_close(Port),
- timer:sleep(120000),
+ UUIDL = binary_to_list(UUID),
+ %% We need to satisfy imgadm *shakes fist* this seems to be a minimal
+ %% manifest that is enough to not make it throw up.
+
+ {ok, DS} = libsniffle:dataset_get(UUID),
+ Manifest = jsxd:from_list([{<<"manifest">>,
+ [{<<"v">>, 2},
+ {<<"uuid">>, UUID},
+ {<<"disabled">>, false},
+ {<<"type">>, <<"zvol">>},
+ {<<"state">>, <<"active">>}]},
+ {<<"zpool">>, <<"zones">>}]),
+ %% Need to set the correct type
+ Manifest1 = case jsxd:get([<<"type">>], DS) of
+ {ok, <<"zone">>} ->
+ jsxd:set([<<"manifest">>, <<"type">>], <<"zone-dataset">>, Manifest);
+ _ ->
+ Manifest
+ end,
+ %% and write it to zoneamd's new destination folder ...
+ file:write_file("/var/imgadm/images/zones-" ++ UUIDL ++ ".json", jsx:encode(Manifest1)),
+ Cmd = "zfs list -Hp -t all -r zones/" ++ UUIDL,
+
+ wait_image(0, Cmd).
+
+
+wait_image(N, Cmd) when N < 3 ->
+ timer:sleep(5000),
+ wait_image(length(re:split(os:cmd(Cmd), "\n")), Cmd);
+
+wait_image(_, _) ->
lager:debug("<IMG> done waiting.", []).
-spec zoneadm(ZUUID::fifo:uuid()) -> [{ID::binary(),
View
9 apps/chunter/src/chunter_vmadm.erl
@@ -54,7 +54,7 @@ start(UUID, Image) ->
lager:debug("[vmadm] ~s", [R]),
R.
--spec delete(UUID::fifo:uuid(), Mem::binary()) -> ok.
+-spec delete(UUID::fifo:uuid(), Mem::number()) -> ok.
delete(UUID, Mem) ->
lager:info([{fifi_component, chunter}],
@@ -155,13 +155,8 @@ create(Data) ->
Res = case wait_for_tex(Port) of
ok ->
chunter_vm_fsm:load(UUID);
- {error, 1 = E} ->
- lager:error([{fifi_component, chunter}],
- "vmad:create - Failed: ~p.", [E]),
- chunter_vm_fsm:load(UUID);
{error, E} ->
- chunter_server:unprovision_memory(Mem*1024*1024),
-
+ delete(UUID, Mem*1024*1024),
lager:error([{fifi_component, chunter}],
"vmad:create - Failed: ~p.", [E]),
E
View
2 plugins/zone_cpu/zone_cpu.erl
@@ -14,7 +14,7 @@ zone_cpu({KStat, Acc}) ->
K =:= "effective" orelse
K =:= "maxusage" orelse
K =:= "bursting_sec"
- ] || Vs <- Data1],
+ ] || Vs <- Data1, is_list(Vs)],
{KStat, build_obj(Data2, Acc)}.
build_obj([Keys | R], Data) ->
View
2 plugins/zone_memstat/zone_memstat.erl
@@ -10,7 +10,7 @@ zone_memstat({KStat, Acc}) ->
K =:= "rss" orelse
K =:= "physcap" orelse
K =:= "swap" orelse
- K =:= "swapcap"] || Vs <- Data1],
+ K =:= "swapcap"] || Vs <- Data1, is_list(Vs)],
{KStat, build_obj(Data2, Acc)}.
build_obj([Keys | R], Data) ->
View
2 plugins/zone_net/zone_net.erl
@@ -13,7 +13,7 @@ zone_net({KStat, Acc}) ->
K =:= "oerrors" orelse
K =:= "ipackets64" orelse
K =:= "rbytes64" orelse
- K =:= "ierrors"] || Vs <- Data1],
+ K =:= "ierrors"] || Vs <- Data1, is_list(Vs)],
{KStat, build_obj(Data2, Acc)}.
fix_name(Name) ->
View
14 rebar.config
@@ -10,16 +10,16 @@
{eunit_opts, [{report,{eunit_surefire,[{dir,"."}]}}]}.
{deps,
[
- {lager, ".*", {git, "git://github.com/basho/lager.git", {tag, "1.0.0"}}},
+ {lager, ".*", {git, "git://github.com/basho/lager.git", {tag, "1.2.2"}}},
{jsx, ".*", {git, "http://github.com/talentdeficit/jsx.git", {tag, "v1.3.3"}}},
{erlsom, ".*", {git, "http://github.com/willemdj/erlsom.git", {tag, "bc48604f7a74440da66aa7dba95a3bf634fdf138"}}},
- {ranch, "0.4.*", {git, "https://github.com/extend/ranch.git", {tag, "0.4.0"}}},
+ {ranch, "0.8.*", {git, "https://github.com/extend/ranch.git", {tag, "0.8.1"}}},
{erltrace, ".*", {git, "https://github.com/project-fifo/erltrace.git", {tag, "0.1.2"}}},
{jsxd, ".*", {git, "http://github.com/Licenser/jsxd.git", {tag, "0.1.6"}}},
- {eplugin, ".*", {git, "http://github.com/Licenser/eplugin.git", {tag, "0.1.0"}}},
+ {eplugin, ".*", {git, "http://github.com/Licenser/eplugin.git", {tag, "0.1.1"}}},
{ekstat, ".*", {git, "https://github.com/Licenser/ekstat.git", {tag, "0.1.0"}}},
- {libsniffle, ".*", {git, "http://github.com/project-fifo/libsniffle.git", {tag, "0.2.4"}}},
- {libsnarl, ".*", {git, "http://github.com/project-fifo/libsnarl.git", {tag, "0.2.4"}}},
- {libhowl, ".*", {git, "http://github.com/project-fifo/libhowl.git", {tag, "0.1.5"}}},
- {fifo_spec, ".*", {git, "https://github.com/project-fifo/fifo_spec.git", {tag, "0.1.0"}}}
+ {libsniffle, ".*", {git, "http://github.com/project-fifo/libsniffle.git", {tag, "0.2.6"}}},
+ {libsnarl, ".*", {git, "http://github.com/project-fifo/libsnarl.git", {tag, "0.2.5"}}},
+ {libhowl, ".*", {git, "http://github.com/project-fifo/libhowl.git", {tag, "0.1.6"}}},
+ {fifo_spec, ".*", {git, "https://github.com/project-fifo/fifo_spec.git", {tag, "0.1.2"}}}
]}.
View
2 rel/pkg/Makefile
@@ -1,4 +1,4 @@
-VERSION=0.3.7p6
+VERSION=0.3.8
COMPONENT=chunter
SUFFIX:=$(shell echo $(SUFFIX))
BASENAME:=$(COMPONENT)-$(VERSION)$(SUFFIX)
View
6 rel/pkg/install.sh
@@ -2,7 +2,7 @@
. /usbkey/config
-TESTED_VERSIONS=joyent_20120906T221231Z\|joyent_20121203T193049Z\|joyent_20120726T184637Z\|joyent_20121018T224723Z\|joyent_20130222T000747Z
+TESTED_VERSIONS=joyent_20120906T221231Z\|joyent_20121203T193049Z\|joyent_20120726T184637Z\|joyent_20121018T224723Z\|joyent_20130222T000747Z\|joyent_20130405T010449Z
DST=/opt
@@ -31,6 +31,10 @@ else
fi
fi
+# We've to initialize imgadm or it will die horribly .... *sigh*
+[ -d /var/imgadm ] || imgadm update
+[ -d /var/imgadm/images ] || mkdir -p /var/imgadm/images
+
(cd $DST; uudecode -p $DIR/$BASE|tar xzf -)
mkdir -p /var/log/chunter
sed -i .bak -e "s/127.0.0.1/${IP}/g" /opt/chunter/etc/app.config
View
2 rel/reltool.config
@@ -1,6 +1,6 @@
{sys, [
{lib_dirs, ["../deps", "../apps"]},
- {rel, "chunter", "0.3.7p6",
+ {rel, "chunter", "0.3.8",
[
kernel,
stdlib,

0 comments on commit 509a017

Please sign in to comment.